Skip to content

Upgrade to gcode-preview 3.0.0-alpha.6 - #1

Merged
sophiedeziel merged 2 commits into
mainfrom
upgrade-gcode-preview-3.0-alpha.5
Sep 8, 2026
Merged

Upgrade to gcode-preview 3.0.0-alpha.6#1
sophiedeziel merged 2 commits into
mainfrom
upgrade-gcode-preview-3.0-alpha.5

Conversation

@sophiedeziel

Copy link
Copy Markdown
Contributor

Updates this demo to the 3.0 API.

What changed

  • GCodePreview.init(...) -> new GCodePreview(...) (named import). The component function keeps its GCodePreviewUI name so the class and the component don't collide.
  • WebGLPreview type is gone; the instance is typed GCodePreview and kept in a ref instead of state (the state version handed out a handle that had captured undefined).
  • allowDragNDrop -> droppable, preview.resize() -> preview.sceneManager.resize(), preview.layers.length -> preview.countLayers.
  • The hand-rolled setTimeout chunk loader is gone, along with the window[id] timer stash and the global Window index-signature augmentation in src/types/index.d.ts. processGCodeStream() now chunks, parses and draws by itself.
  • @types/three ^0.144.0 -> ^0.169.0 so the types match the three 0.169.0 actually resolved (single three instance).

Note: response.body has to be piped through TextDecoderStream before it is handed to processGCodeStream. The parser splits chunks on newlines, so raw Uint8Array chunks render nothing, silently.

Worth eyeballing

  • Loading is now progressive streaming instead of manual 250-line chunks, so both models grow in while the file downloads.
  • 3.0 keeps real G-code coordinates rather than re-centering on the build volume, so a model may sit differently in frame than before.
  • The camera position is persisted to localStorage and can override initialCameraPosition — a stale saved camera will win on a repeat visit.

The firebase PR preview deploy is the way to check all of this visually.

Assisted by Claude Code - Opus 5

- `import * as GCodePreview` + `GCodePreview.init()` -> named `{ GCodePreview }`
  + `new GCodePreview()`; the component function keeps the `GCodePreviewUI`
  name so the class and the component no longer collide.
- `WebGLPreview` type is gone: the preview instance is now typed `GCodePreview`
  and held in a ref (the old state-based handle captured a stale `undefined`).
- `allowDragNDrop` -> `droppable`, `preview.resize()` ->
  `preview.sceneManager.resize()`, `preview.layers.length` ->
  `preview.countLayers`.
- Replace the hand-rolled setTimeout chunk loader (and the `window[id]` timer
  stash it needed, plus the global `Window` index-signature augmentation) with
  `processGCodeStream()`, which parses and renders progressively on its own.
  The response body is decoded with `TextDecoderStream` first: the parser
  splits chunks on newlines and silently renders nothing when fed raw bytes.
- Loads are guarded by an AbortController so a superseded fetch cannot stream
  into a new job, and the preview is disposed on unmount.
- `@types/three` ^0.144.0 -> ^0.169.0 to match the `three` 0.169.0 that
  gcode-preview resolves to (single three instance, verified with `npm ls`).

Assisted by Claude Code - Opus 5
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 21fe28b):

https://gcode-preview-react--pr1-upgrade-gcode-previe-4totfkfa.web.app

(expires Tue, 15 Sep 2026 03:51:25 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c787db3520fae43f256c13f53bbe62214d2df228

@sophiedeziel sophiedeziel changed the title Upgrade to gcode-preview 3.0.0-alpha.5 Upgrade to gcode-preview 3.0.0-alpha.6 Sep 8, 2026
@sophiedeziel
sophiedeziel merged commit 589b8ad into main Sep 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant