ParticleSystem
Manages particle state as well as the forces and constraints that act on its particles.
ParticleSystem( particles, iterations )
src/systems/ParticleSystem.js:15
-
particlesInt | ArrayNumber of particles or array of initial particle positions
-
iterationsIntNumber of constraint iterations per system tick
accumulateForces( delta )
private
src/systems/ParticleSystem.js:345
Accumulate forces acting on particles.
-
deltaFloatTime step
addConstraint( constraint )
src/systems/ParticleSystem.js:226
Add a constraint
-
constraintConstraint
addPinConstraint( constraint )
src/systems/ParticleSystem.js:246
Add a pin constraint.
Although intended for instances of PointConstraint, this can be any
type of constraint and will be resolved last in the relaxation loop.
-
constraintConstraint
getAngle( a, b, c )
Float
src/systems/ParticleSystem.js:132
Alias for Vec3.angle. Calculates angle from positions.
-
aIntParticle index
-
bIntParticle index
-
cIntParticle index
Angle in radians
getDistance( a, b )
Float
src/systems/ParticleSystem.js:120
Alias for Vec3.getDistance. Calculates distance from positions.
-
aIntParticle index
-
bIntParticle index
Distance
src/systems/ParticleSystem.js:108
Alias for Vec3.copy. Copys vector from positions.
-
iIntParticle index
-
outVec3
out
integrate( delta )
private
src/systems/ParticleSystem.js:192
Calculate particle's next position through Verlet integration.
Called as part of tick.
-
deltaFloatTime step
removeConstraint( constraint )
src/systems/ParticleSystem.js:236
Alias for Collection.removeAll. Remove all references to a constraint.
-
constraintConstraint
removeForce( force )
src/systems/ParticleSystem.js:335
Alias for Collection.removeAll. Remove all references to a force.
-
forceForce
removePinConstraint( constraint )
src/systems/ParticleSystem.js:258
Alias for Collection.removeAll. Remove all references to a pin constraint.
-
constraintConstraint
satisfyConstraintGroup( group, [count], [itemSize] )
private
src/systems/ParticleSystem.js:292
Resolve a group of constraints.
-
groupArrayList of constraints
-
[count]IntOverride for number of particles a constraint affects
-
[itemSize]IntOverride for particle index stride
satisfyConstraints( )
private
src/systems/ParticleSystem.js:268
Run relaxation loop, resolving constraints per defined iterations. Constraints are resolved in order by type: global, local, pin.
setPosition( i, x, y, z )
src/systems/ParticleSystem.js:94
Alias for Vec3.set. Sets vector of positions and positionsPrev.
-
iIntParticle index
-
xFloat -
yFloat -
zFloat
setWeight( i, w )
src/systems/ParticleSystem.js:145
Set a particle's mass
-
iIntParticle index
-
wFloatWeight
tick( delta )
src/systems/ParticleSystem.js:369
Step simulation forward one frame. Applies forces, calculates particle positions, and resolves constraints.
-
deltaFloatTime step
_iterations Int
private
src/systems/ParticleSystem.js:62
Number of constraint relaxation loop iterations
accumulatedForces Float32Array (Vec3)
src/systems/ParticleSystem.js:45
Accumulated forces currently acting on particles