Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cannon-es instead of Havok as the physics engine #1

Merged
merged 9 commits into from
Mar 29, 2024

Conversation

TeenageMutantCoder
Copy link
Owner

@TeenageMutantCoder TeenageMutantCoder commented Mar 29, 2024

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

@TeenageMutantCoder TeenageMutantCoder merged commit bc00402 into main Mar 29, 2024
@TeenageMutantCoder TeenageMutantCoder deleted the use-cannon branch March 29, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant