Live data from Hacker News

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

brm.io

51–60 of 64 posts

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

#51

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…

Sounds like Gish! http://www.chroniclogic.com/gish.htm

When I saw Gish for the first time, I thought the same but I bet they fake a lot of physics.

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

#52
post #40

Why all those "physics engines" are so jittery? Are there no ways to solve such a system with perceptually exact accurancy in realtime? Those kinds of approximations are the source of some of the most hilarious bugs in games over last deacade or so. Please don't read this as a critique of this particular project which is pretty good at what it's trying to do. I just wonder why AAA games use pretty much the same math?…

Animation is an illusion of motion caused by a sequence of still images. The way a physics engine works is by computing those still images -- the frames -- for each iteration in a mathematical model (the physics you want.) If you want 60 frames per second for a smooth animation, you have to compute the whole frame less than 1/60th of a second. The more complicated your physics model is, the harder it is to do this. >…

> "Better math" is a curious term. If you want more accuracy, you have to give up speed.

What I mean is for example to integrate something numerically you can just add small increments but this will lead often to crap unstable solutions. Or you can use Runge-Kutta and get very accurate stable result.

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

#53
post #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...

Box2D is ported from C++ to Flash and then from ActionScript to JavaScript. So it might be slow to get updates and bug fixes.

But it looks usable and seems to have the same features as Matter.js

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

#54
I am familiar with P2 JS, looked through PhysicsJS and the two very basic arcade engines grown within Phaser JS. Matter JS seems to have the exact same feature set like any other library. I haven't seen any 2D web engine, besides the JS ports of Box2D, which supports continuous collision detection (CCD), which would prevent a lot of tunneling, especially on slower mobile phones.

Why is that? CCD doesn't look more complex in theory than any other concept in a 2d physics engine.

P2JS: https://github.com/schteppe/p2.js PhysicsJS: http://wellcaffeinated.net/PhysicsJS/ Phaser: http://phaser.io/

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

#55
When I was evaluating engines for Hype Pro's [1] physics system, I compared based on file size, commit/project activity, how easy it would be to modify and integrate, and the license (for obvious reasons). I looked at Matter.js, Verlet, PhysicsJS, p2.js, JPE, Newton, and box2d-js. While many have their respective strengths, overall Matter.js stood a notch above the rest. The code has been easy to work with and Liam has also been responsive in fixing bugs or accepting patches. It is truly a gem of a project.

[1] http://tumult.com/hype-pro/

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

#58

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…

Maybe this is something like what you described: try the 'Blob Test' example from Box2D-html5

https://code.google.com/p/box2d-html5/

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

#59
post #28

Earlier quoted context omitted.

in 3d you normally represent by a 4x4 matrix, which can be easily reduced to 6 floats (x y z translation, and x y z rotations). The problem with doing that little work is you'll very quickly be bottlenecked by copying memory to/from the GPU. If you want to do any raycasts for instance, or query for occlusion/bounds testing, you need to upload data to the GPU, run a (potentialy very slow, serial) query, then copy the…

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.

You don't have to wait for video games for the future, GPU physics is commonplace in games. See eg https://en.wikipedia.org/wiki/List_of_games_with_hardware-ac... though that list hasn't been kept up to date.

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

#60
post #24

http://i.imgur.com/QcKoWLj.png Doesn't seem to render correctly on Chrome 39. Works fine on latest Firefox.

Same for me (chrome 39.0.2171.99, win 7) But it seems to work using webgl renderer !

Indeed, changing that makes it work for me too, using canvas is broken. ( In the settings to the right, Renderer -> renderer )
Post reply on HN