Name | Type | Description |
---|---|---|
scene |
Scene | 场景对象。 |
Example:
//创建相机对象。
var camera = new Cesium.Camera(scene);
camera.position = new Cesium.Cartesian3();
camera.direction = Cesium.Cartesian3.negate(Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
camera.up = Cesium.Cartesian3.clone(Cesium.Cartesian3.UNIT_Y);
camera.frustum.fov = Cesium.Math.PI_OVER_THREE;
camera.frustum.near = 1.0;
camera.frustum.far = 2.0;
Members
-
staticCesium.Camera.DEFAULT_OFFSET : HeadingPitchRange
-
The default heading/pitch/range that is used when the camera flies to a location that contains a bounding sphere.
-
A scalar to multiply to the camera position and add it back after setting the camera to view the rectangle. A value of zero means the camera will view the entire
Camera#DEFAULT_VIEW_RECTANGLE
, a value greater than zero will move it further away from the extent, and a value less than zero will move it close to the extent. -
staticCesium.Camera.DEFAULT_VIEW_RECTANGLE : Rectangle
-
The default rectangle the camera will view on creation.
-
readonlychanged : Event
-
Gets the event that will be raised when the camera has changed by
percentageChanged
. -
constrainedAxis : Cartesian3
-
If set, the camera will not be able to rotate past this axis in either direction.
-
Default Value:
undefined
-
The default amount to rotate the camera when an argument is not provided to the look methods.
-
Default Value:
Math.PI / 60.0
-
The default amount to move the camera when an argument is not provided to the move methods.
-
Default Value:
100000.0;
-
The default amount to rotate the camera when an argument is not provided to the rotate methods.
-
Default Value:
Math.PI / 3600.0
-
The default amount to move the camera when an argument is not provided to the zoom methods.
-
Default Value:
100000.0;
-
direction : Cartesian3
-
相机视图方向。
-
readonlydirectionWC : Cartesian3
-
Gets the view direction of the camera in world coordinates.
-
设置相机绕点旋转是否开启循环模式。
Example:
var scene = viewer.scene; var camera = scene.camera; //设置相机循环模式 camera.flyCircleLoop = true;
-
视野中的空间区域,即视锥体。
-
Default Value:
PerspectiveFrustum()
See:
-
获取相机方位角,单位为弧度。
-
readonlyinverseTransform : Matrix4
-
Gets the inverse camera transform.
-
Default Value:
Matrix4.IDENTITY
-
readonlyinverseViewMatrix : Matrix4
-
Gets the inverse view matrix.
See:
-
The factor multiplied by the the map size used to determine where to clamp the camera position when zooming out from the surface. The default is 1.5. Only valid for 2D and the map is rotatable.
-
Default Value:
1.5
-
readonlymoveEnd : Event
-
Gets the event that will be raised when the camera has stopped moving.
-
readonlymoveStart : Event
-
Gets the event that will be raised at when the camera starts to move.
-
The amount the camera has to change before the
changed
event is raised. The value is a percentage in the [0, 1] range.-
Default Value:
0.5
-
获取相机的俯仰角,单位为弧度。
-
position : Cartesian3
-
相机对象的位置。
-
readonlypositionCartographic : Cartographic
-
Gets the
Cartographic
position of the camera, with longitude and latitude expressed in radians and height in meters. In 2D and Columbus View, it is possible for the returned longitude and latitude to be outside the range of valid longitudes and latitudes when the camera is outside the map. -
readonlypositionWC : Cartesian3
-
Gets the position of the camera in world coordinates.
-
right : Cartesian3
-
相机的右方向。
-
readonlyrightWC : Cartesian3
-
Gets the right direction of the camera in world coordinates.
-
获取相机旋转角度,单位为弧度。
-
readonlytransform : Matrix4
-
Gets the camera's reference frame. The inverse of this transformation is appended to the view matrix.
-
Default Value:
Matrix4.IDENTITY
-
up : Cartesian3
-
相机的上方向。
-
readonlyupWC : Cartesian3
-
Gets the up direction of the camera in world coordinates.
-
readonlyviewMatrix : Matrix4
-
Gets the view matrix.
Methods
-
cameraToWorldCoordinates(cartesian, result) → Cartesian4
-
Transform a vector or point from the camera's reference frame to world coordinates.
Name Type Description cartesian
Cartesian4 The vector or point to transform. result
Cartesian4 optional The object onto which to store the result. Returns:
The transformed vector or point. -
cameraToWorldCoordinatesPoint(cartesian, result) → Cartesian3
-
Transform a point from the camera's reference frame to world coordinates.
Name Type Description cartesian
Cartesian3 The point to transform. result
Cartesian3 optional The object onto which to store the result. Returns:
The transformed point. -
cameraToWorldCoordinatesVector(cartesian, result) → Cartesian3
-
Transform a vector from the camera's reference frame to world coordinates.
Name Type Description cartesian
Cartesian3 The vector to transform. result
Cartesian3 optional The object onto which to store the result. Returns:
The transformed vector. -
Cancels the current camera flight if one is in progress. The camera is left at it's current location.
-
computeViewRectangle(ellipsoid, result) → Rectangle|undefined
-
Computes the approximate visible rectangle on the ellipsoid.
Name Type Default Description ellipsoid
Ellipsoid Ellipsoid.WGS84
optional The ellipsoid that you want to know the visible region. result
Rectangle optional The rectangle in which to store the result Returns:
The visible rectangle or undefined if the ellipsoid isn't visible at all. -
Disables reflection modification previously turned on with enableReflection.
-
Return the distance from the camera to the front of the bounding sphere.
Name Type Description boundingSphere
BoundingSphere The bounding sphere in world coordinates. Returns:
The distance to the bounding sphere. -
Modifies this frustum so it always renders from the reflection of itself through the plane specified.
Name Type Description plane
Plane optional the reflection of plane -
相机绕中心点旋转。
Name Type Description center
Number 在场景中所绘制点的三维空间坐标值。 Example:
var scene = viewer.scene; var camera = scene.camera; var handlerPoint = new Cesium.DrawHandler(viewer,Cesium.DrawMode.Point); handlerPoint.drawEvt.addEventListener(function(result){ center = result.object.position; //相机绕中心点旋转。 camera.flyCircle(center); });
-
Fly the camera to the home view. Use
Camera#.DEFAULT_VIEW_RECTANGLE
to set the default view for the 3D scene. The home view for 2D and columbus view shows the entire map.Name Type Description duration
Number optional The duration of the flight in seconds. If omitted, Cesium attempts to calculate an ideal duration based on the distance to be traveled by the flight. See Camera#flyTo
-
相机从当前位置飞行到新的空间位置。
Name Type Description options
Object 对象具有以下属性: Name Type Description destination
Cartesian3 | Rectangle 相机在WGS84世界坐标系中的最终位置,或是自顶向下视图中可见的矩形区域。 orientation
Object optional 包含了方位(direction)、上方向(up)以及方位角(heading)、俯仰角(pitch)、滚动角(roll)属性的对象。默认情况下,3D中方位(direction)指向框架中心,在Columbus视图中指向负z方向。 在3D中上方向(up)指向本地北方向,而在Columbus视图中指向正y方向。在无限滚动模式下,二维视图不使用方向(orientation)。 duration
Number optional 飞行持续时间(以秒为单位)。如果省略,由飞行距离计算合理的持续时间。 complete
Camera~FlightCompleteCallback optional 飞行完成时执行的功能。 cancel
Camera~FlightCancelledCallback optional 飞行取消时执行的功能。 endTransform
Matrix4 optional 飞行完成时相机将处于的参考系的变换矩阵。 maximumHeight
Number optional 飞行中的最大高度。 easingFunction
EasingFunction | EasingFunction~Callback optional 释放时调用功能。 pitchAdjustHeight
Number optional If camera flyes higher than that value, adjust pitch duiring the flight to look down, and keep Earth in viewport. flyOverLongitude
Number optional There are always two ways between 2 points on globe. This option force camera to choose fight direction to fly over that longitude. flyOverLongitudeWeight
Number optional Fly over the lon specifyed via flyOverLongitude only if that way is not longer than short way times flyOverLongitudeWeight. Throws:
-
DeveloperError : 若提供了方向(direction )、上方向(up)两者之一,则两者都需要提供。
Example:
// 1. 飞向通过top-down视图表示的位置 viewer.camera.flyTo({ destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0) }); // 2. 飞向通过top-down视图表示的矩形 viewer.camera.flyTo({ destination : Cesium.Rectangle.fromDegrees(west, south, east, north) }); // 3. 飞向利用单位向量表示方向(orientatin)的位置 viewer.camera.flyTo({ destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0), orientation : { direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734), up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339) } }); // 4. 飞向利用方位角(heading)、俯仰角(pitch)、滚动角(roll)表示方向(orientatin)的位置 viewer.camera.flyTo({ destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0), orientation : { heading : Cesium.Math.toRadians(175.0), pitch : Cesium.Math.toRadians(-35.0), roll : 0.0 } });
-
-
Flies the camera to a location where the current view contains the provided bounding sphere.
The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. The heading and the pitch angles are defined in the local east-north-up reference frame. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center. If the range is zero, a range will be computed such that the whole bounding sphere is visible.
In 2D and Columbus View, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the range. The heading will be aligned to local north.
Name Type Description boundingSphere
BoundingSphere The bounding sphere to view, in world coordinates. options
Object optional Object with the following properties: Name Type Description duration
Number optional The duration of the flight in seconds. If omitted, Cesium attempts to calculate an ideal duration based on the distance to be traveled by the flight. offset
HeadingPitchRange optional The offset from the target in the local east-north-up reference frame centered at the target. complete
Camera~FlightCompleteCallback optional The function to execute when the flight is complete. cancel
Camera~FlightCancelledCallback optional The function to execute if the flight is cancelled. endTransform
Matrix4 optional Transform matrix representing the reference frame the camera will be in when the flight is completed. maximumHeight
Number optional The maximum height at the peak of the flight. pitchAdjustHeight
Number optional If camera flyes higher than that value, adjust pitch duiring the flight to look down, and keep Earth in viewport. flyOverLongitude
Number optional There are always two ways between 2 points on globe. This option force camera to choose fight direction to fly over that longitude. flyOverLongitudeWeight
Number optional Fly over the lon specifyed via flyOverLongitude only if that way is not longer than short way times flyOverLongitudeWeight. easingFunction
EasingFunction | EasingFunction~Callback optional Controls how the time is interpolated over the duration of the flight. -
Gets the magnitude of the camera position. In 3D, this is the vector magnitude. In 2D and Columbus view, this is the distance to the map.
Returns:
The magnitude of the position. -
getPickRay(windowPosition, result) → Ray
-
Create a ray from the camera position through the pixel at
windowPosition
in world coordinates.Name Type Description windowPosition
Cartesian2 The x and y coordinates of a pixel. result
Ray optional The object onto which to store the result. Returns:
Returns theCartesian3
position and direction of the ray. -
Return the pixel size in meters.
Name Type Description boundingSphere
BoundingSphere The bounding sphere in world coordinates. drawingBufferWidth
Number The drawing buffer width. drawingBufferHeight
Number The drawing buffer height. Returns:
The pixel size in meters. -
getRectangleCameraCoordinates(rectangle, result) → Cartesian3
-
Get the camera position needed to view a rectangle on an ellipsoid or map
Name Type Description rectangle
Rectangle The rectangle to view. result
Cartesian3 optional The camera position needed to view the rectangle Returns:
The camera position needed to view the rectangle -
Rotate each of the camera's orientation vectors around
axis
byangle
Name Type Description axis
Cartesian3 The axis to rotate around. angle
Number optional The angle, in radians, to rotate by. Defaults to defaultLookAmount
. -
通过目标(target)和偏移(offset)设置相机位置、方向。 目标(target)以世界坐标方式表示;偏移(offset)是在以目标为中心的本地“东-北-上”参考系中的笛卡尔坐标或“方位角/俯仰角/范围(heading/pitch/range)”。 如果偏移(offset)由笛卡尔坐标表示,它表示距离由变换矩阵定义的参考系中心的偏移量。 如果偏移(offset)由“heading/pitch/range”表示,方位角(heading)和俯仰角(pitch)的角度由根据变换矩阵定义的参考系确定,方位角(heading)从y轴开始朝向x轴增加,俯仰角(pitch)为从xy平面的旋转角度,正的俯仰角位于平面下方,负的俯仰角位于平面上方。 范围(range)为距中心点的距离。在2D中必须为自上而下视图,相机位于俯视目标的上方,目标上方的高度值是偏移量的大小。方位角根据偏移确定,如果不能从偏移确定方位角,则方位角为北方向。
Name Type Description target
Cartesian3 目标在世界坐标中的空间位置。. offset
Cartesian3 | HeadingPitchRange 距以目标为中心的本地“东-北-上”参考系的偏移。 Throws:
-
DeveloperError : 变形时不支持lookAt方法。
Example:
// 1. 利用笛卡尔坐标设置偏移 var center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0); viewer.camera.lookAt(center, new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0)); // 2. 利用HeadingPitchRange设置偏移 var center = Cesium.Cartesian3.fromDegrees(-72.0, 40.0); var heading = Cesium.Math.toRadians(50.0); var pitch = Cesium.Math.toRadians(-20.0); var range = 5000.0; viewer.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));
-
-
Sets the camera position and orientation using a target and transformation matrix. The offset can be either a cartesian or heading/pitch/range. If the offset is a cartesian, then it is an offset from the center of the reference frame defined by the transformation matrix. If the offset is heading/pitch/range, then the heading and the pitch angles are defined in the reference frame defined by the transformation matrix. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center. In 2D, there must be a top down view. The camera will be placed above the center of the reference frame. The height above the target will be the magnitude of the offset. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.
Name Type Description transform
Matrix4 The transformation matrix defining the reference frame. offset
Cartesian3 | HeadingPitchRange optional The offset from the target in a reference frame centered at the target. Throws:
-
DeveloperError : lookAtTransform is not supported while morphing.
Example:
// 1. Using a cartesian offset var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-98.0, 40.0)); viewer.camera.lookAtTransform(transform, new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0)); // 2. Using a HeadingPitchRange offset var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-72.0, 40.0)); var heading = Cesium.Math.toRadians(50.0); var pitch = Cesium.Math.toRadians(-20.0); var range = 5000.0; viewer.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, range));
-
-
Rotates the camera around its right vector by amount, in radians, in the opposite direction of its up vector.
Name Type Description amount
Number optional The amount, in radians, to rotate by. Defaults to defaultLookAmount
.See:
-
Rotates the camera around its up vector by amount, in radians, in the opposite direction of its right vector.
Name Type Description amount
Number optional The amount, in radians, to rotate by. Defaults to defaultLookAmount
.See:
-
Rotates the camera around its up vector by amount, in radians, in the direction of its right vector.
Name Type Description amount
Number optional The amount, in radians, to rotate by. Defaults to defaultLookAmount
.See:
-
Rotates the camera around its right vector by amount, in radians, in the direction of its up vector.
Name Type Description amount
Number optional The amount, in radians, to rotate by. Defaults to defaultLookAmount
.See:
-
Translates the camera's position by
amount
alongdirection
.Name Type Description direction
Cartesian3 The direction to move. amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
. -
Translates the camera's position by
amount
along the opposite direction of the camera's view vector.Name Type Description amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
.See:
-
Translates the camera's position by
amount
along the opposite direction of the camera's up vector.Name Type Description amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
.See:
-
Translates the camera's position by
amount
along the camera's view vector.Name Type Description amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
.See:
-
Translates the camera's position by
amount
along the opposite direction of the camera's right vector.Name Type Description amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
.See:
-
Translates the camera's position by
amount
along the camera's right vector.Name Type Description amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
.See:
-
Translates the camera's position by
amount
along the camera's up vector.Name Type Description amount
Number optional The amount, in meters, to move. Defaults to defaultMoveAmount
.See:
-
pickEllipsoid(windowPosition, ellipsoid, result) → Cartesian3
-
Pick an ellipsoid or map.
Name Type Default Description windowPosition
Cartesian2 The x and y coordinates of a pixel. ellipsoid
Ellipsoid Ellipsoid.WGS84
optional The ellipsoid to pick. result
Cartesian3 optional The object onto which to store the result. Returns:
If the ellipsoid or map was picked, returns the point on the surface of the ellipsoid or map in world coordinates. If the ellipsoid or map was not picked, returns undefined. -
Rotates the camera around
axis
byangle
. The distance of the camera's position to the center of the camera's reference frame remains the same.Name Type Description axis
Cartesian3 The axis to rotate around given in world coordinates. angle
Number optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount
. -
Rotates the camera around the center of the camera's reference frame by angle downwards.
Name Type Description angle
Number optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount
. -
Rotates the camera around the center of the camera's reference frame by angle to the left.
Name Type Description angle
Number optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount
. -
Rotates the camera around the center of the camera's reference frame by angle to the right.
Name Type Description angle
Number optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount
. -
Rotates the camera around the center of the camera's reference frame by angle upwards.
Name Type Description angle
Number optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount
. -
设置相机位置、方向和变换。
Name Type Description options
Object 对象具有以下属性: Name Type Description destination
Cartesian3 | Rectangle optional 相机在WGS84世界坐标系中的最终位置,或是自顶向下视图中可见的矩形区域。 orientation
Object optional 包含了方位(direction)、上方向(up)以及方位角(heading)、俯仰角(pitch)、滚动角(roll)属性的对象。 默认情况下,3D中方位(direction)指向框架中心,在Columbus视图中指向负z方向。 在3D中上方向(up)指向本地北方向,而在Columbus视图中指向正y方向。在无限滚动模式下,二维视图不使用方向(orientation)。 endTransform
Matrix4 optional 表示相机参考坐标系的变换矩阵。 Example:
// 1. 通过top-down视图设置位置。 viewer.camera.setView({ destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0) }); // 2 通过方位角、俯仰角、滚动角设置视图。 viewer.camera.setView({ destination : cartesianPosition, orientation: { heading : Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north) pitch : Cesium.Math.toRadians(-90), // default value (looking down) roll : 0.0 // default value } }); // 3. 相机空间位置不变,改变方位角、俯仰角和滚动角。. viewer.camera.setView({ orientation: { heading : Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north) pitch : Cesium.Math.toRadians(-90), // default value (looking down) roll : 0.0 // default value } }); // 4. 通过自顶向下视图查看矩形。 viewer.camera.setView({ destination : Cesium.Rectangle.fromDegrees(west, south, east, north) }); // 5. 通过使用单位向量的方向(orientation)设置相机位置。. viewer.camera.setView({ destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0), orientation : { direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734), up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339) } });
-
停止相机绕中心点旋转。
-
Switches the frustum/projection to orthographic. This function is a no-op in 2D which will always be orthographic.
-
Switches the frustum/projection to perspective. This function is a no-op in 2D which must always be orthographic.
-
Rotate the camera counter-clockwise around its direction vector by amount, in radians.
Name Type Description amount
Number optional The amount, in radians, to rotate by. Defaults to defaultLookAmount
.See:
-
Rotate the camera clockwise around its direction vector by amount, in radians.
Name Type Description amount
Number optional The amount, in radians, to rotate by. Defaults to defaultLookAmount
.See:
-
Sets the camera so that the current view contains the provided bounding sphere.
The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. The heading and the pitch angles are defined in the local east-north-up reference frame. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center. If the range is zero, a range will be computed such that the whole bounding sphere is visible.
In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the range. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.
Name Type Description boundingSphere
BoundingSphere The bounding sphere to view, in world coordinates. offset
HeadingPitchRange optional The offset from the target in the local east-north-up reference frame centered at the target. Throws:
-
DeveloperError : viewBoundingSphere is not supported while morphing.
-
-
worldToCameraCoordinates(cartesian, result) → Cartesian4
-
Transform a vector or point from world coordinates to the camera's reference frame.
Name Type Description cartesian
Cartesian4 The vector or point to transform. result
Cartesian4 optional The object onto which to store the result. Returns:
The transformed vector or point. -
worldToCameraCoordinatesPoint(cartesian, result) → Cartesian3
-
Transform a point from world coordinates to the camera's reference frame.
Name Type Description cartesian
Cartesian3 The point to transform. result
Cartesian3 optional The object onto which to store the result. Returns:
The transformed point. -
worldToCameraCoordinatesVector(cartesian, result) → Cartesian3
-
Transform a vector from world coordinates to the camera's reference frame.
Name Type Description cartesian
Cartesian3 The vector to transform. result
Cartesian3 optional The object onto which to store the result. Returns:
The transformed vector. -
Zooms
amount
along the camera's view vector.Name Type Description amount
Number optional The amount to move. Defaults to defaultZoomAmount
.See:
-
Zooms
amount
along the opposite direction of the camera's view vector.Name Type Description amount
Number optional The amount to move. Defaults to defaultZoomAmount
.See:
Type Definitions
-
A function that will execute when a flight is cancelled.
-
A function that will execute when a flight completes.