LookLightweight
Marching cubes
Metaballs and gooey surfaces from a field of values.
Turning an invisible field of values into a solid surface. Metaballs (blobs that merge when they touch), gooey shapes and terrain with caves all come from it. Finer detail costs a lot more time per frame.
- Breaks when
- resolution vs fps trade-off is steep
- Also called
- metaballs, isosurface, MarchingCubes
Prompts
Metaballs that feel heavy
Three.js MarchingCubes addon at resolution 48: seven balls with strengths 0.6–1.2 moving on slow damped springs toward the pointer (stiffness 3, damping 0.9), subtract 0.4 so the surface is fat, enableUvs off, MeshPhysicalMaterial with clearcoat 1, roughness 0.25, transmission 0. Update the field every frame but skip re-meshing when no ball moved more than 0.002 units.
Terrain with caves
Marching cubes on a 3D noise field (64³): density = y − heightNoise(x, z) + 0.5 × caveNoise(x, y, z), threshold 0. Compute normals from the field gradient (central differences) rather than from triangles so the surface is smooth. Build in a Web Worker, transfer the buffers, and chunk the world into 4 pieces.
2D version for understanding
Marching squares on a Canvas 2D: a 40×25 grid, three moving metaballs as the field, corner samples drawn as dots (filled when inside), and the iso-contour segments drawn per cell with linear interpolation along the edges. Show the 16 case lookup as the thing doing the work; let the pointer drag one ball.
Related
Resources · 2
- three.js example: marching cubesmrdoobsite · code · demoJul 30, 2026
- Coding Adventure: Marching CubesSebastianLaguevideo · codeJul 3, 2026