Skip to content

Add --preview HTML viewer to scrollcase build - #5

Merged
csparker247 merged 2 commits into
mainfrom
scrollcase-preview
Oct 2, 2026
Merged

csparker247 merged 2 commits into
mainfrom
scrollcase-preview

Conversation

@csparker247

Copy link
Copy Markdown
Member

Summary

scrollcase build --preview writes <name>-preview.html next to the output STLs and opens it in the default browser. It's a single file with no server: the parts are embedded as one GLB, and three.js loads from jsDelivr, so viewing it needs a network connection.

The viewer has:

  • Per part: show/hide, color picker, and an opacity slider. Each part draws a depth-only pass first, so the stacked honeycomb walls fade smoothly instead of switching between solid and see-through.
  • Explode: pulls the halves apart along the split axis (Y) and moves the stand out past the left half.
  • Poses: Upright (case +Z up) or On stand (lying on the stand at −Y; labelled On side when there's no stand). The model rotates rather than the camera, so the orbit controls always work in a normal Y-up world.
  • View: ground grid toggle, background color, reset view, and Save snapshot, which downloads a PNG of just the 3D view, without the panel.

Upstream villa used the OCP CAD Viewer in VS Code and trimesh's notebook viewer for this; we hadn't ported either.

trimesh moves from a dev dependency to a runtime one. Nothing else is new in pyproject.toml.

Testing

  • tests/test_preview.py checks that every part is embedded as a named GLB node in display order, and that the title is escaped in both <title> and the inline JSON.
  • Full suite: 69 passed.
  • Checked by hand in Chrome on examples/generic.toml (about a 9.7 MB page): opacity fade, explode in both poses, grid toggle, part and background colors, and snapshot output (a valid PNG with no panel). No console errors.

🤖 Generated with Claude Code

csparker247 and others added 2 commits October 2, 2026 11:45
`scrollcase build --preview` writes <name>-preview.html next to the STLs
and opens it. The page embeds every part as one GLB and renders it with
three.js from a CDN, with per-part visibility, color and opacity, an
explode slider, upright/on-stand poses, a grid toggle, a background color,
and a PNG snapshot of the view.

trimesh moves from a dev dependency to a runtime one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write the preview as utf-8 regardless of locale, decode the embedded GLB
via fetch, show load failures in the status overlay, and defer revoking
the snapshot blob URL so the download can start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@csparker247
csparker247 merged commit 17c97a6 into main Oct 2, 2026
2 checks passed
@csparker247
csparker247 deleted the scrollcase-preview branch October 2, 2026 16:47
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