Creates a new MutableMatrix44_ instance.
The typed array containing the matrix components
Configuration object containing the typed array constructor
Gets the class name identifier for this matrix type.
The string 'MutableMatrix44'
Converts the matrix to a GLSL mat4 string representation with float precision.
A GLSL-compatible string representation of the matrix
Converts the matrix to a GLSL mat4 string representation with integer values.
A GLSL-compatible string representation of the matrix with integer values
Indicates whether this matrix is an identity matrix class.
This property should be overridden in derived classes that represent identity matrices to return true.
False for the base AbstractMatrix class
Gets the value at position (0,0) in the matrix.
The value at position (0,0)
Sets the value at position (0,0) in the matrix.
The value to set
Gets the value at position (0,1) in the matrix.
The value at position (0,1)
Sets the value at position (0,1) in the matrix.
The value to set
Gets the value at position (0,2) in the matrix.
The value at position (0,2)
Sets the value at position (0,2) in the matrix.
The value to set
Gets the value at position (0,3) in the matrix.
The value at position (0,3)
Sets the value at position (0,3) in the matrix.
The value to set
Gets the value at position (1,0) in the matrix.
The value at position (1,0)
Sets the value at position (1,0) in the matrix.
The value to set
Gets the value at position (1,1) in the matrix.
The value at position (1,1)
Sets the value at position (1,1) in the matrix.
The value to set
Gets the value at position (1,2) in the matrix.
The value at position (1,2)
Sets the value at position (1,2) in the matrix.
The value to set
Gets the value at position (1,3) in the matrix.
The value at position (1,3)
Sets the value at position (1,3) in the matrix.
The value to set
Gets the value at position (2,0) in the matrix.
The value at position (2,0)
Sets the value at position (2,0) in the matrix.
The value to set
Gets the value at position (2,1) in the matrix.
The value at position (2,1)
Sets the value at position (2,1) in the matrix.
The value to set
Gets the value at position (2,2) in the matrix.
The value at position (2,2)
Sets the value at position (2,2) in the matrix.
The value to set
Gets the value at position (2,3) in the matrix.
The value at position (2,3)
Sets the value at position (2,3) in the matrix.
The value to set
Gets the value at position (3,0) in the matrix.
The value at position (3,0)
Sets the value at position (3,0) in the matrix.
The value to set
Gets the value at position (3,1) in the matrix.
The value at position (3,1)
Sets the value at position (3,1) in the matrix.
The value to set
Gets the value at position (3,2) in the matrix.
The value at position (3,2)
Sets the value at position (3,2) in the matrix.
The value to set
Gets the value at position (3,3) in the matrix.
The value at position (3,3)
Sets the value at position (3,3) in the matrix.
The value to set
Gets the X translation component from the matrix.
The X translation value
Sets the X translation component in the matrix.
The X translation value to set
Gets the Y translation component from the matrix.
The Y translation value
Sets the Y translation component in the matrix.
The Y translation value to set
Gets the Z translation component from the matrix.
The Z translation value
Sets the Z translation component in the matrix.
The Z translation value to set
Converts the matrix to a WGSL mat4x4f string representation with float precision.
A WGSL-compatible string representation of the matrix
Converts the matrix to a WGSL mat4x4i string representation with integer values.
A WGSL-compatible string representation of the matrix with integer values
StaticcompositionGets the composition type for this matrix class.
The composition type enum value
Swaps two elements in the internal array.
Left index
Right index
Adds the given vector to the current translation component.
The translation vector to add
This matrix instance for method chaining
Gets a matrix element at the specified row and column.
The row index (0-3)
The column index (0-3)
The matrix element at the given position
Creates a copy of this matrix.
A new MutableMatrix44 instance with the same values as this matrix
Copies all components from another matrix to this matrix.
The source matrix to copy from
This matrix instance for method chaining
Calculates the determinant of this 4x4 matrix.
The determinant value
Flattens the matrix into a regular JavaScript array. Elements are returned in column-major order (WebGL compatible).
An array containing all 16 matrix elements
Sets this matrix to a rotation matrix based on the given quaternion.
The quaternion to convert to a rotation matrix
This matrix instance for method chaining
Extracts the rotation part of this matrix.
A new MutableMatrix44 instance containing only the rotation transformation
Extracts the scale part of this matrix.
A new MutableVector3 instance containing the scale values for each axis
Extracts the scale factors from this matrix and stores them in an output vector.
The output vector to store the scale factors
The output vector containing the scale components
Extracts the translation part of this matrix.
A new MutableVector3 instance containing the translation values
Extracts the translation part of this matrix into the provided vector.
The vector to store the translation values
The output vector with translation values
Sets this matrix to the identity matrix.
This matrix instance for method chaining
Inverts this matrix in place.
If the matrix is numerically singular, it is set to the identity matrix
instead of being filled with Infinity/NaN.
Use MutableMatrix44.tryInvert when the caller needs to detect the failure.
This matrix instance for method chaining
Checks if this is a dummy matrix (empty array).
true if the matrix has no elements, false otherwise
Checks if this matrix is approximately equal to another matrix.
The matrix to compare with
The tolerance for floating-point comparison (default: Number.EPSILON)
true if matrices are approximately equal within the given tolerance
Checks if this matrix is exactly equal to another matrix. Uses strict equality comparison for all elements.
The matrix to compare with
true if matrices are exactly equal, false otherwise
Checks if the matrix's internal storage shares the same ArrayBuffer as the provided one.
This method is useful for determining if two matrices share the same underlying memory, which can be important for performance optimizations and avoiding unnecessary data copying.
The ArrayBuffer to compare against
True if the internal storage uses the same ArrayBuffer, false otherwise
Multiplies this matrix by another matrix from the right side (this * mat). This operation transforms this matrix in place.
The matrix to multiply from the right
This matrix instance for method chaining
Multiplies this matrix by another matrix from the left side (mat * this). This operation transforms this matrix in place.
The matrix to multiply from the left
This matrix instance for method chaining
Multiplies the scaling factors to the current matrix. This applies scaling transformation to each column of the matrix.
The scaling factors for X, Y, and Z axes
This matrix instance for method chaining
Multiplies this matrix with a 3D vector and stores the result (treating it as a point with w=1).
The 3D vector to multiply
The output vector to store the result
The output vector containing the transformed point
Multiplies this matrix with a 4D vector and stores the result in an output vector.
The 4D vector to multiply
The output vector to store the result
The output vector containing the multiplication result
Multiplies this matrix with a 4D vector and stores the XYZ components in a 3D vector.
The 4D vector to multiply
The output 3D vector to store the XYZ components
The output vector containing the XYZ components of the result
Sets the translation component of this matrix without affecting other components.
The translation vector to set
This matrix instance for method chaining
Gets the raw Float32Array containing the matrix data.
The internal Float32Array with matrix values in column-major order
Sets this matrix to a rotation matrix from a vector containing X, Y, Z rotation angles.
Vector containing rotation angles (x, y, z) in radians
This matrix instance for method chaining
Sets this matrix to a rotation matrix around the X-axis.
The rotation angle in radians
This matrix instance for method chaining
Sets this matrix to a rotation matrix with rotations around X, Y, and Z axes in that order. The rotation order is: Z * Y * X (applied from right to left).
Rotation angle around X-axis in radians
Rotation angle around Y-axis in radians
Rotation angle around Z-axis in radians
This matrix instance for method chaining
Sets this matrix to a rotation matrix around the Y-axis.
The rotation angle in radians
This matrix instance for method chaining
Sets this matrix to a rotation matrix around the Z-axis.
The rotation angle in radians
This matrix instance for method chaining
Sets this matrix to a scaling matrix with the given vector.
The scaling factors for X, Y, and Z axes
This matrix instance for method chaining
Sets a value at the specified row and column position.
The row index (0-3)
The column index (0-3)
The value to set
This matrix instance for method chaining
Sets all 16 components of the matrix with individual values. Values are specified in row-major order but stored internally in column-major order.
Element at row 0, column 0
Element at row 0, column 1
Element at row 0, column 2
Element at row 0, column 3
Element at row 1, column 0
Element at row 1, column 1
Element at row 1, column 2
Element at row 1, column 3
Element at row 2, column 0
Element at row 2, column 1
Element at row 2, column 2
Element at row 2, column 3
Element at row 3, column 0
Element at row 3, column 1
Element at row 3, column 2
Element at row 3, column 3
This matrix instance for method chaining
Converts this transformation matrix to Euler angles (XYZ rotation order).
A Vector3 containing the Euler angles [x, y, z] in radians
Converts this transformation matrix to Euler angles and stores them in an output vector.
The output vector to store the Euler angles
The output vector containing the Euler angles [x, y, z] in radians
Converts the matrix to a human-readable string representation. Elements are displayed in row-major order for intuitive reading.
A formatted string representation of the matrix
Converts the matrix to a human-readable string with rounded values. Uses financial rounding for better readability of floating-point numbers.
A formatted string representation with approximated values
Sets this matrix to a translation matrix with the given vector.
The translation vector
This matrix instance for method chaining
Transposes this matrix in place (swaps rows and columns).
This matrix instance for method chaining
Attempts to invert this matrix in place.
The matrix is left unchanged when it is numerically singular, which lets callers keep the previous valid value.
True if the inversion succeeded, false if the matrix is singular
Gets the matrix element at the specified flat index.
This provides direct access to the underlying Float32Array storage using a single index rather than row/column coordinates.
The zero-based flat index into the matrix storage
The matrix element value at the specified index
Sets this matrix to the zero matrix (all elements are 0).
This matrix instance for method chaining
Static_Creates a dummy matrix with zero-length array (for placeholder purposes).
A new Matrix44 instance with an empty array
Static_Creates a matrix from 16 individual values in column-major order. This matches the internal storage format used by WebGL.
Element at row 0, column 0
Element at row 1, column 0
Element at row 2, column 0
Element at row 3, column 0
Element at row 0, column 1
Element at row 1, column 1
Element at row 2, column 1
Element at row 3, column 1
Element at row 0, column 2
Element at row 1, column 2
Element at row 2, column 2
Element at row 3, column 2
Element at row 0, column 3
Element at row 1, column 3
Element at row 2, column 3
Element at row 3, column 3
A new Matrix44 instance
Static_Creates a matrix from 16 individual values in row-major order. This is the most intuitive way to specify matrix values, as you can write them in the same 4x4 layout as they appear visually. Note that internally, WebGL uses column-major storage.
Element at row 0, column 0
Element at row 0, column 1
Element at row 0, column 2
Element at row 0, column 3
Element at row 1, column 0
Element at row 1, column 1
Element at row 1, column 2
Element at row 1, column 3
Element at row 2, column 0
Element at row 2, column 1
Element at row 2, column 2
Element at row 2, column 3
Element at row 3, column 0
Element at row 3, column 1
Element at row 3, column 2
Element at row 3, column 3
A new Matrix44 instance
Static_Creates a matrix from a fixed-size array (Array16) in column-major order.
An Array16 containing exactly 16 matrix elements
A new Matrix44 instance with copied values
Static_Creates a matrix from a fixed-size array (Array16) in row-major order. The input array is converted from row-major to column-major order.
An Array16 containing exactly 16 matrix elements in row-major order
A new Matrix44 instance with converted values
Static_Creates a matrix from a variable-length array in column-major order.
An array containing at least 16 matrix elements
A new Matrix44 instance with copied values
Static_Creates a matrix from a variable-length array in row-major order. The input array is converted from row-major to column-major order.
An array containing at least 16 matrix elements in row-major order
A new Matrix44 instance with converted values
Static_Creates a 4x4 matrix from a 3x3 matrix by embedding it in the upper-left corner. The resulting matrix has the 3x3 matrix in the upper-left, with the bottom-right element set to 1 and other elements set to 0.
The 3x3 matrix to embed
A new Matrix44 instance
Static_Creates a new matrix by copying another Matrix44 instance.
The source matrix to copy
A new Matrix44 instance with copied values
Static_Creates a rotation matrix from a quaternion.
The quaternion representing the rotation
A new Matrix44 instance representing the rotation transformation
Static_Creates a matrix from a Float32Array in column-major order with copying.
A new Matrix44 instance with copied values
Static_Creates a matrix from a Float32Array in row-major order with copying. The input array is assumed to be in row-major order and will be converted to column-major order for internal storage.
A Float32Array containing 16 matrix elements in row-major order
A new Matrix44 instance with converted values
Static_Creates a rotation matrix from a quaternion and stores it in an output matrix.
The quaternion representing the rotation
The output matrix to store the result
The output matrix containing the rotation matrix
Static_Creates a matrix directly from a Float32Array in column-major order. The array is used directly without copying (shares the same memory).
A new Matrix44 instance using the provided array
Static_Creates a 4x4 identity matrix.
A new IdentityMatrix44 instance representing the identity matrix
Static_Creates an inverse matrix from the given matrix. Uses optimized computation for 4x4 matrix inversion.
If the matrix is numerically singular, an identity matrix is returned instead of dividing by zero. Use Matrix44.tryInvert when the caller needs to detect the failure.
The matrix to invert
A new Matrix44 instance representing the inverted matrix, or the identity matrix if the input is singular
Static_Computes the inverse of a matrix and stores the result in an output matrix. This is the mutable version of the invert method for performance optimization.
If the matrix is numerically singular, the output matrix is set to the
identity matrix instead of being filled with Infinity/NaN.
Use Matrix44.tryInvertTo when the caller needs to detect the failure.
The matrix to invert
The output matrix to store the result
The output matrix containing the inverted matrix, or the identity matrix if the input is singular
Static_Multiplies two 4x4 matrices and returns the result. Optimized to handle identity matrices efficiently.
The left matrix in the multiplication
The right matrix in the multiplication
A new Matrix44 instance representing the matrix product (l_mat * r_mat)
Static_Multiplies two 4x4 matrices and stores the result in an output matrix. This is the mutable version of the multiply method for performance optimization.
The left matrix in the multiplication
The right matrix in the multiplication
The output matrix to store the result
The output matrix containing the multiplication result
Static_Multiplies a matrix with data from a typed array and stores the result. This method is optimized for working with raw array data.
The left matrix in the multiplication
The right operand as a typed array
The output matrix to store the result
The offset in the array for composition data
The output matrix containing the multiplication result
Static_Creates a rotation matrix from a 3D vector containing Euler angles.
A vector containing rotation angles [x, y, z] in radians
A new Matrix44 instance representing the rotation
Static_Creates a rotation matrix around the X-axis.
The rotation angle in radians
A new Matrix44 instance representing the X-axis rotation
Static_Creates a rotation matrix from Euler angles (XYZ order). Applies rotations in the order: X, then Y, then Z.
Rotation around X-axis in radians
Rotation around Y-axis in radians
Rotation around Z-axis in radians
A new Matrix44 instance representing the combined rotation
Static_Creates a rotation matrix around the Y-axis.
The rotation angle in radians
A new Matrix44 instance representing the Y-axis rotation
Static_Creates a rotation matrix around the Z-axis.
The rotation angle in radians
A new Matrix44 instance representing the Z-axis rotation
Static_Creates a scaling matrix from a 3D vector.
The scaling factors for each axis [x, y, z]
A new Matrix44 instance representing the scaling transformation
Static_Creates a translation matrix from a 3D vector.
The translation vector
A new Matrix44 instance representing the translation transformation
Static_Creates a transpose matrix from the given matrix. For identity matrices, returns the same matrix since transpose of identity is identity.
The matrix to transpose
A new Matrix44 instance representing the transposed matrix
Static_Attempts to create the inverse of the given matrix. Uses optimized computation for 4x4 matrix inversion.
Returns null instead of dividing by zero when the matrix is numerically singular (see MathUtil.isSingularDet).
The matrix to invert
A new Matrix44 instance representing the inverted matrix, or null if the matrix is not invertible
Static_Attempts to compute the inverse of a matrix and store the result in an output matrix. The output matrix is left untouched when the input is numerically singular, which lets callers keep the previous valid value.
The matrix to invert
The output matrix to store the result
True if the inversion succeeded, false if the matrix is singular
Static_Creates a zero matrix (all elements are 0).
A new Matrix44 instance with all elements set to 0
A mutable 4x4 matrix class that extends the immutable Matrix44 class.
This class provides a mutable interface for 4x4 matrix operations commonly used in 3D graphics, including transformations, rotations, scaling, and projections. The matrix is stored in column-major order internally, which is compatible with WebGL.
Example