new CameraController
Provides methods for common camera manipulations.
Throws:
Members
-
constrainedAxis :Cartesian3
-
If set, the camera will not be able to rotate past this axis in either direction.
- Default Value:
- undefined
-
defaultLookAmount :Number
-
The default amount to rotate the camera when an argument is not provided to the look methods.
- Default Value:
- Math.PI / 60.0
-
defaultMoveAmount :Number
-
The default amount to move the camera when an argument is not provided to the move methods.
- Default Value:
- 100000.0;
-
defaultRotateAmount :Number
-
The default amount to rotate the camera when an argument is not provided to the rotate methods.
- Default Value:
- Math.PI / 3600.0
-
defaultZoomAmount :Number
-
The default amount to move the camera when an argument is not provided to the zoom methods.
- Default Value:
- 100000.0;
-
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.5
-
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.5
-
<static> heading :Number
-
The camera heading in radians.
-
<static> tilt :Number
-
The the camera tilt in radians
Methods
-
createCorrectPositionAnimation
-
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. -
getExtentCameraCoordinates
-
Get the camera position needed to view an extent on an ellipsoid or map
Parameters:
Name Type Argument Description extent
Extent The extent to view. result
Cartesian3 <optional>
The camera position needed to view the extent Throws:
DeveloperError : extent is required.Returns:
Cartesian3 The camera position needed to view the extent -
getMagnitude
-
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. -
getPickRay
-
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. Throws:
DeveloperError : windowPosition is required.Returns:
Object Returns the Cartesian3 position and direction of the ray. -
look
-
Rotate each of the camera's orientation vectors around
axis
byangle
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
.Throws:
DeveloperError : axis is required. -
lookAt
-
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 : eye is required.
-
DeveloperError : target is required.
-
DeveloperError : up is required.
-
DeveloperError : lookAt is not supported in 2D mode because there is only one direction to look.
-
DeveloperError : lookAt is not supported while morphing.
-
-
lookDown
-
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
. -
lookLeft
-
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
. -
lookRight
-
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
. -
lookUp
-
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
. -
move
-
Translates the camera's position by
amount
alongdirection
.Parameters:
Name Type Argument Description direction
Cartesian3 The direction to move. amount
Number <optional>
The amount, in meters, to move. Defaults to defaultMoveAmount
.Throws:
DeveloperError : direction is required. -
moveBackward
-
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
. -
moveDown
-
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
. -
moveForward
-
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
. -
moveLeft
-
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
. -
moveRight
-
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
. -
moveUp
-
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
. -
pickEllipsoid
-
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. Throws:
DeveloperError : windowPosition is required.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. -
rotate
-
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.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. Throws:
DeveloperError : axis is required.Example
// Rotate about a point on the earth. var center = ellipsoid.cartographicToCartesian(cartographic); var transform = Matrix4.fromTranslation(center); controller.rotate(axis, angle, transform);
-
rotateDown
-
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. -
rotateLeft
-
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. -
rotateRight
-
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. -
rotateUp
-
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. -
setPositionCartographic
-
Moves the camera to the provided cartographic position.
Parameters:
Name Type Description cartographic
Cartographic The new camera position. Throws:
DeveloperError : cartographic is required. -
twistLeft
-
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
. -
twistRight
-
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
. -
viewExtent
-
View an extent on an ellipsoid or map.
Parameters:
Name Type Argument Default Description extent
Extent The extent to view. ellipsoid
Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid to view. Throws:
DeveloperError : extent is required. -
zoomIn
-
Zooms
amount
along the camera's view vector.Parameters:
Name Type Argument Description amount
Number <optional>
The amount to move. Defaults to defaultZoomAmount
. -
zoomOut
-
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
.