A quaternion, used to represent rotation.

// Rotate a SceneObject around the world Y axis
//@input SceneObject obj

// Degrees to rotate by
var degrees = 90 * getDeltaTime();

// Convert degrees to radians
var radians = degrees * (Math.PI / 180);

// Axis to rotate around
var axis = vec3.up();

// Rotation we will apply to the object's current rotation
var rotationToApply = quat.angleAxis(radians, axis);

// Get the object's current world rotation
var oldRotation = script.obj.getTransform().getWorldRotation();

// Get the new rotation by rotating the old rotation by rotationToApply
var newRotation = rotationToApply.multiply(oldRotation);

// Set the object's world rotation to the new rotation
script.obj.getTransform().setWorldRotation(newRotation);

Constructors

  • Creates a new quat.

    Parameters

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

    Returns quat

Properties

w: number

w component of the quat.

x: number

x component of the quat.

y: number

y component of the quat.

z: number

z component of the quat.

Methods

  • Returns the dot product of the two quats.

    Parameters

    Returns number

  • Returns whether this quat and b are equal.

    Parameters

    Returns boolean

  • Returns the rotation angle of the quat.

    Returns number

  • Returns the rotation axis of the quat.

    Returns vec3

  • Returns an inverted version of the quat.

    Returns quat

  • Returns the product of this quat and b.

    Parameters

    Returns quat

  • Returns the result of rotating direction vector vec3 by this quat.

    Parameters

    Returns vec3

  • Normalizes the quat.

    Returns void

  • Returns an euler angle representation of the quat, in radians.

    Returns vec3

  • Returns a string representation of the quat.

    Returns string