Physics: w/o global gravity, Cannon.js ignores friction, Ammo.js totally broken

I observed some strange behavior of Cannon.js in case there is no global gravitation configured (enablePhysics()), but the gravitational force is provided with applyForce() each physics update cycle. IMHO this should not make a big difference. But it looks as if friction is completely ignored then.

Using Ammo.js instead gives a totally broken motion.

Oimo behaves differently, but still somehow reasonable.

The effect can be seen here: Babylon.js Playground

Pinging @Cedric

You need to build a new Vector3 for applyForce second parameter.

https://playground.babylonjs.com/#3STT3N#7

Once fixed with Ammo, the friction is visible.

2 Likes

Ah, thank you so much @Cedric!, Iā€™d never ever figured that out :). Worth a notice in the documentation that the vector is not read-only?

What about the first parameter? Can it be reused?