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

    Class LinesDataAccumulator

    Lines data accumulator with FULL multi-type support

    CRITICAL: Flat buffers matching types/lines.ts:170-194 CRITICAL: widths is PER-VERTEX (N,), NOT per-segment!

    Handles Float32Array, Uint8Array, and Uint16Array for colors 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
    vertexBuffer: Float32Array
    segmentBuffer: Uint32Array
    widthBuffer: Float32Array
    colorBuffer:
        | Uint8Array<ArrayBufferLike>
        | Float32Array<ArrayBufferLike>
        | Uint16Array<ArrayBufferLike>
    sharpnessBuffer: Float32Array
    scalarBuffer: Uint8Array<ArrayBufferLike> | Float32Array<ArrayBufferLike>

    Per-vertex scalar buffer for colormap lookup. Allocated as Float32Array initially; replaced with Uint8Array on first fill if the input scalars are Uint8. Float16 input stays in the default Float32 buffer (widened at fill time via the typed-array .set() numeric conversion).

    types: LinesAccumulatorTypes | null = null
    hasColors: boolean = false
    hasSharpness: boolean = false
    hasScalars: boolean = false

    tracks whether scalars were ever filled this session.

    _disposed: boolean = false

    Flips to true on dispose(); fill/ensureCapacity then throw.

    usedVertexCount: number = 0

    Highest vertex / segment indices touched by any fill() call. Lets ensureCapacity() copy only the live prefix into the new buffers instead of the full capacity.

    usedSegmentCount: number = 0
    colorComponents: 3 | 4 = 3

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

    vertexCapacity: number
    segmentCapacity: number
    ndim: number
    allocations: number = 0
    totalGrowths: number = 0
    • 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 LoadedPointsDataAccumulator.configureColorComponents.

      Parameters

      • components: 3 | 4

      Returns void

    • Ensure capacity for both vertices and segments.

      Parameters

      • vertexCount: number

        Actual vertex count needed

      • OptionalsegmentCount: number

        Optional actual segment count. When omitted, defaults to vertexCount. This is exact for particle tracks (N vertices → N-1 segments, ratio 1:1) and a safe over-estimate for typical line meshes (ratio 1.5:1 vertices-to-segments).

      Returns boolean

      true if buffers grew

      Always pass the actual segment count when known. The fallback is sized for safety, not for efficiency — under-sizing here causes silent buffer truncation when the loader later writes segments past the estimated boundary.

    • Fill accumulator buffers with multi-type support

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

      NOTE: widths uses vertexOffset (per-vertex), NOT segmentOffset!

      Parameters

      Returns void

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

    • Direct accessor for the per-vertex scalar buffer.

      Lazy-allocated on first access. Non-scalar line datasets keep scalarBuffer.length === 0 indefinitely, saving 4 B/vertex.

      Returns Uint8Array<ArrayBufferLike> | Float32Array<ArrayBufferLike>

    • mark scalars as present. Used by loaders that write directly into scalarBuffer via getScalarBuffer() (zero-copy path) and therefore need to flip hasScalars without going through fill().

      Returns void