Jump to content

Debug Inspector and TypeScript


Flux
 Share

Recommended Posts

Hi,

So, I've been following many tutorials but appear to be stuck at the first hurdle. I don't appear to be able to use the Debug Inspector if I'm using TypeScript and ES6 imports.

I've setup my first scene using the initial tutorial (a sphere and a surface) on the website just fine using the TypeScript documentation (creating a Game class and so on).

To do this in the ES6 way I import BabylonJS from node_modules by doing import * as BABYLON from 'babylonjs'; at the top of my .ts file and it works like a charm.

Then I add this.scene.debugLayer.show(); to show the debug panel and I'm then faced with the following error in the Chrome debug console:

babylon.inspector.bundle.js:408 Uncaught ReferenceError: BABYLON is not defined
    at INSPECTOR (babylon.inspector.bundle.js:408)
    at Object.t (babylon.inspector.bundle.js:408)
    at __webpack_require__ (babylon.inspector.bundle.js:21)
    at Object.<anonymous> (babylon.inspector.bundle.js:49)
    at __webpack_require__ (babylon.inspector.bundle.js:21)
    at babylon.inspector.bundle.js:41
    at babylon.inspector.bundle.js:44

This is because it's absolutely right, the namespace BABYLON isn't included globally, my application is ES6, imports libraries where needed and then concatenates using Webpack.

I moved to BabylonJS because it's dev team seemed to embrace TypeScript and ES6 but can't believe that something like this would have been overlooked? So that leads me to thinking I'm doing something wrong here.

The only way I can see this working (which I found some libraries to do) is if the show() function to take the BABYLON object directly as an optional parameter, rather than expect for it to exist on the window (because it won't if you're importing ES6 style and webpacking).

Open to thoughts and suggestions on this one as I'm new to BabylonJS. If I'm right with the above and it's just not something that has been done yet, I don't mind submitting a pull request.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...