Hey everyone!
Last time this was talked about was a couple of years ago and I was wondering, what is the best physics engine to use with typescript? I tried cannonjs but the lack of types made it hard to work with. I also tried rapierjs but it had several components that just do not work as intended/documented (character controller f.e.).
Bear in mind the goal is to use it in a game setting ![]()
Thank you!
cannon is typed: GitHub - pmndrs/cannon-es: 💣 A lightweight 3D physics engine written in JavaScript. are you using the dead one? cannon.js hasn’t been maintained for many (like 10?) years.
but cannon is slow, maybe hundreds of times slower than rapier. so i would probably pick that. whatever went wrong with the character controller must have been your codes fault.
in the react space this would be my preferred choice for a game type character controller GitHub - pmndrs/ecctrl: 🕹️ A floating rigibody character controller (all rapier based again, fully typed).
Cannon is still the best choice in practice if your goal is to ship a three.js game and stay productive.
In my case, the demo below deliberately pushes Cannon harder than most typical examples and addresses its known weak spots, especially Trimesh handling. Instead of relying on Cannon alone, I built a JavaScript control layer around cannon.js 0.20.0 (latest) that manages updates, collision filtering, and stability fixes at runtime.
Demo:
https://theneoverse.web.app/#threeviewer&&burn-city
This approach solves several common complaints about Cannon:
• Trimesh instability is mitigated by controlling when and how meshes are added, updated, and queried
• Game logic stays deterministic because the control layer decides how physics steps are applied
• three.js integration remains simple and predictable
• No WASM boundary, no opaque internals, everything is debuggable in plain JavaScript
Compared to alternatives:
• Rapier is extremely fast, but once you hit undocumented or broken features, you are stuck fighting the engine
• Ammo is powerful, but the API and TypeScript story slow development dramatically
• Oimo lacks depth for larger game systems
Cannon’s strength is that it is transparent and hackable. When something does not behave the way you want, you can work around it instead of waiting on engine fixes. For game development, that flexibility often matters more than raw performance.
If you are willing to build a thin control layer on top of Cannon, it remains the most reliable and practical physics option for three.js games today.