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

    Class Quaternion

    A class representing a quaternion for rotations.

    Index

    Constructors

    • Creates a new Quaternion.

      Parameters

      • x: number = 0

        The x component. Defaults to 0.

      • y: number = 0

        The y component. Defaults to 0.

      • z: number = 0

        The z component. Defaults to 0.

      • w: number = 1

        The w component. Defaults to 1.

      Returns Quaternion

    Properties

    w: number

    The w component.

    x: number

    The x component.

    y: number

    The y component.

    z: number

    The z component.

    Methods

    • Resets the quaternion to the identity rotation.

      Returns this

      this

    • Calculates the Euclidean length of the quaternion.

      Returns number

      The length.

    • Normalizes the quaternion to a unit length of 1.

      Returns this

      this

    • Sets the components of the quaternion.

      Parameters

      • x: number

        The x component.

      • y: number

        The y component.

      • z: number

        The z component.

      • w: number

        The w component.

      Returns this

      this

    • Sets the quaternion from axis and angle.

      Parameters

      • axis: Vector3D

        The rotation axis (must be normalized).

      • angle: number

        The rotation angle in radians.

      Returns this

      this