Chestnut Labs G-code Preview
    Preparing search index...

    Chestnut Labs G-code Preview

    A worker-based, cross-vendor G-code toolpath stack for the browser: parse .gcode and .gcode.3mf off the main thread, normalize them into a versioned intermediate representation (ToolpathIR), and render an interactive Three.js preview — with first-class Vue, React, Svelte, and Web Component adapters over one shared, framework-neutral engine.

    This is the SDK manual (these Guide and Concept pages). The generated API reference — every public export of all ten @chestnutlabs/* packages — is a companion site linked from the API reference item in the top nav.

    Install the adapter for your framework plus three (the renderer declares three as a peer dependency; npm ≥ 7 installs it automatically, pnpm/yarn users add it explicitly):

    npm install @chestnutlabs/gcode-preview-vue three     # or -react, -svelte, -element
    

    Prefer no framework? Use the Web Component:

    npm install @chestnutlabs/gcode-preview-element three
    
    <script setup>
    import { GcodePreview } from '@chestnutlabs/gcode-preview-vue';
    import { shallowRef } from 'vue';
    const file = shallowRef(null);
    </script>

    <template>
    <input type="file" accept=".gcode,.3mf" @change="file = $event.target.files?.[0] ?? null" />
    <div style="height: 70vh">
    <GcodePreview :source="file" @ready="(s) => console.log(`${s.segments} segments`)" />
    </div>
    </template>

    Every adapter ships the same defaulted <GcodePreview> surface — source, parseOptions, buildVolume, quality, colorMode, layerRange, scrub, showTravel, progress, cameraMode, theme, createWorker — plus a lower-level API (composable / hook / store / action) for building your own controls. <GcodePreview :source="file" /> is the whole thin path; the full viewer is reachable without switching APIs.

    You want… Install
    A drop-in viewer in Vue / React / Svelte @chestnutlabs/gcode-preview-{vue,react,svelte}
    A viewer with no framework @chestnutlabs/gcode-preview-element
    To build your own viewer on the shared controller @chestnutlabs/gcode-preview-core
    Just the parser → IR (no rendering) @chestnutlabs/gcode-parser + @chestnutlabs/toolpath-core
    A headless still image (server thumbnails) renderStill from @chestnutlabs/gcode-renderer-three

    Status: published — all ten @chestnutlabs/* packages are on npm (latest v0.2.0, lockstep-versioned with provenance). Governance and epic status live in the repository docs.