scene.activeCameras order effecting PostProcess, GUI (+GUI Camera) and Gizmos

Bug(s) Demonstration: https://playground.babylonjs.com/#0D4FWK#3
note: I’ve commented the relevant bits of code.
edit: Changed url increment to #3. #1 was misleading about the bug I was trying to demonstrate.

The playground demonstration shows the gizmos picking meshes on scene.activeCameras[scene.activeCameras - 1] instead of the camera specified with UtilityLayerRenderer’s setRenderCamera function. Swapping the cameras around, however, results in the post process applying to the gui, when the gui camera is first in scene.activeCameras, despite its layerMask.

My intention is to eventually create a gui for toggling post process effects while using gizmos for positioning meshes within the scene.

edit: (1) The gui shouldn’t be affected by post processes, and (2) the gizmos mesh picking shouldn’t happen from the guiCamera. Click the meshes in either camera view and then do the same after clicking the button at the bottom of the screen. Clicking the button will reverse the order of scene.activeCameras to show that you can have one or the other, but not both.

this is a related post Gizmo and Multiviews

cc @Cedric

It’s not a bug. At the moment CreateGizmo is called, activeCameras is not populated yet. I’m not sure when it is but I guess it’s during rendering (just before maybe? maybe @PolygonalSun can help here)
Anyway, activeCameras being empty, the camera [0] is undefined and you are right, setRenderCamera has no effect.
But, if you change the signature of CreateGizmo is pass the camera as a parameter, then use it, it works fine.

Another solution is to delay the construction of the gizmo.

1 Like

Sorry, that if statement in CreateGizmo was misleading about the bug I was trying to demonstrate. (I posted it before going to bed :sweat_smile:) I edited my original post to add more context and incremented the playground url to #3 and moved camera creation to CreateScene, before my other static function calls.

Hi and welcome to the Community,
I’m not sure to fully understand the ‘bug’ with the gizmo, but for (quote)

Isn’t it so that you just have to tell the pointers to not use the gui camera? Sorry, if I misunderstood it.

2 Likes

You understood perfectly! And that solves it, thank you!