126 points · by xchip · 9y ago · 62 comments
Matter.js: http://brm.io/matter-js/
Cannon.js: http://www.cannonjs.org/
PhysicsJS: http://wellcaffeinated.net/PhysicsJS/
Box2DJS: http://box2d-js.sourceforge.net/ (Emscripten-compiled from flash)
p2: https://github.com/schteppe/p2.js
Ammo.js: https://github.com/kripken/ammo.js/ (Emscripten-compiled from C++)
JPE: https://github.com/colorhook/JPE
Oimo.js: https://github.com/lo-th/Oimo.js/
Planck.js: https://github.com/shakiba/planck.js
Personally i found the linked content to be much more approachable than your links, though they are undoubtedly better physics engines.
PheT also has lots of good stuff: https://phet.colorado.edu/
I've been trying to understand js physics simulation for many years, and this is the first demo that I find understandable. Amazing work!
I also wrote a tutorial on how constraints work (probably the the most difficult part)
Is it deterministic? Does it do destructive updates?
This is destructive:
this.position += this.velocityIn Chrome, the fourth box from the top starts sliding when it hits the floor, pushing the box to the right clear off the floor box. Every box eventually slides along the floor and falls into the pit.
In Firefox, the fourth from the top stays put. It never pushes the box on the right, though all the rest eventually slide into the pit.
I think the "neither instance seems to actually make physical sense" is due to a lack of friction.
Friction is a biggie that I need to add ASAP!
You can look at the source code and see if that's what it's doing.
So you want to change the simulation? Change the initial setup.
This is obviously not user friendly, but I'm not sure how you can possibly suggest this is not a simulation.
Having always the same animation helps debugging. But yeah I should have added the option to add a mouse!
... does it have conservation of energy? Can you track total energy somehow?
... does it obey approximately some kind of Liouville theorem?
You're going to need a geometric integrator for that, probably an energy-momentum integrator. In practice it is often better to conserve the symplectic form instead of energy, though, and you can show that for fixed time-steps you can't get all of energy/momentum/symplecticity at the same time (I haven't looked at this for a while, a student of the school of Marsden jump in if I'm saying anything wrong). Furthermore, these guarantees all require integrability...
I was asking about these simplified physics engines (in games, etc.) that are probably not deriving physical laws out of whole conservation- (or Noetherian symmetry-) cloth.
The movie folks have larger compute time budgets, and I've seen various geometric integrators used there. I know of at least one studio that uses implicit midpoint for thin shell simulation. The Cal-Tech influence has wormed its way into the graphics research world, at least, and you see some papers pop up there frequently looking at geometric integrators. This Danish guy (I'm forgetting his name) at Disney publishes papers every now and then on the topic.
http://htmlpreview.github.io/?https://github.com/aguaviva/Ph...
this one shows how to solve a double/n pendulum, which is something that is not explained in detail anywhere. So if you want to learn how constraints work that should get you up to speed!
Somehow boxes slide along a flat floor with no deceleration until they fall off the screen
a) physics programs are supposed to offer interactivity. Else whats the point?
b) the physics look unearthly
To solve differential equations for which analytical solutions do not exist?
Edit: Differential inclusions, if inequality constraints are included in the system (as they would here).
Box2D with many more objects consumes 22%.
Oimo, with a 3D rendering scene with TONS of objects: 35% CPU..
Matter.js, lots of objects with mouse interaction: 15% CPU.
Plank, lots of objects: 25%
I'm wondering how/why this ended up in the front page...