Skip to content

rayVsAabb3

rayVsAabb3(origin, dir, box): RayHit3 | null

Defined in: src/modules/collision-3d/narrowphase3.ts:89

Ray vs centre-based AABB, by the slab method. Returns the entry distance and the axis of the entry face, or null when the ray misses, the box is entirely behind the origin, or the origin is on or inside the box.

t is parametric in units of dir, so a unit dir makes it a world distance while a full segment to - from makes t <= 1 a segment test.

Corner tie-break: axes are tested in x, y, z order and an axis only takes over the entry face on a strictly greater entry, so the earlier axis wins a tie.

Vec3

Vec3

Aabb3

RayHit3 | null