Interface: ICustomCameraControls
viewer.ICustomCameraControls
interface
description
Interface for custom camera controls.
This is a specification for implementers to model:
it is not an exported method or class.
Custom camera controls allow the API user to freely move the viewer's camera and define the camera projection used. These camera properties are used to render the viewer 3D scene directly into the viewer's GL context.
Custom camera controls must implement the onActivate, onAnimationFrame, onAttach, onDeactivate, onDetach, onReference, and onResize methods.
Custom camera controls trigger rerendering automatically when the camera pose or projection is changed through the projectionMatrix and viewMatrix callbacks.
See the model view projection article on MDN for an introduction to view and projection matrices.
Custom camera controls can choose to make updates on each animation frame or only based on user input. Invoking updates on each camera frame is more resource intensive.
Only a single custom camera control instance can be attached to the viewer at any given time.
#
Methods#
onActivateâ–¸ onActivate(viewer
, viewMatrix
, projectionMatrix
, reference
): void
Method called when the camera controls have been activated and is responsible for moving the viewer's camera and defining its projection. This method gives the camera controls a chance to initialize resources, perform any transitions, and determine initial state.
description
Use the Viewer.getContainer method
to get the container for determining the viewer size
and aspect as well as for attaching event handlers.
Use the view matrix to determine initial properties such as camera position, forward vector, and up vector.
Use the projection matrix to determine the initial projection properties.
Store the reference coordiante translations during future reference reference changes.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom camera controls instance was just added to. |
viewMatrix | number [] | The viewer's view matrix. |
projectionMatrix | number [] | The viewers's projection matrix. |
reference | LngLatAlt | The viewer's reference. |
#
Returnsvoid
#
Defined inviewer/interfaces/ICustomCameraControls.ts:67
#
onAnimationFrameâ–¸ onAnimationFrame(viewer
, frameId
): void
Method called for each animation frame.
desdcription
Custom camera controls can choose to
make updates on each animation frame or only based on
user input. Invoking updates on each animation frame is
more resource intensive.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom camera controls instance is attached to. |
frameId | number | The request animation frame's id. |
#
Returnsvoid
#
Defined inviewer/interfaces/ICustomCameraControls.ts:86
#
onAttachâ–¸ onAttach(viewer
, viewMatrixCallback
, projectionMatrixCallback
): void
Method called when the camera controls have been attached to the viewer. This gives the camera controls a chance to initialize resources.
description
Camera controls are attached to the
viewer with the with Viewer.attachCustomCameraControls
method.
Use the matrix callback functions to modify the camera pose and projection of the viewer's camera.
Invoking the matrix callbacks has no effect if the custom camera controls have not been activated.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom camera controls instance was just added to. |
viewMatrixCallback | (viewMatrix : number []) => void | - |
projectionMatrixCallback | (projectionMatrix : number []) => void | - |
#
Returnsvoid
#
Defined inviewer/interfaces/ICustomCameraControls.ts:110
#
onDeactivateâ–¸ onDeactivate(viewer
): void
Method called when the camera controls have been deactivated. This gives the camera controls a chance to clean up resources and event listeners.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom camera controls instance is attached to. |
#
Returnsvoid
#
Defined inviewer/interfaces/ICustomCameraControls.ts:124
#
onDetachâ–¸ onDetach(viewer
): void
Method called when the camera controls have been detached from the viewer. This gives the camera controls a chance to clean up resources and event listeners.
description
Camera controls are attached to the
viewer with the with Viewer.detachCustomCameraControls
method.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom camera controls instance was just detached from. |
#
Returnsvoid
#
Defined inviewer/interfaces/ICustomCameraControls.ts:138
#
onReferenceâ–¸ onReference(viewer
, reference
): void
Method called when the viewer's reference position has changed. This gives the custom camera controls a chance to reposition the camera.
description
Calculate the updated topocentric positions
for scene objects using the previous reference, the
new provided reference as well as the
geodeticToEnu and
enuToGeodetic functions.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom renderer is added to. |
reference | LngLatAlt | The viewer's current reference position. |
#
Returnsvoid
#
Defined inviewer/interfaces/ICustomCameraControls.ts:156
#
onResizeâ–¸ onResize(viewer
): void
Method called when the viewer has been resized.
description
Use this method to modify the projection.
#
ParametersName | Type |
---|---|
viewer | IViewer |
#
Returnsvoid