• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Datatypes

    Edit

    Quaternion

    A Quaternion represents rotation and direction in 3D space, consisting of x, y, z, and w components. They are crucial for 3D movement and rotation, offering advantages such as avoiding gimbal lock.

    Properties

    Returns the rotation of a Quaternion in Euler angles representation.

    Returns a normalized copy of the Quaternion.

    x

    number

    Represents the x component of the Quaternion.

    y

    number

    Represents the y component of the Quaternion.

    z

    number

    Represents the z component of the Quaternion.

    w

    number

    Represents the w (scalar) component of the Quaternion.

    Represents a Quaternion for no rotation.

    kEpsilon

    number

    Represents a small number greater than zero for comparison.

    Methods

    Assigns new values to the Quaternion's components.

    Parameters

    newX

    number

    The new x component.

    newY

    number

    The new y component.

    newZ

    number

    The new z component.

    newW

    number

    The new w component.

    Returns

    void

    Aligns the Quaternion's z-axis towards a target direction.

    Parameters

    The target direction vector.

    Returns

    void

    Sets the Quaternion to rotate from one direction to another.

    Parameters

    fromDirection
    Vector3

    The vector to rotate from.

    toDirection
    Vector3

    The vector to rotate to.

    Returns

    void

    Modifies the quaternion to a unit length version of itself.

    Returns

    void

    Creates a Quaternion that rotates from one direction to another.

    Parameters

    fromDirection
    Vector3

    The vector to rotate from.

    toDirection
    Vector3

    The vector to rotate to.

    Returns

    Quaternion

    A rotation from fromDirection to toDirection.

    Returns the inverse of the Quaternion.

    Parameters

    rotation
    Quaternion

    The rotation to inverse.

    Returns

    Quaternion

    The inverse rotation.

    Gradually changes a Quaternion from one rotation to another.

    Parameters

    The starting rotation.

    The end rotation.

    t

    number

    The amount to interpolate.

    Returns

    Quaternion

    An interpolated quaternion rotation.

    Interpolates a Quaternion over an arbitrary range.

    Parameters

    The starting rotation.

    The end rotation.

    t

    number

    The unclamped interpolation amount.

    Returns

    Quaternion

    An interpolated quaternion rotation.

    Linearly interpolates between two quaternions.

    Parameters

    The starting rotation.

    The end rotation.

    t

    number

    The amount to interpolate.

    Returns

    Quaternion

    An interpolated quaternion rotation.

    The 'LerpUnclamped' method is similar to Lerp, but here the interpolation factor isn't clamped to the range [0, 1].

    Parameters

    The starting rotation.

    The end rotation.

    t

    number

    The unclamped interpolation amount.

    Returns

    Quaternion

    Returns a Quaternion that is interpolated over an arbitrary range.

    Creates a Quaternion rotation around an axis by a specified angle.

    Parameters

    angle

    number

    The angle of rotation.

    The rotation axis.

    Returns

    Quaternion

    A Quaternion around the specified axis with the given angle.

    Provides a quaternion that makes an object face towards a specified direction.

    Parameters

    forward
    Vector3

    The direction to be faced.

    upwards
    Vector3

    The direction to be used as 'upwards'.

    Returns

    Quaternion

    A Quaternion that aligns an object's forward direction towards the specified direction.

    Calculates the dot product of two quaternions.

    Parameters

    The first quaternion.

    The second quaternion.

    Returns

    number

    The dot product of the two quaternions.

    Returns the angle in degrees between two rotations.

    Parameters

    The first rotation.

    The second rotation.

    Returns

    number

    The angle in degrees between the two rotations.

    Creates a Quaternion rotation from Euler angles.

    Parameters

    x

    number

    The angle around the x-axis in degrees.

    y

    number

    The angle around the y-axis in degrees.

    z

    number

    The angle around the z-axis in degrees.

    Returns

    Quaternion

    A Quaternion from the Euler angles.

    Gradually changes a Quaternion towards a target rotation.

    Parameters

    The current rotation.

    The target rotation.

    maxDegreesDelta

    number

    The maximum number of degrees to rotate by in each call.

    Returns

    Quaternion

    A Quaternion rotated towards the target.

    Modifies the quaternion to a unit length version of itself.

    Parameters

    The Quaternion to be normalized.

    Returns

    Quaternion

    The normalized version of the quaternion.

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.