Create a new BitMask instance.

An object containing valid states and their corresponding initial boolean values (default is null).

Hierarchy

  • Number
    • BitMask

Properties

states: Record<string, string>

The enum associated with this structure.

Accessors

  • get isEmpty(): boolean

    True if this bitmask is empty (no active states).

    Returns boolean

Methods

  • Add a state to the bitmask.

    Parameters

    • state: string

      The state to add.

    Returns void

    Throws an error if the provided state is not valid.

  • Clear the bitmask, setting all states to inactive.

    Returns void

  • Creates a clone of this BitMask instance.

    Returns BitMask

    A new BitMask instance with the same value and valid states as this instance.

  • Check if a specific state is active.

    Parameters

    • state: string

      The state to check.

    Returns boolean

    True if the state is active, false otherwise.

  • Checks if two bitmasks structures are compatible (the same valid states).

    Parameters

    • otherBitMask: BitMask

      The bitmask structure to compare with.

    Returns boolean

    True if the two bitmasks have the same structure, false otherwise.

  • Remove a state from the bitmask.

    Parameters

    • state: string

      The state to remove.

    Returns void

    Throws an error if the provided state is not valid.

  • Toggle the state of a specific state in the bitmask.

    Parameters

    • state: string

      The state to toggle.

    • Optionalenabled: boolean

      Toggle on (true) or off (false)? If undefined, the state is switched automatically.

    Returns undefined | number

    Throws an error if the provided state is not valid.

  • Serializes the bitmask to a JSON string.

    Returns string

    The JSON string representing the bitmask.

  • Convert value of this BitMask to object representation according to structure.

    Returns Object

    The data represented by the bitmask.

  • Get a string representation of the bitmask in binary format.

    Returns string

    The string representation of the bitmask.

  • Get the current value of the bitmask.

    Returns number

    The current value of the bitmask.

  • Creates a new BitMask instance from a JSON string.

    Parameters

    • jsonString: string

      The JSON string representing the bitmask.

    Returns BitMask

    A new BitMask instance created from the JSON string.

  • Generates shader constants based on the provided states.

    Parameters

    • states: string[]

      An array containing valid states.

    Returns string

    Shader bit mask constants generated from the states.