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 | Array

    Number of particles or array of initial particle positions

  • iterations Int

    Number of constraint iterations per system tick

accumulateForces( delta ) private
src/systems/ParticleSystem.js:345

Accumulate forces acting on particles.

  • delta Float

    Time step

addConstraint( constraint )
src/systems/ParticleSystem.js:226

Add a constraint

addForce( force )
src/systems/ParticleSystem.js:325

Add a force

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.

create( ) static
src/systems/ParticleSystem.js:86

Create instance, accepts constructor arguments.

getAngle( a, b, c ) Float
src/systems/ParticleSystem.js:132

Alias for Vec3.angle. Calculates angle from positions.

  • a Int

    Particle index

  • b Int

    Particle index

  • c Int

    Particle index

Returns: Float

Angle in radians

getDistance( a, b ) Float
src/systems/ParticleSystem.js:120

Alias for Vec3.getDistance. Calculates distance from positions.

  • a Int

    Particle index

  • b Int

    Particle index

Returns: Float

Distance

getPosition( i, out ) Vec3
src/systems/ParticleSystem.js:108

Alias for Vec3.copy. Copys vector from positions.

  • i Int

    Particle index

  • out Vec3
Returns: Vec3

out

integrate( delta ) private
src/systems/ParticleSystem.js:192

Calculate particle's next position through Verlet integration. Called as part of tick.

  • delta Float

    Time step

removeConstraint( constraint )
src/systems/ParticleSystem.js:236

Alias for Collection.removeAll. Remove all references to a constraint.

removeForce( force )
src/systems/ParticleSystem.js:335

Alias for Collection.removeAll. Remove all references to a force.

removePinConstraint( constraint )
src/systems/ParticleSystem.js:258

Alias for Collection.removeAll. Remove all references to a pin constraint.

satisfyConstraintGroup( group, [count], [itemSize] ) private
src/systems/ParticleSystem.js:292

Resolve a group of constraints.

  • group Array

    List of constraints

  • [count] Int

    Override for number of particles a constraint affects

  • [itemSize] Int

    Override 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 Int

    Particle index

  • x Float
  • y Float
  • z Float
setWeight( i, w )
src/systems/ParticleSystem.js:145

Set a particle's mass

  • i Int

    Particle index

  • w Float

    Weight

tick( delta )
src/systems/ParticleSystem.js:369

Step simulation forward one frame. Applies forces, calculates particle positions, and resolves constraints.

  • delta Float

    Time step

_count Int private
src/systems/ParticleSystem.js:71

Number of particles in system

_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

positions Float32Array (Vec3)
src/systems/ParticleSystem.js:29

Current particle positions

positionsPrev Float32Array (Vec3)
src/systems/ParticleSystem.js:37

Previous particle positions

weights Float32Array (Float)
src/systems/ParticleSystem.js:53

Particle mass