Use cannon-es instead of Havok as the physics engine #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At this time, BabylonJS does not have any abstraction for Vehicles using the Havok engine. BabylonJS/Babylon.js#13800
I did not want to implement entirely custom physics, so I needed a library that could fit my needs.
BabylonJS Physics V1 allowed the use of Ammo.js, Cannon.js, and Oimo.js, but they all seemed like they were unmaintained and had little documentation. Ammo.js was updated more recently, and it should be very reliable since it was compiled directly from the Bullet Physics engine C++ source code, but I disliked the lack of TS types. I also considered using ammojs-typed, but it still seemed like too much work. I don't really like the Bullet Physics interface since it clashes with JS/TS conventions, and the Bullet Physics documentation is relatively unpleasant to use. https://pybullet.org/Bullet/BulletFull/annotated.html
When doing research on the available options, I read a thread on the Three.js forum that showed a list of potential options.
I ended up choosing cannon-es since I preferred its documentation, and I adapted most of my code from the Raycast Vehicle example they provided.
To assist with debugging the physics (since it is handled completely outside of BabylonJS), I copied code from cannon-es-debugger-babylonjs that allows me to view a visual representation of the physics models. I initially installed it via npm, but I ended up copying the source code due to type and dependency issues.
Recording.2024-03-29.183817.mp4