Every particle is an ECS entity with Position and Velocity. One JavaScript kernel moves them, on the CPU or as a WebGPU compute shader.
–
–
Main-thread time is what the simulation costs your game loop. On the GPU the work runs in parallel and the particles are drawn straight from the kernel's buffer, so they never travel back to JavaScript.
world.update() tick 0| entity | x | y | speed |
|---|
kernelSystem() parses this function and compiles it to WGSL and to a JS loop. Pointer position and strength arrive as uniforms (u).