The runtime

Maths

29 symbols, imported from @driftengine/core.

Explained in Coordinates and units.

Interfaces

Bounds
How big a piece of geometry is, and where it sits.

Functions

angleDelta
Signed shortest angular distance from a to b, in (-π, π].
boundsOfBox
Bounds for a box the caller names itself, into bounds the caller owns.
boundsOfPositions
Measure a vertex array, into bounds the caller owns.
boxInFrustum
Whether an axis-aligned box is anywhere inside the frustum, by the same question the sphere test asks: outside only when wholly beyond one plane.
clamp
createBounds
createFrustum
damp
Framerate-independent exponential approach of a toward b. lambda is the convergence rate in 1/seconds (higher = snappier).
dampAngle
damp along the shortest arc between two angles.
dampTracking
Exponential approach of a toward a target that is itself moving, at velocity.
frustumFromViewProjection
Pull the six planes out of a view-projection matrix.
hslToRgb
hue in degrees (any range), saturation/lightness in [0, 1].
lerp
lerpAngle
lerp along the shortest arc — the angular counterpart for render interpolation.
mixColor
mixColorInto
In-place mixColor for per-frame use — allocating here would be a hot-path bug.
rayClosestOnLine
The closest approach between a ray and an infinite line, written into out.
rayPlane
Where a ray meets an infinite plane, or -1.
raySphere
The nearest positive distance along a ray to a sphere's surface, or -1.
scaleColor
smoothstep
Hermite interpolation between two edges: 0 below a, 1 above b.
sphereInFrustum
Whether a world-space sphere is anywhere inside the frustum.
wrapAngle
Fold an angle into (-π, π]. Simulation state uses this so a long session cannot accumulate an unbounded angle and lose float precision. Anything replaying a recorded session depends on staying bit-stable over its length.

Types

Frustum
The six planes bounding what a camera can see, and whether a sphere is among them.
FrustumPlanes
Planes in either precision. Double precision is for a world past 2^24 units, where a plane's offset is a number a single float cannot hold to the metre; cellsInFrustum asks for it.
Vec3
RGB triplet, each channel in [0, 1]. Mutable tuple for direct uniform upload.

Constants

DEG_TO_RAD
TAU