11113
May 13, 2019, 9:28am
1
https://developer.playcanvas.com/en/api/pc.CameraComponent.html#layers
I assign new arrays directly.
this.layerNew = this.app.scene.layers.getLayerByName('New');
var layers = this.camera.camera.layers;
layers.push(this.layerNew.id);
this.camera.camera.layers = layers;
Why don’t layers that dynamically change cameras render New
Layer?The layer array debugging has changed, that is, it can’t render New.
This is an odd one. I would have thought that would work.
Can you post a link to your project? Perhaps there’s something in the setup of the layers that is causing the issue?
11113
May 13, 2019, 10:00am
3
Wait a minute for me to make a demo.
11113
May 13, 2019, 10:36am
4
https://playcanvas.com/editor/scene/755347
push is effective;
remover is invalid;
After removal, drawcall did not decrease.
There does look like to be an issue where there’s no API to remove a camera from a layer.
This is my workaround: https://playcanvas.com/editor/scene/755356
Press 1 to add the layer, 2 to remove the layer.
1 Like
11113
May 13, 2019, 12:19pm
6
It did solve the problem. Why didn’t I think about it?
To be fair, I only found that out from looking through the camera source code. The disable function removes the camera from all the layers. I couldn’t find another way to remove the camera from the layer without going through the layer object itself which felt wrong to do.