Files
make-cad/viewer
NiJingzhe e5ed7b547e feat(viewer): reverse-engineering studio — human-annotated STEP reconstruction loop
Interactive re-mode (re.html) plus a local case server implementing the
ppt-master handshake: the human selects faces / draws regions / labels intent
on the original STEP, the browser composes a submission with server-side
entity context, and a waiting agent reconstructs per the existing
reconstruction contract and writes artifacts the UI polls back.

- viewer/server (stdlib-only): STEP -> synthesized Scene 2.0 projection
  (GLB + entity sidecars, same shape as package scenes), region resolve
  (centroid projection + front-facing filter), entity descriptors,
  atomic submissions, ndjson side recording, --daemon/--wait/--wait-only/
  --shutdown CLI with lockfile and 590s budget
- viewer/src: extract shared cad-three/entity-facts modules (main.ts now
  consumes them), new SceneView class (assembly/picking/highlight) reused
  by both studio viewports
- re-mode UI: annotation canvas (circle/lasso), intent palette, context
  preview, submit flow, rebuilt v3 package loading, comparison image,
  feature tree, evaluation tab
- governance: only the browser writes submission.json; UI never edits
  geometry — code stays the single source of truth
- tests: 6 server tests (scene contract, region math, submission context
  + named failures, wait handshake exit codes, HTTP endpoints)
2026-09-05 00:30:46 +08:00
..
2026-07-23 03:16:40 +08:00

SimpleCAD Product Viewer

This browser-only viewer opens canonical .scadpkg product packages (package schema 3.0) without importing SimpleCAD, Python, or OpenCascade. The loader validates package.json, the exact member closure (definitions/, occurrences/root.json, blobs/, projections/scene/scene.json), and the embedded evaluated scene before parsing GLB or entity assets. It rejects older package schemas, standalone Scene ZIPs, and any package with missing, extra, length-mismatched, or hash-mismatched members. Product definition ZIPs and feature-graph archives are integrity-checked as package blobs but never re-packed, because the viewer renders exclusively from the scene projection.

Run

npm install
npm run dev

Open http://localhost:5173/, click Open .scadpkg, and select a package written directly by the functional capture API:

scad.capture(result, "out/product.scadpkg")

The same file can be dropped directly into the viewport.

The file picker accepts local .scadpkg product packages only. The viewer does not load packages from URL query parameters or require a built-in case registry.

Reverse-Engineering Studio (re.html)

The second entry, re.html, is the interactive reconstruction studio: a human annotates a STEP target, an agent reconstructs from those annotations, and the studio displays the rebuilt result next to the original. See docs/skill/references/workflows/reverse-engineering-studio.md for the full agent-side loop.

# from the repo root — binds 127.0.0.1:7170 and opens the studio
uv run python -m viewer.server <case_dir> --daemon

The case directory must contain the STEP target (*.step/*.stp); the server synthesizes the same GLB + entity-sidecar scene projection packages carry, so face/edge/vertex picking works identically on both sides. The rebuilt side loads the agent's captured v3 rebuilt.scadpkg through the normal package loader. During development, npm run dev proxies /api to the server port.

Governance: the studio UI only selects and describes — it never edits geometry. Only the browser writes re_work/submission.json; the agent waits on it via uv run python -m viewer.server <case_dir> --wait-only and writes artifacts (rebuild.py, rebuilt.step, rebuilt.scadpkg, comparison.png, evaluation.json) that the UI polls. Every event lands in re_work/session.ndjson as the training record.

Inspecting A Product

The Components tab shows the evaluated occurrence hierarchy. Select an occurrence to inspect its definition, visibility, and evaluated body data. The visibility control on each row hides or shows that occurrence.

The Features tab federates the immutable feature DAGs embedded by every part and nested assembly definition. Selecting a feature shows its operation, definition-local identity, inputs, outputs, parameters, source spans, and linked geometry. Connector and joint selections resolve through the package indexes to the exact producing feature when that evidence exists.

The source panel lists the content-addressed source snapshots embedded by the definition closure. Selecting a mapped feature opens the exact source asset, scrolls to its recorded line range, and highlights that range without reading files from the local machine.

Select components, solids, faces, edges, or vertices in the viewport to inspect evaluated geometry and measurements. Geometry selections link back to the feature DAG through stable definition, node, output-slot, and topology evidence.