new Camera()
The camera is defined by a position, orientation, and view frustum.
The orientation forms an orthonormal basis with a view, up and right = view x up unit vectors.
The viewing frustum is defined by 6 planes. Each plane is represented by a
The orientation forms an orthonormal basis with a view, up and right = view x up unit vectors.
The viewing frustum is defined by 6 planes. Each plane is represented by a
Cartesian4 object, where the x, y, and z components
define the unit vector normal to the plane, and the w component is the distance of the
plane from the origin/camera position.
Example:
// Create a camera looking down the negative z-axis, positioned at the origin,
// with a field of view of 60 degrees, and 1:1 aspect ratio.
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;
Demo:
Source:
Scene/Camera.js, line 76
Members
-
staticCamera.DEFAULT_VIEW_FACTOR :Number
-
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.Source: Scene/Camera.js, line 244 -
staticCamera.DEFAULT_VIEW_RECTANGLE :Rectangle
-
The default extent the camera will view on creation.Source: Scene/Camera.js, line 236
-
constrainedAxis :Cartesian3
-
If set, the camera will not be able to rotate past this axis in either direction.
-
Default Value:
undefinedSource: Scene/Camera.js, line 182 -
defaultLookAmount :Number
-
The default amount to rotate the camera when an argument is not provided to the look methods.
-
Default Value:
Math.PI / 60.0Source: Scene/Camera.js, line 162 -
defaultMoveAmount :Number
-
The default amount to move the camera when an argument is not provided to the move methods.
-
Default Value:
100000.0;Source: Scene/Camera.js, line 155 -
defaultRotateAmount :Number
-
The default amount to rotate the camera when an argument is not provided to the rotate methods.
-
Default Value:
Math.PI / 3600.0Source: Scene/Camera.js, line 169 -
defaultZoomAmount :Number
-
The default amount to move the camera when an argument is not provided to the zoom methods.
-
Default Value:
100000.0;Source: Scene/Camera.js, line 176 -
direction :Cartesian3
-
The view direction of the camera.Source: Scene/Camera.js, line 113
-
readonlydirectionWC :Cartesian3
-
Gets the view direction of the camera in world coordinates.Source: Scene/Camera.js, line 642
-
frustum :Frustum
-
The region of space in view.
-
Default Value:
PerspectiveFrustum()See:
Source: Scene/Camera.js, line 145 -
heading :Number
-
Gets or sets the camera heading in radians.Source: Scene/Camera.js, line 683
-
readonlyinverseTransform :Matrix4
-
Gets the inverse camera transform.
-
Default Value:
Matrix4.IDENTITYSource: Scene/Camera.js, line 566 -
readonlyinverseViewMatrix :Matrix4
-
Gets the inverse view matrix.
See:
Source: Scene/Camera.js, line 598 -
maximumTranslateFactor :Number
-
The factor multiplied by the the map size used to determine where to clamp the camera position when translating across the surface. The default is 1.5. Only valid for 2D and Columbus view.
-
Default Value:
1.5Source: Scene/Camera.js, line 189 -
maximumZoomFactor :Number
-
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 2.5. Only valid for 2D.
-
Default Value:
2.5Source: Scene/Camera.js, line 196 -
position :Cartesian3
-
The position of the camera.Source: Scene/Camera.js, line 103
-
positionCartographic :Cartographic
-
Gets the
Cartographicposition 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.Source: Scene/Camera.js, line 614 -
readonlypositionWC :Cartesian3
-
Gets the position of the camera in world coordinates.Source: Scene/Camera.js, line 628
-
right :Cartesian3
-
The right direction of the camera.Source: Scene/Camera.js, line 131
-
readonlyrightWC :Cartesian3
-
Gets the right direction of the camera in world coordinates.Source: Scene/Camera.js, line 670
-
tilt :Number
-
Gets or sets the camera tilt in radians.Source: Scene/Camera.js, line 716
-
transform :Matrix4
-
Modifies the camera's reference frame. The inverse of this transformation is appended to the view matrix.
-
Default Value:
Matrix4.IDENTITYSee:
Source: Scene/Camera.js, line 92 -
up :Cartesian3
-
The up direction of the camera.Source: Scene/Camera.js, line 122
-
readonlyupWC :Cartesian3
-
Gets the up direction of the camera in world coordinates.Source: Scene/Camera.js, line 656
-
readonlyviewMatrix :Matrix4
-
Gets the view matrix.
See:
Source: Scene/Camera.js, line 582
Methods
-
cameraToWorldCoordinates(cartesian, result) → Cartesian4
-
Transform a vector or point from the camera's reference frame to world coordinates.
Name Type Description cartesianCartesian4 The vector or point to transform. resultCartesian4 optional The object onto which to store the result. Returns:
The transformed vector or point.Source: Scene/Camera.js, line 874 -
cameraToWorldCoordinatesPoint(cartesian, result) → Cartesian3
-
Transform a point from the camera's reference frame to world coordinates.
Name Type Description cartesianCartesian3 The point to transform. resultCartesian3 optional The object onto which to store the result. Returns:
The transformed point.Source: Scene/Camera.js, line 895 -
cameraToWorldCoordinatesVector(cartesian, result) → Cartesian3
-
Transform a vector from the camera's reference frame to world coordinates.
Name Type Description cartesianCartesian3 The vector to transform. resultCartesian3 optional The object onto which to store the result. Returns:
The transformed vector.Source: Scene/Camera.js, line 916 -
clone() → Camera
-
Returns a duplicate of a Camera instance.
Returns:
A new copy of the Camera instance.Source: Scene/Camera.js, line 2075 -
flyTo(options)
-
Flies the camera from its current position to a new position.
Name Type Description optionsObject Object with the following properties: Name Type Default Description destinationCartesian3 The final position of the camera in WGS84 (world) coordinates. directionCartesian3 optional The final direction of the camera in WGS84 (world) coordinates. By default, the direction will point towards the center of the frame in 3D and in the negative z direction in Columbus view or 2D. upCartesian3 optional The final up direction in WGS84 (world) coordinates. By default, the up direction will point towards local north in 3D and in the positive y direction in Columbus view or 2D. durationNumber 3.0optional The duration of the flight in seconds. completeCamera~FlightCompleteCallback optional The function to execute when the flight is complete. cancelCamera~FlightCancelledCallback optional The function to execute if the flight is cancelled. endTransformMatrix4 optional Transform matrix representing the reference frame the camera will be in when the flight is completed. convertBoolean trueoptional When true, the destination is converted to the correct coordinate system for each scene mode. Whenfalse, the destination is expected to be in the correct coordinate system.Throws:
-
DeveloperError : If either direction or up is given, then both are required.
Source: Scene/Camera.js, line 2050 -
-
flyToRectangle(options, endTransform)
-
Flies the camera from its current position to a position where the entire rectangle is visible.
Name Type Description optionsObject Object with the following properties: Name Type Default Description destinationRectangle The rectangle to view, in WGS84 (world) coordinates, which determines the final position of the camera. durationNumber 3.0optional The duration of the flight in seconds. completeCamera~FlightCompleteCallback optional The function to execute when the flight is complete. cancelCamera~FlightCancelledCallback optional The function to execute if the flight is cancelled. endTransformMatrix4 optional Transform matrix representing the reference frame the camera will be in when the flight is completed. Source: Scene/Camera.js, line 2065 -
getMagnitude() → Number
-
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.Source: Scene/Camera.js, line 1362 -
getPickRay(windowPosition, result) → Object
-
Create a ray from the camera position through the pixel at
windowPositionin world coordinates.Name Type Description windowPositionCartesian2 The x and y coordinates of a pixel. resultRay optional The object onto which to store the result. Returns:
Returns theCartesian3position and direction of the ray.Source: Scene/Camera.js, line 1860 -
getRectangleCameraCoordinates(rectangle, result) → Cartesian3
-
Get the camera position needed to view an rectangle on an ellipsoid or map
Name Type Description rectangleRectangle The rectangle to view. resultCartesian3 optional The camera position needed to view the rectangle Returns:
The camera position needed to view the rectangleSource: Scene/Camera.js, line 1677 -
look(axis, angle)
-
Rotate each of the camera's orientation vectors around
axisbyangleName Type Description axisCartesian3 The axis to rotate around. angleNumber optional The angle, in radians, to rotate by. Defaults to defaultLookAmount. -
lookAt(eye, target, up)
-
Sets the camera position and orientation with an eye position, target, and up vector. This method is not supported in 2D mode because there is only one direction to look.
Name Type Description eyeCartesian3 The position of the camera. targetCartesian3 The position to look at. upCartesian3 The up vector. Throws:
-
DeveloperError : lookAt is not supported while morphing.
Source: Scene/Camera.js, line 1442 -
-
lookDown(amount)
-
Rotates the camera around its right vector by amount, in radians, in the opposite direction of its up vector.
Name Type Description amountNumber optional The amount, in radians, to rotate by. Defaults to defaultLookAmount.See:
Source: Scene/Camera.js, line 1100 -
lookLeft(amount)
-
Rotates the camera around its up vector by amount, in radians, in the opposite direction of its right vector.
Name Type Description amountNumber optional The amount, in radians, to rotate by. Defaults to defaultLookAmount.See:
Source: Scene/Camera.js, line 1061 -
lookRight(amount)
-
Rotates the camera around its up vector by amount, in radians, in the direction of its right vector.
Name Type Description amountNumber optional The amount, in radians, to rotate by. Defaults to defaultLookAmount.See:
Source: Scene/Camera.js, line 1074 -
lookUp(amount)
-
Rotates the camera around its right vector by amount, in radians, in the direction of its up vector.
Name Type Description amountNumber optional The amount, in radians, to rotate by. Defaults to defaultLookAmount.See:
Source: Scene/Camera.js, line 1087 -
move(direction, amount)
-
Translates the camera's position by
amountalongdirection.Name Type Description directionCartesian3 The direction to move. amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount. -
moveBackward(amount)
-
Translates the camera's position by
amountalong the opposite direction of the camera's view vector.Name Type Description amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount.See:
Source: Scene/Camera.js, line 998 -
moveDown(amount)
-
Translates the camera's position by
amountalong the opposite direction of the camera's up vector.Name Type Description amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount.See:
Source: Scene/Camera.js, line 1023 -
moveForward(amount)
-
Translates the camera's position by
amountalong the camera's view vector.Name Type Description amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount.See:
Source: Scene/Camera.js, line 985 -
moveLeft(amount)
-
Translates the camera's position by
amountalong the opposite direction of the camera's right vector.Name Type Description amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount.See:
Source: Scene/Camera.js, line 1048 -
moveRight(amount)
-
Translates the camera's position by
amountalong the camera's right vector.Name Type Description amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount.See:
Source: Scene/Camera.js, line 1035 -
moveUp(amount)
-
Translates the camera's position by
amountalong the camera's up vector.Name Type Description amountNumber optional The amount, in meters, to move. Defaults to defaultMoveAmount.See:
Source: Scene/Camera.js, line 1010 -
pickEllipsoid(windowPosition, ellipsoid, result) → Cartesian3
-
Pick an ellipsoid or map.
Name Type Default Description windowPositionCartesian2 The x and y coordinates of a pixel. ellipsoidEllipsoid Ellipsoid.WGS84optional The ellipsoid to pick. resultCartesian3 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.Source: Scene/Camera.js, line 1771 -
rotate(axis, angle)
-
Rotates the camera around
axisbyangle. The distance of the camera's position to the center of the camera's reference frame remains the same.Name Type Description axisCartesian3 The axis to rotate around given in world coordinates. angleNumber optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount. -
rotateDown(angle)
-
Rotates the camera around the center of the camera's reference frame by angle downwards.
Name Type Description angleNumber optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount.See:
Source: Scene/Camera.js, line 1201 -
rotateLeft(angle)
-
Rotates the camera around the center of the camera's reference frame by angle to the left.
Name Type Description angleNumber optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount.See:
Source: Scene/Camera.js, line 1275 -
rotateRight(angle)
-
Rotates the camera around the center of the camera's reference frame by angle to the right.
Name Type Description angleNumber optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount.See:
Source: Scene/Camera.js, line 1262 -
rotateUp(angle)
-
Rotates the camera around the center of the camera's reference frame by angle upwards.
Name Type Description angleNumber optional The angle, in radians, to rotate by. Defaults to defaultRotateAmount.See:
Source: Scene/Camera.js, line 1214 -
setPositionCartographic(cartographic)
-
Moves the camera to the provided cartographic position.
Name Type Description cartographicCartographic The new camera position. Source: Scene/Camera.js, line 1416 -
setTransform(transform)
-
Sets the camera's transform without changing the current view.
Name Type Description transformMatrix4 The camera transform. Source: Scene/Camera.js, line 789 -
twistLeft(amount)
-
Rotate the camera counter-clockwise around its direction vector by amount, in radians.
Name Type Description amountNumber optional The amount, in radians, to rotate by. Defaults to defaultLookAmount.See:
Source: Scene/Camera.js, line 1145 -
twistRight(amount)
-
Rotate the camera clockwise around its direction vector by amount, in radians.
Name Type Description amountNumber optional The amount, in radians, to rotate by. Defaults to defaultLookAmount.See:
Source: Scene/Camera.js, line 1157 -
viewRectangle(rectangle, ellipsoid)
-
View an rectangle on an ellipsoid or map.
Name Type Default Description rectangleRectangle The rectangle to view. ellipsoidEllipsoid Ellipsoid.WGS84optional The ellipsoid to view. Source: Scene/Camera.js, line 1701 -
worldToCameraCoordinates(cartesian, result) → Cartesian4
-
Transform a vector or point from world coordinates to the camera's reference frame.
Name Type Description cartesianCartesian4 The vector or point to transform. resultCartesian4 optional The object onto which to store the result. Returns:
The transformed vector or point.Source: Scene/Camera.js, line 811 -
worldToCameraCoordinatesPoint(cartesian, result) → Cartesian3
-
Transform a point from world coordinates to the camera's reference frame.
Name Type Description cartesianCartesian3 The point to transform. resultCartesian3 optional The object onto which to store the result. Returns:
The transformed point.Source: Scene/Camera.js, line 832 -
worldToCameraCoordinatesVector(cartesian, result) → Cartesian3
-
Transform a vector from world coordinates to the camera's reference frame.
Name Type Description cartesianCartesian3 The vector to transform. resultCartesian3 optional The object onto which to store the result. Returns:
The transformed vector.Source: Scene/Camera.js, line 853 -
zoomIn(amount)
-
Zooms
amountalong the camera's view vector.Name Type Description amountNumber optional The amount to move. Defaults to defaultZoomAmount.See:
Source: Scene/Camera.js, line 1330 -
zoomOut(amount)
-
Zooms
amountalong the opposite direction of the camera's view vector.Name Type Description amountNumber optional The amount to move. Defaults to defaultZoomAmount.See:
Source: Scene/Camera.js, line 1347
Type Definitions
-
FlightCancelledCallback()
-
A function that will execute when a flight is cancelled.Source: Scene/Camera.js, line 2091
-
FlightCompleteCallback()
-
A function that will execute when a flight completes.Source: Scene/Camera.js, line 2086
