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.
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.
Sorry, that if statement in CreateGizmo was misleading about the bug I was trying to demonstrate. (I posted it before going to bed ) 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.