Bounding box / bounding sphere

An invisible box or sphere wrapped around a detailed object so visibility, picking, and possible collisions can be checked cheaply.

invisible box around the modelrough collision shapecheap shape for hit testingthe circle used to check if an object is visiblewhy does my object vanish near the edge of the screenhit boxAABBboundng box

See it

Live demo coming soon

What it is

A bounding volume is a simple shape wrapped around a more complicated object. An axis-aligned bounding box, or AABB, stores minimum and maximum coordinates along the world axes. A bounding sphere stores a center and radius. Testing either one is far cheaper than testing every triangle in the mesh.

Bounds are the first question in frustum culling, picking, broad-phase collision detection, and spatial indexes: could these objects possibly touch or be visible? Boxes fit rectangular objects more tightly; spheres are rotation-invariant and especially cheap. A game's hitbox is the same idea aimed at gameplay rather than rendering. An oriented bounding box fits rotated objects better but costs more to update and test.

Gotcha: a bounding-volume hit is only a maybe. Empty corners of a box and empty space inside a sphere create false positives, so precise interactions need a second narrow-phase test. Bounds also go stale when vertices move, instances spread out, or transforms change without an update.

Ask AI for it

Add broad-phase bounds to this three.js scene. Build a THREE.Box3 for each static mesh with Box3.setFromObject(), derive a THREE.Sphere from the box, and show both through Box3Helper plus a wireframe sphere debug mesh. Update dynamic bounds after world matrices change, use Box3.intersectsBox() to find possible collision pairs, then run the existing triangle-level test only for those pairs. Color false-positive box hits amber and confirmed narrow-phase hits red.

You might have meant

frustum cullingpicking via ray castingtransforms coordinate spacesmesh geometrylod