Selecting physics engine

Ive searched around for a physics engine to use, and currently gravitate towards oimo, though i see there seems to be 2 different versions.

One is Oimo.js, while the other is OimoPhysics. I see more examples for Oimo.js, but OimoPhysics seems to be more updated.

Im having trouble deciding which between the 2 to use and would like some insight.

I’d rather use rapier (Now you have a third choice … Good luck :sweat_smile:)

Seriously! what are your criteria? Well maintained, performance, lightweight, ease of use, documentation, use wasm/or not …

This link PHY may help you decide (or confuses you even more)

1 Like

Was selecting mainly for Lightweight and Ease of Use. I’m hoping to stick with purely vanilla JS as well.

I was actually deciding between Ammo, Cannon, and Oimo, and initially decided on Oimo. But stumbled on the fact Oimo has those 2 versions, and am wondering if there are any major differences between them, reasons one would be better than the other, etc. Oimo.js seems to have more examples around it, but it’s last update was a few years further back than OimoPhysics.

Rapier seems a lot more unstable in the demos compared to most others on this site. For example, the structure just collapses, while on other engines it stays in the correct shape: PHY

Also with the “start” demo, the couch just immediately drops through the floor as soon as the balls fall on top of it, while other engines don’t seem to have this issue.

Any idea why this is happening?

2 Likes

Ammo original:

Ammo improved:
https://enable3d.io/examples/raycast-vehicle.html
Ammo improved:

Ammo cars:
https://alteredqualia.com/xg/examples/animation_physics_level.html

3 Likes

Let me add Physijs (based on ammo) and its port to Three.js r150.

2 Likes

Depends on your needs. If you need continuous collision detection to prevent fast moving objects from passing through walls, rapier might be your only choice. I know Ammo and Cannon don’t support this.

2 Likes

If you want to make a case for Ammo/Physijs, just mention Soft bodies Cloth or volumes simulations, and who doesn’t love breaking things apart.

feels-good

But the OP is asking for lightweight, simplicity and ease of use, Cannon.js maybe? I mean 35kB Minified + Gzipped

3 Likes

I’d use Havok or Ammo, but they are both pretty tricky to get rolling. But physics simulation is tricky already… and Ammo (and probably Havok even tho the wasm port is relatively recent) are super battle tested. They’re really the only JS engines I trust. All other engines I’ve tried have nice working small demos, but quickly self destruct when presented with larger simulations or more complex use cases.
Ammo aka Bullet has been used in soooo many projects that pretty much all the bugs have been hammered out. It’s still really easy to break it with incorrect code… in fact it’s almost guaranteed, but by itself it’s super robust/solid once you know what you’re doing. Memory management is a pain… as it is with all wasm style apps… but yea. just my 2c.

If you just need a character running around a map, you could also use the threejs occtree fps sample… its dead simple to get working, and really fast.
https://threejs.org/examples/?q=fps#games_fps

Also mesh-bvh has a nice character control demo: three-mesh-bvh - Character Movement

4 Likes

Thank you everyone, I feel I now have a better understanding of what to expect from the physics engine options.

1 Like

Don’t use rapier, its too unstable. I’ve done extensive testing and replicated multiplayer and it breaks down way too easily.

rapier is so unstable?

I have used Ammo for several games and some work projects, and encountered some frustrating minor shortcomings. However, it is indeed one of the most comprehensive physics engines. Recently, I started using Havok and made a game with it, and it is indeed better.

1 Like