🧊 Menger Sponge
About this simulation
The Menger sponge is a three-dimensional fractal first described by the Austrian mathematician Karl Menger in 1926 while studying topological dimension. It extends the idea behind the Sierpiński carpet into three dimensions: instead of removing squares from a 3×3 grid, it removes cubes from a 3×3×3 grid of a solid cube. The result is a self-similar solid riddled with holes at every scale — one of the most recognisable 3D fractals in mathematics.
How it works
- Start with one solid cube.
- Divide it into a 3×3×3 grid of twenty-seven equal sub-cubes.
- Remove the single center sub-cube and the six sub-cubes at the center of each face, leaving twenty.
- Recurse into each of the twenty remaining cubes, repeating the same subdivide-and-remove step down to the chosen recursion level n.
Key equations
N(n) = 20^n — number of filled cubes remaining after n iterations.
V(n) = (20/27)^n · V0 — fraction of the original volume still filled after n iterations.
D = log(20)/log(3) ≈ 2.7268 — the fractal (Hausdorff) dimension, between a filled plane (2) and a filled solid (3).
Controls
- Recursion level n — how many times the 3×3×3 subdivide-and-remove step is applied, from 0 (a plain cube) up to 3.
- Rendering (Solid / Wireframe) — switch between shaded solid cubes and a wireframe view of the same geometry.
- Autorotate — toggle automatic orbiting of the camera around the sponge.
- Reset camera — return the view to its default position and target.
- Drag to orbit, scroll or pinch to zoom — the view is fully interactive at any time.
Did you know?
As the recursion level increases, the Menger sponge's volume shrinks toward zero while its surface area grows without bound — it approaches infinite surface area enclosing zero volume. It is also known as a "universal curve": every possible curve of topological dimension one can be found, up to distortion, somewhere inside the Menger sponge, making it a favourite subject for popular math outreach projects like MegaMenger, which build giant sponges out of folded business cards.