Camera

Camera

new

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 {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);
camera.up = Cesium.Cartesian3.clone(Cesium.Cartesian3.UNIT_Y);
camera.frustum.fovy = Cesium.Math.PI_OVER_THREE;
camera.frustum.near = 1.0;
camera.frustum.far = 2.0;
Demo:
Source:

Members

:Cartesian3

If set, the camera will not be able to rotate past this axis in either direction.
Default Value:
  • undefined

:Number

The default amount to rotate the camera when an argument is not provided to the look methods.
Default Value:
  • Math.PI / 60.0

:Number

The default amount to move the camera when an argument is not provided to the move methods.
Default Value:
  • 100000.0;

:Number

The default amount to rotate the camera when an argument is not provided to the rotate methods.
Default Value:
  • Math.PI / 3600.0

:Number

The default amount to move the camera when an argument is not provided to the zoom methods.
Default Value:
  • 100000.0;

:Cartesian3

The view direction of the camera.

:Cartesian3

Gets the view direction of the camera in world coordinates.

:Frustum

The region of space in view.
Default Value:
  • PerspectiveFrustum()
See:

:Number

Gets or sets the camera heading in radians.

:Matrix4

Gets the inverse camera transform.
Default Value:

:Matrix4

Gets the inverse view matrix.
See:

: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.5

: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.5

:Cartesian3

The position of the camera.

:Cartesian3

Gets the position of the camera in world coordinates.
The right direction of the camera.

:Cartesian3

Gets the right direction of the camera in world coordinates.

:Number

Gets or sets the camera tilt in radians

:Matrix4

Modifies the camera's reference frame. The inverse of this transformation is appended to the view matrix.
Default Value:
See:

:Cartesian3

The up direction of the camera.

:Cartesian3

Gets the up direction of the camera in world coordinates.

:Matrix4

Gets the view matrix.
See:

Methods

Transform a vector or point from the camera's reference frame to world coordinates.

Parameters:
Name Type Argument Description
vector Cartesian4 The vector or point to transform.
result Cartesian4 <optional>
The object onto which to store the result.
Returns:
Cartesian4 The transformed vector or point.

Returns a duplicate of a Camera instance.

Returns:
Camera A new copy of the Camera instance.

Create an animation to move the map into view. This method is only valid for 2D and Columbus modes.

Parameters:
Name Type Description
duration Number The duration, in milliseconds, of the animation.
Throws:
DeveloperException : duration is required.
Returns:
Object The animation or undefined if the scene mode is 3D or the map is already ion view.

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:
Number The magnitude of the position.

Create a ray from the camera position through the pixel at windowPosition in world coordinates.

Parameters:
Name Type Argument Description
windowPosition Cartesian2 The x and y coordinates of a pixel.
result Ray <optional>
The object onto which to store the result.
Returns:
Object Returns the Cartesian3 position and direction of the ray.

Get the camera position needed to view an rectangle on an ellipsoid or map

Parameters:
Name Type Argument Description
rectangle Rectangle The rectangle to view.
result Cartesian3 <optional>
The camera position needed to view the rectangle
Returns:
Cartesian3 The camera position needed to view the rectangle

Rotate each of the camera's orientation vectors around axis by angle

Parameters:
Name Type Argument Description
axis Cartesian3 The axis to rotate around.
angle Number <optional>
The angle, in radians, to rotate by. Defaults to defaultLookAmount.
See:

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.

Parameters:
Name Type Description
eye Cartesian3 The position of the camera.
target Cartesian3 The position to look at.
up Cartesian3 The up vector.
Throws:
  • DeveloperError : lookAt is not supported in 2D mode because there is only one direction to look.
  • DeveloperError : lookAt is not supported while morphing.

Rotates the camera around its right vector by amount, in radians, in the opposite direction of its up vector.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument Description
amount Number <optional>
The amount, in radians, to rotate by. Defaults to defaultLookAmount.
See:

Translates the camera's position by amount along direction.

Parameters:
Name Type Argument Description
direction Cartesian3 The direction to move.
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 view vector.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument Description
amount Number <optional>
The amount, in meters, to move. Defaults to defaultMoveAmount.
See:

Pick an ellipsoid or map.

Parameters:
Name Type Argument Default Description
windowPosition Cartesian2 The x and y coordinates of a pixel.
ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid to pick.
result Cartesian3 <optional>
The object onto which to store the result.
Returns:
Cartesian3 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 by angle. The distance of the camera's position to the center of the camera's reference frame remains the same.

Parameters:
Name Type Argument 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.
transform Matrix4 <optional>
A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
Example
// Rotate about a point on the earth.
var center = ellipsoid.cartographicToCartesian(cartographic);
var transform = Cesium.Matrix4.fromTranslation(center);
camera.rotate(axis, angle, transform);
See:

Rotates the camera around the center of the camera's reference frame by angle downwards.

Parameters:
Name Type Argument Description
angle Number <optional>
The angle, in radians, to rotate by. Defaults to defaultRotateAmount.
transform Matrix4 <optional>
A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
See:

Rotates the camera around the center of the camera's reference frame by angle to the left.

Parameters:
Name Type Argument Description
angle Number <optional>
The angle, in radians, to rotate by. Defaults to defaultRotateAmount.
transform Matrix4 <optional>
A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
See:

Rotates the camera around the center of the camera's reference frame by angle to the right.

Parameters:
Name Type Argument Description
angle Number <optional>
The angle, in radians, to rotate by. Defaults to defaultRotateAmount.
transform Matrix4 <optional>
A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
See:

Rotates the camera around the center of the camera's reference frame by angle upwards.

Parameters:
Name Type Argument Description
angle Number <optional>
The angle, in radians, to rotate by. Defaults to defaultRotateAmount.
transform Matrix4 <optional>
A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
See:

Moves the camera to the provided cartographic position.

Parameters:
Name Type Description
cartographic Cartographic The new camera position.

Sets the camera's transform without changing the current view.

Parameters:
Name Type Description
The Matrix4 camera transform.

Rotate the camera counter-clockwise around its direction vector by amount, in radians.

Parameters:
Name Type Argument 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.

Parameters:
Name Type Argument Description
amount Number <optional>
The amount, in radians, to rotate by. Defaults to defaultLookAmount.
See:

View an rectangle on an ellipsoid or map.

Parameters:
Name Type Argument Default Description
rectangle Rectangle The rectangle to view.
ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid to view.

Transform a vector or point from world coordinates to the camera's reference frame.

Parameters:
Name Type Argument Description
cartesian Cartesian4 The vector or point to transform.
result Cartesian4 <optional>
The object onto which to store the result.
Returns:
Cartesian4 The transformed vector or point.

Zooms amount along the camera's view vector.

Parameters:
Name Type Argument Description
amount Number <optional>
The amount to move. Defaults to defaultZoomAmount.
See:

Zooms amount along the opposite direction of the camera's view vector.

Parameters:
Name Type Argument Description
amount Number <optional>
The amount to move. Defaults to defaultZoomAmount.
See: