Shadow camera and layers

To switch between layer 2 and 3 I have to know which layer I am actually rendering.
And unless I am wrong there are no function to test what layers are enabled or disabled.
The only parameter you can access is the mask and do a bitewise operation to know which is enabled.
Here 1 << 2 checks if layer 2 is enabled. 1 << 3 would check the third bite, therefore the layer 3.
Then using set will enable the layer and disable any other.

I guess I could have simply used an extra variable to store the state…