MeshInstance#mask exposes the light mask as a raw bitmask of internal constants
MeshInstance#mask selects the lights that light a mesh instance. It is a raw bitmask, documented as a combination of MASK_AFFECT_DYNAMIC, MASK_AFFECT_LIGHTMAPPED and MASK_BAKE:
https://github.com/playcanvas/engine/blob/7389dfc47e70f0e5e50216d26cec3af2101e2214/src/scene/mesh-instance.js#L1235-L1245
Those three constants are marked @ignore, so they are not in the API reference, and the only public way to set the light mask of a mesh instance takes values that are not part of the public API:
https://github.com/playcanvas/engine/blob/7389dfc47e70f0e5e50216d26cec3af2101e2214/src/scene/constants.js#L813-L838
The components expose the same choices as named properties instead. LightComponent has affectDynamic, affectLightmapped and bake, and RenderComponent has lightmapped:
https://github.com/playcanvas/engine/blob/7389dfc47e70f0e5e50216d26cec3af2101e2214/src/framework/components/light/component.js#L1081-L1153
RenderComponent has no property for the light mask of its mesh instances. It writes their mask itself through MeshInstance#setLightmapped, when the mesh instances are assigned and whenever lightmapped changes, so a mask set directly on one of its mesh instances is lost at the next of those:
https://github.com/playcanvas/engine/blob/7389dfc47e70f0e5e50216d26cec3af2101e2214/src/framework/components/render/component.js#L366 https://github.com/playcanvas/engine/blob/7389dfc47e70f0e5e50216d26cec3af2101e2214/src/framework/components/render/component.js#L397-L407 https://github.com/playcanvas/engine/blob/7389dfc47e70f0e5e50216d26cec3af2101e2214/src/scene/mesh-instance.js#L2056-L2065
Hey, I'd love to pick this one up if it's still free. Can I be assigned to this issue?
I read through MeshInstance#mask, the @ignored MASK_* constants, and how LightComponent and RenderComponent#lightmapped (via setLightmapped) handle the mask today.
My idea is to add named boolean properties on MeshInstance, similar to what LightComponent has (one for receiving lightmapped lighting, one for being a bake target), and keep mask internal. I'd also make sure RenderComponent doesn't wipe out a value set on a mesh instance.
Does that direction sound right, or would you rather make the MASK_* constants public and keep mask as the API? Happy to go with whatever you prefer, and I'll open a PR once we've settled on it.