wasm-spatial-core
    Preparing search index...

    Class WorkerHandle

    A handle to a point cloud processing Web Worker.

    Create via createPointCloudWorker(wasmUrl). The Worker loads the WASM module in a separate thread and executes the full Octree → Tileset pipeline.

    Example (JS)

    const worker = createPointCloudWorker('https://example.com/spatial_core_bg.wasm');
    worker.onProgress((stage, progress) => {
    console.log(`${stage}: ${(progress * 100).toFixed(1)}%`);
    });
    worker.onComplete((result) => {
    console.log(`Generated ${result.tileCount} tiles`);
    });
    worker.onError((err) => {
    console.error('Worker error:', err);
    });
    worker.process(positions, colors, options);
    Index
    • Create a new inline Worker for point cloud processing.

      Arguments

      • wasmUrl — URL to the WASM module file (.wasm).

      The Worker is created as a Blob URL from an inline script. It loads the WASM module, initializes it, and waits for process commands.

      Parameters

      • wasm_url: string

      Returns WorkerHandle

    • Cancel the current processing job.

      The Worker will stop as soon as possible (between octree build and tileset generation phases).

      Returns void

    • Initialize the Worker (load and initialize WASM).

      Must be called before process. The Worker will post a ready message when initialization is complete.

      Returns void

    • Register a cancellation callback.

      Called when the Worker is cancelled mid-processing.

      Parameters

      • callback: Function

      Returns void

    • Register a completion callback.

      Callback receives the result object with tilesetJson, tileCount, totalBytes, and tileSizes.

      Parameters

      • callback: Function

      Returns void

    • Register an error callback.

      Callback receives an error object with message and stage.

      Parameters

      • callback: Function

      Returns void

    • Register a progress callback.

      Callback receives (stage: string, progress: number) where stage is "octree" or "tileset" and progress is 0.0 to 1.0.

      Parameters

      • callback: Function

      Returns void

    • Submit a point cloud for processing in the Worker.

      Positions and colors are transferred (zero-copy) to the Worker.

      Arguments

      • positionsFloat32Array of [x, y, z, ...].
      • colors — Optional Uint8Array of [r, g, b, ...].
      • optionsWorkerOptions for octree configuration.

      Parameters

      • positions: Float32Array
      • colors: Uint8Array<ArrayBufferLike> | null | undefined
      • options: WorkerOptions

      Returns void

    • Submit a GeoTIFF for terrain processing in the Worker.

      The Worker will parse the GeoTIFF, optionally apply color ramp and hillshade, and generate a GLB terrain mesh.

      Arguments

      • geotiff_bytesUint8Array of raw GeoTIFF data.
      • color_ramp — Optional color ramp (0=Terrain, 1=Heat, 2=Ocean, 3=Gray), or None.
      • azimuth — Hillshade light azimuth (degrees, 0=N, 90=E). Default 315.
      • altitude — Hillshade light altitude (degrees). Default 45.

      Parameters

      • geotiff_bytes: Uint8Array
      • Optionalcolor_ramp: number | null
      • Optionalazimuth: number | null
      • Optionalaltitude: number | null

      Returns void