newton
Version:
A playful, particle-based physics engine designed from the ground up for JavaScript.
20 lines (15 loc) • 620 B
text/jade
p.
When building a simulation, you frequently want to refer to
a group of Particles, Forces, and Constraints as a single entity.
Newton uses the concept of Bodies for grouping elements.
p.
Instead of adding Particles and Constraints directly to the Simulator,
we can instead add them as a group in a Body:
pre.CodeBlock.
var rope = Newton.Body();
rope.add(Newton.Particle(500 + i * 20, 180));
rope.add(Newton.RopeConstraint(prev, current));
sim.add(rope);
p.
Keep in mind, Bodies are just for bookkeeping - logical groupings so your code can be readable.
They have no impact on the simulation.