Inside the lamp
Lava's lamp as its simulation sees it: eight thousand particles of wax seen from the side, each blob in a colour of its own, a moment kept every five seconds.
// The lamp as its simulation sees it: view="blobs" draws its
// particles from the side, each blob in a colour of its own, and
// view="warmth" each particle by how warm it is. snapshot() hands
// back a picture of the frame drawn next, for a row of moments.
import { Lava } from "@cesarvenzac/lava/react";
import type { Lava as Lamp } from "@cesarvenzac/lava";
let lamp: Lamp | null = null;
<Lava view="blobs" handle={(made) => (lamp = made)} />;
// Every five seconds of the lamp's own time (paused, or off
// screen, its time stands still):
const picture = await lamp?.snapshot(); // an ImageBitmap, or null
canvas.getContext("2d")?.drawImage(picture, 0, 0);
The lamp is a simulation: wax as particles in 3D, warmed by a coil under the floor, rising, gathering under the top and sinking back. Here each particle is a dot, drawn where it is, the ones further back sinking into the liquid.
Blobs
Each particle knows which blob it belongs to. When a neck thins and parts, the smaller side takes a label of its own, and a colour with it. Two blobs that meet stay two, pressed together, until the liquid between them has drained, about half a minute, and then the smaller takes the larger's. The pool is the largest of all, in a muted tone of the bulb's light.
Warmth
The coil heats the wax lying on it, its heat swelling and fading every forty-five seconds. Wax warmer than fifty degrees is lighter than the liquid and rises; the liquid takes the heat back at its skin, most near the top, until it's heavier again and sinks. Blue is the pool's warmth and cooler, the wax's hot colour what's fresh off the coil.
Wax
The same particles, drawn as the lamp is: spread onto a grid as a field of how full each cell is, then ray-marched through a long lens and lit by the bulb through the wax beneath.
In your own pages
It's an option of Lava: view="blobs" or view="warmth". And snapshot() hands back a picture of the next frame drawn, which is how this row keeps its moments.