2x4b Posted January 5, 2018 Share Posted January 5, 2018 Hi again, I have recently run into a wall that I could use some help with. I am using an advancedTexture for a GUI. The problem is, that when I add a second camera to the scene as a minimap, the GUI no longer receives pointer events. Here is an example https://www.babylonjs-playground.com/#XCPP9Y#387 As you can see, the button doesn't work. Obviously I need to get the buttons working again. If I remove the minimap, everything works as expected. Any ideas? Thank you Quote Link to comment Share on other sites More sharing options...
brianzinn Posted January 5, 2018 Share Posted January 5, 2018 scene.cameraToUseForPointershttps://doc.babylonjs.com/classes/3.1/scene#cameratouseforpointers-nullable-lt-camera-classes-3-1-camera-gt-https://www.babylonjs-playground.com/#XCPP9Y#388 Quote Link to comment Share on other sites More sharing options...
2x4b Posted January 5, 2018 Author Share Posted January 5, 2018 (edited) Thanks brianzinn. Your solution works so long as the button is not linked to a mesh. I didn't know there would be a difference, so didn't include that information in my original post. Sorry. Now I just have to work out why area being displayed as the button is not the area that responds to the click. https://www.babylonjs-playground.com/#XCPP9Y#389 In this playground, the area that responds to the clicks is above the sphere by the height of the sphere. Edited January 5, 2018 by 2x4b more information Quote Link to comment Share on other sites More sharing options...
brianzinn Posted January 5, 2018 Share Posted January 5, 2018 Maybe somebody else can explain (otherwise it looks like a bug somewhere), but the order the cameras are pushed matters:https://www.babylonjs-playground.com/#XCPP9Y#390 Quote Link to comment Share on other sites More sharing options...
2x4b Posted January 5, 2018 Author Share Posted January 5, 2018 If I push the minimap first, as you did in the playground ( https://www.babylonjs-playground.com/#XCPP9Y#390 ), the minimap gets obscured by objects rendered in the second camera. I need the minimap on top, that is why I pushed it second. I think it could be a bug, as the buttons graphical portion is displayed in the correct place. Surely the area responding to pointer input and the area used for displaying the button should match. Thank you for your help brianzinn. brianzinn 1 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted January 5, 2018 Share Posted January 5, 2018 I wonder if minimap is picking up pointer event... (oversized overlay)? Idk. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted January 5, 2018 Share Posted January 5, 2018 Looks like the minimap getting obscured can't be worked around as the render order is purely the index in activeCameras array:https://github.com/BabylonJS/Babylon.js/blob/c320730ee34a4de5edb8f0ec513cba9fe779ab57/src/babylon.scene.ts#L3614 There's another new question about GUI pointer events off, so wonder if these are related. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 5, 2018 Share Posted January 5, 2018 This should work: https://www.babylonjs-playground.com/#XCPP9Y#389 Let me ding into it to fix the bug brianzinn 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 5, 2018 Share Posted January 5, 2018 Ok it is not a bug The GUI will use its cached values for picking and thus the latest rendering is the truth. In you case the latest rendering is done for the MM camera Here is a way to fix it by using layerMask: https://www.babylonjs-playground.com/#XCPP9Y#391 Quote Link to comment Share on other sites More sharing options...
2x4b Posted January 9, 2018 Author Share Posted January 9, 2018 That is awesome! Thank you! I was under the impression that the GUI doesn't use layerMasks. This fix also means I don't have to shrink the GUI to 0 scale for rendering the mm camera. Great! 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.