Skip to content

Documentation / @ripl/3d / Camera

Class: Camera ​

Defined in: 3d/src/core/camera.ts:82

An interactive camera controlling the 3D context's view and projection, with mouse/touch orbit, pan, and zoom.

Extends ​

Constructors ​

Constructor ​

new Camera(context, options?): Camera

Defined in: 3d/src/core/camera.ts:167

Parameters ​

ParameterType
contextContext3D
options?CameraOptions

Returns ​

Camera

Overrides ​

Disposer.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
defaultKeyreadonlytypeof defaultKeyThe key under which resources are retained when no explicit key is provided.Disposer.defaultKeycore/src/core/disposer.ts:11

Accessors ​

far ​

Get Signature ​

get far(): number

Defined in: 3d/src/core/camera.ts:148

The distance to the far clipping plane.

Returns ​

number

Set Signature ​

set far(value): void

Defined in: 3d/src/core/camera.ts:152

Parameters ​
ParameterType
valuenumber
Returns ​

void


fov ​

Get Signature ​

get fov(): number

Defined in: 3d/src/core/camera.ts:128

The vertical field of view in degrees.

Returns ​

number

Set Signature ​

set fov(value): void

Defined in: 3d/src/core/camera.ts:132

Parameters ​
ParameterType
valuenumber
Returns ​

void


near ​

Get Signature ​

get near(): number

Defined in: 3d/src/core/camera.ts:138

The distance to the near clipping plane.

Returns ​

number

Set Signature ​

set near(value): void

Defined in: 3d/src/core/camera.ts:142

Parameters ​
ParameterType
valuenumber
Returns ​

void


position ​

Get Signature ​

get position(): Vector3

Defined in: 3d/src/core/camera.ts:98

The camera's world-space position (eye point).

Returns ​

Vector3

Set Signature ​

set position(value): void

Defined in: 3d/src/core/camera.ts:102

Parameters ​
ParameterType
valueVector3
Returns ​

void


projection ​

Get Signature ​

get projection(): "perspective" | "orthographic"

Defined in: 3d/src/core/camera.ts:158

The projection type, either 'perspective' or 'orthographic'.

Returns ​

"perspective" | "orthographic"

Set Signature ​

set projection(value): void

Defined in: 3d/src/core/camera.ts:162

Parameters ​
ParameterType
value"perspective" | "orthographic"
Returns ​

void


target ​

Get Signature ​

get target(): Vector3

Defined in: 3d/src/core/camera.ts:108

The world-space point the camera looks at.

Returns ​

Vector3

Set Signature ​

set target(value): void

Defined in: 3d/src/core/camera.ts:112

Parameters ​
ParameterType
valueVector3
Returns ​

void


up ​

Get Signature ​

get up(): Vector3

Defined in: 3d/src/core/camera.ts:118

The world-space up direction.

Returns ​

Vector3

Set Signature ​

set up(value): void

Defined in: 3d/src/core/camera.ts:122

Parameters ​
ParameterType
valueVector3
Returns ​

void

Methods ​

dispose() ​

dispose(): void

Defined in: 3d/src/core/camera.ts:500

Disposes all resources under the given key, or all resources if no key is provided.

Returns ​

void

Overrides ​

Disposer.dispose


flush() ​

flush(): void

Defined in: 3d/src/core/camera.ts:198

Flushes pending camera changes to the 3D context's view and projection matrices.

Returns ​

void


lookAt() ​

lookAt(target): void

Defined in: 3d/src/core/camera.ts:297

Points the camera at a new world-space target.

Parameters ​

ParameterTypeDescription
targetVector3The world-space point to look at.

Returns ​

void


orbit() ​

orbit(deltaTheta, deltaPhi): void

Defined in: 3d/src/core/camera.ts:230

Orbits the camera around its target on a sphere.

Parameters ​

ParameterTypeDescription
deltaThetanumberThe horizontal (azimuthal) rotation to apply, in radians.
deltaPhinumberThe vertical (polar) rotation to apply, in radians. Clamped to avoid flipping over the poles.

Returns ​

void


pan() ​

pan(dx, dy): void

Defined in: 3d/src/core/camera.ts:260

Pans the camera and its target together across the view plane.

Parameters ​

ParameterTypeDescription
dxnumberThe distance to move along the camera's right axis, in world units.
dynumberThe distance to move along the camera's up axis, in world units.

Returns ​

void


retain() ​

protected retain(value, key?): void

Defined in: core/src/core/disposer.ts:14

Registers a disposable resource under an optional key for later cleanup.

Parameters ​

ParameterTypeDefault value
valueDisposableundefined
keyPropertyKeyDisposer.defaultKey

Returns ​

void

Inherited from ​

Disposer.retain


zoom() ​

zoom(delta): void

Defined in: 3d/src/core/camera.ts:280

Dollies the camera toward or away from its target along the view direction.

Parameters ​

ParameterTypeDescription
deltanumberThe distance to move toward the target, in world units. Positive zooms in, negative zooms out. Clamped so the target never crosses the near plane, which would empty the frustum.

Returns ​

void