OrthographicProjection

View source

ExtendsProjection

Represents the orthographic variant of the Projection contract used by Camera.

This class identifies its variant with ProjectionType.Orthographic.

Examples

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

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

Constructor


constructor(left?: number, right?: number, top?: number, bottom?: number)

View source

Creates an orthographic projection value from rectangular view bounds.

The constructor stores the four bounds as supplied. It does not validate, clamp, normalize, or reorder them. Defaults are left = -1, right = 1, top = 1, and bottom = -1.

Parameters

NameDescriptionDefault
left?

Left view bound.

-1
right?

Right view bound.

1
top?

Top view bound.

1
bottom?

Bottom view bound.

-1

Properties


readonlytype: number

View source

Numeric projection discriminator for this value.

Default: ProjectionType.Orthographic

Methods


isOrthographic(): boolean

View source

Reports that this projection uses orthographic mapping.

Returns

Always true for an orthographic projection.

asProjectionMatrix(near: number, far: number): Matrix4

View source

Builds an orthographic matrix from the stored bounds and clipping distances.

This method delegates to OrthographicProjection.from with (left, right, top, bottom, near, far) from this value and returns the new matrix created by that call. It does not mutate the projection.

Parameters

NameDescriptionDefault
near

Near clipping distance.

—
far

Far clipping distance.

—

Returns

A new orthographic projection matrix.

staticfrom(left: number, right: number, top: number, bottom: number, near: number, far: number, out?: Matrix4): Matrix4

View source

Builds an orthographic matrix from explicit bounds and clipping distances.

The method computes w = 1 / (right - left), h = 1 / (top - bottom), and p = 1 / (far - near). It then computes x = (right + left) * w, y = (top + bottom) * h, z = (far + near) * p, and zInv = -2 * p, and writes the resulting scale, translation, and depth terms into out. The supplied matrix is overwritten and returned; when omitted, a new Matrix4 is used. No bounds or clipping-distance validation is performed.

Parameters

NameDescriptionDefault
left

Left view bound.

—
right

Right view bound.

—
top

Top view bound.

—
bottom

Bottom view bound.

—
near

Near clipping distance.

—
far

Far clipping distance.

—
out?

Matrix to overwrite; defaults to a new matrix.

...

Returns

The newly created or supplied matrix.

staticserialize(value: OrthographicProjection): OrthographicProjectionSerial

View source

Serializes an orthographic projection’s discriminator and bounds.

The returned object always has type: 'orthographic' and copies left, right, top, and bottom from value without validating them.

Parameters

NameDescriptionDefault
value

Projection value to serialize.

—

Returns

Serialized orthographic settings.

staticdeserialize(value: OrthographicProjectionSerial, out?: OrthographicProjection): OrthographicProjection

View source

Deserializes orthographic bounds into a projection value.

The method copies value.left, value.right, value.top, and value.bottom directly. It does not validate the input or copy its type field. Without out, it creates a new OrthographicProjection; with out, it updates and returns that same object.

Parameters

NameDescriptionDefault
value

Serialized orthographic settings.

—
out?

Projection value to update.

...

Returns

The new or supplied projection value.

staticvalidateSerial(value: unknown): value is OrthographicProjectionSerial

View source

Checks whether a value has the serialized orthographic shape.

The value must be a non-null object containing type, left, right, top, and bottom, with type === 'orthographic' and all four bounds having the number JavaScript type. Extra properties are allowed; numeric values are not required to be finite or ordered.

Parameters

NameDescriptionDefault
value

Value to check.

—

Returns

true when the required serialized fields match.