Skip to main content

Function: createProjectionMatrix()

createProjectionMatrix(width, height, cameraPosition, zoom, pixelsPerUnit?): Matrix3x3

Defined in: rendering/shaders/utils/create-projection-matrix.ts:15

Creates a projection matrix for rendering with a camera. The projection matrix is centered on the camera position and applies zoom.

Parameters​

width​

number

The width of the viewport.

height​

number

The height of the viewport.

cameraPosition​

Vector2

The position of the camera in world coordinates.

zoom​

number

The zoom level to apply to the projection.

pixelsPerUnit?​

number = 1

The number of pixels one world unit occupies (see calculatePixelsPerUnit). Defaults to 1.

Returns​

Matrix3x3

A 3x3 projection matrix that can be used for rendering.