Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Class LoadedPointsDataAccumulator

    Points data accumulator with FULL multi-type support

    Handles Float32Array, Uint8Array, and Uint16Array natively (no conversion) to maintain memory efficiency and consistency with multi-type GPU buffer pool.

    Type is detected on first fill() and remains fixed for the accumulator's lifetime.

    Implements

    Index
    • Create a new Points data accumulator with multi-type support

      Parameters

      • initialCapacity: number = 1024

        Initial capacity in number of points (default: 1024)

      • ndim: number = 3

        Number of dimensions in source data (default: 3)

      • totalPoints: number = 0

        Total points in dataset for metadata tracking (default: 0)

      Returns LoadedPointsDataAccumulator

      const accumulator = new LoadedPointsDataAccumulator(8192, 4, 10000);
      accumulator.ensureCapacity(5000);
      accumulator.fill(0, { positions, colors, radii, sharpness });
      const data = accumulator.getData(5000);
    positionBuffer: Float32Array
    colorBuffer:
        | Uint8Array<ArrayBufferLike>
        | Float32Array<ArrayBufferLike>
        | Uint16Array<ArrayBufferLike>
    radiiBuffer: Uint8Array<ArrayBufferLike> | Float32Array<ArrayBufferLike>
    sharpnessBuffer:
        | Uint8Array<ArrayBufferLike>
        | Float32Array<ArrayBufferLike>
        | Uint16Array<ArrayBufferLike>
    scalarBuffer:
        | Uint8Array<ArrayBufferLike>
        | Float32Array<ArrayBufferLike>
        | Uint16Array<ArrayBufferLike>

    per-point scalar buffer for colormap lookup.

    types: PointsAccumulatorTypes | null = null
    hasColors: boolean = false
    hasRadii: boolean = false
    hasSharpness: boolean = false
    hasScalars: boolean = false

    tracks whether scalars were ever filled this session.

    _disposed: boolean = false

    Flips to true on dispose(). Getters/fill/getData throw a descriptive error if called after disposal so caller bugs don't silently operate on the empty-buffer state.

    usedCount: number = 0

    Highest point index touched by any fill() call. Lets ensureCapacity() copy only the live prefix into the new buffers instead of the full capacity — when growing 1024 → 1536 after filling 800 points, the position copy goes from 12288 floats down to 2400 floats, a 5× reduction on the hot loading path.

    colorComponents: 3 | 4 = 3

    Components per color item: 3 (RGB) or 4 (RGBA — alpha = per-point opacity).

    capacity: number
    allocations: number = 0
    totalGrowths: number = 0
    ndim: number
    totalPoints: number
    usedSpatialIndex: boolean = false
    • Declare the color layout (3 = RGB, 4 = RGBA) BEFORE the first color fill. The loader knows the layout from the zarr array shape at open time; the accumulator needs it to size every color buffer. Throws if colors were already written with a different layout — the layout is a property of the dataset, not of an individual load. Mirrors LoadedGSplatsDataAccumulator.configureColorComponents.

      Parameters

      • components: 3 | 4

      Returns void

    • Ensure accumulator has sufficient capacity, growing if needed

      Uses the shared 1.5x-capped-at-needed growth strategy (./growth.ts) to minimize reallocation events while avoiding excessive memory overhead. Growth preserves attribute types (Uint8/Uint16/Float32).

      Parameters

      • needed: number

        Minimum required capacity (number of points)

      Returns boolean

      true if capacity was grown, false if already sufficient

      // Ensure space for 10000 points
      const didGrow = accumulator.ensureCapacity(10000);
      if (didGrow) {
      console.log('Accumulator grew to', accumulator.getStats().capacity);
      }
    • Get LoadedPointsData with NATIVE types (zero-copy subarrays)

      Returns views (subarrays) into accumulator buffers with native types preserved. No conversion or copying occurs. Computes fresh bounds from positions.

      Parameters

      • count: number

        Number of points to return (must be ≤ capacity)

      Returns LoadedPointsData

      LoadedPointsData with subarrays pointing to accumulator buffers

      Error if count > capacity

      const data = accumulator.getData(5000);
      // data.positions is a subarray of accumulator.positionBuffer
      // data.colors might be Uint8Array, Uint16Array, or Float32Array
      console.log('Actual type:', data.colors?.constructor.name);
      console.log('Dtype:', data.metadata.dtypes.colors); // 'uint8', 'uint16', or 'float32'
    • Fill accumulator buffers at offset with point data

      Detects attribute types on first fill and creates appropriately-typed buffers. Subsequent fills must use matching types. Preserves native types (no conversion).

      Parameters

      • offset: number

        Starting point index to fill from

      • data: Partial<LoadedPointsData>

        Partial point data to fill (any subset of attributes)

        • positions

          3D positions (Float32Array, size: count*3)

        • colors

          Optional colors (Float32Array|Uint8Array|Uint16Array, size: count*3)

        • radii

          Optional radii (Float32Array|Uint8Array, size: count)

        • sharpness

          Optional sharpness (Float32Array|Uint8Array, size: count)

      Returns void

      // First fill: detects types (Uint8 colors)
      accumulator.fill(0, {
      positions: new Float32Array([1,2,3]),
      colors: new Uint8Array([255, 128, 0])
      });
      // Accumulator now has Uint8Array colorBuffer

      // Subsequent fills: must use same types
      accumulator.fill(1, {
      positions: new Float32Array([4,5,6]),
      colors: new Uint8Array([0, 255, 128]) // Must be Uint8Array
      });
    • Update accumulator metadata

      Updates metadata fields for the accumulated points. Note: bounds parameter is ignored - getData() always computes fresh bounds from positions.

      Parameters

      • metadata: {
            ndim?: number;
            totalPoints?: number;
            usedSpatialIndex?: boolean;
            bounds?: Box3;
            usedEffectiveRadius?: boolean;
        }

        Partial metadata update

        • Optionalndim?: number

          Number of dimensions

        • OptionaltotalPoints?: number

          Total points in full dataset

        • OptionalusedSpatialIndex?: boolean

          Whether spatial index was used for loading

        • Optionalbounds?: Box3

          Ignored (computed in getData())

        • OptionalusedEffectiveRadius?: boolean

          Tracked but not used in return

      Returns void

    • Throws if a mutating call lands on a disposed accumulator. Read-only getters return the empty buffers so disposal assertions can inspect the cleared state without raising.

      Parameters

      • method: string

      Returns void

    • Returns
          | Uint8Array<ArrayBufferLike>
          | Float32Array<ArrayBufferLike>
          | Uint16Array<ArrayBufferLike>

    • Returns Uint8Array<ArrayBufferLike> | Float32Array<ArrayBufferLike>

    • Returns
          | Uint8Array<ArrayBufferLike>
          | Float32Array<ArrayBufferLike>
          | Uint16Array<ArrayBufferLike>

    • Direct accessor for the scalar buffer (used by loaders writing through).

      The accumulator starts with a zero-length scalar buffer to avoid reserving 4 B/point on the common no-scalars path. The first getScalarBuffer() call allocates to current capacity so the spatial-index loader's direct-write path (loadVertexRanges → scalarBuffer) writes into a real buffer.

      Returns
          | Uint8Array<ArrayBufferLike>
          | Float32Array<ArrayBufferLike>
          | Uint16Array<ArrayBufferLike>