Create a new Quat instance.
Optional
x: number | number[] = 0The quaternion's x component. Defaults to 0. If x is an array of length 4, the array will be used to populate all components.
Optional
y: number = 0The quaternion's y component. Defaults to 0.
Optional
z: number = 0The quaternion's z component. Defaults to 0.
Optional
w: number = 1The quaternion's w component. Defaults to 1.
The w component of the quaternion.
The x component of the quaternion.
The y component of the quaternion.
The z component of the quaternion.
Static
Readonly
IDENTITYA constant quaternion set to [0, 0, 0, 1] (the identity).
Static
Readonly
ZEROA constant quaternion set to [0, 0, 0, 0].
Reports whether two quaternions are equal.
The quaternion to be compared against.
True if the quaternions are equal and false otherwise.
Reports whether two quaternions are equal using an absolute error tolerance.
The quaternion to be compared against.
Optional
epsilon: number = 1e-6The maximum difference between each component of the two quaternions. Defaults to 1e-6.
True if the quaternions are equal and false otherwise.
Gets the rotation axis and angle for a given quaternion. If a quaternion is created with
setFromAxisAngle
, this method will return the same values as provided in the original
parameter list OR functionally equivalent values.
The 3-dimensional vector to receive the axis of rotation.
Angle, in degrees, of the rotation.
Sets the specified quaternion to the supplied numerical values.
The x component of the quaternion.
The y component of the quaternion.
The z component of the quaternion.
The w component of the quaternion.
Self for chaining.
Sets a quaternion from Euler angles specified in XYZ order.
Angle to rotate around X axis in degrees. If ex is a Vec3, the three angles will be read from it instead.
Optional
ey: numberAngle to rotate around Y axis in degrees.
Optional
ez: numberAngle to rotate around Z axis in degrees.
Self for chaining.
Performs a spherical interpolation between two quaternions. The result of the interpolation is written to the quaternion calling the function.
The quaternion to interpolate from.
The quaternion to interpolate to.
The value controlling the interpolation in relation to the two input quaternions. The value is in the range 0 to 1, 0 generating q1, 1 generating q2 and anything in between generating a spherical interpolation between the two.
Self for chaining.
const q1 = new pc.Quat(-0.11, -0.15, -0.46, 0.87);
const q2 = new pc.Quat(-0.21, -0.21, -0.67, 0.68);
const result;
result = new pc.Quat().slerp(q1, q2, 0); // Return q1
result = new pc.Quat().slerp(q1, q2, 0.5); // Return the midpoint interpolant
result = new pc.Quat().slerp(q1, q2, 1); // Return q2
A quaternion.