Skip to main content
A rotation as (x, y, z, w). Bone rotations come as quaternions. Global class, no import.
Fields are 32-bit floats; assigning a non-number or NaN throws.

Overview

Common

from, set, mul, lerp, normalize…

Creating

identity, fromAngles, fromAxisAngle.

Using

rotate, slerp, toAngles, toAxisAngle.

Common

Every argument takes any QuatLike, not just a Quaternion. Only set() and normalize() change the value. Nothing changes its arguments. Unlike the other classes, mul and div with a quaternion compose rotations (below). lerp takes the shorter arc and returns a unit quaternion.

mul


With a number, every component. With a quaternion, a.mul(b) applies b first, then a, and a.div(b) is a * b⁻¹.

Creating

fromAxisAngle


A turn of degrees around axis. The axis doesn’t need to be unit length.

Using

rotate


vector turned by this rotation. Expects a unit quaternion, so normalize() one you built by hand.

slerp


Spherical blend along the shorter arc at constant angular speed. t isn’t clamped. lerp is cheaper and close enough for small steps.

toAngles


Back to view angles, or to a unit axis and 0–360 degrees.

Example

Draws a short axis gizmo on every enemy’s head bone.