Skip to main content

BimLines

Convenience bundle wired onto BimCoreApi as api.lines. The easy path for drawing lines: call add with a slab and get back a LineHandle to toggle, restyle, move, or remove it — no StandardLineSource / LineAggregator bookkeeping.

const line = api.lines.add(slab, { transform });
line.visible = false;
line.remove();

A default LineRenderer is provisioned per rendering group the first time add targets it, so overlay layers work by passing renderingGroupId to add — no manual onRebuild wiring. Renderers are built lazily, including group 0's: an api.lines nobody draws with costs no mesh and no shader compile.

A group needing renderer options this façade does not expose (world-space widths, depth participation) has two routes: pass rendererOptions to the add that first targets the group, or construct the renderer yourself and hand it over with useRenderer. Ownership of a group is explicit and single-claim — a second claim throws rather than silently double-drawing the same segments through two renderers.

Self-disposes when the host scene is disposed (the renderers and aggregator each subscribe to scene.onDisposeObservable); dispose tears down early.

Index

Constructors

constructor

  • new BimLines(scene: Scene, options?: BimLinesOptions): BimLines
  • Parameters

    • scene: Scene
    • options: BimLinesOptions = {}

    Returns BimLines

Properties

readonlyaggregator

aggregator: LineAggregator

Shared aggregator: add() registers sources here.

Accessors

renderer

  • get renderer(): LineRenderer
  • Renderer for Babylon rendering group 0, provisioned on first access. Public as an escape hatch for renderer-level tweaks; most consumers only need add.


    Returns LineRenderer

Methods

add

  • Register a slab of line segments and return a handle to it. The handle owns the underlying source's lifecycle; use it to toggle visibility, restyle, transform, replace content, or remove.

    @throws

    RangeError if renderingGroupId is not an integer in 0 .. ${MAX_RENDERING_GROUPS - 1} — Babylon never dispatches other groups, so the lines would silently never draw.

    @throws

    Error if this instance (or its scene) has been disposed.


    Parameters

    Returns LineHandle

dispose

  • dispose(): void
  • Remove every issued handle (they become inert, exactly as after their own remove()), then tear down every renderer this instance provisioned plus the aggregator. Renderers handed over via useRenderer are left to their owner. Idempotent; the host scene's disposal does the same automatically.


    Returns void

isDisposed

  • isDisposed(): boolean
  • True once this instance can no longer be used — after dispose, or after the host scene's disposal took the aggregator (and every renderer) with it. Agrees with the guard add throws on.


    Returns boolean

removeAll

  • removeAll(): void
  • Remove every handle this façade issued (equivalent to calling LineHandle.remove on each). Handles a consumer still holds become inert, as they would after their own remove(). Sources registered directly on aggregator are untouched.

    The rebuilds coalesce into one upload per affected group.


    Returns void

useRenderer

  • useRenderer(groupId: number, renderer: LineRenderer): void
  • Hand a consumer-built renderer to this façade for groupId, so add routes that group to it instead of provisioning a default one. Use when a group needs renderer wiring beyond rendererOptions (e.g. an existing renderer shared with other systems).

    The renderer stays the caller's to dispose — dispose leaves it alone.

    @throws

    Error if the group is already claimed (by an earlier useRenderer, by an add() that provisioned it, or — for group 0 — by a read of renderer), or if this renderer instance already serves another group (one mesh cannot draw two groups' slabs). Claim before those run.

    @throws

    Error if this instance (or its scene) has been disposed.

    @throws

    RangeError if groupId is out of Babylon's range.


    Parameters

    • groupId: number
    • renderer: LineRenderer

    Returns void