A volcanic island erupts at dusk, and every lava flow cools into new land.
Lava is a thin flow on a heightfield moved by a cellular Bingham-fluid model: between each cell and its eight neighbors it only moves when thicker than a critical depth set by its yield strength, and the flux follows the Bingham formula with a viscosity that climbs exponentially as it cools, so flows slow, thicken and stall on their own. Heat travels with the lava, radiates away fastest from thin sheets and is quenched by the sea in clouds of steam. Below the solidus a cell's lava turns into rock and joins the terrain, so each flow builds the ground the next one runs over, lava deltas push the coast outward, and old rock slowly turns green again. The block is drawn per pixel with an orthographic voxel-space raycast, with glowing Voronoi cracks in the crust, bloom, steam clouds and a summit ash plume lit from below.
Try it. Click the island to open a new vent. Up and Down change the eruption rate, T toggles a 4x time-lapse and R grows a fresh island. Left alone, the summit keeps erupting and new flank vents open now and then.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a lava flow simulation on a volcanic island with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple, seen from above:
- Make a canvas that fills the window and is sharp on high-DPI screens. Keep a 128 by 128 grid of ground heights shaped like a volcano: a noisy cone rising out of a sea at height zero.
- Give every cell a lava thickness and a temperature (1 is fresh, about 0.45 is solid). A vent at the summit adds hot lava every frame.
- Each step, lava flows toward each lower neighbor only if it is thicker than a critical depth (yield strength divided by slope), at a rate proportional to thickness cubed times slope over viscosity. Make viscosity and yield strength grow exponentially as it cools, limit how much a cell gives away per step, and carry heat with the lava.
- Cool the lava every step, faster when thin and much faster in the sea. Below the solid temperature, add the lava to the ground and clear it, so flows build new land.
- Draw with ImageData scaled up: hillshaded green land, blue sea, and lava from dark red to yellow-white by temperature.
Once that works, make it beautiful:
- Turn new rock black and let it slowly turn green with age.
- Draw the island in isometric view: for each screen column, march through the heightfield from front to back and fill pixels above a running y-buffer.
- Add steam puffs where lava meets water, a soft glow around hot lava, and click to open new vents.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as lava tubes that keep flows hot, a long time-lapse, or a crust texture with glowing cracks.