Jump to content

Scene.dispose() Pointer Issues


Matt574
 Share

Recommended Posts

Hi Guys,

 

I'm relatively new to Babylon.js and from what I'm seeing so far it is an excellent tool!

 

I am however having a slight issue with scene.dispose(). I've noticed that when I call this method pointer methods no longer work. so I have an onPointerDown event which works fine before scene.dispose() but after I call it the pointer down no longer works!

 

What can I do to re-enable this after I dispose a scene?

 

Also what other properties need to be re-activated after dispose?

 

Many Thanks

 

Matt

Link to comment
Share on other sites

Hi Matt!

Welcome :-)

 

First, just to understand - why do you need to use the scene.dispose() ? 

 

The scene contains all of the objects that are required to... render a single scene :), including user interactions (the action manager, the pointer down and up etc'). If you dispose a scene, you will have to create a new one, that will handle those events again. 

Link to comment
Share on other sites

Hi Raanan, thanks for the warm welcome : )

 

Basically I want to be able to clear my scene from all meshes cameras lights etc so reset it I guess. If I create a new scene after disposing the old one the renderer seems to loose its scope and doesn't render anything. Do I need to set the new scene to be active?

 

Cheers!

Link to comment
Share on other sites

The "active scene" is the one being rendered by the engine. You probably have somewhere an engine.runRenderLoop hidden in your code. Inside you probably have a scene.render() call. You just need to change the scene reference here.

 

BTW, you can also clear all array of the scene. But if you really want to get rid of everything, scene.dispose() would of course work.

Link to comment
Share on other sites

Thanks for the reply's guys. I couldn't get the new scene method to work so i ended up just clearing out all the arrays within the scene as suggested by Raanan. However it would be great if i could get the new scene method to work. 

 

What i have is this:

window.addEventListener("DOMContentLoaded", function(){    new App("appViewport"); },false);var global;var App = function(canvasID){      global = this;        this.canvas = document.getElementById(canvasID);    this.engine = new BABYLON.Engine(this.canvas, true);    this.scene = new BABYLON.Scene(this.engine);    this.assetsManager = new BABYLON.AssetsManager(this.scene);}

Then elsewhere in my application when i want to reset the current scene i use:

global.scene.dispose();global.scene = new BABYLON.Scene(global.engine);

This doesn't appear to work. Is there a way to drop the reference to the old scene as mentioned above?

 

Many Thanks

 

Matt

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...