Water Sphere
A swirling ball of water made of thousands of droplets, simulated and projected in 3D by Rust compiled to WebAssembly. Click it and it sprays apart, then pours back together. Drag to look around it.
Click the water to splash it apart. Drag to turn the camera around the sphere.
- Droplets
- 12,000
- Back in the sphere
- 100%
- Step time
- 0.00 ms
- Frames per second
- 0
Every droplet has a home on a sphere: most sit in six helical ribbons, the rest fill the body. A spring pulls each droplet toward its home while the whole sphere turns and the ribbons wind and unwind, and that is all the swirling is. Light from the upper left shades each droplet by which way its patch of water faces.
A click casts a ray through the sphere and kicks every droplet outward, hardest near where you hit it, with a twist added. The springs switch off, so the droplets fly free under light drag and gravity, and the fastest stretch into streaks. Then each one's spring eases back in at its own moment, with a sideways sweep so they spiral home instead of falling straight back.
Rust does all of it: the physics, the orbit camera, the perspective projection and a counting sort that orders every droplet from far to near. JavaScript only reads the finished draw list out of WebAssembly's memory and paints glass-bubble sprites onto a 2D canvas, so there is no WebGL and no copying of droplet data. The module is about 300 lines with no dependencies.