Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class Matrix3

    A class representing a 3x3 matrix. Used for 2D transformations or normal matrices.

    Index
    data: Float32Array = ...

    The matrix data in column-major order.

    • Calculates the normal matrix (transpose of the inverse of the upper-left 3x3 of a 4x4 matrix). Used for transforming normals correctly when non-uniform scaling is present.

      Parameters

      • m: { data: Float32Array }

        The source 4x4 matrix.

      Returns this

      this

    • Sets the matrix to the identity matrix.

      Returns this

      this

    • Sets the matrix from the upper-left 3x3 part of a 4x4 matrix.

      Parameters

      • m: { data: Float32Array }

        The source 4x4 matrix.

      Returns this

      this

    • Transforms a Vector3D by this 3x3 matrix (result = M * v).

      Parameters

      • v: { x: number; y: number; z: number }

        The vector to transform.

      • result: { x: number; y: number; z: number } = v

        Optional target vector (defaults to v).

      Returns { x: number; y: number; z: number }

      The transformed vector.