@twinfinity/core
    Preparing search index...

    Class LineAggregator

    Combines multiple LineSources into one slab per rendering group, ready for upload to a LineRenderer. The aggregator owns the combined buffers, grows them in place (doubling) as needed, and rebuilds once per render tick — driven by scene.onBeforeRenderObservable via addOnce so idle frames pay zero observer overhead.

    Lifecycle:

    const aggregator = new LineAggregator(scene);
    aggregator.onRebuild.add(({ slab, renderingGroupId }) => {
        renderers[renderingGroupId].upload(slab);
    });
    aggregator.addSource(source);
    // source mutations auto-schedule rebuilds via onBeforeRender
    aggregator.dispose();
    

    Self-disposes when the host Scene is disposed.

    Index

    Constructors

    Properties

    onRebuild: Observable<AggregatedSlab> = ...

    Fires once per rendering group per render tick when content changed. Handlers should be cheap and not mutate sources synchronously (mutations will schedule the next rebuild, but nested flush() calls during a handler are no-ops).

    Methods

    • Register a source with this aggregator. Sources contribute to the combined slab for their renderingGroupId, in addSource order within a group. Adding a source schedules a rebuild.

      Throws if the source is already registered (with this or another aggregator) — sources are single-owner.

      Parameters

      Returns void

    • Release per-group buffer slack accumulated by doubling-on-growth. Useful after a load phase finishes (e.g. after LineGeometryBuilder.build resolves) when no further growth is expected — at peak the combined buffer can hold up to 2× the current segment count.

      threshold (default 1.5) compacts a group only when capacity > count * threshold. Groups with no segments are released to zero capacity. Safe between rebuilds; data is preserved so consumers reading the slab before the next rebuild see the same content.

      Parameters

      • threshold: number = 1.5

      Returns void

    • Tear down. Removes scene observers, clears combined buffers, detaches all sources (without disposing them — that's the caller's call). Idempotent.

      Returns void

    • Force a synchronous rebuild and emit. Use for tests, headless rendering, or scripts that need the post-mutation state immediately. Not for the render hot path — defeats RAF coalescing.

      Nested flush() calls (e.g. from inside an onRebuild handler) are no-ops: the reentrancy guard prevents recursion.

      Returns void

    • True after dispose().

      Returns boolean

    • True when frustum culling is active.

      Returns boolean

    • Detach a source. Schedules a rebuild of the group the source belonged to. The source's own dispose() is not called — caller decides.

      Parameters

      Returns void

    • Toggle per-source frustum culling. When on, an onBeforeRender observer recomputes each source's world-space AABB visibility against the active camera's frustum every frame; sources fully outside the frustum are skipped during combine. When off (default), no per-frame observer is installed and every visible source contributes regardless of camera.

      Toggling re-dirties all groups so the next rebuild reflects the new culling state.

      Parameters

      • enabled: boolean

      Returns void