Documentation
    Preparing search index...

    Function defineLayer

    • The bit index of the layer called name, defining it if this is the first time the registry has seen it (§46).

      const ui = defineLayer("ui");     // 1, on a fresh registry
      defineLayer("ui") === ui; // true — idempotent, forever

      Allocation is by first definition (see the module header), so it is deterministic given the same sequence of calls and reproducible from a serialized document by replaying the saved names in order. Most code should call layerMask instead and never see an index at all; this function is for the caller that wants the bit position itself — a serializer, a diagnostics table, or a consumer packing masks by hand.

      Parameters

      • name: string

      Returns number

      FourError INVALID_APPLICATION_STATE when name is empty (a layer with no name cannot be written to a scene file, which §46 requires), or when the registry already holds LAYER_COUNT layers. Both throw unconditionally — in production too — because there is no value to return and continuing would silently alias two layers onto one bit.