docs/superpowers/specs/2026-10-19-fold-design.md

00ea029d0652da12d0f4237769e7020b72cfa7f3
fold/docs/superpowers/specs/2026-10-19-fold-design.md rendered · source · history · blame · raw

633 lines · 33782 bytes

26 symbols in this file
  1# Fold — design
  2
  3## Intent
  4
  5Origami instructions are written in a formal diagram language. The
  6Yoshizawa–Randlett system fixes what a dashed line means (valley), what a
  7dash-dot line means (mountain), what each arrowhead means (fold, fold and
  8unfold, turn over, rotate, repeat), and it has been stable for sixty years.
  9It is a real notation, and it is designed for paper.
 10
 11Every origami app treats the diagram as a picture: a sequence of
 12photographs or scanned drawings you page through, with the notation reduced
 13to decoration. The paper never moves, and the diagram and the model can
 14disagree because nothing connects them.
 15
 16This app has one source of truth. A model is a folded geometry with
 17labelled creases; from that data the app **generates the Yoshizawa–Randlett
 18diagram** and **animates the fold**, and the two cannot contradict each
 19other because they are two renderings of the same thing. You drag
 20perpendicular to a crease and the paper rotates about it, through the
 21angle, at your pace, stopping where you stop.
 22
 23## Goals
 24
 25- Dragging a fold moves the paper continuously from 0° to its final fold
 26  angle and back, tracking the finger, with correct layer ordering at every
 27  intermediate angle.
 28- The diagram for a step is generated from the step's geometry: crease line
 29  styles from which way each fold turns as seen, arrows from which facets
 30  move, about which axis, and by which technique.
 31- The notation is correct Yoshizawa–Randlett, not an approximation of it.
 32- Models are data files, not code. Adding a model is adding a file.
 33- Entirely offline. No account, no network.
 34- Two-finger orbit and pinch zoom on the model at any point in the
 35  sequence, so you can look underneath a flap.
 36- Ships on the App Store, with VoiceOver and Dynamic Type support at the
 37  level of `krz/daybyday` — every screen passes Xcode's accessibility audit
 38  at the default and the largest text size.
 39
 40## Non-goals
 41
 42- Paper simulation. No stiffness, no self-collision response, no
 43  crumpling. Paper is rigid flat facets hinged at creases, except during a
 44  step flagged `nonRigid` (see *Interpolation*), whose bending is designed,
 45  not simulated.
 46- Deriving layer order from geometry. Layer order is authored and checked,
 47  never computed. Computing it in general is a hard problem and getting it
 48  wrong looks worse than any amount of authoring effort.
 49- Deriving a step's axes and moving sets from a frame diff. See *Steps are
 50  authored* below.
 51- Wet folding, curved creases, or anything that is not a straight crease
 52  between flat facets.
 53- Modern designers' models. See *Rights*.
 54- Teaching origami through text. The diagram and the motion are the
 55  instruction. The accessibility labels are the exception and are required.
 56
 57## Anti-goals
 58
 59- Facets that interpenetrate on screen. A flap passing through the layer
 60  below it destroys the sense that this is paper, and a viewer notices
 61  immediately even when they could not say why.
 62- A fold that snaps. If the drag is quantised, or the last 10° completes
 63  itself, the premise is gone.
 64- Diagram notation that is nearly right. The audience for this app is
 65  people who read diagrams, and a wrong arrowhead is as visible to them as
 66  a misspelling.
 67- Inventing a file format when FOLD exists.
 68- Shipping an engine with nothing to fold. Models cannot be authored in
 69  existing tools; see *Authoring*.
 70
 71## Rights
 72
 73**Traditional models only.** Origami models designed in the modern era are
 74the intellectual property of their designers, and diagramming someone
 75else's model without permission is both a legal problem and, in the origami
 76community, a serious breach. Every model here is traditional, long
 77predating any individual claim. Each model's `file_author` is
 78`"Traditional"` and the validator enforces it.
 79
 80**v1 ships four: the cup, the crane, the sampan and the box.** The box is
 81the masu. The sampan was chosen over the paper boat folded from a hat: it
 82starts from a square, its middle steps are plain folds, and its one hard
 83step — turning the model inside out — comes last, the same kind of 3D
 84opening as the masu's. The paper boat needs a rectangle and two collapses
 85mid-sequence. Published sampan sequences differ in their middle steps; the
 86one authored is recorded in `docs/authoring/sampan.md`. The frog base,
 87fish base, flapping bird and preliminary base are the same kind of thing
 88and come afterwards, cheaply, because the compiler will exist. Four is thin
 89for a first release but defensible; one is not, and eight is authoring work
 90better done once you know how the folding feels in the hand.
 91
 92A later release that includes designed models needs the designer's
 93permission, per model, in writing. That is a licensing project, not an
 94engineering one, and it is out of scope here.
 95
 96## Constraints
 97
 98- iOS 26, Swift 6, iPhone and iPad (`TARGETED_DEVICE_FAMILY = "1,2"`).
 99  iPad is the better device for this and the layout should assume it will
100  be used there.
101- XcodeGen `project.yml`, matching the layout of `krz/moonrise`.
102- Bundle prefix `sh.krz`, `DEVELOPMENT_TEAM = ZCNAX3VL9D`.
103- Geometry, format handling and notation generation live in a SwiftPM
104  package with no UIKit or SwiftUI dependency. The renderer may import
105  Metal and MetalKit.
106- 0BSD, origin on gitbay.org.
107- No third-party runtime dependencies in the app. Authoring tooling may
108  depend on whatever is convenient; it does not ship.
109
110## The model format
111
112Models are **FOLD** files — the JSON format from Demaine, Ku and Lang
113(2016), spec v1.2 at `github.com/edemaine/fold`, `doc/spec.md`,
114MIT-licensed.
115
116Keys used from the standard:
117
118| Key | Use |
119|---|---|
120| `file_spec` | `1.2` |
121| `file_creator` | `"foldc"` |
122| `file_title`, `file_author` | the model's name; `"Traditional"` |
123| `file_classes` | `["singleModel", "diagrams"]` |
124| `vertices_coords` | 3D vertex positions in the folded state of that frame; 2-element entries mean z = 0 |
125| `edges_vertices` | `[u, v]` endpoints, defining edge orientation |
126| `edges_assignment` | `B` boundary, `M` mountain, `V` valley, `F` flat, `U` unassigned; `C` and `J` are rejected |
127| `edges_foldAngle` | degrees in [−180, 180]; positive for valley, negative for mountain, 0 for `F`, `U` and `B`. The sign must match `edges_assignment`, as the spec requires, and the validator checks it |
128| `faces_vertices` | vertex IDs counterclockwise; the order defines the face's normal |
129| `faceOrders` | `[f, g, s]` triples; `s = +1` means `f` is above `g`, on the side `g`'s normal points toward in the folded state; `s = -1` below; `s = 0` unknown |
130| `file_frames` | frames 1…N (see *Frames and step numbering*) |
131| `frame_parent`, `frame_inherit` | `0` and `true` on every frame in `file_frames` |
132
133Because `s` is relative to `g`'s normal, two triples can only be compared
134after normalising each by its faces' normals in that frame: `[f, g, +1]`
135with `[g, f, +1]` is consistent when the faces face opposite ways. Cycle
136detection and every other order check normalise first.
137
138Two places are stricter than the spec. It allows `faceOrders` cycles (a
139square twist has one); the validator rejects them, and no traditional model
140in scope needs one. It recommends `J` edges to split faces that overlap in
141several regions or are nonconvex; `J` is rejected and faces must be convex.
142A crease that ends inside the sheet (a pinch) leaves a nonconvex face around
143its end, which is split by a **subdivision edge**: assigned `F`, flat in
144every frame, creased by no step (no step moves its two faces differently), with no `edges_krz:firstCreasedAtStep`, and never drawn.
145
146### Frames and step numbering
147
148FOLD's top-level frame properties describe the **key frame**, frame 0, and
149`file_frames[i]` is frame `i + 1`.
150
151- Frame 0 is the unfolded sheet.
152- **Step n**, counting from 1, takes frame n − 1 to frame n, and its record
153  is frame n's `krz:step`. A model with N steps has N + 1 frames.
154- Every index this project calls a step — in `krz:step`,
155  `edges_krz:firstCreasedAtStep`, the validator's defects, `FoldStep.index`
156  and the UI's "Step n" — is this n. The only zero-based indices are array
157  subscripts.
158- Every frame in `file_frames` carries `frame_parent: 0` and
159  `frame_inherit: true`, so tools that implement FOLD's frame inheritance
160  see the shared topology. Each frame overrides `vertices_coords`,
161  `edges_assignment`, `edges_foldAngle` and `faceOrders`, and never
162  `edges_vertices` or `faces_vertices`.
163
164### One topology, every frame
165
166**Frame 0 is the sheet already subdivided by every crease the whole
167sequence will ever use**, with the not-yet-folded ones carrying
168`edges_foldAngle` 0 and assignment `F`. Every frame therefore shares one
169`vertices_coords` length, one `edges_vertices` and one `faces_vertices`;
170only coordinates, fold angles, assignments and `faceOrders` differ between
171frames.
172
173This is what makes interpolation possible: vertex *i* in frame *k* and
174vertex *i* in frame *k+1* are the same point of paper, so rotating the
175moving facets carries one frame to the next. Without it there is no vertex
176correspondence between frames and nothing to interpolate. The validator
177enforces it.
178
179A crease that runs through several layers of a folded state is several
180edges, one per layer, coincident in space. A step that folds through those
181layers changes all of them; its axis names one.
182
183The cost of a shared topology is that a crease the reader has not met yet
184exists in the data from the start, so the diagram generator needs to know
185when each crease first becomes visible. FOLD has no key for that, so the
186models carry one.
187
188### Extension keys
189
190FOLD reserves keys without a colon. These are this app's, under `krz:`:
191
192| Key | Where | Use |
193|---|---|---|
194| `edges_krz:firstCreasedAtStep` | key frame, inherited | per edge, the step n at which the crease is first made; `null` for a boundary |
195| `krz:step` | frames 1…N | the step that produced this frame (below) |
196| `krz:faceOrders_midFold` | frames 1…N | layer order to use while this step is in motion; required when the step's moving sets overlap in projection, and on every `foldAndUnfold`, where it holds the order at the peak |
197
198The edge key follows the spec's own example, `edges_tm:structuralType`, so
199FOLD tools that select edge properties by the `edges_` prefix treat it as
200edge data and renumber it with the edges.
201
202Extension keys mean other FOLD tools ignore part of the data. FOLD is still
203the right choice for the geometry: it is a published spec with a careful
204layer-order model, and reinventing that would be worse than extending it.
205
206### Steps are authored, not derived
207
208The app does not derive a step's crease axes and moving facets by diffing
209consecutive frames. That would be an algorithm with real ambiguities —
210which side of the crease moved, whether a whole-model reorientation is a
211fold, how to partition several simultaneous axes — inferring something the
212author already knows.
213
214Each frame's `krz:step` carries it explicitly:
215
216```
217{ "kind": "fold" | "foldAndUnfold" | "turnOver" | "rotate",
218  "technique": "plain" | "insideReverse" | "outsideReverse"
219             | "squash" | "petal" | "sink",
220  "instruction": "Valley fold the right corner to the left edge.",
221  "axes": [ { "edge": 17, "movingFaces": [3, 4, 5],
222              "startAngle": 0, "endAngle": 180, "peakAngle": null,
223              "parent": null, "window": [0, 1], "angles": null } ],
224  "rotateDegrees": 90,
225  "turnOverAxis": "vertical" | "horizontal",
226  "repeatOf": 4,
227  "nonRigid": false,
228  "pop": null,
229  "viewpoint": { "eye": [0, 0, 1], "up": [0, 1, 0] } }
230```
231
232- `axes`: the angles are the axis edge's `edges_foldAngle` at the start,
233  at the end, and — for `foldAndUnfold` only — at the turning point.
234  `parent` is the index of the axis whose motion carries this one,
235  `window` its span of *t*, and `angles` a solved curve (see
236  *Interpolation*); `foldc` writes all three.
237- `nonRigid` and `pop`: the step has no rigid motion and opens, pops and
238  closes (see *Interpolation*). Reverse folds and sinks. `pop` holds the
239  flap's spine, the angle it opens to, the two phase boundaries on *t*, the
240  opening axes, the popped pose and the closing axes; `foldc` writes it.
241- `technique`: drives the notation and the instruction's wording; geometry
242  ignores it. `plain` for anything that is not a named technique.
243- `instruction`: the step in words, written by the author in the fold
244  script. It is the paper view's accessibility label and the diagram's
245  caption. It is authored because a generator cannot know that a vertex is
246  "the right corner" or that a line is "the centre".
247- `rotateDegrees`: required for `rotate`; the rotation is about `eye`, so positive is counterclockwise as
248  seen from the viewpoint.
249- `turnOverAxis`: required for `turnOver`; the screen axis, as seen from the
250  viewpoint, the model turns about.
251- `repeatOf`: on a step expanded from a repeat, the step it repeats.
252- `viewpoint`: `eye` is the unit direction from the model toward the viewer
253  (the diagram is orthographic, so there is no eye position); `up` is
254  screen-up. Most steps use `[0, 0, 1]` and `[0, 1, 0]`.
255
256All of a step's axes share one parameter, so a petal fold or a reverse fold
257is one step with several axes and several moving sets, driven together.
258The traditional models need this. How those axes move together is set out
259in *Interpolation*.
260
261### Step kinds
262
263| Kind | Geometry | How it advances |
264|---|---|---|
265| `fold` | one or more axes, start → end angle | a drag, as below |
266| `foldAndUnfold` | axes go start → peak → start | a drag out and back |
267| `turnOver` | no crease; the model turns 180° about `turnOverAxis` | a one-finger horizontal drag across the model |
268| `rotate` | no crease; the model turns in plane by `rotateDegrees` | a one-finger horizontal drag across the model |
269
270`turnOver` and `rotate` are steps in `file_frames` like any other. Their
271end frame is the start frame rotated about the centre of its bounding box —
272the coordinates change and the camera does not. The diagram's viewpoint is
273fixed and the reader's mental model is of turning the paper over in their
274hands, so the **model** reorients, not the camera. Because the coordinates
275carry the orientation, nothing else has to track it.
276
277Repeats — "repeat steps 4–6 behind" — are **expanded into explicit steps**
278in the data, each with `repeatOf` naming the step it repeats. Each expanded
279step's diagram shows its own fold (a repeat done behind is drawn as the
280fold behind that it is) plus the repeat mark. A first-class repeat would
281save file size and cost correctness.
282
283## How it works
284
285### Interpolation
286
287Decided by measurement: `docs/decisions/0001-interpolation-model.md`.
288
289Between frame n − 1 and frame n, step n's axes form a tree. Each axis
290rotates its moving faces rigidly about its crease line, on one shared
291parameter *t* in 0...1, and carries its children with it:
292
293- The crease line is the axis edge's endpoints in frame n − 1.
294- The axis is directed the way the moving face adjacent to the edge
295  traverses it in `faces_vertices` order. A positive rotation about that
296  direction (right-hand rule) turns the moving face toward the side its
297  normal points to, which is a valley — so the rotation is
298  `angle(t) − startAngle`, with the sign FOLD already gives fold angles.
299- A face's transform is its axis's rotation followed by the parent axis's
300  transform, up the tree.
301- Each axis runs on its **window** `[t0, t1]` of *t*, waiting before it and
302  holding after it. Two flaps of equal reach folding toward each other on
303  one window collide at 120°. On separate windows they do not, and
304  `foldc`'s scripts stagger them.
305- `angle` is linear on the window for `fold`, and a tent through
306  `peakAngle` for `foldAndUnfold`, unless the axis has a **curve**.
307- Where the step's faces form loops around interior vertices, the angles
308  are coupled nonlinearly — at a flat-foldable degree-4 vertex with
309  consecutive sectors α, β, tan(ρ₁/2) = k·tan(ρ₂/2), k = cos((α+β)/2) /
310  cos((α−β)/2). Linear angles tear such a vertex by more than half the
311  sheet partway through. `foldc` holds one driving crease linear and solves
312  the rest so every loop closes. It writes each solved angle as a curve of
313  257 samples; cubic Hermite interpolation between them keeps the tear
314  under 1e-6.
315- `turnOver` and `rotate` rotate every vertex about the start frame's
316  bounding-box centre by *t* times the step's angle.
317
318**Non-rigid steps** (`docs/decisions/0002-non-rigid-steps.md`). An inside
319reverse fold has no rigid motion with the flap closed; the only rigid path
320unfolds the flap flat and refolds it, which on the crane would undo earlier
321steps on screen. Reverse folds and sinks are flagged `nonRigid` and move in
322three phases on *t*:
323
3241. **Open**, rigid: the flap opens on its spine to 20° from flat by default
325   (authored per step). Where the flap's near layers run on under another
326   flap, the whole near side turns about the spine's line, with bend lines
327   on that line (decision 0003).
3282. **Pop**: the tip passes from outside the flap to inside it, by
329   as-rigid-as-possible interpolation on a render mesh: frame 0's creases
330   plus lines every 1/32 of its longer side in each direction. The render
331   mesh is the renderer's; the FOLD topology is unchanged.
3323. **Close**, rigid: the flap closes on the reverse-fold branch, with solved
333   curves, and the tip lands between its layers.
334
335The isometry gate does not apply to the pop. The **bound** does: no
336render-mesh edge changes length by more than 10%. On a two-layer flap the
337pop measured 7.9% opened to 30° and 29% opened to 60°. That is one flap at
338one resolution; the crane's flaps are narrower and several layers deep, so
339each flagged step's strain is measured when it is authored. The
340interpenetration check applies to all three phases. A step is non-rigid
341because its script says so — a reverse fold or sink names the spine its
342flap opens on — not because a solver failed: with the flap closed the
343solver finds a rigid motion to the right coordinates with the wrong
344layering. The petal fold is rigid (it has solved curves) and is not
345flagged. The sampan's inversion and the masu's wall-raising are classified
346when they are authored, by `foldc`'s closure test together with the
347interpenetration check, the layer rules and a look in the app. If either
348has no rigid motion it needs a decision, since open, pop, close needs a
349spine to open on.
350
351### Layer ordering during a fold
352
353`faceOrders` is authored for every frame. While step n is in motion, the
354**active ordering** is `krz:faceOrders_midFold` if frame n has one, and
355otherwise frame n's `faceOrders`, applied from the moment the fold begins:
356a facet being folded over is above its destination for the whole motion,
357which is what the end frame's ordering says. A pair with no triple there
358takes frame n − 1's, which covers a flap leaving a stack. Each source is
359checked for cycles with the normals of the state it describes — the peak
360for a `foldAndUnfold`'s mid-fold order. A `foldAndUnfold`
361ends where it started, so neither end frame orders the moving faces against
362the faces they lie on at the peak; its `krz:faceOrders_midFold` is that
363order, computed by `foldc`.
364
365The orders themselves are checked in every frame by three consistency
366rules, on every stack of coincident faces: two faces joined at a crease
367folded to ±180 are ordered as its assignment requires; where two folded
368creases coincide, their face pairs nest rather than interleave; and a face
369whose interior crosses a folded crease's line does not lie between that
370crease's two faces. A guessed or overridden order that breaks one is
371impossible paper, even when no face collides with another — the
372interpenetration checker cannot see that, because a wrongly ordered flap
373moves through exactly the same coordinates.
374
375Two rules make this safe rather than merely convenient:
376
3771. The validator requires frame n − 1's and frame n's orderings to agree on
378   every pair **not involving a moving facet**. A step where this
379   simplification would be visible in the still part of the model fails
380   authoring.
3812. When a step's moving sets overlap in projection, such a step **must**
382   carry `krz:faceOrders_midFold`, and the validator rejects it if it does
383   not. Decision 0001 found that the problem this was meant to prevent, two
384   flaps passing through each other, is a collision. Ordering cannot fix a
385   collision; staggered windows on *t* do. It found no case left for the
386   rule, and removing it is an open decision.
387
388When a traditional model has a step that cannot satisfy these, the fix is
389to split the step into sub-steps until it can. Dropping the model is the
390last resort and needs a decision, not a shrug.
391
392### Rendering
393
394Metal, with a small renderer written for this: the geometry is a render
395mesh of a few thousand triangles (see *Non-rigid steps*), and both SceneKit
396(deprecated) and
397RealityKit (whose dynamic-mesh support is more than this needs) would
398contribute more risk than they remove.
399
400Depth handling is **hybrid**. `faceOrders` is defined only for faces that
401overlap geometrically; it says nothing about facets separated in 3D, which
402is most of a folded model. Depth testing off everywhere is right for a
403coplanar stack and wrong for the rest. So:
404
405- Two faces are linked when they overlap in projection, their normals are
406  within 2° of each other's line, and each one's vertices lie within
407  sin 2° × the model's bounding-box diagonal of the other's plane. A **cluster** is a
408  connected group of linked faces. The tolerance is wide on purpose: a facet just leaving or just arriving on a
409  stack is nearly coplanar with it, and the depth buffer alone would
410  z-fight there.
411- The depth buffer resolves clusters separated in space.
412- Within a cluster, faces are drawn back-to-front by the active ordering,
413  with depth test on (less-or-equal) and depth writes off; then the
414  cluster's faces are drawn again depth-only, colour writes off, so that
415  clusters drawn later are hidden behind it. Without the second pass a
416  cluster writes no depth and anything drawn after it draws over it.
417- The `s` sign is evaluated **against the current view direction**, using
418  `g`'s current normal, because "above" in FOLD means "on the side `g`'s
419  normal points toward", that reverses when you orbit underneath the model,
420  and a moving stack's normals turn with it.
421
422Facets are drawn two-sided — paper has a coloured side and a white side,
423and which side you are seeing is information.
424
425### The diagram
426
427The diagram for step n draws **frame n − 1** — the paper before the step,
428as a printed diagram does — orthographically from step n's `viewpoint`,
429with step n's creases and arrows on it. The diagram does **not** rotate when
430you orbit the model; the model view orbits and the diagram stays put,
431because a diagram is a fixed drawing and orbiting it would make it
432something else.
433
434Edges:
435
436- `B` edges, and creases folded in frame n − 1 (fold angle not 0): solid,
437  as the outline of the folded shape.
438- creases made in an earlier step and flat again in frame n − 1 (fold
439  angle 0, `edges_krz:firstCreasedAtStep` < n): solid, lighter.
440- step n's crease, including every edge coincident with an axis: dashed
441  for a valley, dash-dot for a mountain, **as seen from the viewpoint**.
442  The axis turns the moving face toward its own normal when its angle
443  increases, so the fold is a valley as seen when the sign of the turn
444  (end − start, or peak − start for `foldAndUnfold`) times the sign of the
445  moving face's normal · `eye` is positive. FOLD's assignment cannot be
446  used here: it is relative to each face's own normal, so on a flipped
447  layer or after a turn-over it names the opposite fold, and coincident
448  edges on different layers disagree.
449- creases whose `edges_krz:firstCreasedAtStep` is later than n, and
450  subdivision edges: not drawn.
451
452Arrows and symbols:
453
454- `plain` folds: one fold arrow per axis, curving from the moving facet
455  across the crease to its destination — the valley-fold arrow for a
456  valley as seen, the mountain-fold ("fold behind") arrow for a mountain.
457- `foldAndUnfold`: the fold-and-unfold arrow.
458- the named techniques (`insideReverse`, `outsideReverse`, `squash`,
459  `petal`, `sink`): the arrows the reference prescribes for that technique
460  (the push arrow for a reverse fold or sink, for example), not one fold
461  arrow per axis. The glyph for each is chosen from the reference below and
462  the choice recorded beside the snapshots.
463- the turn-over and rotate symbols for those kinds.
464- the repeat mark on a step with `repeatOf`.
465
466**Edges occluded by layers above them are omitted.** Yoshizawa–Randlett
467diagrams distinguish what you can see from what you cannot, and drawing a
468hidden crease as though it were visible is the "nearly right notation"
469failure. This means clipping each edge against the union of the faces
470`faceOrders` puts above either of its incident faces, from the diagram's
471viewpoint — the union, so that
472an edge under the seam between two adjacent upper faces is hidden — a real
473algorithm with its own tests, and in scope.
474
475### Gesture
476
477- Drag on the paper during a `fold`: drives *t*. The app samples the
478  screen path of the first moving set's centroid from *t* = 0 to 1 and
479  sets *t* to the point on that path nearest the centroid's screen
480  position when grabbed plus the drag's translation, searched outward from the current *t* so the
481  parameter cannot jump. The facet follows the finger wherever you grab it.
482  When the path is under 8 points long — travel nearly along the view
483  direction — the mapping is degenerate and falls back to a vertical drag
484  over a fixed 160-point throw.
485- `foldAndUnfold`: the same mapping over the outbound half of the path
486  (*t* 0 → 0.5), then over the return half (*t* 0.5 → 1) once the peak is
487  reached.
488- One-finger horizontal drag across the model: drives *t* for a `turnOver`
489  or `rotate` step, as the drag's distance over the model's on-screen
490  width. A flick does not complete it.
491- Two-finger drag: orbit. Pinch: zoom.
492- Only the gesture for the current step's kind is live.
493- The fold parameter is never advanced by the app. The step completes when
494  *t* reaches 1 and the finger lifts. Releasing earlier leaves the paper
495  where it is.
496
497## Authoring
498
499**Authoring is the project's main risk.**
500
501Existing FOLD tools — Oriedita, Rabbit Ear, Origami Simulator — author a
502single crease pattern. None of them produces a multi-frame sequence with
503per-frame folded coordinates, per-frame layer order, and per-step moving
504sets. Authoring in existing tools and validating with a CLI would in
505practice mean hand-writing hundreds of geometrically exact numbers per
506frame, per model. The engine can be finished and correct and still have
507nothing to show.
508
509So the tooling is part of the project. A command-line tool, `foldc`, macOS
510only, never shipped in the app, takes
511
512- a crease pattern (a FOLD file, exportable from existing tools), and
513- a fold script: an ordered list of steps, each naming its kind and
514  technique, its instruction text, its creases (by the points they run
515  between), its moving side (by a point inside it), and where they differ
516  from the defaults: fold angles, the turning-point angle of a fold and
517  unfold, the turn-over axis, the rotation, the step it repeats, the
518  viewpoint, **layer-order overrides** and the mid-fold order,
519
520and **computes** every frame: the folded coordinates by applying each
521step's rotations in order, the edges each crease covers in every layer,
522`edges_krz:firstCreasedAtStep`, and a first guess at `faceOrders` from the
523fold order, with the script's overrides applied on top. It validates as it
524goes and reports the first step that fails.
525
526Layer-order corrections live **in the script**, never in the generated
527file. A shipped `.fold` must regenerate exactly from its script and crease
528pattern, so an edit to the output would be lost on the next compile — and
529a test compares the two.
530
531That is the difference between a model being weeks of arithmetic and a
532model being an afternoon. It is also ordinary geometry code, not research.
533
534### Why there is no version of this without the compiler
535
536**The numbers are not choosable.** For the crane — roughly 35 creases
537subdividing the square into 40–60 faces, over 15–20 steps — a model file
538holds on the order of 4,000 numbers, and almost every one is the image of a
539point on the square under a specific composition of rotations. Each has one
540correct value to full precision, and the isometry check catches a 1e-6
541error. These are computed, never typed.
542
543**"Hand-authoring" is the compiler with the reusable parts removed.** To
544produce those coordinates by hand you would write a script that applies the
545rotations and prints JSON — which is the compiler, in a file you throw
546away. What `foldc` adds beyond that is crease resolution by endpoint,
547moving-set resolution by contained point, multi-layer crease resolution,
548`edges_krz:firstCreasedAtStep` assignment, the layer-order guess and
549overrides, and per-frame validation. Roughly a third of the task, and the
550third that makes every model after the first cheap.
551
552**Model-level tests need the same precision.** Assertions about the cup,
553crane, sampan and box need the same exact coordinates as a shipped model, so
554they run on compiled models and live with the catalogue (Tasks 8 and 15).
555The unit tests written before the compiler exists use small synthetic
556sheets whose folded coordinates are integers or halves and can be typed
557exactly — a fold in half, a letter fold, a sheet folded in quarters — and
558the compiler's own tests check that it reproduces those fixtures.
559
560### The cup first, the crane last
561
562The first model compiled is **the cup**: six steps — five folds of one
563axis each and a turn-over — no reverse folds, six layers where the two corner flaps cross and
564eight in the centre once both top flaps are down. It exercises the entire chain — script, compile,
565validate, interpolate, diagram, render, fold under a finger — without
566exercising any of the hard parts at the same time. The version authored
567folds the top flaps down, the front one in front and the back one after the
568turn-over; it does not tuck them into the pocket, which inserts a flap
569between layers. Opening the cup into 3D at the end is not a step.
570
571The crane is **last** of the four, as the model that proves multi-axis
572steps and deep layer ordering work. Debugging a new compiler against the
573hardest traditional model, with its petal folds and eight-deep wing stacks,
574would confuse tool bugs with authoring mistakes.
575
576### Where the effort goes once the chain works
577
578Per model: export a crease pattern, write a short script, compile, then
579**correct the guessed layer orders** with overrides in the script. The
580guess — a folded flap lands on the side of the stack it arrived from — is
581right most of the time and wrong in exactly the interesting places, because
582a reverse fold or a tuck puts a flap *between* existing layers and the
583guess gets that backwards every time. The validator's layer-order rules and
584the interpenetration checker are what make the correction loop tractable:
585between them they name the pair, the step and, for a collision, the point
586in the fold. Reckon on an afternoon per model, and longer for the first.
587
588## What's left to the builder
589
590- Line weights and dash patterns for the diagram, within the notation's
591  requirements.
592- Paper colour, back colour, and the lighting model. Flat shading with a
593  single directional term is probably right; paper is not shiny.
594- How tightly the model is framed, given the authored viewpoint.
595- Whether the step list is a visible strip or revealed on demand.
596- The fold script's surface syntax beyond the JSON form the plan defines.
597
598## Evidence the quality bars are met
599
600The headline bars get mechanical checks rather than judgement:
601
602- **No interpenetration.** The catalogue test samples each step's fold
603  parameter and tests facet-facet intersection at each sample, across every
604  model. This is the only way the claim survives four models, then eight,
605  and later edits.
606- **No impossible layering.** The validator checks every frame's orders
607  against the crease, nesting and inside rules (*Layer ordering during a
608  fold*).
609- **No stretching.** The catalogue test samples every rigid step of every
610  model and checks every edge length against frame 0. Flagged steps are
611  held to the 10% bound on the render mesh instead.
612- **Correct notation.** The diagram generator is covered by golden-image
613  snapshot tests. The reference is Randlett's own conventions as set out in
614  *The Art of Origami* (1961) and the symbol set as summarised by
615  OrigamiUSA; where the two differ, OrigamiUSA's is used, and the choice is
616  recorded next to the snapshots.
617
618## Open decisions for the author
619
6201. **Name.** "Fold" is not going to be available. The repo and bundle ID
621   use `fold` / `sh.krz.fold` as working names.
6222. **Authoring tooling, and how many models.** Settled: build the
623   compiler, cup first, four models for v1. The plan is 18 tasks: two
624   interpolation spikes (Tasks 0 and 0b), the engine, non-rigid steps (7b), the compiler, the app and the
625   cup, then the crane, sampan and box as one gated authoring task.
6263. **The interpolation model for coupled steps.** Settled (decisions 0001
627   and 0002): an axis tree with windows and solved curves for rigid steps,
628   including the petal fold; open, pop, close for reverse folds and sinks,
629   opened to 20° by default (decision 0003), held to 10% strain.
6304. **Which boat.** Settled: the sampan (see *Rights*).
6315. **The overlapping-moving-sets rule.** Decision 0001 found no case it
632   covers that staggered windows and the near-coplanar clusters do not.
633   Removing it is open.