ParticleSystem
Manages particle state as well as the forces and constraints that act on its particles.
ParticleSystem
( particles, iterations
)
src/systems/ParticleSystem.js:15
-
particles
Int | ArrayNumber of particles or array of initial particle positions
-
iterations
IntNumber of constraint iterations per system tick
accumulateForces
( delta
)
private
src/systems/ParticleSystem.js:345
Accumulate forces acting on particles.
-
delta
FloatTime step
addConstraint
( constraint
)
src/systems/ParticleSystem.js:226
Add a constraint
-
constraint
Constraint
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.
-
constraint
Constraint
getAngle
( a, b, c
)
Float
src/systems/ParticleSystem.js:132
Alias for Vec3.angle
. Calculates angle from positions
.
-
a
IntParticle index
-
b
IntParticle index
-
c
IntParticle index
Angle in radians
getDistance
( a, b
)
Float
src/systems/ParticleSystem.js:120
Alias for Vec3.getDistance
. Calculates distance from positions
.
-
a
IntParticle index
-
b
IntParticle index
Distance
src/systems/ParticleSystem.js:108
Alias for Vec3.copy
. Copys vector from positions
.
-
i
IntParticle index
-
out
Vec3
out
integrate
( delta
)
private
src/systems/ParticleSystem.js:192
Calculate particle's next position through Verlet integration.
Called as part of tick
.
-
delta
FloatTime step
removeConstraint
( constraint
)
src/systems/ParticleSystem.js:236
Alias for Collection.removeAll
. Remove all references to a constraint.
-
constraint
Constraint
removeForce
( force
)
src/systems/ParticleSystem.js:335
Alias for Collection.removeAll
. Remove all references to a force.
-
force
Force
removePinConstraint
( constraint
)
src/systems/ParticleSystem.js:258
Alias for Collection.removeAll
. Remove all references to a pin constraint.
-
constraint
Constraint
satisfyConstraintGroup
( group, [count], [itemSize]
)
private
src/systems/ParticleSystem.js:292
Resolve a group of constraints.
-
group
ArrayList 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
.
-
i
IntParticle index
-
x
Float -
y
Float -
z
Float
setWeight
( i, w
)
src/systems/ParticleSystem.js:145
Set a particle's mass
-
i
IntParticle index
-
w
FloatWeight
tick
( delta
)
src/systems/ParticleSystem.js:369
Step simulation forward one frame. Applies forces, calculates particle positions, and resolves constraints.
-
delta
FloatTime 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