Methods
# addForce(forceFunction)
Add global force
Parameters:
Name | Type | Description |
---|---|---|
forceFunction |
function
|
Function that returns force vector |
# addParticle(particle)
Add particle to simulation
Parameters:
Name | Type | Description |
---|---|---|
particle |
PhysicsParticle
|
Particle to add |
# applyGlobalForces()
Apply global forces to all particles
# createExplosion(center, particleCount, force)
Create particle explosion effect
Parameters:
Name | Type | Default | Description |
---|---|---|---|
center |
Vector2D
|
Explosion center |
|
particleCount |
number
|
20 | Number of particles |
force |
number
|
100 | Explosion force |
# createFountain(source, particlesPerFrame)
Create particle fountain effect
Parameters:
Name | Type | Default | Description |
---|---|---|---|
source |
Vector2D
|
Fountain source |
|
particlesPerFrame |
number
|
3 | Particles spawned per frame |
# removeParticle(particle)
Remove particle from simulation
Parameters:
Name | Type | Description |
---|---|---|
particle |
PhysicsParticle
|
Particle to remove |
# setBoundaryMode(mode)
Set boundary behavior
Parameters:
Name | Type | Description |
---|---|---|
mode |
string
|
Boundary mode ('bounce', 'wrap', 'none') |
# setBounds(width, height)
Set simulation boundaries
Parameters:
Name | Type | Description |
---|---|---|
width |
number
|
Boundary width |
height |
number
|
Boundary height |
# update(deltaTime)
Update physics simulation
Parameters:
Name | Type | Description |
---|---|---|
deltaTime |
number
|
Time step |
# updateParticles(deltaTime)
Update all particles
Parameters:
Name | Type | Description |
---|---|---|
deltaTime |
number
|
Time step |