How dgreenheck/threejs-particle-fluids works
Three.js Particle Fluids is a WebGPU particle-physics library for simulating and rendering liquids, soft bodies, cloth, and smoke. The principal workflow is to configure a Simulation, add particle-based materials or obstacles, advance simulation steps, and render the resulting scene. Internally, shared particle state and solver infrastructure support specialized material systems, spatial queries, and collision handling. The graph reflects documented capabilities and sampled construction/import evidence; several subsystem internals and the Simulation step implementation were not excerpted, so some connections are intentionally omitted or marked unverified.
Main entry points: Simulation.ts Simulation · particles.ts Particle State · FluidSystem.ts Fluid Solver · GasSystem.ts Gas and Smoke
Components 20
Simulation API
- Simulation
src/simulation/Simulation.ts - Material Handles
src/simulation/handles.ts
Particle Engine
- Particle State
src/core/particles.ts - Solver Loop
src/core/loop.ts - Neighbor Grid
src/core/hashGrid/HashGrid.ts - Collision Systems
src/core/collision/PrimitiveSet.ts - Contact Solver
src/core/contact/solve.ts
Material Solvers
- Fluid Solver
src/fluids/FluidSystem.ts - Viscosity Solver
src/fluids/ViscositySolver.ts - Softbody Solver
src/softbody/SoftbodySystem.ts - Cloth Solver
src/cloth/ClothSystem.ts - Gas and Smoke
src/gas/GasSystem.ts - Heat Transport
src/gas/heat.ts
Rendering and Geometry
- SDF Baking
src/sdf/bake.ts - Fluid Surface
src/fluids/render/FluidSurfaceRenderer.ts - Surface Field
src/fluids/render/SurfaceField.ts - Gas Renderers
src/gas/render/GasVolumeRenderer.ts - Particle Renderer
src/render/particles.ts
Other components
- Application
- WebGPU Renderer
Connections 26
- Application → Simulation: configures
README.md - Simulation → Material Handles: manages
src/simulation/Simulation.ts - Simulation → Particle State: creates
src/simulation/Simulation.ts - Simulation → Solver Loop: steps with
- Simulation → Fluid Solver: constructs
- Simulation → Softbody Solver: constructs
src/simulation/Simulation.ts - Simulation → Cloth Solver: constructs
src/simulation/Simulation.ts - Simulation → Collision Systems: configures
- Fluid Solver → Particle State: updates
src/fluids/FluidSystem.ts - Fluid Solver → Neighbor Grid: builds neighbors
src/fluids/FluidSystem.ts - Fluid Solver → Viscosity Solver: supports viscosity
- Softbody Solver → Particle State: solves against
src/softbody/SoftbodySystem.ts - Cloth Solver → Particle State: constrains
- Gas and Smoke → Particle State: uses
src/gas/GasSystem.ts - Gas and Smoke → Heat Transport: uses
src/gas/GasSystem.ts - Gas and Smoke → Fluid Solver: uses fluid API
src/gas/GasSystem.ts - Collision Systems → Particle State: tests against
src/core/collision/PrimitiveSet.ts - Contact Solver → Particle State: solves contacts
src/core/contact/solve.ts - Solver Loop → Particle State: advances
- SDF Baking → Collision Systems: creates fields for
src/sdf/bake.ts - Fluid Solver → Fluid Surface: renders through
src/fluids/render/FluidSurfaceRenderer.ts - Fluid Surface → Surface Field: samples
src/fluids/render/FluidSurfaceRenderer.ts - Gas and Smoke → Gas Renderers: renders through
- Simulation → Particle Renderer: creates debug view
src/simulation/Simulation.ts - Particle Renderer → Particle State: reads buffers
src/render/particles.ts - Application → WebGPU Renderer: renders scene
README.md