High-Performance Fluid Dynamics

This engine achieves a consistent 75 FPS by offloading heavy numerical analysis to WebAssembly (WASM). By compiling Rust to WASM, the simulation executes at near-native speeds, allowing the browser to process the thousands of linear operations required for every single.

Computational Load

On a typical 128 × 128 grid, the solver manages over 16,000 cells. With 20 iterations per project and diffuse step to ensure numerical stability, the Rust core performs over 1.3 million calculations per frame.

Rendering Pipeline

Instead of slow DOM updates, the density field is passed as a Raw Float32 Array directly to a WebGL Fragment Shader. This allows for per-pixel interpolation and hardware-accelerated color mapping at zero CPU cost.

The simulation solves the Navier-Stokes equations for incompressible flow. The mathematical core relies on four primary stages executed in a tight loop:

Interactive: Move the mouse around the canvas to inject momentum.