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

    Class SceneManager

    WebGL-based G-code preview renderer

    Index

    Constructors

    Properties

    camera: PerspectiveCamera | OrthographicCamera

    Three.js camera (perspective or orthographic)

    canvas: HTMLCanvasElement

    Canvas element being rendered to

    controls: OrbitControls

    Orbit controls for camera

    job: Job
    lastRenderTime: number = 0

    Last render time in milliseconds

    onFrameRendered?: () => void

    Called after every rendered frame, for consumers that track render stats.

    Holds a single callback: assigning it replaces any previous one.

    renderer: WebGLRenderer & {
        info: {
            memory: { geometries: number; textures: number };
            render: {
                calls: number;
                lines: number;
                points: number;
                triangles: number;
            };
        };
    }

    Three.js WebGL renderer

    scene: Scene

    Three.js scene

    defaultExtrusionColor: Color = ObjectsManager.defaultExtrusionColor

    Default extrusion color

    Accessors

    • get backgroundColor(): Color

      Gets the current background color

      Returns Color

      Current background color

    • set backgroundColor(value: string | number | Color): void

      Sets the background color

      Parameters

      • value: string | number | Color

        Color value as number, string, or Color instance

      Returns void

    • get boundingBoxColor(): ColorRepresentation

      Gets the current bounding box color

      Returns ColorRepresentation

      Color representation or undefined if not set

    • set boundingBoxColor(value: ColorRepresentation): void

      Sets the bounding box color

      Parameters

      • value: ColorRepresentation

        Color value or undefined to hide the bounding box

      Returns void

    • get endLayer(): number

      Gets the current end layer (1-based index)

      Returns number

      End layer number

    • set endLayer(value: number): void

      Sets the end layer (1-based index)

      Parameters

      • value: number

        Layer number to end rendering at

      Returns void

    • get extrusionColor(): Color | Color[]

      Gets the current extrusion color(s)

      Returns Color | Color[]

      Color or array of colors for extruded paths

    • set extrusionColor(value: string | number | Color | ColorRepresentation[]): void

      Sets the extrusion color(s)

      Parameters

      • value: string | number | Color | ColorRepresentation[]

        Color value(s) as number, string, Color instance, or array of ColorRepresentation

      Returns void

    • get lastSegmentColor(): ColorRepresentation

      Gets the current last segment color

      Returns ColorRepresentation

      Color representation or undefined if not set

    • set lastSegmentColor(value: ColorRepresentation): void

      Sets the last segment color

      Parameters

      • value: ColorRepresentation

        Color value or undefined to clear

      Returns void

      Highlighting the last segment splits the final path out of its batch, so a change redraws the scene rather than recoloring in place.

    • get singleLayerMode(): boolean

      Gets whether single layer mode is enabled

      Returns boolean

      True if single layer mode is active

    • set singleLayerMode(value: boolean): void

      Sets single layer mode

      Parameters

      • value: boolean

        True to enable single layer mode

      Returns void

    • get startLayer(): number

      Gets the current start layer (1-based index)

      Returns number

      Start layer number

    • set startLayer(value: number): void

      Sets the start layer (1-based index)

      Parameters

      • value: number

        Layer number to start rendering from

      Returns void

    • get topLayerColor(): ColorRepresentation

      Gets the current top layer color

      Returns ColorRepresentation

      Color representation or undefined if not set

    • set topLayerColor(value: ColorRepresentation): void

      Sets the top layer color

      Parameters

      • value: ColorRepresentation

        Color value or undefined to clear

      Returns void

      Highlighting the top layer picks specific paths out of the per-tool batches, so a change redraws the scene rather than recoloring in place.

    • get travelColor(): Color

      Gets the current travel move color

      Returns Color

      Current travel move color

    • set travelColor(value: string | number | Color): void

      Sets the travel move color

      Parameters

      • value: string | number | Color

        Color value as number, string, or Color instance

      Returns void

    Methods

    • Experimental

      Renders paths incrementally using an animation loop

      Parameters

      • pathCount: number = undefined

        Number of paths to render per frame

      Returns Promise<void>

      Promise that resolves when rendering is complete

    • Updates the clipping planes for the 3D preview based on the start and end layers.

      This method calculates the minimum and maximum Z values from the specified start and end layers. A bound that is unset — or that sits at the very end of the layer stack — leaves that side of the range unbounded: an endLayer equal to the layer count is no restriction, so moves outside the printed layers (travel moves above the top layer, most commonly) stay visible.

      It then updates the clipping planes for shader materials and line clipping using these Z values.

      Returns void