PhantomWarrior562

[Solved] Physics Engine CannonJSPlugin cannot be found

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites
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.. :P

 

Share this post


Link to post
Share on other sites

 

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

GB0O7ky.png

9WYJC55.png


Thank you in advance for the help

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.