Live data from Hacker News

Matter.js – A 2D rigid body physics engine for the web

brm.io

41–50 of 64 posts

Re: Matter.js – A 2D rigid body physics engine for the web

#42

demo request: I want a demo where the user can control a soft body ball such that the ball is comprised of chain segments, connected with string constant k. The pressure of the ball would be calculated depending on the area enclosed by the chain's polygon and would be applied to each segment equally, to the outwards side. Controls would be left/right as a simple added force to all segments of the ball. Jump would be…

You probably want a soft body physics engine, not a rigid body one. Something that could use Verlet + pressure-based techniques, for example.

Re: Matter.js – A 2D rigid body physics engine for the web

#43
post #5

Pros: The samples play well, look fun, and it looks like a great solution to small physics demos in JS. Great job! Cons: Playing with the Stress demos (especially #2) really shows the slowdowns and downsides to using a JS based engine. At 450 boxes (+ 4 bounding walls), it runs at 20fps on my Macbook and thats with a lot of jitter and overlap. Not as fun. Edit: Significantly better w/ WebGL render, @32fps, and with s…

How does it compare to, say, Box2D ported to JS using Emscripten? http://kripken.github.io/box2d.js/webgl_demo/box2d.html

Good question. I also wonder how it compares to other popular 2D js physics engines:

p2.js: http://schteppe.github.io/p2.js/

PhysicsJS: http://wellcaffeinated.net/PhysicsJS/

Re: Matter.js – A 2D rigid body physics engine for the web

#46
post #38

Earlier quoted context omitted.

The question then becomes how slow is copying to/from the GPU versus doing the computation on the CPU when it comes to 100s/1000s of active bodies. I agree that normally (small examples) it wouldn't be worth it, but for any large simulations, and say, video games of the future, I have yet to see someone attempt to do this. Perhaps it truly isn't beneficial enough... but who knows.

> The question then becomes how slow is copying to/from the GPU versus doing the computation on the CPU when it comes to 100s/1000s of active bodies. The amount of time spent inside a GPGPU kernel for updating 1000 rigid bodies wouldn't even be as much as the length of time to copy the data back and forth. You've also got to consider the acceleration structure used for the collision detection. If you have a hierarchi…

Thanks for the insights :)

Re: Matter.js – A 2D rigid body physics engine for the web

#48
post #33

This is very impressive! The most advanced JS 2d rigid body physics engine to date! You can do a lot of optimization though, probably double the speed. Tip: V8 loves objects and hates parsing strings. Your functional spaghetti style is a bit weird though. I hate using the "find in file" function in my editor. I wanted to "rip" some of the functionality, but it's so entangled I would probably need all your other funct…

It is more advanced than Box2D [0]? What makes you say that?

http://blog.sethladd.com/2011/09/box2d-javascript-example-wa...

Re: Matter.js – A 2D rigid body physics engine for the web

#50

demo request: I want a demo where the user can control a soft body ball such that the ball is comprised of chain segments, connected with string constant k. The pressure of the ball would be calculated depending on the area enclosed by the chain's polygon and would be applied to each segment equally, to the outwards side. Controls would be left/right as a simple added force to all segments of the ball. Jump would be…

You probably want a soft body physics engine, not a rigid body one. Something that could use Verlet + pressure-based techniques, for example.

Well, I was precisely interested if it could be modeled with a chain. Otherwise thank you for you pointers.
Post reply on HN