@pmndrs/bvh
    Preparing search index...

    Interface GenerateMeshBvhWorkerOptions

    interface GenerateMeshBvhWorkerOptions {
        idleTimeoutMs?: number;
        onBuild?: (event: BvhPoolBuildEvent) => void;
        pool?: BvhWorkerPool;
        recycleAboveBytes?: number;
        size?: number;
        transferInput?: boolean;
        worker?: "auto" | "never" | "always";
    }

    Hierarchy (View Summary)

    Index
    idleTimeoutMs?: number

    A worker left with nothing to build for this many milliseconds is ended, and its tinybvh WASM memory (64 MiB at least, more after a big build) goes back to the system; the next build starts a fresh worker (a module load and a WASM start, a few milliseconds). Inline, the calling thread's tinybvh instance is dropped the same way. Default Infinity (WORKER_IDLE_TIMEOUT_MS): idle workers live as long as the pool. The P9 lever "freeing CPU copies" (docs/internals/design/memory.md): a pool of 4 holds 256 MiB while idle.

    onBuild?: (event: BvhPoolBuildEvent) => void

    Called for every build as it is queued, started on a worker (or inline) and finished: built, failed or cancelled (see BvhPoolBuildEvent). For tools that time builds per mesh. A listener that throws doesn't break the pool (the error is rethrown on a later turn).

    A pool to build on, shared with other users; it is not disposed with this object. Default: a pool of its own.

    recycleAboveBytes?: number

    A worker whose last build left its tinybvh WASM memory larger than this many bytes is ended after answering, and a fresh worker takes the next build: the memory goes back to the system at once. Default WORKER_RECYCLE_ABOVE_BYTES (256 MiB); Infinity keeps workers for the pool's life. Inline builds (no Worker) release their WASM instance the same way (createTinyBvhBuilder's releaseAboveBytes).

    size?: number

    Workers in the pool. Default defaultWorkerPoolSize: one less than the logical cores, at least 1 and at most 4. Workers start when builds need them, not before, so an idle pool costs nothing.

    transferInput?: boolean

    Move every build's input arrays into the worker instead of copying them; the caller's arrays are empty afterwards. An array that views only part of its buffer (glTF accessors into one BIN buffer) is copied instead, so the buffer's other arrays stay usable. Default false. A build can choose for itself with BvhBuildRequest.transferInput.

    worker?: "auto" | "never" | "always"

    'auto' (default) uses workers when Worker exists, and builds inline from then on if one can't be started or fails to load (it errs before saying it loaded; no build was sent to it, so none is lost). 'never' always builds inline; 'always' throws when there is no Worker and rejects the builds when a worker can't start or load.