@twinfinity/core
    Preparing search index...

    Class LineRenderer

    Renders an arbitrary count of 3D line segments in a single GPU draw call.

    Each segment is one thin-instance of a unit quad; per-instance attributes drive screen-space extrusion, colour, width and dash phase. Dash patterns stay phase-continuous across the joints of a polyline (each segment carries its arc offset from the polyline start).

    The renderer makes no assumption about coordinate system, handedness, axis-up, or units. Segment coordinates are passed straight to the GPU as world-space positions in whatever convention the host scene uses.

    Lifecycle:

    const renderer = new LineRenderer(scene);
    renderer.upload(slab);     // any number of times; later calls replace earlier
    renderer.clear();          // release GPU data, keep the renderer usable
    renderer.dispose();        // tear down; do not reuse after this
    

    The renderer self-disposes when the host Scene is disposed — public methods short-circuit after that. Manual dispose() followed by scene disposal is also safe (double-dispose is a no-op).

    The renderer never retains the slab passed to upload(); everything it needs is copied to its own typed-array caches.

    Index

    Constructors

    Methods

    • Drop the current segment data. Releases the per-instance GPU buffers so VRAM is reclaimed; the JS-side caches are kept so the next upload() skips their allocation. The renderer remains usable.

      Returns void

    • Fully tear down the renderer. Releases GPU buffers, drops the JS caches, unsubscribes from scene observers, and disposes the unit-quad mesh and shader material. Do not reuse the instance after calling this.

      Idempotent — a second call (e.g. from the scene-dispose hook after a manual dispose) is a no-op.

      Returns void

    • Current global dash period multiplier.

      Returns number

    • Reports the renderer's memory footprint.

      • gpuBytes: per-instance attribute data currently uploaded to GPU.
      • jsBytes: renderer-owned caches that survive across uploads.
      • instanceCount: number of segments currently being drawn.

      Returns { gpuBytes: number; instanceCount: number; jsBytes: number }

    • True after dispose() has run (manually or via scene tear-down).

      Returns boolean

    • True if the renderer is in world-unit width mode.

      Returns boolean

    • Global multiplier on every dash pattern's period.

      Default 1.0 means built-in patterns render at the renderer's design defaults (sized for metre-scale worlds). Set higher for larger worlds or to make dashes more prominent; lower to compress them.

      When the T8LD pattern primitive ships, patterns will carry their own scale and this becomes an additive multiplier on top — same knob, still useful.

      Parameters

      • value: number

      Returns void

    • Partial-update style override. Each field is independent: undefined leaves the corresponding override alone, null clears it, any other value applies it as the override for every rendered segment.

      Parameters

      Returns void

    • Toggle width interpretation between screen-space pixels (false, default) and world units (true, depth-attenuated).

      Parameters

      • on: boolean

      Returns void

    • Replace the current segment data with slab. Copies what's needed into the renderer's GPU and JS caches; does not retain slab after return. Callers that need a CPU-side copy (e.g. for picking) must keep their own reference.

      Passing a slab with count === 0 is equivalent to clear().

      Parameters

      Returns void