Quaternion
Defined in: client/api.d.ts:9214
Mutable quaternion for three-dimensional rotations. Components are scalar-first (w, x, y, z), matching GLM — not the x, y, z, w order some libraries use.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Quaternion(
w,x,y,z):Quaternion
Defined in: client/api.d.ts:9222
Creates a quaternion in scalar-first w, x, y, z component order. Watch the trap: the scalar w is the first argument, unlike the x, y, z, w order used by some other libraries.
Parameters
Section titled “Parameters”number
Initial scalar component (comes first — this is not x, y, z, w order).
number
Initial X imaginary component.
number
Initial Y imaginary component.
number
Initial Z imaginary component.
Returns
Section titled “Returns”Quaternion
Methods
Section titled “Methods”clone()
Section titled “clone()”clone():
Quaternion
Defined in: client/api.d.ts:9321
Creates an independent copy of this quaternion.
Returns
Section titled “Returns”Quaternion
New quaternion with the same components.
conjugate()
Section titled “conjugate()”conjugate():
Quaternion
Defined in: client/api.d.ts:9271
Computes the conjugate without changing this quaternion.
Returns
Section titled “Returns”Quaternion
New conjugated quaternion.
dot(
other):number
Defined in: client/api.d.ts:9292
Computes the quaternion dot product.
Parameters
Section titled “Parameters”Quaternion
Quaternion used for the dot product.
Returns
Section titled “Returns”number
Scalar dot product.
inverse()
Section titled “inverse()”inverse():
Quaternion
Defined in: client/api.d.ts:9277
Computes the inverse rotation without changing this quaternion.
Returns
Section titled “Returns”Quaternion
New inverse quaternion.
mul(
other):this
Defined in: client/api.d.ts:9259
Composes this rotation with another quaternion in place.
Parameters
Section titled “Parameters”Quaternion
Rotation composed after this quaternion.
Returns
Section titled “Returns”this
This mutated quaternion for chaining.
normalize()
Section titled “normalize()”normalize():
this
Defined in: client/api.d.ts:9265
Normalizes this quaternion in place; a zero quaternion becomes the identity rotation instead of NaN.
Returns
Section titled “Returns”this
This unit quaternion for chaining.
rotateVector()
Section titled “rotateVector()”rotateVector(
vector):Vector3
Defined in: client/api.d.ts:9299
Applies this rotation to a vector without mutating either value.
Parameters
Section titled “Parameters”vector
Section titled “vector”Vector to rotate.
Returns
Section titled “Returns”New rotated vector.
set(
w,x,y,z):this
Defined in: client/api.d.ts:9315
Replaces all quaternion components in place.
Parameters
Section titled “Parameters”number
Replacement scalar component.
number
Replacement X imaginary component.
number
Replacement Y imaginary component.
number
Replacement Z imaginary component.
Returns
Section titled “Returns”this
This mutated quaternion for chaining.
slerp()
Section titled “slerp()”slerp(
target,t):this
Defined in: client/api.d.ts:9285
Spherically interpolates this quaternion toward a target in place.
Parameters
Section titled “Parameters”target
Section titled “target”Quaternion
Destination rotation.
number
Interpolation factor; 0 keeps the current rotation and 1 reaches target.
Returns
Section titled “Returns”this
This mutated quaternion for chaining.
toEuler()
Section titled “toEuler()”toEuler():
Vector3
Defined in: client/api.d.ts:9305
Converts this rotation to Euler angles in radians.
Returns
Section titled “Returns”Pitch, yaw, and roll as a Vector3.
toJSON()
Section titled “toJSON()”toJSON():
object
Defined in: client/api.d.ts:9333
Converts this quaternion to a plain object for JSON.stringify.
Returns
Section titled “Returns”object
Object containing the current components.
w:
number
x:
number
y:
number
z:
number
toString()
Section titled “toString()”toString():
string
Defined in: client/api.d.ts:9327
Formats this quaternion for logging and debugging.
Returns
Section titled “Returns”string
Text in Quaternion(w, x, y, z) form.
fromAxisAngle()
Section titled “fromAxisAngle()”
staticfromAxisAngle(axis,angle):Quaternion
Defined in: client/api.d.ts:9356
Creates a rotation around an axis.
Parameters
Section titled “Parameters”Rotation axis; it is normalized internally.
number
Rotation angle in radians.
Returns
Section titled “Returns”Quaternion
New axis-angle rotation quaternion.
fromEuler()
Section titled “fromEuler()”
staticfromEuler(pitch,yaw,roll):Quaternion
Defined in: client/api.d.ts:9348
Creates a rotation from Euler angles.
Parameters
Section titled “Parameters”number
Pitch angle in radians.
number
Yaw angle in radians.
number
Roll angle in radians.
Returns
Section titled “Returns”Quaternion
New rotation quaternion.
identity()
Section titled “identity()”
staticidentity():Quaternion
Defined in: client/api.d.ts:9339
Creates the identity rotation.
Returns
Section titled “Returns”Quaternion
New Quaternion(1, 0, 0, 0).
Properties
Section titled “Properties”length
Section titled “length”
readonlylength:number
Defined in: client/api.d.ts:9247
Read-only magnitude (norm) of this quaternion; 1 for a unit rotation.
lengthSquared
Section titled “lengthSquared”
readonlylengthSquared:number
Defined in: client/api.d.ts:9252
Read-only squared magnitude, avoiding a square-root calculation.
w:
number
Defined in: client/api.d.ts:9227
Mutable scalar component.
x:
number
Defined in: client/api.d.ts:9232
Mutable X imaginary component.
y:
number
Defined in: client/api.d.ts:9237
Mutable Y imaginary component.
z:
number
Defined in: client/api.d.ts:9242
Mutable Z imaginary component.