Lens Scripting API

    Class quat

    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);
    Index

    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 a new quat with angle angle and axis axis.

      Parameters

      • angle: number
      • axis: vec3

      Returns quat

    • Returns the angle between a and b.

      Parameters

      Returns number

    • Returns the dot product of the two quats.

      Parameters

      Returns number

    • Returns whether this quat and b are equal.

      Parameters

      Returns boolean

    • Returns a new quat using the euler angles x, y, z (in radians).

      Parameters

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

      Returns quat

    • Returns a new quat using the euler angle eulerVec (in radians).

      Parameters

      Returns quat

    • Creates a quaternion from a matrix.

      Parameters

      Returns quat

    • Creates a quaternion from a mat4.

      Parameters

      Returns quat

    • 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 a new quat linearly interpolated between a and b.

      Parameters

      Returns quat

    • Returns a new quat with a forward vector forward and up vector up.

      Parameters

      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 a new quat using the euler angles x, y, z (in radians).

      Parameters

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

      Returns quat

    • Returns the identity quaternion.

      Returns quat

    • Returns a rotation quat between direction vectors from and to.

      Parameters

      Returns quat

    • Returns a new quat spherically linearly interpolated between a and b.

      Parameters

      Returns quat

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

      Returns vec3

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

      Returns vec3

    • Returns a string representation of the quat.

      Returns string

    MMNEPVFCICPMFPCPTTAAATR