[{from, to}] entity pair batches.
Number of pairs processed per worker.
Custom event names for dispatching results.
Registered source entities.
Whether to auto-update, not managed directly here.
Registered destination entities.
Active Worker objects.
Script URL/path for spawning Worker instances.
Deregisters an entity pair (by index). Also re-batches and re-spawns workers.
Index of the pair to remove.
Registers an entity pair for distance calculation with an event name. Triggers an update of batches and worker allocation.
The first/source entity (must have .position).
The second/target entity (must have .position).
The CustomEvent name for reporting results.
Sends current batches to workers for processing. Each entity's .position is used and projected to flat [x, y, z] arrays for computation. Worker will emit CustomEvents for computed distances.
Splits all registered pairs into batches and creates fresh Worker objects. Each worker is assigned a postMessage handler for dispatching results via CustomEvents.
DistanceWorkerManager – Manages the batching, registration, and updating of 3D distance computations using parallel Web Workers (see DistanceWorker.js).
Splits up entity pairs into batches, distributes computation to workers, and dispatches
CustomEvent
results with calculated distances.Param: options
Param: options.batchSize
How many entity pairs per worker.
Param: options.workerScript
URL or path to the worker script (DistanceWorker.js).
Example