DevTools access scene

Hi there,

I’ve switched to typescript on a local dev (npm install) for a few weeks now, up till now goes very well.
However, before when working with the referenced cdn script path in the html file I could list my options for objects in the DevTools from chrome.

I could for example enter scene, or scene.activeCamera to get my active camera.

VM17723:1 Uncaught ReferenceError: scene is not defined
    at <anonymous>:1:1

This now returns this error.

What’s the way to access this again in this workflow?
Thanks!

Possible reason is that now you call your objects listing snippet before the scene is initialized.
Or, probably, you need to use this.scene ?
Hard to say without seeing the actual code :slight_smile:

1 Like

Try setting window.BABYLON = BABYLON in your index/entry file.

If that doesnt work, you can configure your bundler to not bundle babylon so that you can still use the cdn script.

2 Likes

On the playground window.scene is set equal to the scene object returned from your scene creating function, so you can type scene in the console to log and inspect the object.

On a local typescript project you should be able to do something like below after creating your scene and then you can access it from anywhere including from the console. Not sure but I think that’s what you’re after? :slight_smile:

(window as any).scene = scene;
4 Likes

Thank you for all of your answers.
Only

(windows as any).scene = scene;

worked to be able to access the scene properties in the console of chrome.

2 Likes