- position
- -
- velocity
- -
- init
- -
- update
- -
- attribute
- -
- dispatch
- -
Two instanced arrays are initialized once, updated in place, and read back as a render attribute.
The official example couples a storage-backed particle simulation to an instanced SpriteNodeMaterial. This study keeps initialization, force accumulation, velocity clamping, wrapping, and compute-to-render state visible, with a direct CPU/InstancedMesh reference for WebGL2.
Preparing deterministic particle state.
Two instanced arrays are initialized once, updated in place, and read back as a render attribute.
Each particle loops over attractors, accumulates gravity and spin, clamps velocity, then wraps through the bounded field.
WebGPU executes `renderer.compute()` over storage arrays; WebGL2 uses the same force contract through a CPU update reference.
Position and velocity live in writable GPU storage instead of ordinary JavaScript objects.
One compute invocation accumulates gravity and axis-aligned spinning from every attractor.
A speed clamp keeps a few close encounters from destabilizing the particle field.
The same storage position becomes a SpriteNodeMaterial instance attribute.
The direct path preserves the simulation contract without pretending WebGL2 supports compute.
Measure the active compute-to-render path after tuning the force budget.
This is a deterministic adaptation of the official compute-attractors particles example: seeded storage state and three fixed attractors keep the simulation reproducible while initialization, force accumulation, speed clamping, wrapping, compute dispatch, and the direct fallback remain executable.
Sources: official compute-attractors example · TSL · StorageBufferNode · SpriteNodeMaterial · InstancedMesh