HomeAlgorithms & AIOctree Spatial Partitioning

Octree Spatial Partitioning

Interactive 3D octree simulator: watch a cube of space recursively subdivide around moving spheres, compare octree broad-phase comparisons against naive O(n²) checks, and see collisions resolve in real time.

Algorithms & AI3DModerate60 FPS📱 Mobile-adapted
spatial-compression ↗ Open standalone

An octree recursively subdivides a cube of 3D space into eight octants wherever too many objects land in one region, turning collision detection from an O(n²) check-every-pair problem into something closer to O(n log n). This simulator builds a fresh loose octree every frame around a swarm of moving spheres, draws every node's bounding cube, and highlights real sphere-sphere collisions in red — with live counters comparing how many comparisons the octree actually performed against how many a naive all-pairs check would have needed. Tune the per-node object cap and the maximum subdivision depth to see the tree grow shallower or deeper, and how that trades node-traversal overhead against comparisons per leaf.

⚙ Under the hood

Watch a cube of 3D space recursively subdivide into an octree around moving spheres, with live counters comparing octree broad-phase collision comparisons against a naive O(n²) all-pairs check.

octreecollision-detectionspatial-partitioningalgorithmsbroad-phase

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)