Dad72 Posted August 24, 2018 Share Posted August 24, 2018 @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 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 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 To properly display the gizmo I am forced to put 1 render group id then reset it to 0. 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? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 24, 2018 Share Posted August 24, 2018 Pinging @trevordev Quote Link to comment Share on other sites More sharing options...
trevordev Posted August 24, 2018 Share Posted August 24, 2018 @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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 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 (??) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 @trevordev In fact I just realized that when I dispose the scene, the GizmoManager is not disposed. If I dispose GizmoManager before of dispose the scene, same thing, the GizmoManager is not disposed Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 I did a pg that reproduce http://playground.babylonjs.com/#8GY6J8#115 See in the console. The GizmoManager is not disposed. Quote Link to comment Share on other sites More sharing options...
trevordev Posted August 24, 2018 Share Posted August 24, 2018 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 No, scene.dispose (), do not eliminate gizmoManager gizmo.dispose () does not eliminate the gizmoManager. dispose () does not work. Quote Link to comment Share on other sites More sharing options...
trevordev Posted August 24, 2018 Share Posted August 24, 2018 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? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 The gizmo is eliminated from the scene, but it remains present if you look in the console: http://playground.babylonjs.com/#8MGKWK#36 Quote Link to comment Share on other sites More sharing options...
trevordev Posted August 24, 2018 Share Posted August 24, 2018 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 Yes. So on the PG it works as expected. but on my project I do not know what's going on. I'm trying to understand why, but I think I'm going to eliminate the engine too and recreating it to solve can be my problem. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 By recreating the engine, it corrects my problem. I do not really know why. By cons, I still have the problem of gizmo which is inside the object as in this image: An idea of what can cause this. Quote Link to comment Share on other sites More sharing options...
trevordev Posted August 24, 2018 Share Posted August 24, 2018 That would happen if the gizmos and the box are in the same scene somehow, are you passing in the scene parameter when creating the box and can you confirm that it is the main scene? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 Thank you for all your help Trevor. I finally understood why. That's why I used that when I loaded the camera. let pass = new BABYLON.PassPostProcess("pass", 1, scene.activeCamera); pass.samples = 8; By removing that. it works now. trevordev 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 24, 2018 Author Share Posted August 24, 2018 Maybe you have an explanation of why this postProcess create this problem? Just by curiosity. Quote Link to comment Share on other sites More sharing options...
trevordev Posted August 27, 2018 Share Posted August 27, 2018 This actually looks like a bug, I got a PG repro here: http://playground.babylonjs.com/#8MGKWK#38 from a spectorjs capture it looks like when the depth buffer clear is done its occurring on the wrong buffer so when the gizmos are drawn they get occluded. Created https://github.com/BabylonJS/Babylon.js/issues/5013 Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 28, 2018 Author Share Posted August 28, 2018 Thank you for checking this and for the explanation. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.