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

    Class Quaternion

    Quaternion representation containing x, y, z, and w components. Used for interpolation and smooth, gimbal-lock-free 3D rotations.

    Index

    Constructors

    • Create a new Quaternion

      Parameters

      • Optionalx: number = 0

        X component

      • Optionaly: number = 0

        Y component

      • Optionalz: number = 0

        Z component

      • Optionalw: number = 1

        W component

      Returns Quaternion

    Methods

    • Copy components from another Quaternion into this one

      Parameters

      Returns this

      The current Quaternion (for chaining)

    • Sets this Quaternion from Euler angles (pitch, yaw, roll) in radians

      Parameters

      • x: number

        Pitch (rotation around X in radians)

      • y: number

        Yaw (rotation around Y in radians)

      • z: number

        Roll (rotation around Z in radians)

      Returns this

      The current Quaternion (for chaining)

    • Set this Quaternion to the identity rotation (0, 0, 0, 1)

      Returns this

      The current Quaternion (for chaining)

    • Normalizes this Quaternion in-place

      Returns this

      The current Quaternion (for chaining)

    • Sets the components of this Quaternion

      Parameters

      • x: number

        X component

      • y: number

        Y component

      • z: number

        Z component

      • w: number

        W component

      Returns this

      The current Quaternion (for chaining)

    • Spherical Linear Interpolation (slerp) between this and a target quaternion in-place.

      Parameters

      • target: Quaternion

        The destination rotation

      • t: number

        Interpolation factor (0.0 to 1.0)

      Returns this

      The current Quaternion (for chaining)

    • Converts this Quaternion to a 4x4 rotation matrix

      Parameters

      • Optionalout: Mat4 = ...

        Optional matrix to store result

      Returns Mat4

      The rotation matrix

    Properties

    w: number
    x: number
    y: number
    z: number