Expand description
The engine’s transform convention, in one place: the column-major 4x4 layout
every renderer uniform is written in, the multiply and the two inverses over
it, the T * R(YXZ) * S composition joints and props both build their matrix
through, and the quaternion conversions that let a rotation be interpolated
along the shorter arc rather than component-wise through its Euler angles.
Constants§
- IDENTITY
- Column-major 4x4 identity.
Functions§
- blend_
matrices - Interpolate two affine matrices in TRS space by weight
f, clamped to[0, 1]. Translation and scale blend linearly while rotation is quaternion-slerped along the shorter arc, matching what a clip does between keyframes, so a blended pose is continuous with a clip’s own sampling. - compose
- Compose a column-major
T * R * Saffine matrix from a rotation 3x3, per-axis scale, and translation. - decompose
- Decompose a column-major affine matrix into translation, a unit rotation
quaternion, and per-axis scale: the inverse of
composefor a positive-scaleT * R * Smatrix. Scale is recovered as the length of each rotation column; a zero-length column yields a zero scale axis and the rotation falls back to identity for that axis. - euler_
yxz_ from_ quat - YXZ Euler angles in degrees recovered from a unit rotation quaternion: the
inverse of
rotation_mat3composed withquat_to_mat3. glTF stores node rotations as quaternions; the glTF importer converts them to the EulerJointPoserepresentation this engine’s joints use. The conversion is matrix-exact for non-degenerate rotations; at gimbal lock (pitch ±90°) it folds the rotation onto the yaw axis with zero roll. - mat4_
affine_ inverse - Inverse of an affine matrix whose bottom row is
[0, 0, 0, 1]. The upper 3x3 is inverted via the adjugate; the translation is mapped through it. A near-singular upper 3x3 (degenerate scale) falls back to identity rather than producing NaNs. - mat4_
inverse - Inverse of a general 4x4 matrix, by cofactor expansion. Returns
IDENTITYwhen the determinant is singular or non-finite, so a degenerate input yields a usable matrix instead of spreading NaNs through the pass that asked. Unlikemat4_affine_inversethis handles a projection’s bottom row, which is what the screen-space passes need to invert a view-projection and rebuild world position from depth. - mat4_
mul - Column-major 4x4 multiply:
a * b. - trs_
matrix - Column-major
T * R(YXZ) * Smodel matrix. The single home of the engine’s transform convention: joints, props, and runtime transforms all build their matrix here so they compose consistently.