3D-City Model
    Preparing search index...

    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.

    How many entity pairs per worker.

    URL or path to the worker script (DistanceWorker.js).

    // Register a pair and listen for CustomEvent:
    manager.register(entityA, entityB, "myDistanceEvent");
    window.addEventListener("myDistanceEvent", e => console.log(e.detail)); // distance
    manager.update(); // triggers computation
    Index

    Constructors

    Properties

    batches: { from: Object[]; to: Object[] }[]

    [{from, to}] entity pair batches.

    batchSize: number

    Number of pairs processed per worker.

    eventNames: string[]

    Custom event names for dispatching results.

    from: any[]

    Registered source entities.

    loop: boolean

    Whether to auto-update, not managed directly here.

    to: any[]

    Registered destination entities.

    workers: Worker[]

    Active Worker objects.

    workerScript: string

    Script URL/path for spawning Worker instances.

    Methods

    • Deregisters an entity pair (by index). Also re-batches and re-spawns workers.

      Parameters

      • index: number

        Index of the pair to remove.

      Returns void

    • Registers an entity pair for distance calculation with an event name. Triggers an update of batches and worker allocation.

      Parameters

      • entity1: Object

        The first/source entity (must have .position).

      • entity2: Object

        The second/target entity (must have .position).

      • eventName: string

        The CustomEvent name for reporting results.

      Returns void

    • 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.

      Returns void

    • Splits all registered pairs into batches and creates fresh Worker objects. Each worker is assigned a postMessage handler for dispatching results via CustomEvents.

      Returns void