Nano WebGPU API - v0.11.0
    Preparing search index...

    Class Mat4

    4x4 matrix representation, commonly used for 3D transformations, camera rotations, and projections.

    Index

    Constructors

    Methods

    • Clone this matrix into a new Mat4

      Returns Mat4

      A new matrix with the same values

    • Copy the values of another matrix into this matrix

      Parameters

      • other: Mat4

        The matrix to copy from

      Returns this

      The current matrix (for chaining)

    • Resets this matrix to the identity matrix

      Returns this

      The current matrix (for chaining)

    • Inverts this matrix (in-place)

      Returns this

      The current matrix (for chaining)

    • Generates a Look-At view matrix

      Parameters

      • eye: Vec3

        The position of the camera

      • center: Vec3

        The point the camera is looking at

      • up: Vec3

        The up vector of the camera

      Returns this

      The current matrix (for chaining)

    • Multiplies this matrix by another matrix (in-place)

      Parameters

      • other: Mat4

        The matrix to multiply by

      Returns this

      The current matrix (for chaining)

    • Generates an orthogonal projection matrix

      Parameters

      • left: number

        Left bound of the frustum

      • right: number

        Right bound of the frustum

      • bottom: number

        Bottom bound of the frustum

      • top: number

        Top bound of the frustum

      • near: number

        Near clipping plane

      • far: number

        Far clipping plane

      Returns this

      The current matrix (for chaining)

    • Generates a perspective projection matrix

      Parameters

      • fovy: number

        Field of view in radians

      • aspect: number

        Aspect ratio (width / height)

      • near: number

        Near clipping plane

      • far: number

        Far clipping plane

      • reversedZ: boolean = false

      Returns this

      The current matrix (for chaining)

    • Rotates this matrix around the X, Y, and Z axes (Euler angles)

      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

      Returns this

      The current matrix (for chaining)

    • Scales this matrix by the given vector or x, y, z values

      Parameters

      • x: number | Vec3

        X scale or Vec3 vector

      • Optionaly: number

        Y scale

      • Optionalz: number

        Z scale

      Returns this

      The current matrix (for chaining)

    • Transforms a directional vector by this matrix (ignoring translation)

      Parameters

      • dir: Vec3

        The direction vector to transform

      • Optionalout: Vec3 = ...

        Optional vector to store the result

      Returns Vec3

      The transformed direction vector

    • Translates this matrix by the given vector or x, y, z values

      Parameters

      • x: number | Vec3

        X translation or Vec3 vector

      • Optionaly: number

        Y translation

      • Optionalz: number

        Z translation

      Returns this

      The current matrix (for chaining)

    • Transposes this matrix (in-place)

      Returns this

      The current matrix (for chaining)

    • Creates a Mat4 from a Quaternion rotation

      Parameters

      • q: Quaternion

        The quaternion representing the rotation

      • Optionalout: Mat4 = ...

        Optional pre-allocated matrix to store the result

      Returns Mat4

      The rotation matrix

    Properties

    values: Float32Array

    The 16 internal matrix values