Skip to content

Transform3D Showcase

Showcases the power of the Transform3D API with chainable operations, relative positioning, and smooth matrix-based interpolation using quaternion SLERP.

The Transform3D class provides a mathematically correct way to compose 3D transformations using matrix operations and quaternions. This eliminates common issues like gimbal lock and provides smooth, natural interpolation paths.

Build complex transformations step-by-step:

const transform = Transform3D.identity()
.translate(x, y, z)
.rotateZ(Math.PI / 8)
.scaleBy(1.5, 1.5, 1.5);

Create hierarchical transforms with proper composition:

// Satellites orbit around parent
const orbit = Transform3D.identity()
.translate(x, y, z)
.rotateY(angle);
// Apply to CSS
element.style.transform = orbit.toCSSMatrix3D();

Matrix-based interpolation with quaternion SLERP prevents gimbal lock:

const interpolated = interpolateTransform(
from,
to,
progress,
easing
);

Benefits:

  • ✓ Natural rotation paths
  • ✓ No gimbal lock artifacts
  • ✓ Single matrix operation
  • ✓ Proper transform composition

Combine transforms hierarchically:

// Combine parent and child
const worldTransform = parent.multiply(child);
// Apply to points
const worldPos = transform.apply(localPos);
// Invert transform
const inverse = transform.inverse();