Construct an empty AABB (min = +∞, max = −∞). The empty AABB
satisfies addPoint(p) => min = max = p for the first point
added, and overlaps(b) => false against any other AABB —
same convention as Bounds.
Optionalmin: XYZPointoptional initial minimum corner
Optionalmax: XYZPointoptional initial maximum corner
Expand this AABB to include the given AABB. With clear=true,
copies the input AABB directly — same shape as Bounds.addBounds.
the AABB to fold in
Optionalclear: boolean = falsereset this AABB before folding
Expand this AABB to include the given point.
the point to fold in
Reset the AABB to its empty state.
Returns a deep copy of this AABB.
True if this AABB fully encloses the given point.
point x
point y
point z
Build this AABB from a flat vertex buffer (x,y,z triplets), optionally
transformed by a column-major 4×4 matrix — the bridge from raw mesh /
glTF geometry (e.g. a Mesh's vertices or a parsed glTF node) to an
AABB3d. Replaces the current bounds (seeds empty, then folds in the
count vertices); for the point-array form use AABB3d#addPoint.
The per-vertex math is delegated to transformedBounds (the
shared math/vertex.ts helper) rather than duplicated here, so the
flat-buffer ↔ AABB conversion stays in one place. Allocation-free.
source vertex positions (x,y,z triplets)
number of vertices to read from src
Optionalmatrix: ArrayLike<number>optional column-major 4×4 (16 elements); identity if omitted
this AABB, for chaining
True if every coordinate is a finite number. Used by the
Octree to reject inserts whose bounding box is the
empty AABB (a sprite with no shape and never updated) — without
this guard a ±Infinity corner would silently classify into
an arbitrary octant and never come back out via remove.
True if this AABB overlaps the given AABB on every axis. The intersection includes the boundary (shared face/edge/corner counts as overlap), same convention as Bounds.overlaps so Octree candidate sets don't drop items that sit exactly on an octant boundary.
the other AABB to test against
True if this AABB overlaps a sphere. Computes the squared
distance from the sphere center to the nearest point on the
AABB and compares against r² — avoids the sqrt on the hot
path. Used by Octree.querySphere.
sphere center x
sphere center y
sphere center z
sphere radius (must be ≥ 0; r=0 becomes a point-in-AABB test)
Set min and max corners directly. Mirror of Bounds.setMinMax.
minimum corner x
minimum corner y
minimum corner z
maximum corner x
maximum corner y
maximum corner z
A 3D axis-aligned bounding box — the 3D sibling of Bounds.
Used by Octree as the bounding primitive of every node (root, subnodes, queries). Intentionally minimal: only the operations the Octree hot path needs are implemented, with a small handful of helpers (AABB3d#contains, AABB3d#overlaps, AABB3d#overlapsSphere) for test-driven
querySphere/queryAABBcallers.Coordinate convention matches the rest of melonJS 3D code (see Camera3d): Y-down, +Z forward / away from the camera.
Lives next to Octree under
physics/broadphase/rather thanmath/to mirror Bounds (which lives inphysics/, notmath/). It originated as a broadphase-internal primitive; it is now also the public 3D-bounds type returned by Mesh#getBounds3d (the 3D analog of Renderable#getBounds → Bounds), built from mesh geometry via AABB3d#fromVertices.