Apply a series of force functions or forces to t. Null/undefined entries are skipped silently.
It also updates the velocity and position of the returned version of t.
// Wind adds acceleration. Force is dampened by mass constwind = Forces.accelerationForce({ x:0.00001, y:0 }, `dampen`);
// Gravity adds acceleration. Force is magnified by mass constgravity = Forces.accelerationForce({ x:0, y:0.0001 }, `multiply`);
// Friction is calculated based on velocity. Force is magnified by mass constfriction = Forces.velocityForce(0.00001, `multiply`);
// Flip movement velocity if we hit a wall. And dampen it by 10% constbouncer = Forces.constrainBounce({ width:1, height:1 }, 0.9);
lett = { position:Points.random(), mass:0.1 };
// Apply list of forces, returning a new version of the thing t = Forces.apply(t, gravity, wind, friction, bouncer );
Apply a series of force functions or forces to
t
. Null/undefined entries are skipped silently. It also updates the velocity and position of the returned version oft
.