Particle Fluid Hero

group .........
3D and WebGL scenes
human .........
/lab/particle-fluid-hero

── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────

A call to action sitting in a pit of two hundred and fifty shapes that behave like a coarse fluid. Each pair inside the spacing radius pushes apart, blends velocity toward their average, and raises a density count on both; that count then softens gravity, damping, and the separation correction for the frame, which is what keeps a settled pile from boiling. Neighbour lookups go through a spatial hash rebuilt every frame, so the pair test stays local rather than quadratic. Press and drag to inject pointer velocity into anything within range. Canvas 2D with no physics library.

── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────

  • * Density is the whole trick

    Every close pair raises a density count on both bodies, and that count is then read back to soften gravity, the separation correction, and the velocity blend for that frame. Without it a settled pile keeps injecting energy into itself and boils.

  • * Neighbours come from a hash, not a scan

    Bodies are bucketed into cells the width of the interaction radius each frame, and only the nine surrounding cells are tested. Two hundred and fifty bodies at full quadratic cost would be thirty thousand pair tests per frame.

  • * Drawn between the last two positions

    Each shape is rendered at the midpoint of its previous and current position rather than at its current one. It is a half-frame of motion blur for free, and it hides the jitter from the position corrections.