Quaternion
A quaternion, used in three.js to represent rotations.
Iterating through an instance yields its components (x, y, z, w) in order.
three.js expects quaternions to be normalized.
Instances are mutable and not thread-safe; confine an instance (and any object graph holding it) to a single thread, exactly as in three.js.
Reading x/y/z/w has no side effect. Writing any of them, or calling a mutating method, fires the registered onChange callback (see that method).
Functions
Returns the angle between this quaternion and q in radians.
Returns a new quaternion with copied values from this instance.
Returns the rotational conjugate of this quaternion: the same rotation in the opposite direction about the rotational axis.
Copies the values of quaternion into this instance.
Returns the dot product of this quaternion and v.
Sets this quaternion to the identity quaternion (no rotation).
Inverts this quaternion via conjugate. The quaternion is assumed to have unit length.
Multiplies this quaternion by q.
Normalizes this quaternion. It computes the quaternion that performs the same rotation but has length 1. A zero-length quaternion becomes the identity.
Registers callback to run whenever this quaternion's state changes (via a component setter or a mutating method). Reads never fire it.
Pre-multiplies this quaternion by q.
Sets this quaternion to a uniformly random, normalized quaternion.
Sets this quaternion from the rotation specified by the given Euler angles.
Sets this quaternion from the given rotation matrix m (the upper 3x3 of which must be an unscaled rotation).
Serialization result: the components of this quaternion as [x, y, z, w].