Projection

View source

Defines the polymorphic projection value contract used by Camera.

Use PerspectiveProjection or OrthographicProjection for the built-in projection values; their type values are represented by ProjectionType.

Examples

import { Camera, OrthographicProjection } from '@wimaengine/render-core'

const camera = new Camera(new OrthographicProjection(-1, 1, 1, -1))
const matrix = camera.projectionMatrix()

Constructor


constructor()

Methods


asProjectionMatrix(_near: number, _far: number): Matrix4

View source

Returns the base projection matrix.

The base implementation ignores both clipping distances and returns a new identity Matrix4. The Camera calls this method polymorphically; concrete projection values provide their own transforms.

Parameters

NameDescriptionDefault
_near

Near clipping distance, ignored by the base implementation.

—
_far

Far clipping distance, ignored by the base implementation.

—

Returns

A new identity matrix.

staticserialize(_value: unknown): object

View source

Serializes the base projection value.

The base implementation ignores _value and returns a new empty object. It does not select a ProjectionType or persist concrete settings; Camera.serialize uses the built-in projection serializers for camera data.

Parameters

NameDescriptionDefault
_value

Value ignored by the base serializer.

—

Returns

Empty serialized representation.

staticdeserialize(_value: unknown, out?: Projection): Projection

View source

Deserializes the base projection value.

The base implementation ignores _value and returns the supplied out object unchanged, or a new Projection when out is omitted. It does not select a concrete projection; Camera.deserialize chooses the built-in projection from its serialized discriminator.

Parameters

NameDescriptionDefault
_value

Serialized value ignored by the base deserializer.

—
out?

Projection object to return, defaulting to a new base value.

...

Returns

The supplied output object or a new base projection.