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

    Constructors

    Accessors

    • get camera(): PerspectiveCamera | OrthographicCamera

      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 PerspectiveCamera | OrthographicCamera

    • 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,
          >
      )[]

    Methods

    • Progressive preview (#60): append a path-aligned partial slice as transient geometry. Presentation is governed by progressivePreview (the #60 curtain):

      • 'lines' (default): render the slice 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.
      • 'hold': track progress and emit previewAppend, but build/reveal NO preview geometry — the viewer sees nothing until the final, correctly-coloured build from setIR. A single clean reveal with a live progress signal.
      • 'off': no preview geometry and no previewAppend — the consumer drives its own loading treatment; the old scene (if any) persists until setIR replaces it.

      Parameters

      Returns void

    • Capture the current view as an image Blob (DD-030 D1) — delegates to the shared stage. With includeBuildVolume: false the whole build-volume group (grid/bed/origin/cage) is hidden for the off-screen render only, so background:'transparent' yields a clean toolpath-only cutout (parity with ModelRenderer thumbnails). The live view is untouched: the visibility is restored synchronously before control returns to the event loop, so no intermediate frame is ever painted.

      Parameters

      Returns Promise<Blob>

    • 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:
            | "object"
            | "single"
            | "tool"
            | "feature"
            | "colorChange"
            | "filament"
            | "feedrate"
            | "layerHeight"
            | "power"
            | "moveKind"

      Returns boolean

    • Pick the IR segment under a pointer, or null (#184 — click a segment → its G-code source line via sourceLineOfSegment in @chestnutlabs/toolpath-core). ndcX/ndcY are normalized device coords (each in [-1, 1]); a consumer converts a canvas click with (x/w)*2-1, -(y/h)*2+1. threshold is the world-space line hit radius — auto-derived from the model size when omitted. Lines mode; tube meshes resolve when they carry a vertex→segment table.

      Parameters

      • ndcX: number
      • ndcY: number
      • Optionalthreshold: number

      Returns null | number

    • 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

    • Show/hide the build-volume wireframe cage independently of the bed/plate (#306/#6). Toggles the named volumeCage child in place (no geometry rebuild); persists so a later volume rebuild honors it.

      Parameters

      • visible: boolean

      Returns void

    • Show or hide a single FeatureRole — e.g. hide Skirt/Brim to declutter a part preview, or isolate Support. Feature roles live per-segment inside the extrusion geometry (unlike move kinds, which are whole chunks), so hidden segments are collapsed to NaN positions and the GPU discards them; the original positions are restored when the role is shown again.

      Only meaningful when the file carried feature annotations (capabilities.featureRoles === 'known' — gate the UI on it, like the feature color mode); on an unannotated file every segment is Unknown and hiding a specific role is a no-op. Untouched geometry (no role hidden) is byte-identical to before this call existed. Interacts cleanly with layer clip and scrub.

      Parameters

      Returns void

    • Frame the printed model vs. all extrusion (#306/#6, DD-026 D5/D6). 'object' excludes skirt/prime/purge/tower via the modelBounds → objectBounds precedence so housekeeping doesn't shrink the model in view — but only when the file is classifiable; when neither is available (a genuinely unclassifiable file, e.g. an unmarked prime with no object channel) it discloses an honest error and frames all extrusion. Re-frames.

      Parameters

      • mode: "object" | "all"

      Returns void

    • Toggle interaction-aware quality (DD-020, #306/2) — delegates to the shared stage.

      Parameters

      • mode: "auto" | "off"

      Returns void

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

      Parameters

      • kind: "extrude" | "travel" | "wipe"
      • 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

    • 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