G-code Preview — API Reference
    Preparing search index...
    interface GcodePreviewControls {
        capture(opts?: CaptureOptions): Promise<Blob>;
        frame(): void;
        getCameraState(): null | CameraState;
        getRenderStats(): null | RenderStats;
        isColorModeAvailable(
            mode:
                | "object"
                | "single"
                | "tool"
                | "feature"
                | "colorChange"
                | "filament"
                | "feedrate"
                | "layerHeight"
                | "power"
                | "moveKind",
        ): boolean;
        pickSegment(ndcX: number, ndcY: number, threshold?: number): null | number;
        setBuildVolume(def: BuildVolumeDef | MachineGeometry): void;
        setBuildVolumeCage(visible: boolean): void;
        setCameraMode(mode: CameraMode): void;
        setCameraState(state: CameraState): void;
        setColorMode(mode: ColorMode): boolean;
        setFeatureRoleVisible(role: FeatureRoleValue, visible: boolean): void;
        setFrameContent(mode: "object" | "all"): void;
        setInteractionQuality(mode: "auto" | "off"): void;
        setKindVisible(kind: MoveKindToggle, visible: boolean): void;
        setLayerRange(startLayer: number, endLayer: number): void;
        setProgressivePreview(mode: ProgressivePreview): void;
        setQuality(quality: QualityMode | "auto"): void;
        setQualityMode(mode: QualityPolicy): void;
        setScrubPosition(segIndex: null | number): void;
        setScrubTime(ms: null | number): void;
        setShowRetractions(visible: boolean): void;
        setTheme(theme: Theme): void;
        setView(view: CameraView): void;
    }
    Index

    Methods

    • Capture the currently displayed view as an image Blob (DD-030 D1) — for a user-selected thumbnail, a large-file fallback, or a screenshot. Rejects with E_CAPTURE_UNSUPPORTED before the 3D renderer is ready or on the 2D renderer (which cannot render-to-target). The caller owns the Blob.

      Parameters

      Returns Promise<Blob>

    • Returns void

    • Read the current camera as a serializable snapshot (#268), or null before the renderer is ready / on the 2D renderer (which has no 3D pose).

      Returns null | CameraState

    • Render diagnostics snapshot (DD-027, DD-031 G1) — backend, WebGL version, GPU (hardware/software), geometry mode, build parallelism + worker count, draw calls, tube-byte budget, and parse/build/ first-frame timings — or null before the first render and on the 2D renderer (which produces none). Reachable through the public surface so a diagnostics panel needs no raw.renderer().

      Returns null | RenderStats

    • Capability gate for a color mode against the current file (DD-031 G6) — mirrors GcodePreviewState.availableColorModes for a one-off query. false when the file lacks the channel the mode reads; always true before a parse (optimistic, like setColorMode).

      Parameters

      • mode:
            | "object"
            | "single"
            | "tool"
            | "feature"
            | "colorChange"
            | "filament"
            | "feedrate"
            | "layerHeight"
            | "power"
            | "moveKind"

      Returns boolean

    • Pick the IR segment under a pointer in normalized device coords ([-1, 1], y up), or null (DD-031 G2, #184). Powers source-mapping/inspection UI. The 3D renderer raycasts the toolpath; the 2D renderer returns null (no picking yet). threshold widens the hit test (world units).

      Parameters

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

      Returns null | number

    • Show/hide the build-volume wireframe cage independently of the bed/plate (#306/#6).

      Parameters

      • visible: boolean

      Returns void

    • Switch camera projection (#150, DD-009 D3).

      Parameters

      Returns void

    • Restore a camera snapshot verbatim (#268) — no re-fit to the current model. 2D discloses.

      Parameters

      Returns void

    • Parameters

      Returns boolean

    • Show/hide a single feature role — e.g. hide Skirt/Brim to declutter a part preview. Gate the UI on capabilities.featureRoles === 'known' (like the feature color mode); a no-op on the 2D renderer and on files without feature annotations. Import FeatureRole from @chestnutlabs/toolpath-core.

      Parameters

      Returns void

    • Frame the printed 'object' (excl. skirt/prime) vs 'all' extrusion, and re-frame (#306/#6).

      Parameters

      • mode: "object" | "all"

      Returns void

    • Interaction-aware quality: 'auto' reduces detail while the camera moves (#306/2, DD-020).

      Parameters

      • mode: "auto" | "off"

      Returns void

    • Parameters

      • kind: MoveKindToggle
      • visible: boolean

      Returns void

    • Parameters

      • startLayer: number
      • endLayer: number

      Returns void

    • Set the during-parse preview curtain (#60): 'lines' | 'hold' | 'off'. Applies to the next parse. 3D only.

      Parameters

      Returns void

    • Parameters

      Returns void

    • Set the fidelity policy (DD-023 §4 D6): 'full' | 'adaptive' | 'fast'. 3D only.

      Parameters

      Returns void

    • Parameters

      • segIndex: null | number

      Returns void

    • Time-based scrub (#181): cut the toolpath at print time ms (kinematic axis). null clears the cut. Resolves to a segment-index scrub; no-op before a successful parse.

      Parameters

      • ms: null | number

      Returns void

    • Opt-in retraction/deretraction markers (DD-009 D1, #148). Off by default.

      Parameters

      • visible: boolean

      Returns void

    • Apply a bounded declarative theme (#153, DD-009 D4).

      Parameters

      Returns void

    • Snap to a preset orientation — top/front/iso/… (#268). Instant; preserves the projection. The 2D renderer discloses this via renderer-unsupported rather than moving.

      Parameters

      Returns void