Uncaught ReferenceError: CANNON is not defined

someone may please for love of god, write in some doc a definitive explain about this kind of error. Not just to JS but TS too. I found topics about that and was made some changes on babylonjs and I could contour the problem and now, my simple program don’t has any error. But, it only shows the window of babylon when a scroll event occurs.

Just for someone interested in the solution:
install cannon by npm
and in the index.ts, before babylon import, insert the line:
window.CANNON = require( ‘cannon’ );
NOTE: this don’t solve the error from compiler showed by vscode.

1 Like

Yeah, the docs really should cover the setup process. In case anyone else is struggling with it, here’s what I did to solve it:

npm install cannon
npm install --save-dev @types/cannon

Then, in code:

import cannon from "cannon";

window.CANNON = cannon;
1 Like

I’ll see if I can add some stuff to this section :smiley:

1 Like

Add a section about initializing cannon engine. by carolhmj · Pull Request #683 · BabylonJS/Documentation (github.com)

1 Like

inha inha inha Carolina é nossa rainha! Valeu moça!