I have the (bad?) habit of not naming any Babylon objects (leaving the names as empty ‘’ strings). This caused 2 cameras to share a DepthRenderer, which caused SelectionOutlineLayer to sometimes not or partially render when swapping cameras.
Please see the video below where outlines render well with the player’s ArcRotateCamera, but switching to a FreeCamera causes outline rendering issues.
I simply solved this by giving both cameras unique names.
I was wondering if it would be preferable to create new DepthRenderer()for every Camera regardless of their names?
Thanks for the report (and the clear repro video)!
You’re right that this is error-prone. The internal Scene._depthRenderer dictionary was keyed by camera.id, and since Node.id falls back to name, two unnamed cameras end up colliding on “” and sharing a single DepthRenderer — which is exactly what’s causing your SelectionOutlineLayer issue when switching cameras.
Each camera will now get its own DepthRenderer regardless of name/id, so the workaround of giving them unique names won’t be needed once this is merged.