Skip to content

Documentation / @ripl/3d / Camera

Class: Camera

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

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:190

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:171

The distance to the far clipping plane.

Returns

number

Set Signature

set far(value): void

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

Parameters
ParameterType
valuenumber
Returns

void


fov

Get Signature

get fov(): number

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

The vertical field of view in degrees.

Returns

number

Set Signature

set fov(value): void

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

Parameters
ParameterType
valuenumber
Returns

void


near

Get Signature

get near(): number

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

The distance to the near clipping plane.

Returns

number

Set Signature

set near(value): void

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

Parameters
ParameterType
valuenumber
Returns

void


position

Get Signature

get position(): Vector3

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

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

Returns

Vector3

Set Signature

set position(value): void

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

Parameters
ParameterType
valueVector3
Returns

void


projection

Get Signature

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

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

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

Returns

"perspective" | "orthographic"

Set Signature

set projection(value): void

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

Parameters
ParameterType
value"perspective" | "orthographic"
Returns

void


target

Get Signature

get target(): Vector3

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

The world-space point the camera looks at.

Returns

Vector3

Set Signature

set target(value): void

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

Parameters
ParameterType
valueVector3
Returns

void


up

Get Signature

get up(): Vector3

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

The world-space up direction.

Returns

Vector3

Set Signature

set up(value): void

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

Parameters
ParameterType
valueVector3
Returns

void

Methods

dispose()

dispose(): void

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

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:221

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:312

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:253

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:278

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:298

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. Clamped so the camera never passes the target.

Returns

void