feat(fold): emit per-face isometries for the future 3D viewer (#31) #61

Merged
toph merged 3 commits from vscode-isometries into main 2026-07-04 18:55:23 +00:00
Owner

Groundwork for the deferred 3D-viewer / animation slice, on top of the live preview (#60). Emits each folded face's exact 2D isometry so a future renderer can reconstruct the fold motion.

  • fold_emit adds beloch:faces_matrix per folded frame (inside folded_frame_of_state), one [m00, m01, m10, m11, tx, ty] per face from f.Fold_state.iso, and a top-level beloch:named_lines_frame: "creasePattern" declaring the coordinate frame the named lines live in.
  • fold2svg consumes beloch:faces_matrix through the existing foldedFrame(fold, step) selector, so it reads the selected step's matrices.
  • Goldens regenerated: beloch:faces_matrix count matches frame count per file (e.g. cube-root.fold: 4 frames, 4 matrices).

No behaviour change to the preview — this is pure additional FOLD metadata. dune runtest green (186 tests), tools/test 16/16, extension bun test 14/14.

For #31. Includes the #31 spec + plan (per-face isometry emission, named-line frame declaration). The animation/interpolation that consumes these is still deferred to the 3D-viewer slice (#30, ADR 0015).

Groundwork for the deferred 3D-viewer / animation slice, on top of the live preview (#60). Emits each folded face's exact 2D isometry so a future renderer can reconstruct the fold motion. - `fold_emit` adds `beloch:faces_matrix` **per folded frame** (inside `folded_frame_of_state`), one `[m00, m01, m10, m11, tx, ty]` per face from `f.Fold_state.iso`, and a top-level `beloch:named_lines_frame: "creasePattern"` declaring the coordinate frame the named lines live in. - `fold2svg` consumes `beloch:faces_matrix` through the existing `foldedFrame(fold, step)` selector, so it reads the selected step's matrices. - Goldens regenerated: `beloch:faces_matrix` count matches frame count per file (e.g. `cube-root.fold`: 4 frames, 4 matrices). No behaviour change to the preview — this is pure additional FOLD metadata. `dune runtest` green (186 tests), `tools/test` 16/16, extension `bun test` 14/14. For #31. Includes the #31 spec + plan (per-face isometry emission, named-line frame declaration). The animation/interpolation that consumes these is still deferred to the 3D-viewer slice (#30, ADR 0015).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016FYbXyypfVm4RdPLGBdWYw
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016FYbXyypfVm4RdPLGBdWYw
Stacked on #53 — base is `vscode-preview`.

Emits each folded face's paper→table isometry as `beloch:faces_matrix` and declares the named-line frame (`beloch:named_lines_frame: "creasePattern"`). Ports `fold2svg` to consume the isometry and deletes the float-vertex-pair reconstruction (`applyIso` plus its shoelace reflection detection) — the renderer no longer re-derives, in JS floats, a transform the exact core already holds in `face.iso`. Topology (vertex coincidence, layer order) is already decided exactly upstream and carried as integers, so float coefficients are sufficient here.

Also fixes a pre-existing clip bug the port surfaced: the folded overlay clipped named lines against the final crease pattern's vertices even for intermediate `--step` frames, whose face indices belong to a different dedup pass. It now pulls each line into the face's own table frame (`lineToFace`) and clips against that frame's polygon, dropping the crease-pattern index dependence.

Exact coordinates stay out of scope — rendering lands on float regardless and nothing verifies exactness yet; the reasoning is in #31. The golden-regen tool lives at `tools/regen.ml`.

Follow-up: #54 (integration fixture for the folded named-line overlay).

For #31.

---

`cube-root.bel` folded top view — creases placed on each folded face via the emitted isometry:

![cube-root folded](https://git.toph.so/attachments/a5d7a64e-147f-4ccc-8257-84f6940f600a)

Reviewed-on: #55
toph merged commit adc5078cef into main 2026-07-04 18:55:23 +00:00
toph deleted branch vscode-isometries 2026-07-04 18:55:24 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
toph/beloch!61
No description provided.