Skip to content
M2O Scripting APIScripting reference
Runtime classClient APIGenerated

Quaternion

Defined in: client/api.d.ts:1735

Mutable quaternion exposed as Core.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.

new Quaternion(w, x, y, z): Quaternion

Defined in: client/api.d.ts:1743

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.

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.

Quaternion

clone(): Quaternion

Defined in: client/api.d.ts:1842

Creates an independent copy of this quaternion.

Quaternion

New quaternion with the same components.


conjugate(): Quaternion

Defined in: client/api.d.ts:1792

Computes the conjugate without changing this quaternion.

Quaternion

New conjugated quaternion.


dot(other): number

Defined in: client/api.d.ts:1813

Computes the quaternion dot product.

Quaternion

Quaternion used for the dot product.

number

Scalar dot product.


inverse(): Quaternion

Defined in: client/api.d.ts:1798

Computes the inverse rotation without changing this quaternion.

Quaternion

New inverse quaternion.


mul(other): this

Defined in: client/api.d.ts:1780

Composes this rotation with another quaternion in place.

Quaternion

Rotation composed after this quaternion.

this

This mutated quaternion for chaining.


normalize(): this

Defined in: client/api.d.ts:1786

Normalizes this quaternion in place; a zero quaternion becomes the identity rotation instead of NaN.

this

This unit quaternion for chaining.


rotateVector(vector): Vector3

Defined in: client/api.d.ts:1820

Applies this rotation to a vector without mutating either value.

Vector3

Vector to rotate.

Vector3

New rotated vector.


set(w, x, y, z): this

Defined in: client/api.d.ts:1836

Replaces all quaternion components in place.

number

Replacement scalar component.

number

Replacement X imaginary component.

number

Replacement Y imaginary component.

number

Replacement Z imaginary component.

this

This mutated quaternion for chaining.


slerp(target, t): this

Defined in: client/api.d.ts:1806

Spherically interpolates this quaternion toward a target in place.

Quaternion

Destination rotation.

number

Interpolation factor; 0 keeps the current rotation and 1 reaches target.

this

This mutated quaternion for chaining.


toEuler(): Vector3

Defined in: client/api.d.ts:1826

Converts this rotation to Euler angles in radians.

Vector3

Pitch, yaw, and roll as a Vector3.


toJSON(): object

Defined in: client/api.d.ts:1854

Converts this quaternion to a plain object for JSON.stringify.

object

Object containing the current components.

w: number

x: number

y: number

z: number


toString(): string

Defined in: client/api.d.ts:1848

Formats this quaternion for logging and debugging.

string

Text in Quaternion(w, x, y, z) form.


static fromAxisAngle(axis, angle): Quaternion

Defined in: client/api.d.ts:1877

Creates a rotation around an axis.

Vector3

Rotation axis; it is normalized internally.

number

Rotation angle in radians.

Quaternion

New axis-angle rotation quaternion.


static fromEuler(pitch, yaw, roll): Quaternion

Defined in: client/api.d.ts:1869

Creates a rotation from Euler angles.

number

Pitch angle in radians.

number

Yaw angle in radians.

number

Roll angle in radians.

Quaternion

New rotation quaternion.


static identity(): Quaternion

Defined in: client/api.d.ts:1860

Creates the identity rotation.

Quaternion

New Quaternion(1, 0, 0, 0).

readonly length: number

Defined in: client/api.d.ts:1768

Read-only magnitude (norm) of this quaternion; 1 for a unit rotation.


readonly lengthSquared: number

Defined in: client/api.d.ts:1773

Read-only squared magnitude, avoiding a square-root calculation.


w: number

Defined in: client/api.d.ts:1748

Mutable scalar component.


x: number

Defined in: client/api.d.ts:1753

Mutable X imaginary component.


y: number

Defined in: client/api.d.ts:1758

Mutable Y imaginary component.


z: number

Defined in: client/api.d.ts:1763

Mutable Z imaginary component.