Optionalx: number
The x component. Default 0.
Optionaly: number
The y component. Default 0.
Optionalz: number
The z component. Default 0.
Optionalw: number
The w component. Default 1.
This callback is invoked, if set, each time a value in this quaternion is changed. The callback is passed one argument, a reference to this quaternion.
The w component of this Quaternion.
The x component of this Quaternion.
The y component of this Quaternion.
The z component of this Quaternion.
Add a given Quaternion or Vector to this Quaternion. Addition is component-wise.
The Quaternion or Vector to add to this Quaternion.
This Quaternion.
Calculates and sets the w component of this Quaternion based on the current x, y, and z components, so that the Quaternion has unit length. Assumes the x, y, and z values are already known and that their combined squared length does not exceed 1.undefined
This Quaternion.
Converts this Quaternion to its conjugate by negating the x, y, and z components while leaving w unchanged. For a unit quaternion, the conjugate is equivalent to the inverse and represents the opposite rotation.undefined
This Quaternion.
Copy the components of a given Quaternion or Vector into this Quaternion.
The Quaternion or Vector to copy the components from.
This Quaternion.
Calculate the dot product of this Quaternion and the given Quaternion or Vector.
The Quaternion or Vector to dot product with this Quaternion.
The dot product of this Quaternion and the given Quaternion or Vector.
Sets this Quaternion from the rotation represented by the given Matrix3, using the algorithm from Ken Shoemake's 1987 SIGGRAPH article "Quaternion Calculus and Fast Animation".
The Matrix3 to convert from.
This Quaternion.
Resets this Quaternion to the identity quaternion (0, 0, 0, 1), which represents no rotation.undefined
This Quaternion.
Calculates the multiplicative inverse of this Quaternion and sets the result. The inverse undoes the rotation represented by this Quaternion. If the Quaternion has zero length, no change is made.undefined
This Quaternion.
Calculate the length of this Quaternion.undefined
The length of this Quaternion.
Calculate the length of this Quaternion squared.undefined
The length of this Quaternion, squared.
Linearly interpolate this Quaternion towards the given Quaternion or Vector.
The Quaternion or Vector to interpolate towards.
Optionalt: number
The percentage of interpolation. Default 0.
This Quaternion.
Multiply this Quaternion by the given Quaternion or Vector.
The Quaternion or Vector to multiply this Quaternion by.
This Quaternion.
Normalizes this Quaternion, scaling it to unit length. If the Quaternion has zero length, no change is made.undefined
This Quaternion.
Rotate this Quaternion on the X axis.
The rotation angle in radians.
This Quaternion.
Rotate this Quaternion on the Y axis.
The rotation angle in radians.
This Quaternion.
Rotate this Quaternion on the Z axis.
The rotation angle in radians.
This Quaternion.
Sets this Quaternion to represent the shortest arc rotation from unit vector a
to unit vector b. This is the minimum rotation needed to align a with b.
Both vectors must be normalized before calling this method.
This Quaternion.
Scale this Quaternion by the given value.
The value to scale this Quaternion by.
This Quaternion.
Set the components of this Quaternion and optionally call the onChangeCallback.
Optionalx: number | object
The x component, or an object containing x, y, z, and w components. Default 0.
Optionaly: number
The y component. Default 0.
Optionalz: number
The z component. Default 0.
Optionalw: number
The w component. Default 0.
Optionalupdate: boolean
Call the onChangeCallback? Default true.
This Quaternion.
Sets this Quaternion from the given view, right, and up axis vectors. The three vectors are written into a temporary Matrix3, which is then converted to a normalized quaternion. All three vectors should be mutually orthogonal unit vectors.
This Quaternion.
Sets this Quaternion to represent a rotation of rad radians around the given
normalized axis vector.
The normalized axis vector around which to rotate.
The rotation angle in radians.
This Quaternion.
Sets this Quaternion from the given Euler object. The conversion respects the Euler's rotation order (e.g., 'XYZ', 'YXZ', 'ZXY', 'ZYX', 'YZX', 'XZY'), producing the equivalent quaternion rotation.
The Euler object to convert from.
Optionalupdate: boolean
Run the onChangeCallback? Default true.
This Quaternion.
Sets the rotation of this Quaternion from the given Matrix4.
The Matrix4 to set the rotation from.
This Quaternion.
Performs a spherical linear interpolation (slerp) between this Quaternion and
the given Quaternion or Vector. Unlike lerp, slerp interpolates along the
shortest arc on the unit sphere, maintaining constant angular velocity and
producing smooth, natural-looking rotations.
The Quaternion or Vector to interpolate towards.
The interpolation factor, typically in the range [0, 1].
This Quaternion.
Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise.
The Quaternion or Vector to subtract from this Quaternion.
This Quaternion.
A quaternion representing a rotation in 3D space. Quaternions avoid gimbal lock and provide smooth interpolation between orientations. The quaternion is stored as four components (x, y, z, w). Use the
identitymethod to reset to the identity quaternion (0, 0, 0, 1), which represents no rotation. Commonly used with Matrix4 for 3D transformations in WebGL rendering.