Skip to main content

Interface: CameraManipulator

Helper that enables camera interaction similar to sketchfab or Google Maps.

Clients notify the camera manipulator of various mouse or touch events, then periodically call its getLookAt() method so that they can adjust their camera(s). Three modes are supported: ORBIT, MAP, and FREE_FLIGHT. To construct a manipulator instance, the desired mode is passed into the create method.

Extends

  • PointerHolder

Properties

isValid

readonly isValid: boolean

Get if the refernce to the native pointer is still valid and strong.

If this is false, this object has been manually released with release() and all other methods on this object will throw an Error.

Inherited from

PointerHolder.isValid

Defined in

src/types/PointerHolder.ts:37

Methods

getLookAt()

getLookAt(): [Float3, Float3, Float3]

Returns

[Float3, Float3, Float3]

Defined in

src/types/CameraManipulator.ts:58


grabBegin()

grabBegin(x, y, strafe): void

Starts a grabbing session (i.e. the user is dragging around in the viewport).

In MAP mode, this starts a panning session. In ORBIT mode, this starts either rotating or strafing. In FREE_FLIGHT mode, this starts a nodal panning session.

Parameters

x: number

X-coordinate for point of interest in viewport space

y: number

Y-coordinate for point of interest in viewport space

strafe: boolean

ORBIT mode only; if true, starts a translation rather than a rotation

Returns

void

Defined in

src/types/CameraManipulator.ts:44


grabEnd()

grabEnd(): void

Ends a grabbing session.

Returns

void

Defined in

src/types/CameraManipulator.ts:56


grabUpdate()

grabUpdate(x, y): void

Updates a grabbing session.

This must be called at least once between grabBegin / grabEnd to dirty the camera.

Parameters

x: number

y: number

Returns

void

Defined in

src/types/CameraManipulator.ts:51


release()

release(): void

Manually release this reference to the native pointer. This will ensure that JS will no longer hold a strong reference, and memory can be safely cleaned up.

If the native pointer is still referenced elsewhere in native code, the underlying memory will not be deleted unless the other references are also released.

If this is not called, the memory will only be cleaned once the JS gabage collector decides to delete this object, which might be at any point in the future.

Calling release() is not required as the GC will destroy this object eventually anyways, but it is recommended to optimize memory usage.

After manually releasing a pointer, all future methods on this object will throw an Error.

Returns

void

Inherited from

PointerHolder.release

Defined in

src/types/PointerHolder.ts:30


scroll()

scroll(x, y, scrolldelta): void

In MAP and ORBIT modes, dollys the camera along the viewing direction. In FREE_FLIGHT mode, adjusts the move speed of the camera.

Parameters

x: number

X-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT mode

y: number

Y-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT mode

scrolldelta: number

In MAP and ORBIT modes, negative means "zoom in", positive means "zoom out" In FREE_FLIGHT mode, negative means "slower", positive means "faster"

Returns

void

Defined in

src/types/CameraManipulator.ts:22


update()

update(deltaTime): void

Processes input and updates internal state.

This must be called once every frame before getLookAt is valid.

Parameters

deltaTime: number

The amount of time, in seconds, passed since the previous call to update.

Returns

void

Defined in

src/types/CameraManipulator.ts:31