Stack panel z-index not working for GUI

I am trying to give my stack panel higher z-index than the 3D button created in the scene. That is, the panel should appear in-front of the 3D button. But it seems to not have any effect. What is the issue here?

https://playground.babylonjs.com/#XCPP9Y#7213

So this is because the 2D GUI is on a plane on top of main scene and the 3D gui is on top of all of that (think about multiple layers).

The best option I can see here would be to create a second scene just for the 2D gui

@Deltakosh Hmm alright. But I thought the z-index would come in handy here. Does it not?

Also for such a case, the screen space 2D buttons should be given a higher importance than 3D buttons placed in the world space, right?

@Deltakosh

Is this the way to create overlay for the 2D buttons - stack panel?
I have tried to create the second scene but I guess I am doing something wrong.

https://playground.babylonjs.com/#XCPP9Y#7299

Correct. More details here:

Sry to object here, Boss;) I studied this part with guru;) @Evgeni_Popov and I guess I can say the recommended option would be to order the 3D layer (scene) so that it shows behind the advanced texture of the 2D GUI, using a 2 cams approach, as demonstrated in this PG:

https://playground.babylonjs.com/#MFN0FQ#1

2 Likes

Thanks!

I got it working with two cameras:

https://playground.babylonjs.com/#XCPP9Y#7300

Happy to hear that. You are very welcomed :smiley:

2 cameras or 2 scenes are kind of ok here :wink:
2 cameras is probably more performant so good job ;D

1 Like

Thanks @Deltakosh but can I request a feature? :slight_smile:
That is instead of creating 2 cameras for such a case, can we use the z-index of 3D GUI and 2D GUI and then use the higher z-index of the GUI element to keep that in front?

It is not possible because the GUI and 3D GUI are two separate modules that don’t know each other. In addition, there’s no z-index in the 3D GUI as the display order is simply the meshes location in the 3D space.

LoL. Yes, of course. My comment was only because you stated “…the best option…”. :wink:
It’s not mine to tell you that in BJS there is (nearly) always an alternate way and both would work like a charm :mage: :grinning_face_with_smiling_eyes: