Class: Fluid
physics/fluid/fluid.Fluid
Simulates a fluid using SPH (Smooth Particle Hydrodynamics).
see
SPH Fluid Sim in Processing
see
Processing Code
see
Particle-based Viscoelastic Fluid Sim
Constructors
constructor
โข new Fluid(opts
)
Creates an Fluid with the given options.
Parameters
Name | Type | Description |
---|---|---|
opts | FluidOptions | The options to setup the fluid with |
Defined in
src/physics/fluid/fluid.ts:77
Properties
collisionGroup
โข collisionGroup: number
Defined in
src/physics/fluid/fluid.ts:51
color
โข color: Color
Defined in
src/physics/fluid/fluid.ts:55
debug
โข debug: boolean
Defined in
src/physics/fluid/fluid.ts:63
debugShapes
โข debugShapes: Map
<Particle
, Circle
>
Defined in
src/physics/fluid/fluid.ts:65
debugTex
โข debugTex: Texture
Defined in
src/physics/fluid/fluid.ts:64
kdTree
โข kdTree: kdTree
Defined in
src/physics/fluid/fluid.ts:53
maxParticles
โข maxParticles: number
Defined in
src/physics/fluid/fluid.ts:50
particleRadius
โข particleRadius: number
Defined in
src/physics/fluid/fluid.ts:49
particles
โข particles: Particle
[] = []
Defined in
src/physics/fluid/fluid.ts:41
physics
โข physics: Physics
The physics world the fluid sim was added to.
Defined in
src/physics/fluid/fluid.ts:70
renderThreshold
โข renderThreshold: number
Defined in
src/physics/fluid/fluid.ts:56
restDensity
โข restDensity: number
Defined in
src/physics/fluid/fluid.ts:43
smoothingRadius
โข smoothingRadius: number
Defined in
src/physics/fluid/fluid.ts:44
smoothingRadiusSqr
โข smoothingRadiusSqr: number
Defined in
src/physics/fluid/fluid.ts:45
stiffness
โข stiffness: number
Defined in
src/physics/fluid/fluid.ts:46
stiffnessNear
โข stiffnessNear: number
Defined in
src/physics/fluid/fluid.ts:47
translate
โข Private
translate: vec2
Defined in
src/physics/fluid/fluid.ts:158
zIndex
โข zIndex: number
The z layer of the fluid.
Defined in
src/physics/fluid/fluid.ts:61
Methods
addParticle
โธ addParticle(pos
): boolean
Adds a particle to the fluid at the given position.
Parameters
Name | Type | Description |
---|---|---|
pos | vec2 | The position to create the particle at in world space. |
Returns
boolean
Wether or not the particle was added
Defined in
src/physics/fluid/fluid.ts:104
debugRender
โธ debugRender(): void
Renders the particles of the fluid as individual circles.
Returns
void
Defined in
src/physics/fluid/fluid.ts:189
integrate
โธ integrate(delta
, gravity
): void
Integrate any forces on the particle, including gravity, and integrate velocity.
Also resets the particle's density from the last update.
Parameters
Name | Type | Description |
---|---|---|
delta | number | The time since the last update |
gravity | vec2 | - |
Returns
void
Defined in
src/physics/fluid/fluid.ts:167
render
โธ render(): void
Queues the fluid to be renderer using the fluid renderer.
Returns
void
Defined in
src/physics/fluid/fluid.ts:182
update
โธ update(delta
): void
Steps the fluid simulation forward in time.
Parameters
Name | Type | Description |
---|---|---|
delta | number | The time since the last update |
Returns
void
Defined in
src/physics/fluid/fluid.ts:125