Skip to content

quatLookRotation

quatLookRotation(forward, up?): Quat

Defined in: src/modules/math/quat.ts:68

The rotation that points the local -Z axis along forward and keeps the local +Y axis as close to up as that allows — what a camera needs to face a target (quatLookRotation(vec3Sub(target, eye))). The right-handed counterpart of Unity’s Quaternion.LookRotation, which aims +Z instead.

Neither input needs to be unit-length. A zero forward has no direction and yields the identity; an up parallel to forward falls back to world +Z, then +X, so the result is always a valid rotation.

Vec3

Vec3 = ...

Quat