/** * Host-side helper that drives a `StreamingPointSource` to completion, * applies a memory-cap downsampling policy, and emits decoded chunks * to a callback. * * Renderers consume this directly: pass `onChunk` as your "upload to * GPU" callback and the host takes care of pacing, abort, and the * end-of-stream `onComplete` notification. */ import type { DecodedPointChunk, PointCloudBBox } from '../types.js'; import { type CreateDecodeWorkerSourceOptions, type DecodeWorkerFormat } from './worker-client.js'; import type { PointSourceInfo, StreamingPointSource } from './types.js'; export interface StreamPointCloudOptions { /** Source format. */ format: DecodeWorkerFormat; /** File or remote-fetched blob. */ blob: Blob; /** Optional label (filename, URL) for diagnostics. */ label?: string; /** * Soft memory cap measured in points. When the source declares more * than this, the host applies stride-based downsampling so the chunks * fit. Default: 25 million (~600 MB GPU at the 24-byte/point format). */ maxPointsInMemory?: number; /** Hard size ceiling — if `blob.size` exceeds, the call rejects. */ maxFileSize?: number; /** Points per chunk during streaming decode. Default: 200_000. */ chunkSize?: number; /** Called once after the source's header parses. */ onOpen?: (info: PointSourceInfo & { stride: number; }) => void; /** Called for each decoded chunk. */ onChunk: (chunk: DecodedPointChunk) => void; /** Periodic progress signal in 0..1. */ onProgress?: (loaded: number, total: number) => void; /** * Called once with the aggregated bbox once the stream finishes. * `classCounts` is the per-class point histogram (256 slots, one per * LAS classification code) aggregated across every emitted chunk, or * `null` when no chunk carried a classifications buffer (#1783). */ onComplete?: (bbox: PointCloudBBox, totalEmitted: number, classCounts: Uint32Array | null) => void; /** Called if the source errors mid-stream. */ onError?: (err: Error) => void; /** Abort signal for the whole stream. */ signal?: AbortSignal; /** Override the source factory (used by tests). */ createSource?: (opts: CreateDecodeWorkerSourceOptions) => StreamingPointSource; } export interface StreamHandle { /** Cancel pending and future decode work. */ cancel(): void; /** Resolves once the stream finishes successfully or is cancelled. */ done: Promise; } export declare function streamPointCloud(opts: StreamPointCloudOptions): StreamHandle; //# sourceMappingURL=host.d.ts.map