Sign in to follow this  
max123

Uncaught ReferenceError: BABYLON is not defined

Recommended Posts

Hi,

I've just updated v3.0 to 3.2 and am getting this error:

Uncaught ReferenceError: BABYLON is not defined.

I'm using requirejs to load BJS, PEP and some other libs. Has something changed in 3.2 definitions?

Share this post


Link to post
Share on other sites
4 minutes ago, RaananW said:

3.2 has moved to UMD, and has a proper amd definition. you can now require babylonjs as a package. 

How did you load it until now? using externals?

requirejs(["pep", "babylon", this.settingsFile]...

Worked great... until now.

Babylon is a small part of the project I'm working on and is loaded via requirejs at runtime when needed.

Share this post


Link to post
Share on other sites

@RaananW, it's defined in the main.js file like following:

requirejs.config({
   shim: {
      easeljs: {
         exports: 'createjs'
      },
      tweenjs: {
         deps: ['easeljs'],
         exports: 'Tween'
      },
      movieclip: {
         deps: ['easeljs', 'tweenjs']
      },
      babylon: {
         exports: "BABYLON"
      },
      pep: {
         deps: ["babylon"]
      }



   },
   paths: {
      createjs: 'libs/createjs-2015.11.26.min',
           "pdfjs-dist": "libs/pdf/pdfjs-dist",
           babylon: "libs/3d/babylon/babylon",
           pep: "libs/3d/babylon/pep",
   }
});

Share this post


Link to post
Share on other sites

Babylon doesnt need the shim anymore, it has a proper amd definition. it will automatically populate the global namespace as a fallback, but requiring babylonjs (using this package name) will load it properly using requirejs

Share this post


Link to post
Share on other sites

Hi @RaananW, thanks for the heads up. I've managed to load 3.2. Here's the requirejs definition (I did keep the shim as to make sure PEP is loaded and available to Babylon first):

 

requirejs.config({
   shim: {
      babylonjs: {
         exports: "BABYLON"
      },
      pep: {
         deps: ["babylonjs"]
      }
   },
   paths: {
           babylonjs: "libs/3d/babylon/babylon",
           pep: "libs/3d/babylon/pep",
   }
});

Hop this helps to whoever has problems with BJS 3.2 and AMD (requirejs).

Note:  I've changed babylon to babylonjs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this