rhodonite
    Preparing search index...

    Class MutableMatrix44

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

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _v: Float32Array = ...

    Internal Float32Array storage for matrix elements

    Accessors

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

    Methods

    • 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

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

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

    • 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 values in column-major order.

      Parameters

      • m00: number
      • m10: number
      • m20: number
      • m30: number
      • m01: number
      • m11: number
      • m21: number
      • m31: number
      • m02: number
      • m12: number
      • m22: number
      • m32: number
      • m03: number
      • m13: number
      • m23: number
      • m33: number

      Returns MutableMatrix44

      A new MutableMatrix44 instance

    • Creates a matrix from 16 values in row-major order. Values are provided in row-major order but stored internally in column-major order.

      Parameters

      • m00: number
      • m01: number
      • m02: number
      • m03: number
      • m10: number
      • m11: number
      • m12: number
      • m13: number
      • m20: number
      • m21: number
      • m22: number
      • m23: number
      • m30: number
      • m31: number
      • m32: number
      • m33: number

      Returns MutableMatrix44

      A new MutableMatrix44 instance

    • Creates a new MutableMatrix44 from a regular array in row-major order. The input data is converted from row-major to column-major order during creation. Only the first 16 elements are used if the array is larger.

      Parameters

      • array: number[]

        An array containing at least 16 elements in row-major order

      Returns MutableMatrix44

      A new MutableMatrix44 instance with data converted to column-major order

    • Creates a new MutableMatrix44 directly from a Float32Array in column-major order. This method does not copy the array, so the matrix will share the same memory as the input array.

      Parameters

      • float32Array: Float32Array

        A Float32Array containing 16 elements in column-major order

      Returns MutableMatrix44

      A new MutableMatrix44 instance using the provided array

    • Creates a rotation matrix with rotations around X, Y, and Z axes in that order.

      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

      A new MutableMatrix44 instance representing the combined rotation