G-code Preview — API Reference
    Preparing search index...
    Index

    Constructors

    Accessors

    • get camera(): OrthographicCamera | PerspectiveCamera

      The camera currently rendered/orbited (#150). Its concrete type follows cameraMode, so external readers must treat it as the union — only perspective cameras carry .fov (guard writes on cameraMode).

      Returns OrthographicCamera | PerspectiveCamera

    • get chunkMeshes(): (
          | LineSegments<
              BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
              Material | Material[],
              Object3DEventMap,
          >
          | Mesh<
              BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
              Material | Material[],
              Object3DEventMap,
          >
      )[]

      Currently built chunk meshes: LineSegments (lines/travel) or Mesh (tubes).

      Returns (
          | LineSegments<
              BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
              Material | Material[],
              Object3DEventMap,
          >
          | Mesh<
              BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
              Material | Material[],
              Object3DEventMap,
          >
      )[]

    • get hasColorChanges(): boolean

      True when the current IR carries M600 color-change boundaries (#147, DD-009 D2).

      Returns boolean

    • get hasRetractions(): boolean

      True when the current IR actually carries positioned retraction events.

      Returns boolean

    • get layerCount(): number

      Number of layers in the retained IR (slider bounds for consumers).

      Returns number

    • get segmentCount(): number

      Number of IR segments (scrub-slider bounds for consumers).

      Returns number

    Methods

    • Progressive preview (#60): append a path-aligned partial slice as transient geometry. Slices always render as lines (cheap, allocation-light) with cumulative every-Nth decimation past the §4.4 thresholds; the eventual setIR(finalIR) REPLACES the whole preview set. Preview meshes ignore layer-range/scrub clipping (their indices are slice-local); kind visibility still applies.

      Parameters

      Returns void

    • Upload a bounded amount of work, then reschedule (§5.3/§8). Public for tests.

      Returns void

    • Synchronously finish all pending uploads (tests; also useful before capture).

      Returns void

    • Fit the camera to the toolpath bounds (falls back to the build volume).

      Returns void

    • Capability gate (§4.6): feature coloring needs the IR to actually carry feature roles — featureRoles: 'unavailable' means the UI must disable it, not render fabricated colors. Single/tool modes are always available.

      Parameters

      • mode: "single" | "tool" | "feature" | "colorChange"

      Returns boolean

    • Parameters

      • width: number
      • height: number

      Returns void

    • Apply a build volume after construction (DD-005 §4.2 amendment: parse → discover machine geometry → apply, no renderer reconstruction). Accepts a plain BuildVolumeDef or a discovered MachineGeometry (circular/polygon beds render as their bounding volume in v1). Emits machine-geometry-mismatch when a consumer-configured volume disagrees with a discovered one by >1 mm.

      Returns void

    • Switch the camera projection (#150, DD-009 D3). The pose (position/orientation) is copied to the incoming camera so the view never jumps, OrbitControls is reattached to it, and its frustum is re-sized before the next render.

      Parameters

      Returns void

    • Switch color mode (attribute rewrite, no geometry rebuild — §4.6). Returns false (and emits an error event) when the mode is capability-gated off.

      Parameters

      Returns boolean

    • Toggle a move kind (extrusion/travel) on or off (whole-chunk visibility, §4.3).

      Parameters

      • kind: "extrude" | "travel"
      • visible: boolean

      Returns void

    • Clip rendering to an inclusive layer range (§4.5). Draw-range trims on the existing chunk geometry only — no rebuild, no new allocations.

      Parameters

      • startLayer: number
      • endLayer: number

      Returns void

    • Live-progress overlay input (DD-006 §4.5): a MappedProgress from the core mapper, or null to hide the overlay entirely. Presentation is decided by confidence — exact gets a marker, approximate gets an uncertainty band, stale grays out, unavailable hides — and every mode change emits progress-presentation-changed.

      Parameters

      Returns void

    • Change the quality tier; rebuilds from the retained IR when one is set.

      Parameters

      Returns void

    • Scrub: render only segments with IR index <= segIndex (within the layer range). null clears the scrub cut.

      Parameters

      • segIndex: null | number

      Returns void

    • Opt-in retraction/deretraction markers (DD-009 D1, #148). Points at each retract (warm) / unretract (cool) event; clipped by the same layer/scrub window as the toolpath. Capability-honest: no markers when the IR carries no retraction events (capabilities.retractions !== 'known').

      Parameters

      • visible: boolean

      Returns void

    • Apply a bounded declarative theme (#153, DD-009 D4), replacing the current one: unspecified fields reset to DEFAULT_THEME. Restyles lights, background, the build-volume grid/box, and swaps the extrude (tube) material preset live — disposing replaced materials/geometry. Lines geometry and the semantic marker/ overlay/origin colors are unaffected.

      Parameters

      Returns void