Optionaldata: ArrayLike<number>Returns a deep copy of this matrix.
Returns the element at the given column and row.
Writes a value at the given column and row.
Returns the transpose.
Returns the inverse, or the identity matrix if this matrix is singular.
Returns the inverse-transpose of the upper-left 3x3, embedded in a 4x4 matrix.
Use this to transform normals when the model matrix contains non-uniform scale.
Sets this matrix to the 4x4 identity.
Sets this matrix to a translation by (x, y, z).
Sets this matrix to a non-uniform scale with the given per-axis factors.
Sets this matrix to a rotation of rad radians around the X axis.
Sets this matrix to a rotation of rad radians around the Y axis.
Sets this matrix to a rotation of rad radians around the Z axis.
Sets this matrix to the rotation defined by quaternion components (qx, qy, qz, qw).
Sets this matrix to a right-handed perspective projection with the WebGPU clip-space depth range [0, 1].
In-place matrix product: this ← a * b. Alias-safe — this may equal a,
b, or both. Computes into a class-private scratch buffer before writing
back so the source data isn't trampled mid-multiply. Use in hot loops to
avoid the per-call Float32Array allocation that multiply() does.
In-place: this ← inverse-transpose of the upper-left 3x3 of src, with
the 4th row/column zeroed and [15] = 1 (the same shape as normalMatrix()).
Alias-safe — src may equal this because we read every src entry into a
local before writing the output. Use in hot loops.
StaticidentityReturns the 4x4 identity matrix.
StatictranslationStaticscaleReturns a non-uniform scale matrix with the given per-axis factors.
StaticrotationStaticrotationStaticrotationStaticfromBuilds a rotation matrix from quaternion components (qx, qy, qz, qw).
StaticperspectiveBuilds a right-handed perspective projection with the WebGPU clip-space depth range [0, 1].
vertical field of view in radians
viewport width / height
near plane distance (positive)
far plane distance (positive)
StaticperspectiveReversed-Z perspective (WebGPU clip-space depth [0,1], but mapping the NEAR
plane to 1 and the FAR plane to 0). Paired with a float depth buffer and a
greater/greater-equal depth test, this spreads depth precision near-
uniformly across the frustum, so a very large far/near ratio no longer
z-fights. Drop-in for perspective; its inverse is still a valid
invViewProj, so shaders that reconstruct world position from the depth
buffer work unchanged — only explicit far-plane tests (far is now 0) and
hardcoded depth-linearization formulas need flipping.
StaticorthographicStaticlookStatictrs
Column-major 4x4 matrix compatible with WebGPU/WGSL.
Internal storage is a Float32Array of 16 elements where the element at column
c, rowrlives atdata[c * 4 + r]. All instance methods are non-mutating (they return a new Mat4); the underlyingdatabuffer is exposed as readonly.