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

    Main array decoder class

    Index
    refRegistry: ArrayRefRegistry
    • Decode an array from zarr, handling all encoding modes

      Parameters

      • zarrArray: Array<DataType, Readable>

        Zarr array handle

      • attrs: ArrayMetadata

        Array metadata from .zattrs

      • OptionalexpectedElements: number

        Expected total elements (for validation)

      • OptionalzarrRootLoc: Location<Readable>

        Zarr root location for resolving array_ref paths (required for array_ref)

      • Optionalsignal: AbortSignal | null

        Optional abort signal forwarded to every chunk read this decode performs (including a resolved array_ref target's), so a caller tearing down mid-fetch can stop the transfer rather than just discard it

      Returns Promise<Float32Array<ArrayBufferLike>>

      Decoded Float32Array

    • Infer quantization bounds from encoding name

      Some encodings have implicit bounds that don't need to be stored:

      • rgb_uint8/rgb_uint16: [0, 1] (standard RGB range)
      • Others: return null (must have explicit bounds field)

      Parameters

      • encName: string

        Encoding name (e.g., "rgb_uint8", "bounded_scalar_uint16")

      Returns [number, number] | null

      Bounds [min, max] or null if not inferrable

    • Decode broadcasted array (uniform values)

      Format: Shape (1, k) replicated to (n_elements, k)

      Parameters

      • data: Float32Array

        Raw data array (shape: (1, k))

      • n_elements: number

        Target number of elements to replicate to

      • k: number

        Feature dimension (e.g., 3 for RGB, 1 for scalar)

      • Optional_expectedElements: number

        Expected total elements (for validation, currently unused)

      Returns Float32Array

    • Decode LUT-encoded array

      Format: Indices (uint8/uint16) + lookup table Modes:

      • "row": One index per row → k values (e.g., positions: one index per point → (x,y,z))
      • "scalar": One index per element → 1 value (e.g., positions: one index per coordinate)

      Parameters

      • indices: Float32Array

        Array of indices into the lookup table

      • lut: number[] | number[][]

        Lookup table containing unique values

      • k: number

        Feature dimension (ignored for scalar mode)

      • lutMode: string = 'row'

        "row" or "scalar" mode

      Returns Float32Array

    • Dequantize integer array to floats

      Format: uint8 or uint16 → float with bounds [min, max] Delegates to the TypeScript worker-fallback kernels for bit-exact routing parity.

      Parameters

      • data: ArrayLike<number>
      • bounds: [number, number]
      • dtype: string

      Returns Float32Array

    • Decode log-space encoded scalar array

      Format: log1p(value)/max_log → uint8/uint16 Decoding delegates to the shared decode_log_scalar_u8/u16 kernel.

      Used for positive scalars with wide dynamic range (e.g., radii)

      Parameters

      • data:
            | Uint8Array<ArrayBufferLike>
            | Float32Array<ArrayBufferLike>
            | Uint16Array<ArrayBufferLike>
      • maxLog: number
      • dtype: string

      Returns Float32Array

    • Decode geometric-log scalar (min/max-anchored, reserved zero level).

      Level 0 decodes to exactly 0; levels [1, 2^bits - 1] decode to exp(minLog + (u - 1)/(2^bits - 2) * (maxLog - minLog)) — uniform relative precision across the array's own nonzero range. Matches the worker/WASM kernels bit-exactly; Python's f64 decode differs because the viewer rounds the logarithmic anchors to f32 first.

      Parameters

      • data: ArrayLike<number>
      • minLog: number
      • maxLog: number
      • dtype: string

      Returns Float32Array

    • Resolve array reference (deduplicated array)

      Per spec section 7.6, this method:

      1. Checks hash-based cache first (fast path for already-loaded arrays)
      2. If not cached, loads the target array from zarr using target path
      3. Recursively decodes the target (it may also be encoded)
      4. Caches the result by hash for future references

      Parameters

      • targetPath: string

        Path to the target array (from encoding.target)

      • hash: string | undefined

        Content hash for caching/verification (from encoding.hash)

      • OptionalexpectedElements: number

        Expected total elements (for validation)

      • OptionalzarrRootLoc: Location<Readable>

        Zarr root location for path resolution

      • Optionalsignal: AbortSignal | null

      Returns Promise<Float32Array<ArrayBufferLike>>

    • Helper: Check if encoding is LUT (lookup table)

      LUT encoding is special because the lookup table is stored in metadata, so we can load only a range of indices from zarr and still decode correctly. This enables efficient range-based loading instead of loading the full array.

      Parameters

      Returns boolean

    • Helper: Check if encoding is broadcasted (uniform value)

      Broadcasted encoding stores a single value that's replicated to all points. For range loading, we just need the single value - no need to extract ranges.

      Parameters

      Returns boolean

    • Helper: Check if an encoding name means direct stored values.

      Parameters

      • name: string | undefined

      Returns boolean

    • Helper: Check if an encoding name is a known LUT encoding.

      Parameters

      • name: string | undefined

      Returns boolean

    • Helper: Check if an encoding name is a known log-scalar encoding.

      Parameters

      • name: string | undefined

      Returns boolean

    • Helper: Check if an encoding name is a geometric-log scalar encoding (min/max-anchored true-log with a reserved zero level).

      Parameters

      • name: string | undefined

      Returns boolean

    • Validate quantization bounds before dequantization.

      Parameters

      • bounds: [number, number]
      • context: string

      Returns [number, number]

    • Helper: Check if an encoding name is known by the decoder.

      Parameters

      • name: string

      Returns boolean

    • Generic per-channel quantization encodings: per-column (per-channel) log (log_perchannel_u8/u16, non-negative), signed-log (signed_log_perchannel_u8/u16, signed), linear/fixed-point (linear_perchannel_u8/u16, identity — COORDINATE positions/centers/vertices), and TRUE-log (geolog_perchannel_u8/u16, wide-range positive — HDR colors). They carry per-channel scale arrays (col_lo/col_hi) rather than global bounds, so they are NOT in isQuantizedEncodingName (the global-scale dequant path); they have their own 'perchannel' load path in the RangeLoader which fully decodes them to float32 (see range-loader/perchannel.ts). The scheme is geometry-agnostic; consumers receive decoded float32.

      Parameters

      • name: string | undefined

      Returns boolean

    • Build the per-channel dequantizer for a log_perchannel_* / signed_log_perchannel_* / linear_perchannel_* / geolog_perchannel_* array. Mirrors the Python decoders (_decode_*_perchannel): log: x = expm1(lo[c] + level/levels·(hi[c]-lo[c])) signed-log: y = lo[c] + level/levels·(hi[c]-lo[c]); x = sign(y)·expm1(|y|) linear: x = lo[c] + level/levels·(hi[c]-lo[c]) (identity; coordinates) geolog: x = 0 at level 0, else exp(lo[c] + (level-1)/(levels-1)·rng) (TRUE-log grid, ln-domain scales; HDR colors — always zero-level) With zero_level: true (current writer for the log/signed-log pair), level 0 is a RESERVED ZERO (decodes to exactly 0) and nonzero levels 1..2^bits-1 span the nonzero-anchored [lo, hi] with denominator 2^bits-2 — same layout as geolog_scalar. Arrays without the flag keep the legacy all-levels mapping above. For any other / float32 / direct encoding it returns the identity, so a raw value passes through unchanged.

      Parameters

      • encoding:
            | {
                name?: string;
                bits?: number;
                col_lo?: number[];
                col_hi?: number[];
                zero_level?: boolean;
            }
            | undefined
      • numCols: number

      Returns (level: number, col: number) => number

      (level, col) => value — level is the raw stored integer (as float).

    • Helper: Check if an encoding name is quantized (uint8/uint16 with bounds).

      Parameters

      • name: string | undefined

      Returns boolean

    • Helper: Check if encoding is quantized (uint8/uint16 with bounds)

      Quantized encodings store data in reduced precision (uint8/uint16) with bounds metadata for dequantization. These can be efficiently range-loaded: load only the needed ranges of quantized data, then dequantize.

      Includes:

      • rgb_uint8, rgb_uint16 (colors)
      • bounded_scalar_uint8, bounded_scalar_uint16 (radii, sharpness)
      • log_scalar_uint8, log_scalar_uint16 (log-space radii)

      Parameters

      Returns boolean

    • Get quantization metadata for range-based decoding

      Extracts the bounds needed to dequantize a subset of quantized data. Returns null if not quantized.

      Parameters

      • attrs: ArrayMetadata

        Array metadata from .zattrs

      • zarrDtype: string

        Actual zarr array dtype (e.g., 'uint16', '<u2'). Required because Python stores the quantized dtype on the zarr array, not in attrs.dtype.

      Returns
          | {
              bounds: [number, number];
              dtype: "uint8" | "uint16";
              isLogSpace: boolean;
              isGeologSpace?: boolean;
          }
          | null

    • Normalize dtype string to canonical format

      Handles all NumPy dtype string variants:

      • 'uint8', '|u1', '<u1', '>u1' → 'uint8'
      • 'uint16', '|u2', '<u2', '>u2' → 'uint16'

      Parameters

      • dtype: string

      Returns "uint8" | "uint16"

    • Get LUT encoding metadata for range-based decoding

      Returns the LUT metadata needed to decode a subset of indices. Returns null if not LUT-encoded.

      Parameters

      Returns { lut: number[] | number[][]; lutMode: string; k: number } | null

    • Validate a stored lut_mode: absent defaults to 'row' (the Python encoder omits it for 1-D arrays), but a present-yet-unknown value throws — matching the worker decoder (workers/data-worker/decode/lut.ts), which already rejects it. Previously the main thread silently treated garbage as row mode.

      Parameters

      • lutMode: string | undefined

      Returns string

    • Decode LUT indices directly (for range-based loading)

      This allows decoding a subset of indices without loading the full array. The indices can be loaded from zarr using range slicing, then decoded using the LUT from metadata.

      Parameters

      • indices:
            | Uint8Array<ArrayBufferLike>
            | Float32Array<ArrayBufferLike>
            | Uint16Array<ArrayBufferLike>

        Indices loaded from a range of the zarr array

      • lutMetadata: { lut: number[] | number[][]; lutMode: string; k: number }

        LUT metadata from getLUTMetadata()

      Returns Float32Array

      Decoded values (Float32Array)

    • Dequantize quantized data directly (for range-based loading)

      This allows dequantizing a subset of quantized data without loading the full array. The quantized ranges can be loaded from zarr using range slicing, then dequantized using the bounds from metadata.

      Parameters

      • quantizedData:
            | Uint8Array<ArrayBufferLike>
            | Float32Array<ArrayBufferLike>
            | Uint16Array<ArrayBufferLike>

        Quantized data loaded from ranges (uint8/uint16)

      • quantMetadata: {
            bounds: [number, number];
            dtype: string;
            isLogSpace: boolean;
            isGeologSpace?: boolean;
        }

        Quantization metadata from getQuantizationMetadata()

      Returns Float32Array

      Dequantized values (Float32Array)