Getting Visible Layers of Camera

Hello,

I am wondering if there is an easy way to know which layers are currently visible by the camera? I have looked at the docs and it does not seem clear that I can do this. I would like to call something like camera.layers.currentlyVisible() and be returned an array of the currently visible layers like [0, 1, 3]

Any response would be greatly appreciated! Thank you

Hi @max,

I don’t think a method that returns this as an array exist, but maybe you could use Layers.test to know if a specific layer is visible :

if ( camera.layers.test(2) ) // then layer 2 is visible

3 Likes

This doesn’t seem to be working for me. The only example I can find looks like this

object.layers.test(camera.layers) // returns true if a layer is shared

Looks like I have to pass a layers object not just the layer I want to check…

I figured something out. I just created an object to hold for which layers are visible. That’s good enough for me, Thank you!

1 Like