How to add Cannon-ES library to SDK.
Awesome Repository. - There are a few examples of using a physics engine in Decentraland. Billiard Game, Shooting game 1, Shooting game 2, Shooting game 3, Car Scene, Frisbee Throwing, BasketBall.
All these examples use cannon.js library to implement physics on the scene, which is outdated and hasn’t maintance since 2016. There are a lot of bugs and shortcomings.
Cannon-ES is the fork of “cannon.js”, with improvements and recently updated.
So what do we need to add it to SDK? A few steps:
- Install cannon-es
Add to “package.json”, cannon-es as dependency to your project and run npm install
- Add the source file to “include” section of tsconfig.json
- Import it with absolute path.
CORRECT:
import {World} from "./node_modules/cannon-es/dist/cannon-es";
INCORRECT:
import {World} from "cannon-es";