rhodonite
    Preparing search index...

    Class MutableMatrix44_<T>

    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.

    const matrix = MutableMatrix44.identity();
    matrix.translate(Vector3.fromCopy(1, 2, 3));
    matrix.rotateY(Math.PI / 4);

    Type Parameters

    Hierarchy (View Summary)

    Implements

    Index
    _v: TypedArray = ...

    Internal typed array storage for matrix elements (Float32Array or Float64Array)

    • get className(): string

      Gets the class name identifier for this matrix type.

      Returns string

      The string 'MutableMatrix44'

    • get glslStrAsFloat(): string

      Converts the matrix to a GLSL mat4 string representation with float precision.

      Returns string

      A GLSL-compatible string representation of the matrix

    • get glslStrAsInt(): string

      Converts the matrix to a GLSL mat4 string representation with integer values.

      Returns string

      A GLSL-compatible string representation of the matrix with integer values

    • get glslStrAsUint(): string

      Gets the GLSL string representation of the matrix as unsigned integer values.

      Returns string

      GLSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get isIdentityMatrixClass(): boolean

      Indicates whether this matrix is an identity matrix class.

      This property should be overridden in derived classes that represent identity matrices to return true.

      Returns boolean

      False for the base AbstractMatrix class

    • get m00(): number

      Gets the value at position (0,0) in the matrix.

      Returns number

      The value at position (0,0)

    • set m00(val: number): void

      Sets the value at position (0,0) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m01(): number

      Gets the value at position (0,1) in the matrix.

      Returns number

      The value at position (0,1)

    • set m01(val: number): void

      Sets the value at position (0,1) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m02(): number

      Gets the value at position (0,2) in the matrix.

      Returns number

      The value at position (0,2)

    • set m02(val: number): void

      Sets the value at position (0,2) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m03(): number

      Gets the value at position (0,3) in the matrix.

      Returns number

      The value at position (0,3)

    • set m03(val: number): void

      Sets the value at position (0,3) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m10(): number

      Gets the value at position (1,0) in the matrix.

      Returns number

      The value at position (1,0)

    • set m10(val: number): void

      Sets the value at position (1,0) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m11(): number

      Gets the value at position (1,1) in the matrix.

      Returns number

      The value at position (1,1)

    • set m11(val: number): void

      Sets the value at position (1,1) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m12(): number

      Gets the value at position (1,2) in the matrix.

      Returns number

      The value at position (1,2)

    • set m12(val: number): void

      Sets the value at position (1,2) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m13(): number

      Gets the value at position (1,3) in the matrix.

      Returns number

      The value at position (1,3)

    • set m13(val: number): void

      Sets the value at position (1,3) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m20(): number

      Gets the value at position (2,0) in the matrix.

      Returns number

      The value at position (2,0)

    • set m20(val: number): void

      Sets the value at position (2,0) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m21(): number

      Gets the value at position (2,1) in the matrix.

      Returns number

      The value at position (2,1)

    • set m21(val: number): void

      Sets the value at position (2,1) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m22(): number

      Gets the value at position (2,2) in the matrix.

      Returns number

      The value at position (2,2)

    • set m22(val: number): void

      Sets the value at position (2,2) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m23(): number

      Gets the value at position (2,3) in the matrix.

      Returns number

      The value at position (2,3)

    • set m23(val: number): void

      Sets the value at position (2,3) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m30(): number

      Gets the value at position (3,0) in the matrix.

      Returns number

      The value at position (3,0)

    • set m30(val: number): void

      Sets the value at position (3,0) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m31(): number

      Gets the value at position (3,1) in the matrix.

      Returns number

      The value at position (3,1)

    • set m31(val: number): void

      Sets the value at position (3,1) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m32(): number

      Gets the value at position (3,2) in the matrix.

      Returns number

      The value at position (3,2)

    • set m32(val: number): void

      Sets the value at position (3,2) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get m33(): number

      Gets the value at position (3,3) in the matrix.

      Returns number

      The value at position (3,3)

    • set m33(val: number): void

      Sets the value at position (3,3) in the matrix.

      Parameters

      • val: number

        The value to set

      Returns void

    • get translateX(): number

      Gets the X translation component from the matrix.

      Returns number

      The X translation value

    • set translateX(val: number): void

      Sets the X translation component in the matrix.

      Parameters

      • val: number

        The X translation value to set

      Returns void

    • get translateY(): number

      Gets the Y translation component from the matrix.

      Returns number

      The Y translation value

    • set translateY(val: number): void

      Sets the Y translation component in the matrix.

      Parameters

      • val: number

        The Y translation value to set

      Returns void

    • get translateZ(): number

      Gets the Z translation component from the matrix.

      Returns number

      The Z translation value

    • set translateZ(val: number): void

      Sets the Z translation component in the matrix.

      Parameters

      • val: number

        The Z translation value to set

      Returns void

    • get wgslStrAsFloat(): string

      Converts the matrix to a WGSL mat4x4f string representation with float precision.

      Returns string

      A WGSL-compatible string representation of the matrix

    • get wgslStrAsInt(): string

      Converts the matrix to a WGSL mat4x4i string representation with integer values.

      Returns string

      A WGSL-compatible string representation of the matrix with integer values

    • get wgslStrAsUint(): string

      Gets the WGSL string representation of the matrix as unsigned integer values.

      Returns string

      WGSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get compositionType(): CompositionTypeEnum

      Gets the composition type for this matrix class.

      Returns CompositionTypeEnum

      The composition type enum value

    • Swaps two elements in the internal array.

      Parameters

      • l: number

        Left index

      • r: number

        Right index

      Returns void

    • Gets a matrix element at the specified row and column.

      Parameters

      • row_i: number

        The row index (0-3)

      • column_i: number

        The column index (0-3)

      Returns number

      The matrix element at the given position

    • Flattens the matrix into a regular JavaScript array. Elements are returned in column-major order (WebGL compatible).

      Returns number[]

      An array containing all 16 matrix elements

    • 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.

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Checks if this is a dummy matrix (empty array).

      Returns boolean

      true if the matrix has no elements, false otherwise

    • Checks if this matrix is approximately equal to another matrix.

      Parameters

      • mat: IMatrix44

        The matrix to compare with

      • delta: number = Number.EPSILON

        The tolerance for floating-point comparison (default: Number.EPSILON)

      Returns boolean

      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.

      Parameters

      Returns boolean

      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.

      Parameters

      • arrayBuffer: ArrayBuffer

        The ArrayBuffer to compare against

      Returns boolean

      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.

      Parameters

      • mat: IMatrix44

        The matrix to multiply from the right

      Returns MutableMatrix44

      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.

      Parameters

      • mat: IMatrix44

        The matrix to multiply from the left

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Multiplies the scaling factors to the current matrix. This applies scaling transformation to each column of the matrix.

      Parameters

      • vec: IVector3

        The scaling factors for X, Y, and Z axes

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Gets the raw Float32Array containing the matrix data.

      Returns TypedArray

      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.

      Parameters

      • vec: IVector3

        Vector containing rotation angles (x, y, z) in radians

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Sets this matrix to a rotation matrix around the X-axis.

      Parameters

      • radian: number

        The rotation angle in radians

      Returns MutableMatrix44

      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).

      Parameters

      • x: number

        Rotation angle around X-axis in radians

      • y: number

        Rotation angle around Y-axis in radians

      • z: number

        Rotation angle around Z-axis in radians

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Sets this matrix to a rotation matrix around the Y-axis.

      Parameters

      • radian: number

        The rotation angle in radians

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Sets this matrix to a rotation matrix around the Z-axis.

      Parameters

      • radian: number

        The rotation angle in radians

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Sets a value at the specified row and column position.

      Parameters

      • row_i: number

        The row index (0-3)

      • column_i: number

        The column index (0-3)

      • value: number

        The value to set

      Returns MutableMatrix44

      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.

      Parameters

      • m00: number

        Element at row 0, column 0

      • m01: number

        Element at row 0, column 1

      • m02: number

        Element at row 0, column 2

      • m03: number

        Element at row 0, column 3

      • m10: number

        Element at row 1, column 0

      • m11: number

        Element at row 1, column 1

      • m12: number

        Element at row 1, column 2

      • m13: number

        Element at row 1, column 3

      • m20: number

        Element at row 2, column 0

      • m21: number

        Element at row 2, column 1

      • m22: number

        Element at row 2, column 2

      • m23: number

        Element at row 2, column 3

      • m30: number

        Element at row 3, column 0

      • m31: number

        Element at row 3, column 1

      • m32: number

        Element at row 3, column 2

      • m33: number

        Element at row 3, column 3

      Returns MutableMatrix44

      This matrix instance for method chaining

    • Converts the matrix to a human-readable string representation. Elements are displayed in row-major order for intuitive reading.

      Returns string

      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.

      Returns string

      A formatted string representation with approximated values

    • 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.

      Returns boolean

      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.

      Parameters

      • i: number

        The zero-based flat index into the matrix storage

      Returns number

      The matrix element value at the specified index

    • Creates a matrix from 16 individual values in column-major order. This matches the internal storage format used by WebGL.

      Parameters

      • m00: number

        Element at row 0, column 0

      • m10: number

        Element at row 1, column 0

      • m20: number

        Element at row 2, column 0

      • m30: number

        Element at row 3, column 0

      • m01: number

        Element at row 0, column 1

      • m11: number

        Element at row 1, column 1

      • m21: number

        Element at row 2, column 1

      • m31: number

        Element at row 3, column 1

      • m02: number

        Element at row 0, column 2

      • m12: number

        Element at row 1, column 2

      • m22: number

        Element at row 2, column 2

      • m32: number

        Element at row 3, column 2

      • m03: number

        Element at row 0, column 3

      • m13: number

        Element at row 1, column 3

      • m23: number

        Element at row 2, column 3

      • m33: number

        Element at row 3, column 3

      • type: FloatTypedArrayConstructor

      Returns IMatrix44

      A new Matrix44 instance

    • 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.

      Parameters

      • m00: number

        Element at row 0, column 0

      • m01: number

        Element at row 0, column 1

      • m02: number

        Element at row 0, column 2

      • m03: number

        Element at row 0, column 3

      • m10: number

        Element at row 1, column 0

      • m11: number

        Element at row 1, column 1

      • m12: number

        Element at row 1, column 2

      • m13: number

        Element at row 1, column 3

      • m20: number

        Element at row 2, column 0

      • m21: number

        Element at row 2, column 1

      • m22: number

        Element at row 2, column 2

      • m23: number

        Element at row 2, column 3

      • m30: number

        Element at row 3, column 0

      • m31: number

        Element at row 3, column 1

      • m32: number

        Element at row 3, column 2

      • m33: number

        Element at row 3, column 3

      • type: FloatTypedArrayConstructor

      Returns IMatrix44

      A new Matrix44 instance

    • Creates a matrix from a variable-length array in row-major order. The input array is converted from row-major to column-major order.

      Parameters

      Returns IMatrix44

      A new Matrix44 instance with converted values

    • 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.

      Parameters

      Returns IMatrix44

      A new Matrix44 instance representing the inverted matrix, or the identity matrix if the input is singular

    • 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.

      Parameters

      Returns IMutableMatrix44

      The output matrix containing the inverted matrix, or the identity matrix if the input is singular

    • Multiplies two 4x4 matrices and stores the result in an output matrix. This is the mutable version of the multiply method for performance optimization.

      Parameters

      • l_mat: IMatrix44

        The left matrix in the multiplication

      • r_mat: IMatrix44

        The right matrix in the multiplication

      • outMat: IMutableMatrix44

        The output matrix to store the result

      Returns IMutableMatrix44

      The output matrix containing the multiplication result

    • Multiplies a matrix with data from a typed array and stores the result. This method is optimized for working with raw array data.

      Parameters

      • l_mat: IMatrix44

        The left matrix in the multiplication

      • r_array: ArrayType

        The right operand as a typed array

      • outMat: IMutableMatrix44

        The output matrix to store the result

      • offsetAsComposition: number

        The offset in the array for composition data

      Returns IMutableMatrix44

      The output matrix containing the multiplication result

    • Creates a rotation matrix from Euler angles (XYZ order). Applies rotations in the order: X, then Y, then Z.

      Parameters

      • x: number

        Rotation around X-axis in radians

      • y: number

        Rotation around Y-axis in radians

      • z: number

        Rotation around Z-axis in radians

      • type: FloatTypedArrayConstructor

      Returns IMatrix44

      A new Matrix44 instance representing the combined rotation

    • 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).

      Parameters

      Returns IMatrix44 | null

      A new Matrix44 instance representing the inverted matrix, or null if the matrix is not invertible

    • 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.

      Parameters

      Returns boolean

      True if the inversion succeeded, false if the matrix is singular