Issue with Layers in Build vs. Editor

Hello everyone,
today I came across a rather interesting bug (?) regarding the layer system.

My scene has two cameras - one perspective and one orthographic - of which the latter is used to display a sort of “overview” mode (think floor plan overview in architecture). Those two cameras are never active at the same time.
The first camera shows the ‘World’ layer (in the demo containg a cube), the second camera shows a custom layer called ‘Overview’ (in the demo containing a sphere).
When you click on a button, the first camera gets disabled and the orthographic one gets enabled, lerps to a position, and stays there. If you click the button again, the process works in the opposite order.
This, for the time being, works just fine in the Editor - but not in a Build. In the built version

  1. the orthographic camera doesn’t show the correct layer(s)
  2. the view cannot be toggled back to the first camera

Here’s a link to the project:
https://playcanvas.com/editor/scene/1048728
and here’s a link to the build:

Interestingly, while the application is launched in the Editor, my browser doesn’t show any errors, while in the Build, there are four (see screenshot). One of which relates to “LAYERID_UI” not being found. I assume there lies the problem, because when I use

this.app.scene.layers.getLayerByName("UI").id

everything seems to work just fine. Is this the intented behavior of the layers array?

All the layerids are part of the scope of pc. Eg pc.LAYERID_WORLD, pc.LAYERID_IMMEDIATE, pc.LAYERID_UI

It’s strange that it was accessible in the launch tab without the scoping :thinking:

Bug report: https://github.com/playcanvas/editor/issues/245

1 Like

It seems to work now, thank you!

1 Like