Skip to content

Camera ​

Abstract base class for cameras.

A camera pairs a world-space transform with a projection, producing the view and projection matrices used to render a viewport. The concrete cameras, OrthographicCamera and PerspectiveCamera, define the projection. This class provides the shared transform, derived matrices, and navigation helpers.

Extends Node and inherits all public properties and methods.

Extended by ​

Types ​

CameraType ​

Identifies a concrete camera implementation.

ts
type CameraType = "OrthographicCamera" | "PerspectiveCamera";

Accessors ​

type CameraType overrides ​

Identifies the camera type.

ts
get abstract type(): CameraType;

projectionMatrix mat4 ​

The camera's projection matrix.

ts
get projectionMatrix(): mat4;

transform TrsTransform ​

The camera's world-space transform.

ts
get transform(): TrsTransform;

viewMatrix mat4 ​

The view matrix: the inverse of the camera's world transform.

ts
get viewMatrix(): mat4;

The camera's local right axis in world space.

ts
get right(): vec3;

up vec3 ​

The camera's local up axis in world space.

ts
get up(): vec3;

frustum Frustum ​

The view frustum derived from the current view-projection.

ts
get frustum(): Frustum;

position vec3 ​

The camera's world-space position.

ts
get position(): vec3;

Methods ​

update() void ​

Recomputes the camera's projection matrix.

ts
update(): void;

getViewProjection() mat4 ​

Computes the combined view-projection matrix.

ts
getViewProjection(): mat4;

setAspectRatio() void ​

Sets the aspect ratio (width / height) of the viewport the camera renders into. Called automatically by the owning viewport when it resizes.

ts
abstract setAspectRatio(aspectRatio): void;
ParameterDescription
aspectRatio: numberThe viewport's width divided by its height.

zoom() void ​

Zooms the view by the given factor relative to the current zoom level. Factors greater than 1 zoom in and factors between 0 and 1 zoom out.

ts
abstract zoom(factor): void;
ParameterDescription
factor: numberThe magnification factor to apply.

pan() void ​

Moves the camera by the given world-space offset.

ts
pan(vec): void;
ParameterDescription
vec: vec3The translation to add to the camera's position.

clipToWorld() vec3 ​

Transforms a position from clip space to world space.

ts
clipToWorld(position): vec3;
ParameterDescription
position: vec3The clip-space position to transform.

Released under the MIT License