Mathematical functions and types for working with matrices
Helpers for building and manipulating 3×3 and 4×4 matrices used throughout the
SDK for camera projection, object transforms, and coordinate conversion.
Matrices are represented as either typed arrays (Float32Array / Float64Array) or
plain JS numeric tuples. All functions accept either form and (where supported) can
write results into an optional destination array to reduce allocations.
This module assumes an affine transform layout where translation occupies the last
column (m[12], m[13], m[14]) and the homogeneous component is m[15].
Many functions treat the matrix as an affine transform (rotation/scale + translation),
while projection helpers (perspective/frustum/ortho) create full projective matrices.
Several helpers (eg. decomposeMat4, some closures like scalingMat4c)
keep internal scratch vectors/matrices to avoid repeated allocations. These are not
thread-safe/re-entrant, but are safe for typical single-threaded JS execution.
xeokit Matrix Math Utilities
Mathematical functions and types for working with matrices
Helpers for building and manipulating 3×3 and 4×4 matrices used throughout the SDK for camera projection, object transforms, and coordinate conversion.
Matrices are represented as either typed arrays (
Float32Array/Float64Array) or plain JS numeric tuples. All functions accept either form and (where supported) can write results into an optional destination array to reduce allocations.Matrix types
Coordinate conventions
This module assumes an affine transform layout where translation occupies the last column (
m[12],m[13],m[14]) and the homogeneous component ism[15]. Many functions treat the matrix as an affine transform (rotation/scale + translation), while projection helpers (perspective/frustum/ortho) create full projective matrices.Common workflows
Performance notes
Several helpers (eg. decomposeMat4, some closures like scalingMat4c) keep internal scratch vectors/matrices to avoid repeated allocations. These are not thread-safe/re-entrant, but are safe for typical single-threaded JS execution.