ShapeDiver Viewer - Camera API
The CameraApi implements all functionality related to the camera.
Methods
-
addEventListener(type, callback)
-
Add a callback to be invoked when a certain event occurs
Parameters:
Name Type Description typeCameraEventType Type of event to subscribe to
callbackEventListenerCallback Function to be called when the event fires
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse APIResponse with an EventListenerToken object. The event listener token can be used to remove the event listener by calling removeEventListener.
-
animateAsync(path [, transition])
-
Animate camera along a path. The camera starts at the first position of the path, so if the camera should start from the current position, add it to the start of the path.
Parameters:
Name Type Argument Description pathArray.<CameraDefinition> Array of camera definition objects defining a camera path
transitionTransitionParameters <optional>
Definition of the parameters to use for the transition (tween)
- Inherited From:
- Overrides:
Returns:
-
Type Description Promise.<APIResponse> APIResponse with a CameraDefinition according to the camera's final position.
-
get()
-
Returns the position and target of the camera as a CameraDefinition. If no target is available for this type of camera, the property target is undefined.
Returns:
-
Type Description APIResponse APIResponse with a CameraDefinition.
-
-
removeEventListener(token)
-
Remove an event listener
Parameters:
Name Type Description tokenEventListenerToken event listener token for event listener to be removed
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse APIResponse with a Boolean data, indicating whether the event listener could be removed.
-
resetAsync( [transition])
-
Reset camera to its currently configured default configuration
Parameters:
Name Type Argument Description transitionTransitionParameters <optional>
Definition of the parameters to use for the transition (tween)
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse APIResponse with a CameraDefinition of the camera's default definition.
-
updateAsync(camera [, transition])
-
Update camera
If target and/or position are provided, the camera will be moved to its new orientation
Parameters:
Name Type Argument Description cameraCameraDefinition The new camera properties
transitionTransitionParameters <optional>
Definition of the parameters to use for the transition (tween)
- Inherited From:
- Overrides:
Returns:
-
Type Description Promise.<APIResponse> APIResponse with a CameraDefinition according to the new properties.
-
updateMatrices(viewMatrix, projectionMatrix)
-
Update camera based on raw camera view and projection matrices.
When providing raw updates to the camera matrices, the camera controls should typically be disabled using setting scene.camera.enableCameraControls
Parameters:
Name Type Description viewMatrixTHREE.Matrix4 camera view matrix, transforming world coordinates to camera coordinates
projectionMatrixTHREE.Matrix4 camera projection matrix
- Inherited From:
- Overrides:
-
zoomAsync( [scenePathsOrBB] [, transition])
-
Zoom to show some or all objects in the scene
Parameters:
Name Type Argument Description scenePathsOrBBArray.<ScenePathType> | THREE.Box3 <optional>
The paths of the scene which the camera should capture or a 3D box which should be encapsulated afterwards. If none are provided, the camera will zoom to the scene extents.
transitionTransitionParameters <optional>
Definition of the parameters to use for the transition (tween)
Returns:
-
Type Description Promise.<APIResponse> APIResponse with a CameraDefinition of the camera's new orientation.
-
Members
-
<readonly> CONTROLTYPE :ControlType
-
Enum for control types.
Type:
- ControlType
- Inherited From:
Properties:
Name Type Default Description ORBITControlType 0 the orbit controls (default for perspective camera)
FPSControlType 1 the fps controls
ORTHOGRAPHICControlType 2 the orthographic controls (default for orthograhpic camera)
-
<readonly> EVENTTYPE :CameraEventType
-
Enum for supported camera event types.
Type:
- Inherited From:
Properties:
Name Type Default Description CAMERA_STARTCameraEventType start a camera movement has started
CAMERA_MOVECameraEventType move a camera movement has been continued
CAMERA_ENDCameraEventType end a camera movement has ended
-
<readonly> TYPE :CameraType
-
Enum for camera types.
Type:
- Inherited From:
Properties:
Name Type Default Description PERSPECTIVECameraType 0 perspective camera
TOPCameraType 1 orthographic camera, top view
BOTTOMCameraType 2 orthographic camera, bottom view
RIGHTCameraType 3 orthographic camera, right view
LEFTCameraType 4 orthographic camera, left view
BACKCameraType 5 orthographic camera, back view
FRONTCameraType 6 orthographic camera, front view
ARCameraType 7 AR camera
Type Definitions
-
CameraDefinition
-
The camera definition including the camera's position and target as Point3d.
Type:
- Object
-
CameraEventType
-
Camera event type, see EVENTTYPE for values
See:
Type:
- String
-
CameraType
-
The camera type, see TYPE for values
Type:
- Number
-
TransitionParameters
-
Definition of a transition function for camera movements
Type:
- Object
- Inherited From:
Properties:
Name Type Argument Default Description defaultBoolean <optional>
false If true store final camera position and target as default.
durationNumber <optional>
1000 duration of the transition in milliseconds
easingString | function <optional>
'Quartic.InOut' In case a string S is provided, the corresponding easing function TWEEN.Easing[S] will be used if it exists. The easing function may also be passed directly, e.g. one of the many provided by Tween, see also TweenExplained, or a manually defined one.
interpolationString <optional>
'CatmullRom' In case a string S is provided, the corresponding interpolation function TWEEN.Interpolation[S] will be used if it exists. Tween supports Linear, Bezier, and CatmullRom.
coordinatesString <optional>
'cylindrical' Defines coordinate system to use for animated camera paths. One of 'spherical' or 'cylindrical'.