gcode-preview - v3.0.0-alpha.4
    Preparing search index...

    Class GCodePreview

    Main G-code preview class that orchestrates rendering and parsing

    import { GCodePreview } from 'gcode-preview';

    const preview = new GCodePreview({
    canvas: document.getElementById('canvas'),
    buildVolume: { x: 200, y: 200, z: 200 }
    });

    // Use the sceneManager directly for most operations
    preview.sceneManager.backgroundColor = '#000000';
    preview.sceneManager.extrusionColor = '#00ff00';

    // Process G-code
    preview.processGCode(gcodeString);
    Index

    Constructors

    Properties

    job: Job

    Job containing parsed G-code data

    Accessors

    • get countLayers(): number

      Gets the total number of layers in the job

      Returns number

      Number of layers

    Methods

    • Clears the preview and resets the parser, sceneManager, gui and job

      Returns void

    • Processes G-code and renders the preview

      Parameters

      • gcode: string | string[]

        G-code string or array of lines

      Returns void

    • Processes G-code using the sceneManager's built-in streaming method

      Parameters

      • gcode: string | string[] | ReadableStream<any>

        G-code string or array of strings to process

      • options: { render?: boolean } = ...

        Options for rendering: { render: boolean }

      Returns Promise<void>

      Parses the G-code, executes commands, and renders the paths if render is true.

    • Parameters

      • stream: ReadableStream

      Returns Promise<void>