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

    Class TypeScriptFallback

    TypeScript fallback class implementing WasmModule interface. Used when WASM is unavailable or fails to load.

    Implements

    Index
    calculate_effective_radii: (
        positions: Float32Array,
        radii: Float32Array,
        displayDims: Uint32Array,
        slicePosition: Float32Array,
        spatialExtendDims: Uint8Array,
        ndim: number,
        numPoints: number,
        output: Float32Array,
    ) => number = calculate_effective_radii

    Calculate effective radii for nD points when sliced.

    When an nD hypersphere is sliced by a hyperplane, the visible cross-section has a smaller radius. This function computes that effective radius.

    Type Declaration

      • (
            positions: Float32Array,
            radii: Float32Array,
            displayDims: Uint32Array,
            slicePosition: Float32Array,
            spatialExtendDims: Uint8Array,
            ndim: number,
            numPoints: number,
            output: Float32Array,
        ): number
      • Calculate effective radii for nD points when sliced.

        Parameters

        • positions: Float32Array

          Point positions [numPoints * ndim]

        • radii: Float32Array

          Original point radii [numPoints]

        • displayDims: Uint32Array

          Dimensions to display (typically [0,1,2]) [numDisplayDims]

        • slicePosition: Float32Array

          Current slice position [ndim]

        • spatialExtendDims: Uint8Array

          Which dims are spatial (1) vs discrete (0). Callers SHOULD pass an array of length ndim for explicit control. For dimensions d >= spatialExtendDims.length, this implementation DEFAULTS to spatial (treats the missing entry as 1). This is the more permissive fallback (extra dims contribute to the Pythagorean distance instead of silently dropping the point as a discrete mismatch); production callers in this codebase enforce length >= ndim at the worker boundary (see projectPointsTo3D). [length: SHOULD be ndim]

        • ndim: number

          Total number of dimensions

        • numPoints: number

          Number of points

        • output: Float32Array

          Output effective radii [numPoints]

        Returns number

        Number of points with non-zero effective radius (visible points)

    Point positions [numPoints * ndim]

    Original point radii [numPoints]

    Dimensions to display (typically [0,1,2]) [numDisplayDims]

    Current slice position [ndim]

    Which dims are spatial (1) vs discrete (0) [ndim]

    Total number of dimensions

    Number of points

    Output effective radii [numPoints]

    Number of points with non-zero effective radius (visible points)

    sort_splats_by_depth: (
        centers3: Float32Array,
        modelView: Float32Array,
        ordering: Uint32Array,
        count: number,
    ) => number = sort_splats_by_depth

    Sort splats back-to-front by camera-space depth.

    Produces the permutation consumed by the aSortedIndex instance attribute: ordering[j] is the original splat index drawn at instance slot j (slot 0 = farthest). Degenerate depth ranges (single depth plane, everything behind the camera) yield the identity ordering. Input is always projected 3D centers, so no ndim cap applies.

    Type Declaration

      • (
            centers3: Float32Array,
            modelView: Float32Array,
            ordering: Uint32Array,
            count: number,
        ): number
      • Sort splats back-to-front by camera-space depth.

        Parameters

        • centers3: Float32Array

          Projected 3D splat centers [count * 3] (x, y, z triplets)

        • modelView: Float32Array

          Column-major 4x4 model-view matrix [16] (camera.matrixWorldInverse × mesh.matrixWorld, THREE.js layout)

        • ordering: Uint32Array

          Output permutation [count] — ordering[j] is the original splat index drawn at instance slot j (slot 0 = farthest)

        • count: number

          Number of splats

        Returns number

        Number of splats placed via depth keys, or 0 when the identity fallback was taken (degenerate depth range — ordering is still written)

    Projected 3D splat centers [count * 3]

    Column-major 4x4 model-view matrix [16]

    Output permutation [count]

    Number of splats

    Number of splats placed via depth keys (0 = identity fallback)

    decode_quantized_u8: (
        data: ArrayLike<number>,
        minVal: number,
        maxVal: number,
        output: Float32Array,
    ) => void = decode_quantized_u8

    Decode quantized uint8 to float32. Maps [0,255] -> [minVal,maxVal]

    Type Declaration

      • (
            data: ArrayLike<number>,
            minVal: number,
            maxVal: number,
            output: Float32Array,
        ): void
      • Decode quantized uint8 data to float32. Maps uint8 [0, 255] to [minVal, maxVal] linearly.

        Parameters

        • data: ArrayLike<number>
        • minVal: number
        • maxVal: number
        • output: Float32Array

        Returns void

    decode_quantized_u16: (
        data: ArrayLike<number>,
        minVal: number,
        maxVal: number,
        output: Float32Array,
    ) => void = decode_quantized_u16

    Decode quantized uint16 to float32. Maps [0,65535] -> [minVal,maxVal]

    Type Declaration

      • (
            data: ArrayLike<number>,
            minVal: number,
            maxVal: number,
            output: Float32Array,
        ): void
      • Decode quantized uint16 data to float32. Maps uint16 [0, 65535] to [minVal, maxVal] linearly.

        Parameters

        • data: ArrayLike<number>
        • minVal: number
        • maxVal: number
        • output: Float32Array

        Returns void

    decode_log_scalar_u8: (
        data: ArrayLike<number>,
        maxLog: number,
        output: Float32Array,
    ) => void = decode_log_scalar_u8

    Decode log-space quantized uint8. Result = expm1(normalized * maxLog)

    Type Declaration

      • (data: ArrayLike<number>, maxLog: number, output: Float32Array): void
      • Decode log-space quantized uint8 data to float32. Decoding: expm1(normalized * maxLog) Callers provide integral codes in [0, 255]; ArrayLike also accepts widened Float32Array codes.

        Parameters

        • data: ArrayLike<number>
        • maxLog: number
        • output: Float32Array

        Returns void

    decode_geolog_scalar_u8: (
        data: ArrayLike<number>,
        minLog: number,
        maxLog: number,
        output: Float32Array,
    ) => void = decode_geolog_scalar_u8

    Decode geometric-log uint8 (reserved zero level; min/max-anchored).

    Type Declaration

      • (
            data: ArrayLike<number>,
            minLog: number,
            maxLog: number,
            output: Float32Array,
        ): void
      • Decode geometric-log quantized uint8 data to float32. Reserved zero level: 0 -> exactly 0; levels [1,255] -> exp(minLog + (u-1)/254 * (maxLog - minLog)). Mirrors the Rust kernel 1:1.

        Parameters

        • data: ArrayLike<number>
        • minLog: number
        • maxLog: number
        • output: Float32Array

        Returns void

    decode_geolog_scalar_u16: (
        data: ArrayLike<number>,
        minLog: number,
        maxLog: number,
        output: Float32Array,
    ) => void = decode_geolog_scalar_u16

    Decode geometric-log uint16 (reserved zero level; min/max-anchored).

    Type Declaration

      • (
            data: ArrayLike<number>,
            minLog: number,
            maxLog: number,
            output: Float32Array,
        ): void
      • Decode geometric-log quantized uint16 data to float32.

        Parameters

        • data: ArrayLike<number>
        • minLog: number
        • maxLog: number
        • output: Float32Array

        Returns void

    decode_linear_perchannel_u8: (
        data: Uint8Array,
        colLo: Float64Array,
        colHi: Float64Array,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_linear_perchannel_u8

    Decode per-channel LINEAR (fixed-point) uint8 codes to float32. Per-column [lo, hi] scales (f64, straight from the JSON attrs); colOffset is the column phase of the first element.

    Type Declaration

      • (
            data: Uint8Array,
            colLo: Float64Array,
            colHi: Float64Array,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel LINEAR (fixed-point) uint8 codes to float32. Identity transform, per-column scales — the COORDINATE encoding. No reserved zero level (mirrors Python's _decode_linear_perchannel).

        Parameters

        • data: Uint8Array
        • colLo: Float64Array
        • colHi: Float64Array
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_linear_perchannel_u16: (
        data: Uint16Array,
        colLo: Float64Array,
        colHi: Float64Array,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_linear_perchannel_u16

    Decode per-channel LINEAR (fixed-point) uint16 codes to float32.

    Type Declaration

      • (
            data: Uint16Array,
            colLo: Float64Array,
            colHi: Float64Array,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel LINEAR (fixed-point) uint16 codes to float32.

        Parameters

        • data: Uint16Array
        • colLo: Float64Array
        • colHi: Float64Array
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_log_perchannel_u8: (
        data: Uint8Array,
        colLo: Float64Array,
        colHi: Float64Array,
        zeroLevel: boolean,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_log_perchannel_u8

    Decode per-channel LOG uint8 codes to float32 (x = expm1(y)). zeroLevel: true = reserved zero code 0 + codes 1..255 over the nonzero-anchored scale; false = legacy all-levels mapping.

    Type Declaration

      • (
            data: Uint8Array,
            colLo: Float64Array,
            colHi: Float64Array,
            zeroLevel: boolean,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel LOG uint8 codes to float32 (x = expm1(y)). The Cholesky-diagonal encoding; zeroLevel per the current-vs-legacy layout contract in decode.rs.

        Parameters

        • data: Uint8Array
        • colLo: Float64Array
        • colHi: Float64Array
        • zeroLevel: boolean
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_log_perchannel_u16: (
        data: Uint16Array,
        colLo: Float64Array,
        colHi: Float64Array,
        zeroLevel: boolean,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_log_perchannel_u16

    Decode per-channel LOG uint16 codes to float32.

    Type Declaration

      • (
            data: Uint16Array,
            colLo: Float64Array,
            colHi: Float64Array,
            zeroLevel: boolean,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel LOG uint16 codes to float32.

        Parameters

        • data: Uint16Array
        • colLo: Float64Array
        • colHi: Float64Array
        • zeroLevel: boolean
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_signed_log_perchannel_u8: (
        data: Uint8Array,
        colLo: Float64Array,
        colHi: Float64Array,
        zeroLevel: boolean,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_signed_log_perchannel_u8

    Decode per-channel SIGNED-LOG uint8 codes (x = sign(y)·expm1(|y|)).

    Type Declaration

      • (
            data: Uint8Array,
            colLo: Float64Array,
            colHi: Float64Array,
            zeroLevel: boolean,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel SIGNED-LOG uint8 codes to float32 (x = sign(y)·expm1(|y|)). The Cholesky off-diagonal encoding.

        Parameters

        • data: Uint8Array
        • colLo: Float64Array
        • colHi: Float64Array
        • zeroLevel: boolean
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_signed_log_perchannel_u16: (
        data: Uint16Array,
        colLo: Float64Array,
        colHi: Float64Array,
        zeroLevel: boolean,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_signed_log_perchannel_u16

    Decode per-channel SIGNED-LOG uint16 codes to float32.

    Type Declaration

      • (
            data: Uint16Array,
            colLo: Float64Array,
            colHi: Float64Array,
            zeroLevel: boolean,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel SIGNED-LOG uint16 codes to float32.

        Parameters

        • data: Uint16Array
        • colLo: Float64Array
        • colHi: Float64Array
        • zeroLevel: boolean
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_geolog_perchannel_u8: (
        data: Uint8Array,
        colLo: Float64Array,
        colHi: Float64Array,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_geolog_perchannel_u8

    Decode per-channel TRUE-log uint8 codes (x = exp(y); HDR colors). Reserved zero level always on (name contract — no flag).

    Type Declaration

      • (
            data: Uint8Array,
            colLo: Float64Array,
            colHi: Float64Array,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel TRUE-log uint8 codes to float32 (x = exp(y)). HDR colors: ln-domain per-column anchors, uniform relative precision. The reserved zero level is part of the name contract (always on).

        Parameters

        • data: Uint8Array
        • colLo: Float64Array
        • colHi: Float64Array
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_geolog_perchannel_u16: (
        data: Uint16Array,
        colLo: Float64Array,
        colHi: Float64Array,
        colOffset: number,
        output: Float32Array,
    ) => void = decode_geolog_perchannel_u16

    Decode per-channel TRUE-log uint16 codes to float32.

    Type Declaration

      • (
            data: Uint16Array,
            colLo: Float64Array,
            colHi: Float64Array,
            colOffset: number,
            output: Float32Array,
        ): void
      • Decode per-channel TRUE-log uint16 codes to float32.

        Parameters

        • data: Uint16Array
        • colLo: Float64Array
        • colHi: Float64Array
        • colOffset: number
        • output: Float32Array

        Returns void

    decode_log_scalar_u16: (
        data: ArrayLike<number>,
        maxLog: number,
        output: Float32Array,
    ) => void = decode_log_scalar_u16

    Decode log-space quantized uint16. Result = expm1(normalized * maxLog)

    Type Declaration

      • (data: ArrayLike<number>, maxLog: number, output: Float32Array): void
      • Decode log-space quantized uint16 data to float32. Callers provide integral codes in [0, 65535]; ArrayLike also accepts widened Float32Array codes.

        Parameters

        • data: ArrayLike<number>
        • maxLog: number
        • output: Float32Array

        Returns void

    decode_lut_scalar_u8: (
        indices: Uint8Array,
        lut: Float32Array,
        output: Float32Array,
    ) => void = decode_lut_scalar_u8

    Decode LUT indices (uint8) to scalar float values

    Type Declaration

      • (indices: Uint8Array, lut: Float32Array, output: Float32Array): void
      • Decode LUT-encoded uint8 indices to float32 (scalar mode). Each index maps to a single float value from the LUT.

        Parameters

        • indices: Uint8Array
        • lut: Float32Array
        • output: Float32Array

        Returns void

    decode_lut_scalar_u16: (
        indices: Uint16Array,
        lut: Float32Array,
        output: Float32Array,
    ) => void = decode_lut_scalar_u16

    Decode LUT indices (uint16) to scalar float values

    Type Declaration

      • (indices: Uint16Array, lut: Float32Array, output: Float32Array): void
      • Decode LUT-encoded uint16 indices to float32 (scalar mode).

        Parameters

        • indices: Uint16Array
        • lut: Float32Array
        • output: Float32Array

        Returns void

    decode_lut_row_u8: (
        indices: Uint8Array,
        lut: Float32Array,
        k: number,
        output: Float32Array,
    ) => void = decode_lut_row_u8

    Decode LUT indices (uint8) to k-element vectors

    Type Declaration

      • (indices: Uint8Array, lut: Float32Array, k: number, output: Float32Array): void
      • Decode LUT-encoded uint8 indices to float32 (row mode). Each index maps to k consecutive float values from the LUT.

        Parameters

        • indices: Uint8Array
        • lut: Float32Array
        • k: number
        • output: Float32Array

        Returns void

    decode_lut_row_u16: (
        indices: Uint16Array,
        lut: Float32Array,
        k: number,
        output: Float32Array,
    ) => void = decode_lut_row_u16

    Decode LUT indices (uint16) to k-element vectors

    Type Declaration

      • (indices: Uint16Array, lut: Float32Array, k: number, output: Float32Array): void
      • Decode LUT-encoded uint16 indices to float32 (row mode).

        Parameters

        • indices: Uint16Array
        • lut: Float32Array
        • k: number
        • output: Float32Array

        Returns void

    decode_broadcasted: (
        value: Float32Array,
        numPoints: number,
        elementsPerPoint: number,
        output: Float32Array,
    ) => void = decode_broadcasted

    Broadcast a value to all points

    Type Declaration

      • (
            value: Float32Array,
            numPoints: number,
            elementsPerPoint: number,
            output: Float32Array,
        ): void
      • Broadcast a single value to all points.

        Contract: value.length must be either 1 (scalar broadcast to all elementsPerPoint slots) or exactly elementsPerPoint (per-element vector replicated across every point). Any other length is rejected because the previous "mixed broadcast" semantics produced surprising rows like [v0, v1, v0] for value.length=2, elementsPerPoint=3.

        Parameters

        • value: Float32Array
        • numPoints: number
        • elementsPerPoint: number
        • output: Float32Array

        Returns void

    extract_3d_positions: (
        positionsNd: Float32Array,
        displayDims: Uint32Array,
        ndim: number,
        numPoints: number,
        output: Float32Array,
    ) => void = extract_3d_positions

    Extract 3D positions from nD positions using display dimension indices.

    Type Declaration

      • (
            positionsNd: Float32Array,
            displayDims: Uint32Array,
            ndim: number,
            numPoints: number,
            output: Float32Array,
        ): void
      • Extract 3D positions from nD positions using display dimension indices.

        Parameters

        • positionsNd: Float32Array
        • displayDims: Uint32Array
        • ndim: number
        • numPoints: number
        • output: Float32Array

        Returns void

    Input nD positions [numPoints * ndim]

    Which dimensions to display as X,Y,Z [3 or fewer]

    Total number of dimensions

    Number of points

    Output 3D positions [numPoints * 3]

    mahalanobis_distance: (
        diff: Float32Array,
        packedL: Float32Array,
        ndim: number,
    ) => number = mahalanobis_distance

    Compute Mahalanobis distance for a single point using packed Cholesky factor.

    Given L (lower-triangular Cholesky of covariance), Mahalanobis distance = ||L⁻¹ · (x - μ)||

    Type Declaration

      • (diff: Float32Array, packedL: Float32Array, ndim: number): number
      • Compute Mahalanobis distance for a single point using packed Cholesky factor.

        Given L (lower-triangular Cholesky of covariance), Mahalanobis distance = ||L⁻¹ · (x - μ)||

        We use forward substitution to solve L·y = d, then ||y|| is the Mahalanobis distance.

        Parameters

        • diff: Float32Array

          Difference vector (x - μ) for the dimensions [ndim]

        • packedL: Float32Array

          Packed Cholesky factor [packedSize]

        • ndim: number

          Dimensionality of the Cholesky

        Returns number

        Mahalanobis distance

    Difference vector (x - μ) [ndim]

    Packed Cholesky factor [packedSize]

    Dimensionality

    Mahalanobis distance

    project_gsplats_nd_to_3d: (
        positions: Float32Array,
        cholesky: Float32Array,
        amplitudes: Float32Array,
        colors: Float32Array,
        discreteVisibility: Uint8Array,
        slicePosition: Float32Array,
        continuousHiddenDims: Uint32Array,
        displayDims: Uint32Array,
        ndim: number,
        splatCount: number,
        colorComponents: number,
        minAmplitude: number,
        truncate: number,
        outCenters3d: Float32Array,
        outCholesky3d: Float32Array,
        outAmplitudes: Float32Array,
        outColors: Float32Array,
        outSourceIndices: Uint32Array,
    ) => number = project_gsplats_nd_to_3d

    Fused nD→3D GSplat projection in a single pass: discrete-visibility gate → continuous attenuation (marginal Cholesky + shifted Gaussian) → visibility (amplitude * attenuation >= minAmplitude) → COMPACTED outputs. Replaces the former 6-call pipeline (compute_gsplats_attenuation + extract_3d_positions + compact_by_mask ×2 + extract_visible_cholesky_3d + compact_attenuated_amplitudes), eliminating ~5 passes and the repeated large-array boundary copies. Bit-identical visible set + values.

    Colors must be pre-normalized to f32 (white-filled when absent) — the kernel takes a single Float32Array because wasm-bindgen can't accept a typed-array union. Outputs are sized for the splatCount worst case; slice each to the returned visible count.

    Type Declaration

      • (
            positions: Float32Array,
            cholesky: Float32Array,
            amplitudes: Float32Array,
            colors: Float32Array,
            discreteVisibility: Uint8Array,
            slicePosition: Float32Array,
            continuousHiddenDims: Uint32Array,
            displayDims: Uint32Array,
            ndim: number,
            splatCount: number,
            colorComponents: number,
            minAmplitude: number,
            truncate: number,
            outCenters3d: Float32Array,
            outCholesky3d: Float32Array,
            outAmplitudes: Float32Array,
            outColors: Float32Array,
            outSourceIndices: Uint32Array,
        ): number
      • Fused nD→3D GSplat projection — TypeScript reference mirroring gsplats_processing.rs::project_gsplats_nd_to_3d.

        Single pass over the splats: discrete-visibility gate → continuous attenuation (marginal Cholesky + shifted Gaussian) → visibility decision (amplitude * attenuation >= minAmplitude) → write COMPACTED outputs (visible centers3D, cholesky3D[6], attenuated amplitudes, colors). Bit-for-bit equivalent to the legacy 6-call pipeline (reuses the same computeMarginalCholesky / mahalanobisDistanceInternal helpers in the same order). Replaces ~5 full passes and the repeated large-array copies.

        Colors are pre-normalized to f32 by the caller (white-filled when absent); colorComponents is 3 (RGB) or 4 (RGBA — alpha is per-splat opacity and compacts with its splat). Outputs are sized for the splatCount worst case; the caller slices each to the returned visible count.

        outSourceIndices records, per emitted splat, the SOURCE index it came from (issue #1423) — compaction destroys that mapping, and picking needs it to translate a storage slot back into an on-disk element index. Pass an EMPTY array to opt out; the recording is then skipped entirely.

        Parameters

        • positions: Float32Array
        • cholesky: Float32Array
        • amplitudes: Float32Array
        • colors: Float32Array
        • discreteVisibility: Uint8Array
        • slicePosition: Float32Array
        • continuousHiddenDims: Uint32Array
        • displayDims: Uint32Array
        • ndim: number
        • splatCount: number
        • colorComponents: number
        • minAmplitude: number
        • truncate: number
        • outCenters3d: Float32Array
        • outCholesky3d: Float32Array
        • outAmplitudes: Float32Array
        • outColors: Float32Array
        • outSourceIndices: Uint32Array

        Returns number

        Number of visible splats written.

    Splat centers [splatCount * ndim]

    Packed Cholesky factors [splatCount * packedSize]

    Splat amplitudes [splatCount]

    Pre-normalized RGB or RGBA [splatCount * colorComponents]

    Precomputed discrete-dim gate [splatCount]

    Current slice [ndim]

    Sorted continuous hidden dims [numContinuous]

    Display dims in requested order [2 or 3]

    Total dimensionality

    Number of splats

    Color channel count (3 = RGB, 4 = RGBA); strides every color read/write

    Visibility threshold

    Truncation radius in sigmas

    Output visible centers [splatCount * 3] worst-case

    Output visible 3D Cholesky [splatCount * 6] worst-case

    Output visible attenuated amplitudes [splatCount] worst-case

    Output visible colors [splatCount * colorComponents] worst-case

    Output SOURCE index per emitted splat [splatCount] worst-case. Compaction destroys the slot → source mapping, which picking needs to reach an on-disk element index (issue #1423). Pass an EMPTY array to opt out — the recording is then skipped entirely.

    Number of visible splats written

    clip_segment_single: (
        p1: Float32Array,
        p2: Float32Array,
        slicePosition: Float32Array,
        tolerance: Float32Array,
        displayDims: Uint32Array,
        ndim: number,
        workspace?: Uint8Array<ArrayBufferLike>,
    ) => Float32Array = clip_segment_single

    Clip a single segment to the nD slice and return interpolation parameters.

    Type Declaration

      • (
            p1: Float32Array,
            p2: Float32Array,
            slicePosition: Float32Array,
            tolerance: Float32Array,
            displayDims: Uint32Array,
            ndim: number,
            workspace?: Uint8Array<ArrayBufferLike>,
        ): Float32Array
      • Clip a single segment to the nD slice and return interpolation parameters.

        Returns [visible, t1, t2] where:

        • visible: 1.0 if any part of segment intersects slice, 0.0 otherwise
        • t1: interpolation parameter for clipped start (0.0 = original start)
        • t2: interpolation parameter for clipped end (1.0 = original end)

        MED-20: pass workspace (length >= ndim) to avoid per-call Uint8Array allocation in hot loops; the buffer is zeroed by this function before use.

        Parameters

        • p1: Float32Array
        • p2: Float32Array
        • slicePosition: Float32Array
        • tolerance: Float32Array
        • displayDims: Uint32Array
        • ndim: number
        • Optionalworkspace: Uint8Array<ArrayBufferLike>

        Returns Float32Array

    Start vertex position [ndim]

    End vertex position [ndim]

    Current slice position [ndim]

    Per-dimension tolerance [ndim]

    Which dimensions to display [numDisplayDims]

    Number of dimensions

    Float32Array [visible, t1, t2] where visible is 1.0 or 0.0

    clip_segments_batch: (
        positions: Float32Array,
        segments: Uint32Array,
        slicePosition: Float32Array,
        tolerance: Float32Array,
        displayDims: Uint32Array,
        ndim: number,
        numSegments: number,
        outputVisibility: Uint8Array,
        outputT1: Float32Array,
        outputT2: Float32Array,
    ) => number = clip_segments_batch

    Batch clip all segments and output visibility mask and interpolation parameters.

    Type Declaration

      • (
            positions: Float32Array,
            segments: Uint32Array,
            slicePosition: Float32Array,
            tolerance: Float32Array,
            displayDims: Uint32Array,
            ndim: number,
            numSegments: number,
            outputVisibility: Uint8Array,
            outputT1: Float32Array,
            outputT2: Float32Array,
        ): number
      • Batch clip all segments and output visibility mask and interpolation parameters.

        Parameters

        • positions: Float32Array

          Vertex positions [numVertices * ndim]

        • segments: Uint32Array

          Segment indices [numSegments * 2]

        • slicePosition: Float32Array

          Current slice position [ndim]

        • tolerance: Float32Array

          Per-dimension tolerance [ndim]

        • displayDims: Uint32Array

          Which dimensions to display [numDisplayDims]

        • ndim: number

          Number of dimensions

        • numSegments: number

          Number of segments

        • outputVisibility: Uint8Array

          Output visibility mask [numSegments]

        • outputT1: Float32Array

          Output t1 parameters [numSegments]

        • outputT2: Float32Array

          Output t2 parameters [numSegments]

        Returns number

        Number of visible segments

    Vertex positions [numVertices * ndim]

    Segment indices [numSegments * 2]

    Current slice position [ndim]

    Per-dimension tolerance [ndim]

    Which dimensions to display [numDisplayDims]

    Number of dimensions

    Number of segments

    Output visibility mask [numSegments]

    Output t1 parameters [numSegments]

    Output t2 parameters [numSegments]

    Number of visible segments

    interpolate_clipped_positions: (
        positions: Float32Array,
        segments: Uint32Array,
        visibility: Uint8Array,
        t1Params: Float32Array,
        t2Params: Float32Array,
        displayDims: Uint32Array,
        ndim: number,
        numSegments: number,
        outputStart: Float32Array,
        outputEnd: Float32Array,
    ) => number = interpolate_clipped_positions

    Interpolate clipped positions to 3D display space.

    Type Declaration

      • (
            positions: Float32Array,
            segments: Uint32Array,
            visibility: Uint8Array,
            t1Params: Float32Array,
            t2Params: Float32Array,
            displayDims: Uint32Array,
            ndim: number,
            numSegments: number,
            outputStart: Float32Array,
            outputEnd: Float32Array,
        ): number
      • Interpolate clipped positions to 3D display space.

        Parameters

        • positions: Float32Array

          Vertex positions [numVertices * ndim]

        • segments: Uint32Array

          Segment indices [numSegments * 2]

        • visibility: Uint8Array

          Visibility mask [numSegments]

        • t1Params: Float32Array

          Start interpolation parameters [numSegments]

        • t2Params: Float32Array

          End interpolation parameters [numSegments]

        • displayDims: Uint32Array

          Which dimensions to display [3]

        • ndim: number

          Number of dimensions

        • numSegments: number

          Total number of segments

        • outputStart: Float32Array

          Output start positions [visibleCount * 3]

        • outputEnd: Float32Array

          Output end positions [visibleCount * 3]

        Returns number

        Number of visible segments written

    Vertex positions [numVertices * ndim]

    Segment indices [numSegments * 2]

    Visibility mask [numSegments]

    Start interpolation parameters [numSegments]

    End interpolation parameters [numSegments]

    Which dimensions to display [3]

    Number of dimensions

    Total number of segments

    Output start positions [visibleCount * 3]

    Output end positions [visibleCount * 3]

    Number of visible segments written

    interpolate_scalars_batch: (
        values: Float32Array,
        segments: Uint32Array,
        visibility: Uint8Array,
        t1Params: Float32Array,
        t2Params: Float32Array,
        numSegments: number,
        outputStart: Float32Array,
        outputEnd: Float32Array,
    ) => number = interpolate_scalars_batch

    Batch interpolate scalar attributes for visible segments.

    Type Declaration

      • (
            values: Float32Array,
            segments: Uint32Array,
            visibility: Uint8Array,
            t1Params: Float32Array,
            t2Params: Float32Array,
            numSegments: number,
            outputStart: Float32Array,
            outputEnd: Float32Array,
        ): number
      • Batch interpolate scalar attributes for visible segments.

        Parameters

        • values: Float32Array

          Per-vertex attribute values [numVertices]

        • segments: Uint32Array

          Segment indices [numSegments * 2]

        • visibility: Uint8Array

          Visibility mask [numSegments]

        • t1Params: Float32Array

          Start interpolation parameters [numSegments]

        • t2Params: Float32Array

          End interpolation parameters [numSegments]

        • numSegments: number

          Total number of segments

        • outputStart: Float32Array

          Output interpolated start values [visibleCount]

        • outputEnd: Float32Array

          Output interpolated end values [visibleCount]

        Returns number

        Number of visible segments written

    Per-vertex attribute values [numVertices]

    Segment indices [numSegments * 2]

    Visibility mask [numSegments]

    Start interpolation parameters [numSegments]

    End interpolation parameters [numSegments]

    Total number of segments

    Output interpolated start values [visibleCount]

    Output interpolated end values [visibleCount]

    Number of visible segments written

    interpolate_colors_batch: (
        colors: Float32Array,
        segments: Uint32Array,
        visibility: Uint8Array,
        t1Params: Float32Array,
        t2Params: Float32Array,
        numSegments: number,
        outputStart: Float32Array,
        outputEnd: Float32Array,
    ) => number = interpolate_colors_batch

    Batch interpolate RGB color attributes for visible segments.

    Type Declaration

      • (
            colors: Float32Array,
            segments: Uint32Array,
            visibility: Uint8Array,
            t1Params: Float32Array,
            t2Params: Float32Array,
            numSegments: number,
            outputStart: Float32Array,
            outputEnd: Float32Array,
        ): number
      • Batch interpolate RGB color attributes for visible segments.

        Parameters

        • colors: Float32Array

          Per-vertex RGB colors [numVertices * 3]

        • segments: Uint32Array

          Segment indices [numSegments * 2]

        • visibility: Uint8Array

          Visibility mask [numSegments]

        • t1Params: Float32Array

          Start interpolation parameters [numSegments]

        • t2Params: Float32Array

          End interpolation parameters [numSegments]

        • numSegments: number

          Total number of segments

        • outputStart: Float32Array

          Output interpolated start colors [visibleCount * 3]

        • outputEnd: Float32Array

          Output interpolated end colors [visibleCount * 3]

        Returns number

        Number of visible segments written

    Per-vertex RGB colors [numVertices * 3]

    Segment indices [numSegments * 2]

    Visibility mask [numSegments]

    Start interpolation parameters [numSegments]

    End interpolation parameters [numSegments]

    Total number of segments

    Output interpolated start colors [visibleCount * 3]

    Output interpolated end colors [visibleCount * 3]

    Number of visible segments written

    calculate_segment_lengths: (
        startPositions: Float32Array,
        endPositions: Float32Array,
        visibleCount: number,
        output: Float32Array,
    ) => void = calculate_segment_lengths

    Calculate 3D segment lengths for visible segments.

    Type Declaration

      • (
            startPositions: Float32Array,
            endPositions: Float32Array,
            visibleCount: number,
            output: Float32Array,
        ): void
      • Calculate 3D segment lengths for visible segments.

        Parameters

        • startPositions: Float32Array

          Clipped start positions [visibleCount * 3]

        • endPositions: Float32Array

          Clipped end positions [visibleCount * 3]

        • visibleCount: number

          Number of visible segments

        • output: Float32Array

          Output segment lengths [visibleCount]

        Returns void

    Clipped start positions [visibleCount * 3]

    Clipped end positions [visibleCount * 3]

    Number of visible segments

    Output segment lengths [visibleCount]

    compute_joint_codes: (
        segments: Uint32Array,
        visibility: Uint8Array,
        t1Params: Float32Array,
        t2Params: Float32Array,
        numSegments: number,
        numVertices: number,
        outputStart: Float32Array,
        outputEnd: Float32Array,
    ) => number = compute_joint_codes

    Per-endpoint joint code: how the line shader should treat this endpoint, and — at an ordinary two-segment joint — which segment it joins.

    0 free polyline end (keep the soft cap); -1 slice-clipped (suppress the cap; no neighbour will arrive); -2 degree->=3 hub (keep the cap); +(slot + 1) joins visible segment slot at that segment's START; -(slot + 3) joins it at that segment's END. slot is a line-texture storage slot, so it survives the depth-sort worker's draw-order permutation. Purely topological — no positions, no angle: the vertex stage measures the bend in SCREEN space so it tracks the camera. See wasm/rust/src/lines_clipping.rs for the full derivation.

    Type Declaration

      • (
            segments: Uint32Array,
            visibility: Uint8Array,
            t1Params: Float32Array,
            t2Params: Float32Array,
            numSegments: number,
            numVertices: number,
            outputStart: Float32Array,
            outputEnd: Float32Array,
        ): number
      • Per-endpoint joint code (drives the shader's join geometry and cap).

        TypeScript reference for the Rust compute_joint_codes kernel — see the Rust doc comment in wasm/rust/src/lines_clipping.rs for the full rationale. This mirror is not just a WASM-missing fallback: it is the production backend for ndim > 16, which the fixed-size Rust kernels cannot serve, so the two must agree exactly.

        Agreement is trivial here in a way it was not for the scalar this replaced: the output is integer index arithmetic, so there is no f32/f64 accumulation order to reconcile between the backends.

        value meaning
        0 free polyline end — keep the soft cap
        -1 slice-clipped — suppress the cap entirely
        -2 degree->=3 hub — keep the cap
        +(slot + 1) joins visible segment slot, at that segment's START
        -(slot + 3) joins visible segment slot, at that segment's END

        slot is a storage slot in the line texture, so it survives the depth-sort worker's draw-order permutation without adjustment.

        Parameters

        • segments: Uint32Array

          Vertex index pairs [numSegments * 2]

        • visibility: Uint8Array

          Visibility mask [numSegments]

        • t1Params: Float32Array

          Start interpolation parameters [numSegments]

        • t2Params: Float32Array

          End interpolation parameters [numSegments]

        • numSegments: number

          Total number of segments

        • numVertices: number

          Total number of source vertices (bounds the touch tables)

        • outputStart: Float32Array

          Output start joint codes [visibleCount]

        • outputEnd: Float32Array

          Output end joint codes [visibleCount]

        Returns number

        Number of visible segments written

    Vertex index pairs [numSegments * 2]

    Visibility mask [numSegments]

    Start interpolation parameters [numSegments]

    End interpolation parameters [numSegments]

    Total number of segments

    Total number of source vertices

    Output start joint codes [visibleCount]

    Output end joint codes [visibleCount]

    Number of visible segments written

    mesh_vertex_visibility_mask: (
        positions: Float32Array,
        slicePosition: Float32Array,
        tolerance: Float32Array,
        displayDims: Uint32Array,
        ndim: number,
        numVertices: number,
        output: Uint8Array,
    ) => number = mesh_vertex_visibility_mask

    Compute per-vertex nD slab membership for a mesh.

    For each non-displayed ("hidden") dimension d, with sliceMin = slicePosition[d] - tolerance[d] and sliceMax = slicePosition[d] + tolerance[d], a vertex is in iff v[d] >= sliceMin && v[d] <= sliceMax for every such d. This is the p1_in branch of WasmModule.clip_segment_single applied per vertex.

    A NaN or ±Inf coordinate on any hidden dimension makes the vertex invisible (the #806 rule, shared with the lines backends).

    Unlike lines, nothing is clipped or interpolated — see WasmModule.compact_visible_faces for the whole-triangle rule and docs/specs/MESH_NODE_SPEC.md §5 for why v1 does not clip.

    The WASM implementation calls validate_ndim and therefore panics above 16 dimensions; pickBackend(ctx, ndim) routes ndim > 16 to the uncapped TypeScript backend.

    Type Declaration

      • (
            positions: Float32Array,
            slicePosition: Float32Array,
            tolerance: Float32Array,
            displayDims: Uint32Array,
            ndim: number,
            numVertices: number,
            output: Uint8Array,
        ): number
      • Compute per-vertex nD slab membership.

        For each non-displayed ("hidden") dimension d, with sliceMin = slicePosition[d] - tolerance[d] and sliceMax = slicePosition[d] + tolerance[d], a vertex is in iff v[d] >= sliceMin && v[d] <= sliceMax for every such d.

        A NaN or ±Inf coordinate on any hidden dimension makes the vertex invisible (the #806 rule). The explicit Number.isFinite test is load-bearing rather than decorative: an infinite tolerance makes sliceMax = +Infinity, and +Infinity <= +Infinity is true, so the bare range test alone would report an infinite coordinate as visible.

        That rule covers the coordinate only, and the slab parameters behave the OPPOSITE way: a NaN in slicePosition or tolerance makes every finite vertex visible (both value < NaN and value > NaN are false, so the test degenerates to "not non-finite" — it fails OPEN), while a negative tolerance inverts the slab and culls everything. Both are caller bugs — these are viewer-computed, not store-supplied — and both backends agree exactly, so neither is guarded. Don't let a NaN tolerance derived from absent dimension metadata reach here expecting it to be culled.

        Parameters

        • positions: Float32Array

          Vertex positions [numVertices * ndim]

        • slicePosition: Float32Array

          Current slice position [ndim]

        • tolerance: Float32Array

          Per-dimension tolerance [ndim]

        • displayDims: Uint32Array

          Which dimensions are displayed [numDisplayDims]

        • ndim: number

          Number of dimensions (uncapped here)

        • numVertices: number

          Number of vertices

        • output: Uint8Array

          Output visibility mask [numVertices] (1 = in, 0 = out)

        Returns number

        Number of visible vertices

    Vertex positions [numVertices * ndim]

    Current slice position [ndim]

    Per-dimension tolerance [ndim]

    Which dimensions are displayed [numDisplayDims]

    Number of dimensions

    Number of vertices

    Output visibility mask [numVertices] (1 = in, 0 = out)

    Number of visible vertices

    compact_visible_faces: (
        faces: Uint32Array,
        vertexMask: Uint8Array,
        numFaces: number,
        output: Uint32Array,
    ) => number = compact_visible_faces

    Compact faces to those whose three vertices are all visible.

    Writes ORIGINAL (un-remapped) vertex indices, so a slice change rebuilds only the index buffer while the vertex attribute buffers stay uploaded in full. The authored per-face index order is preserved, so this is winding-agnostic.

    A face index >= vertexMask.length drops the whole face rather than reading out of bounds — the indices are store-supplied, and the two backends fail differently without the guard (a Rust out-of-bounds read traps with an uncatchable RuntimeError: unreachable; the TS read yields undefined).

    Type Declaration

      • (
            faces: Uint32Array,
            vertexMask: Uint8Array,
            numFaces: number,
            output: Uint32Array,
        ): number
      • Compact faces to those whose three vertices are all visible.

        Writes original (un-remapped) vertex indices: on a slice change only the index buffer is rebuilt, while the vertex attribute buffers stay uploaded in full. drawElements never fetches an unreferenced vertex, so culled vertices cost nothing to draw.

        The authored per-face index order is preserved exactly, so this is winding-agnostic; restoring front-facing winding under a reflected display permutation is a separate caller-owned post-pass (§5.4).

        A face index >= vertexMask.length drops the whole face. The values come from the store — the viewer loads arbitrary, possibly corrupted datasets — and the two backends fail differently without this guard: Rust would read out of bounds and, being panic = "abort", trap with an opaque, uncatchable RuntimeError: unreachable, while here the read would yield undefined and silently diverge. The loader range-checks face indices up front and fails the node with a LoaderError before reaching either backend (§3.5 Stage 2), so on the sanctioned path this is unreachable; it is defense in depth, not a substitute for that gate.

        Parameters

        • faces: Uint32Array

          Triangle vertex indices [numFaces * 3]

        • vertexMask: Uint8Array

          Per-vertex visibility from mesh_vertex_visibility_mask; its length defines the valid vertex range, so pass a view sized exactly numVertices rather than a larger reused scratch buffer

        • numFaces: number

          Number of triangles

        • output: Uint32Array

          Output indices [numFaces * 3] worst case

        Returns number

        Number of visible faces written. Slice output to 3 × this before use. Everything past that point is left untouched — deliberately, to avoid a second pass — so a reused buffer still holds the previous frame's indices and a fresh one holds zeros. Uploading the whole buffer as an index range draws stale or degenerate triangles rather than nothing, which is the failure this return value exists to prevent.

    Triangle vertex indices [numFaces * 3]

    Per-vertex visibility from WasmModule.mesh_vertex_visibility_mask; its LENGTH defines the valid vertex range, so pass a view sized exactly numVertices

    Number of triangles

    Output indices [numFaces * 3] worst case

    Number of visible faces written (slice output to 3x this)