pronotron-tech-art-suite
    Preparing search index...

    Class NativeControlTable<EnumType>

    NativeControlTable class manages a fixed-size native array (as a control table) with an inferred numeric Enum structure. It uses a high-frequency access pattern, ideal for animation or real-time applications where direct memory access is critical for performance.

    enum AnimationData {
    DELAY,
    DURATION,
    ...
    };
    // Any typed array can be used depends on your data
    const controlTable: NativeControlTable<AnimationData> = new NativeControlTable( 2, Float32Array, nodeCountHint );
    controlTable.add( YOUR_ANIMATION_ID, {
    [ AnimationData.DELAY ]: 0.15,
    [ AnimationData.DURATION ]: 1.75
    } );
    // Iterating over the control table,
    const { table, usedSlots, stride } = controlTable;
    for ( i = 0; i < usedSlots; i++ ){
    const slotOffset = i * stride;
    const delay = table[ slotOffset + AnimationData.DELAY ];
    const duration = table[ slotOffset + AnimationData.DURATION ];
    }

    Type Parameters

    • EnumType extends number
    Index

    Constructors

    • Initializes a fixed-size native control table with a specified stride and underlying typed array.

      Type Parameters

      • EnumType extends number

      Parameters

      • stride: number

        Determines the stride size

      • tableType: new (length: number) => NativeTable

        Typed array version

      • nodeCountHint: number

        Used to initialize the fixed-size native array, capacity will expand if needed.

      Returns NativeControlTable<EnumType>

    Properties

    stride: number

    Defines how many elements each node holds.

    4: [ ( +, +, +, + ), ( +, +, +, + ), ... ]
    
    table: NativeTable

    Raw typed array that holds flattened data

    usedSlots: number = 0

    The control table is created with a fixed size. This property tracks how many slots are currently used.

    Methods

    • Retrieves a specific value from a slot by its ID and enum key.

      Parameters

      • ID: SlotID

        Slot ID to get

      • dataKey: EnumType

        Enum key corresponding to the desired value.

      Returns number | Error

      The numeric value stored for that key in the slot, or undefined if the ID does not exist.

    • Checks whether a slot with the given ID currently exists in the table.

      Parameters

      • ID: SlotID

        Slot ID.

      Returns boolean

      true if the slot exists; otherwise false.