Jump to content

positionGizmoEnabled true return getEngine of null (originalScene not exist)


Dad72
 Share

Recommended Posts

@trevordev, Hi,

I found a pretty sneaky bug when I try to activate a gizmo with this line: (It's random this error.)

var manipulator = new BABYLON.GizmoManager(scene);
manipulator.usePointerToAttachGizmos = false;
 manipulator.attachToMesh(mesh);
manipulator.positionGizmoEnabled = true;

this return  getEngine of null

Code in Babylon in the function UtilityLayerRenderer()

// Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
this.utilityLayerScene = new BABYLON.Scene(originalScene.getEngine());

Basically, when I set positionGizmoEnabled to true, the originalScene parameter does not exist.

I can not reproduce it on the PG and I do not understand why it happens on my project, it's been 4 hours that I try to understand and there I give up, I do not understand the logic to this problem.

So that I can not display gizmo on my stage. Maybe you have an idea of what can produce this. This looks like a very sneaky bug for some project.

It's just the originalScene that is not recovering and I do not see what I can do with bad eyes that I inform the scene in the GizmoManager.

Thank you Trevor

Link to comment
Share on other sites

I have another problem too when my gizmo want to show up.

If the image 1 we can see that the gizmo is inside the cube and not before like on the demos on the PG

521084826_2018-08-2417_05_46-Greenshot.png.aa59748358290638aa63dbff42f02c6e.png

 

To properly display the gizmo I am forced to put 1 render group id then reset it to 0.

91970594_2018-08-2417_06_01-Greenshot.thumb.png.5f48d29c93dad3a6d8f055a306d65094.png

We can see that now that it is correctly display.

At no time do I create my objects using renderGroupId. Why is the gizmo is not in first plan(in front of the box) ? would link to the first bug higher?

Link to comment
Share on other sites

@Dad72 Any chance you are doing anything with the gizmos or UtilityLayerRenderer.DefaultUtilityLayer prior to the scene being created, or are you creating multiple scenes?

To repro are you refreshing the webpage or are you using another mechanism to rerun the code?

The 2 issues you listed seem somewhat related pointing to the fact that UtilityLayerRenderer.DefaultUtilityLayer might not be getting initialized correctly if UtilityLayerRenderer.DefaultUtilityLayer.originalScene is null or undefined.

Link to comment
Share on other sites

In fact on my editor, I start by creating an empty scene.
Then I can create more terrain.
My editor allows me to select with a selection menu a terrain that loads the scene.

When I change a terrain, I dispose the scene and I create a new one.  So I recreate a new GizmoManager. I do not dispose the engine.

Edit: By testing what you say, in fact, I think that when I dispose () the scene, UtilityLayerRender is not disposed (??)

 

Link to comment
Share on other sites

So will adding a scene.dispose listener in the gizmoManager manager class that disposes of it when the scene is disposed solve your issue? You will then have to recreate a new gizmos/manager for the new scene.

Edit: another option would be to reuse only one scene and when changing scenes dispose of all the objects in the current scene and load new objects into it.

Link to comment
Share on other sites

See this PG: http://playground.babylonjs.com/#8MGKWK#33 when m is pressed the gizmo manager will be disposed and when that happens it will dispose all of it's inner gizmos aswell.

Also if I add something like line 17 into the gizmo manager it will automatically get disposed when the scene is disposed (you can see it output in the console when run is pressed).

Would that work for you or am I still not understanding?

Link to comment
Share on other sites

This is how dispose works in JS, the garbage collector should collect any object that nothing else is referenced, for certain objects that store hard references (webGL buffers) dispose is needed to be called. After dispose is called on the manager, all internal references are released so it looks to behave as expected. You can always set manager = null; after calling dispose to force an error if you continue to use a disposed object.

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