G-code Preview — API Reference
    Preparing search index...
    Index
    controls: ControlsLike | null = null
    orthographicCamera: OrthographicCamera
    perspectiveCamera: PerspectiveCamera
    • Capture the currently displayed view as an image Blob (DD-030 D1). Renders the current scene + active camera into an off-screen target at the requested size (so it never disturbs the live view nor requires preserveDrawingBuffer), reads it back, and encodes it. Rejects with an E_CAPTURE_UNSUPPORTED error when the renderer cannot render-to-target (a stub GL / no WebGL) or the stage is disposed / context-lost. The caller owns the returned Blob — the library never downloads. With no width/height and no pixelRatio set, the image is the resting drawing-buffer size, as before (also mid-gesture). With a pixelRatio set it is the canvas's CSS size, so setting one never changes it; pass width/height for a crisper image.

      Parameters

      Returns Promise<Blob>

    • Fit a scene-space axis-aligned box to the viewport: the camera looks at the box center along direction (target→camera; default the shared 3/4 pose) and backs off just far enough that every corner lands inside BOTH the vertical and the horizontal field of view at the current aspect, with margin (≥1, default 1.1) of slack. The orthographic frustum is sized to the same projected extent, so a projection toggle keeps the apparent size. Unlike frameTo's bounding-sphere pose this is tight: a wide/flat model fills a wide canvas instead of overflowing a narrow one.

      Parameters

      • min: Vector3
      • max: Vector3
      • opts: { direction?: Vector3; margin?: number } = {}

      Returns void

    • Frame the camera to a scene-space center + radius via the shared 3/4 pose (stage.ts), sizing the ortho frustum and the zoom-distance clamps from the framed model so a projection toggle keeps the apparent size and the user can't dolly through/away from the model (#150/#267).

      Parameters

      • center: Vector3
      • radius: number

      Returns void

    • Change the perspective lens (DD-032) without a re-fit: the target stays and the camera distance is scaled by framingLensScale(new)/framingLensScale(old), the same factor framing uses, so a framed view after setFov(f) equals a fresh frame at f. It keeps the apparent size at ≤50°; above 50° it keeps the frame margin instead (a pure tan dolly would put the camera inside the model). The zoom-distance limits scale by the same factor, so the dolly is never clamped. In orthographic mode the view is untouched; the value is kept and its dolly is applied on the next switch back to perspective. Programmatic: never emits camera-changed. Throws RangeError for a fov outside [10, 120] — it never clamps.

      Parameters

      • fov: number

      Returns void

    • Set the resting pixel ratio: a number in (0, 4], or 'device' (the display's DPR capped at 2, then followed live as it changes). Goes through the interaction-quality controller, so a gesture in progress keeps its reduction and its settle restores the new ratio. Throws RangeError otherwise (never clamps). The default capture size stays the CSS size: pass width/height for a larger image.

      Parameters

      Returns void