Skip to content

Matrix4

new Matrix4(elements?)

THREE equivalent: THREE.Matrix4

Column-major 4x4 matrix backed by a Float32Array. Initialises to identity when called with no arguments.

Differs from THREE.js

multiply() is named mul(). makePerspective takes fov in radians (not degrees) and has a different parameter order than THREE.

Name Type Description
elements Float32Array Flat 16-element column-major storage (read-only accessor).
Method Description
identity(): this Resets to the identity matrix.
copy(m: Matrix4): this Copies elements from another Matrix4.
clone(): Matrix4 Returns a new Matrix4 with the same elements.
compose(position: Vector3, q: Quaternion, scale: Vector3): this Builds a TRS matrix from position, quaternion, and scale.
decompose(position: Vector3, q: Quaternion, scale: Vector3): this Extracts position, quaternion, and scale from this matrix.
invert(): this Inverts the matrix in place.
mul(m: Matrix4): this Post-multiplies this matrix by m.
mulMatrices(a: Matrix4, b: Matrix4): this Sets this to a x b.
makePerspective(fov: number, aspect: number, near: number, far: number): this Builds a perspective projection matrix from radians fov.
makeOrthographic(left, right, top, bottom, near, far): this Builds an orthographic projection matrix.