Understand Body Types: Dynamic, Kinematic, and Static
masterBodies in cannon-es behave differently based on their mass and type:
- Dynamic Bodies: Have a mass greater than 0. They are affected by forces (like gravity) and velocity.
- Static Bodies: Have a mass of 0 (or are explicitly set to
CANNON.Body.STATIC). They are not affected by forces or velocity and remain fixed in position. - Kinematic Bodies: Are not affected by forces but can have a velocity and move around manually.
To create a static body, you can either set mass: 0 or use the type property:
const groundBody = new CANNON.Body({
type: CANNON.Body.STATIC,
shape: new CANNON.Plane(),
})