Unfortunately, it is imposible to reproduce in playground. Because in playground scene.enablePhysics()
doesn’t cause ‘CANNON is undefined’ error.
And I have NO NEED to do like that:
let cannonPlugin = new BABYLON.CannonJSPlugin(true, 10, cannon);
scene.enablePhysics(scene.gravity, cannonPlugin);
So, my first example works good both at 3.2 and 4.0 if we work inside playground. But on my computer it causes ‘CANNON is undefined’ error.
I think I have situation like described in this ticket: Cannon.js NPM "CANNON is not defined" in v4.0.0-alpha.21 but works in v4.0.0-alpha.16
I’ve took a solution how to fix crash from there but it caused gravity problems, that I mentioned above.