Hi am creating multiple viewports with independent layers which my meshes are allocated too. I seem to be running into trouble with the layerMask bitmask values. I will need aleast 8 values to play with, 4 different cameras and triads. The first four work:
however I cannot use any other value after allocating my first four - meshes are places in the wrong viewport etc. I would guess then next one would be 0x160000000.
I’ve also tried normal Integersm but that doesnt work either:
2
4
8
16
Am I doing something wrong, or if there a limitation I need to know about ? Thanks in advance
So just like @sebavan is saying for values like 2, 4, 8, and 16, they would be expressed in hex with the zeroes on the left (eg. 2 = 0x00000002). You should also be able to mix hex and decimal values for the layermasks as long as they match up bit-wise.
Example:
a.layerMask = 1;
b.layerMask = 2;
c.layerMask = 4;
d.layerMask = 8;
e.layerMask = 16;
// Show all five meshes
camera.layerMask = 0x0000001F;
// Show a and e
camera.layerMask = 0x00000011;
ok great its working now. I had to loop over all the meshes and override the default value. setting scene.meshes.forEach(mesh => mesh.layerMask =0) first then I get control
Yes, not easy to understand about layerMask. FYI: This is why (following my desperate request for answers about 18months ago , with the invaluable help and expertise of @Evgeni_Popov, we have introduced this new section of in-depth layer mask in the doc.
Edit: Pls feel free to improve it and make it even more comprehensive.
I didn’t know we had a guide that goes in depth on the layerMask. That’d be a good resource to link on the layerMask page in the Cameras section of the docs. Awesome work @mawa!
Also, I changed the default years ago, so that there are top 4 levels which are beyond the the default. This should be enough for most people to assign without going through all the meshes to make room. They are: