A set of layers, as a bit per layer (§46, §47's LayerMask).
A plain number used as an unsigned 32-bit field: bit i is set when the
mask contains the layer whose index is i. It is a type alias rather than a
branded type or a class because §47 and §48 both declare it as an ordinary
field, because every operation on it is a machine instruction, and because a
class here would allocate per node for no gain.
Values are canonically unsigned — 0 through 0xffffffff — which is what
layerMask and ALL_LAYERS produce and what isLayerMask
accepts. Testing masks with & is safe regardless: JavaScript's bitwise
operators coerce both operands to int32 and the sign bit survives the round
trip, so ALL_LAYERS & 0x80000000 is non-zero exactly as it should be.
A set of layers, as a bit per layer (§46, §47's
LayerMask).A plain
numberused as an unsigned 32-bit field: bit i is set when the mask contains the layer whose index is i. It is a type alias rather than a branded type or a class because §47 and §48 both declare it as an ordinary field, because every operation on it is a machine instruction, and because a class here would allocate per node for no gain.Values are canonically unsigned —
0through0xffffffff— which is what layerMask and ALL_LAYERS produce and what isLayerMask accepts. Testing masks with&is safe regardless: JavaScript's bitwise operators coerce both operands to int32 and the sign bit survives the round trip, soALL_LAYERS & 0x80000000is non-zero exactly as it should be.