Birch-san/box2d-wasm

Is box2d wasm better than matterjs

a6965921 opened this issue · 1 comments

Is box2d wasm better than matterjs I use matterjs FPS is very low

I'm not familiar with matter.js, but:

liabru/matter-js#608

the result is not good enough
There are many rect-boxes are overlap .

certainly, when I play with matter.js demos: it's very easy to make objects intersect. I think Box2D is more accurate.

as for performance: I expect box2d-wasm and box2d.js to be faster than matter.js, because of access to better memory-management techniques. box2d-wasm/box2d.js are written in C++; most of the work executes in WebAssembly/asm.js. objects allocated by the engine are not reference-counted; you don't incur garbage collection costs. moreover, they're allocated with a custom block allocator, which reduces memory fragmentation and keeps the heap small (reducing memory costs and improving locality of reference).

as for features: Box2D has more types of joints:
liabru/matter-js#472

it sounds like matter.js approximates circles:
liabru/matter-js#615

box2d-wasm's liquidfun-wasm release adds the fluid simulation and soft-body capabilities from Google liquidfun. demo here. liquidfun has very bespoke memory management, introducing a slab allocator and stack allocator too. I think it would handle large numbers of particles far better than matter.js.

box2d-wasm also provides comprehensive TypeScript typings. it looks like matter.js uses best-effort JSDoc typings, or types contributed separately via DefinitelyTyped.