PhantomWarrior562 Posted May 9, 2018 Share Posted May 9, 2018 Hey all! I’m a beginner at BabylonJS and ran into a problem. I spent a long time researching how to solve this on the internet, and couldn’t find a solution. I am running a HTML/JavaScript file locally with BabylonJS and my BabylonJS file is unable to see that I am (using a Cannon.js CDN)/(have Cannon.js saved locally) and prints the following error in the console window: BJS - CannonJS is not available. Please make sure you included the js file. BJS - [17:17:19]: Physics Engine CannonJSPlugin cannot be found. Please make sure it is included. This printout happens when I call “scene.enablePhysics();”. My project works just fine otherwise. (More errors appear when I try to use the physics engine that didn’t load, but that isn’t applicable here.) When I don’t enable physics, this error does not occur but of course, the physics engine doesn’t work then. I am using the following for CDN-calling: <script src="https://cdn.babylonjs.com/cannon.js"> When that didn’t work, I tried using the following below after having downloaded a copy of cannon.js (and putting it in the same folder as the .html file that is using BabylonJS). <script src="cannon.js"></script> I feel like I’m missing something very simple, but I’m not sure what it is. Something similar is happening when I try to use Oimo.js (though I would prefer cannon.js). I get the following error for Oimo.js ( “scene.enablePhysics(new BABYLON.Vector3(0,-9.81, 0), new BABYLON.OimoJSPlugin());”): babylon.js:44 Uncaught TypeError: Cannot read property 'World' of undefined at new i (babylon.js:44) at createScene (PlayingAround.html:193) at PlayingAround.html:330 Putting this code in a playground does not make sense because this line of code “scene.enablePhysics();” works just fine in the playground. I was wondering how I could fix this issue. Thanks in advance for the help! Quote Link to comment Share on other sites More sharing options...
JohnK Posted May 10, 2018 Share Posted May 10, 2018 Hi @PhantomWarrior562 and welcome from me. Just did a test with a copy of Cannon.js directly from the Build folder of the Cannonjs Github and everything works well. Suggest you read the Cannonjs ReadMe and use npm to install or copy the raw data from the Build folder or use the CDN link provided. Quote Link to comment Share on other sites More sharing options...
PhantomWarrior562 Posted May 10, 2018 Author Share Posted May 10, 2018 Hi John K., Thanks so much for your help and suggestions! As you suggested, I checked out the CannonJS documentation much more closely. Turns out the problem was being caused by something unrelated to how I was using CannonJS. Turns out, my problem was being caused by my using an older version of BabylonJS. While I was using the CDN for the older version of BabylonJS (https://cdn.babylonjs.com/babylon.js), I was having Cannon.js issues. Once I switched to the CDN with the newer version of BabylonJS (https://preview.babylonjs.com/babylon.js), Cannon.js worked just fine. Thanks again for your help! Quote Link to comment Share on other sites More sharing options...
JohnK Posted May 10, 2018 Share Posted May 10, 2018 How true, so often the problem lies well away from where you think it is. Quote Link to comment Share on other sites More sharing options...
Raggar Posted May 10, 2018 Share Posted May 10, 2018 Same thing can happen if you load CannonJS before BabylonJS. Quote Link to comment Share on other sites More sharing options...
PhantomWarrior562 Posted May 10, 2018 Author Share Posted May 10, 2018 Thanks. CDN ordering being important is good to know. For me, it's actually the other way around: that problem happens to me if I load BabylonJS before CannonJS. Different versions probably require different orders. Thanks for the help, guys! Quote Link to comment Share on other sites More sharing options...
Raggar Posted May 10, 2018 Share Posted May 10, 2018 Just now, PhantomWarrior562 said: Thanks. CDN ordering being important is good to know. For me, it's actually the other way around: that problem happens to me if I load BabylonJS before CannonJS. Different versions probably require different orders. Thanks for the help, guys! Nah. Mistake on my part. I meant the other way around as well. Jesus.. Quote Link to comment Share on other sites More sharing options...
hans200 Posted August 26, 2018 Share Posted August 26, 2018 On 5/10/2018 at 2:13 PM, PhantomWarrior562 said: Hi John K., Thanks so much for your help and suggestions! As you suggested, I checked out the CannonJS documentation much more closely. Turns out the problem was being caused by something unrelated to how I was using CannonJS. Turns out, my problem was being caused by my using an older version of BabylonJS. While I was using the CDN for the older version of BabylonJS (https://cdn.babylonjs.com/babylon.js), I was having Cannon.js issues. Once I switched to the CDN with the newer version of BabylonJS (https://preview.babylonjs.com/babylon.js), Cannon.js worked just fine. Thanks again for your help! Hi @ all, also i am a beginner in babylon. also have the problem with cannon.js it just does not work. in the html babylon.js and cannon.js are inserted Babylon version is 3.2 cannon.js from https://cdnjs.com/libraries/cannon.js/0.6.2 here are the pictures Thank you in advance for the help Quote Link to comment Share on other sites More sharing options...
Raggar Posted August 27, 2018 Share Posted August 27, 2018 Make sure you include cannon.js Before babylon.js. Quote Link to comment Share on other sites More sharing options...
Guest Posted August 27, 2018 Share Posted August 27, 2018 Yep this seems to be the reason why Quote Link to comment Share on other sites More sharing options...
hans200 Posted September 1, 2018 Share Posted September 1, 2018 hello people, sorry for the late reply thats work by me thx GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.