math
Prefer Three.js math classes (Vector3, Euler, Quaternion, Matrix4) over custom implementations: they are well-tested, handle edge cases, and integrate seamlessly with Three.js objects. The same goes for measurement primitives like Box3 and coordinate helpers like Spherical. The throughline is the reference frame — world space versus local space — which is where even the built-ins mislead if you ignore it.
This document covers four areas. Spherical Coordinates and Trigonometry replaces manual sin/cos. Rotations covers choosing between Euler and Quaternion. Billboards covers camera-facing quads, which must be oriented in world space. Measuring an object's size (Box3) covers why measuring a skinned/animated character with setFromObject is corrupted, and what to do instead.
Spherical Coordinates and Trigonometry
For spherical coordinates or anything involving sin/cos, use Euler, Vector3, and Quaternion rather than hand-rolled trigonometry. For an orbit position, build a Spherical and read it into a vector. For a direction from accumulated angles, build an Euler and apply it to a forward vector.
// Instead of manual sin/cos for orbit position:
const spherical = new Spherical(radius, polarAngle, azimuthalAngle)
position.setFromSpherical(spherical)
// For direction from angles:
const euler = new Euler(pitch, yaw, 0, 'YXZ')
const direction = new Vector3(0, 0, -1).applyEuler(euler)