Skip to main content
Version: 3.x

Interface: CameraManager

@cognite/reveal.CameraManager

Interface for manager responsible for all manipulations to the camera, including animations and modification of state. Implementations are responsible for providing a THREE.PerspectiveCamera instance to Cognite3DViewer. Implementations must trigger the cameraChange-event when camera is changed. The default implementation is DefaultCameraManager.

Implemented by

Properties

enabled

Optional enabled: boolean

Enables or disables camera manager. When disabled, camera manager shouldn't consume or react to any DOM events.

Defined in

packages/camera-manager/src/CameraManager.ts:81

Methods

dispose

dispose(): void

obvious

Returns

void

Defined in

packages/camera-manager/src/CameraManager.ts:77


fitCameraToBoundingBox

fitCameraToBoundingBox(boundingBox, duration?, radiusFactor?): void

Moves camera to a place where the content of a bounding box is visible to the camera.

Parameters

NameTypeDescription
boundingBoxBox3-
duration?numberThe duration of the animation moving the camera.
radiusFactor?numberThe ratio of the distance from camera to center of box and radius of the box.

Returns

void

Defined in

packages/camera-manager/src/CameraManager.ts:65


getCamera

getCamera(): PerspectiveCamera

Returns the camera used for rendering in Cognite3DViewer. Note that the camera will not be modified directly by Reveal. Implementations must trigger the cameraChange-event whenever the camera changes.

Returns

PerspectiveCamera

Defined in

packages/camera-manager/src/CameraManager.ts:21


getCameraState

getCameraState(): Required<CameraState>

Get camera's state

Returns

Required<CameraState>

Camera state: position, target and rotation.

Defined in

packages/camera-manager/src/CameraManager.ts:44


off

off(event, callback): void

Unsubscribes from changes of the camera event.

Parameters

NameTypeDescription
event"cameraChange"Name of the event.
callbackCameraChangeDelegateCallback function to be unsubscribed.

Returns

void

Defined in

packages/camera-manager/src/CameraManager.ts:57


on

on(event, callback): void

Subscribes to changes of the camera event. This is used by Reveal to react on changes of the camera.

Parameters

NameTypeDescription
event"cameraChange"Name of the event.
callbackCameraChangeDelegateCallback to be called when the event is fired.

Returns

void

Defined in

packages/camera-manager/src/CameraManager.ts:51


setCameraState

setCameraState(state): void

Set camera's state. Rotation and target can't be set at the same time as they could conflict, should throw an error if both are passed with non-zero value inside state.

example

// store position, target
const { position, target } = cameraManager.getCameraState();
// restore position, target
cameraManager.setCameraState({ position, target });

Parameters

NameTypeDescription
stateCameraStateCamera state, all fields are optional.

Returns

void

Defined in

packages/camera-manager/src/CameraManager.ts:38


update

update(deltaTime, boundingBox): void

Updates internal state of camera manager. Expected to update visual state of the camera as well as it's near and far planes if needed. Called in requestAnimationFrame-loop. Reveal performance affects frequency with which this method is called.

Parameters

NameTypeDescription
deltaTimenumberDelta time since last update in seconds.
boundingBoxBox3Global bounding box of the model(s) and any custom objects added to the scene.

Returns

void

Defined in

packages/camera-manager/src/CameraManager.ts:73