stack3js 0.2.0 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/COMMAND.md +147 -0
  2. package/README.md +171 -4
  3. package/bin/stack3.mjs +1445 -186
  4. package/blender/import_stack.py +89 -0
  5. package/meshing/blocks.py +82 -0
  6. package/meshing/branches.py +62 -0
  7. package/meshing/dexel.py +67 -0
  8. package/meshing/field_data.py +19 -0
  9. package/meshing/finish_blender.py +203 -0
  10. package/meshing/finishing.py +155 -0
  11. package/meshing/geometry.py +71 -0
  12. package/meshing/guided.py +150 -0
  13. package/meshing/implicit.py +178 -0
  14. package/meshing/intersection.py +33 -0
  15. package/meshing/material.py +115 -0
  16. package/meshing/mesh.py +103 -0
  17. package/meshing/network.py +136 -0
  18. package/meshing/regularization.py +213 -0
  19. package/meshing/sections.py +165 -0
  20. package/meshing/signed_distance.py +93 -0
  21. package/package.json +9 -2
  22. package/references/hard-surface/README.md +40 -0
  23. package/references/hard-surface/atlas/concrete-barrier-4view.png +0 -0
  24. package/references/hard-surface/atlas/preview.pipeline.yaml +14 -0
  25. package/references/hard-surface/case-studies/benchmark/README.md +22 -0
  26. package/references/hard-surface/case-studies/benchmark/lod-bevel.pipeline.yaml +258 -0
  27. package/references/hard-surface/finishing/exports.yaml +10 -0
  28. package/references/hard-surface/finishing/finish-lod.pipeline.yaml +33 -0
  29. package/references/hard-surface/finishing/inputs/stack/stack.json +1 -0
  30. package/references/hard-surface/finishing/inputs/stack/stack.png +0 -0
  31. package/references/hard-surface/finishing/regularize.pipeline.yaml +46 -0
  32. package/references/hard-surface/measured-depth/sdf/compare.pipeline.yaml +12 -0
  33. package/references/hard-surface/measured-depth/sdf/inputs/field.npy +0 -0
  34. package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.json +1 -0
  35. package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.png +0 -0
  36. package/references/hard-surface/measured-depth/sdf/inputs/truth.json +1 -0
  37. package/references/hard-surface/measured-depth/sdf/sdf.guide.json +3 -0
  38. package/references/hard-surface/measured-depth/triple-dexel/compare.pipeline.yaml +12 -0
  39. package/references/hard-surface/measured-depth/triple-dexel/dexel.guide.json +3 -0
  40. package/references/hard-surface/measured-depth/triple-dexel/inputs/fixture.json +22 -0
  41. package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.json +22 -0
  42. package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.png +0 -0
  43. package/references/hard-surface/measured-depth/triple-dexel/inputs/triple-dexel.npz +0 -0
  44. package/references/hard-surface/schema/pipeline-fragment.schema.json +5 -0
  45. package/references/hard-surface/schema/pipeline.schema.json +181 -0
  46. package/schema/pipeline-fragment.schema.json +5 -0
  47. package/schema/pipeline.schema.json +181 -0
  48. package/verification/acceptance.py +85 -0
  49. package/verification/assembly.py +96 -0
  50. package/verification/landmarks.py +53 -0
  51. package/verification/panels.py +147 -0
  52. package/verification/projections.py +135 -0
  53. package/verification/verify.py +115 -0
  54. package/viewer/dist/assets/{GLTFExporter--hziUXc8.js → GLTFExporter-xdVCArY-.js} +1 -1
  55. package/viewer/dist/assets/compare-Du4RoRQO.js +6 -0
  56. package/viewer/dist/assets/compare.worker-CgJq-znx.js +21 -0
  57. package/viewer/dist/assets/presets-jXE0t1fU.js +1 -0
  58. package/viewer/dist/assets/preview-cache-BKV0EZl9.js +1 -0
  59. package/viewer/dist/assets/project-DtHHhfo-.js +17 -0
  60. package/viewer/dist/assets/reconstruct.worker-ONc9GyFO.js +21 -0
  61. package/viewer/dist/assets/{script-engine-CLj7QMLe.js → script-engine-Bs3azDYZ.js} +1 -1
  62. package/viewer/dist/assets/style-D6eZHs3D.js +4004 -0
  63. package/viewer/dist/assets/viewer-DIjS0No7.js +2 -0
  64. package/viewer/dist/compare.html +4 -4
  65. package/viewer/dist/index.html +9 -8
  66. package/viewer/dist/project.html +3 -3
  67. package/viewer/dist/assets/compare-DJ8rV3Rn.js +0 -6
  68. package/viewer/dist/assets/compare.worker-DK2lJl0n.js +0 -21
  69. package/viewer/dist/assets/presets-DwdZVYhs.js +0 -1
  70. package/viewer/dist/assets/preview-cache-DRF_H5pq.js +0 -58
  71. package/viewer/dist/assets/project-D8tR6U-_.js +0 -17
  72. package/viewer/dist/assets/reconstruct.worker-Cf8iZwT3.js +0 -21
  73. package/viewer/dist/assets/style-CWGgpweN.js +0 -3947
  74. package/viewer/dist/assets/viewer-CyGodHLY.js +0 -2
package/COMMAND.md ADDED
@@ -0,0 +1,147 @@
1
+ # stack3 command reference
2
+
3
+ Generated from the CLI when packaging. Recipe paths are relative to this document.
4
+
5
+ ## CLI help
6
+
7
+ ```text
8
+ Usage: stack3 <verb> <input> [options]
9
+
10
+ help [topic] Show command help (pipeline, mesh, or capabilities)
11
+ capabilities [--json] List mesh methods, runtime requirements, schemas and example recipes
12
+ example <name> Copy future-tank or traffic-cone into the current directory
13
+ verify -f <manifest> Measure atlas views and mounts in one JSON report
14
+ inspect <input> Check mapped directions and fitted image sizes
15
+ build <input> Build an asset and save it to --output
16
+ pipeline --help Render or run YAML, or export its JSON Schema
17
+ mesh <stack-directory> Extract a surface from saved stack.png + stack.json (--output mesh.glb)
18
+ --mesh-method marching-cubes (default), surface-nets, voxel
19
+ or section-loft, heightfield, smooth-loft, revolve, extended-mc, hermite-dc, mc33, branch-loft, path-sweep, section-network, greedy, monotone, signed-distance-dc
20
+ --guide <part.json> uses pivot-relative stack XYZ scene units.
21
+ section-loft, smooth-loft, branch-loft, heightfield: optional axis (x/y/z, default z)
22
+ section-loft, smooth-loft: optional stations [{slice,outer?,holes?}]
23
+ revolve: axis + origin, optional segments (8-512, default 64)
24
+ path-sweep: path; optional up and profile {outer,holes?} (defaults to first stack section)
25
+ section-network: sections [{source:"independent",origin,u,v,outer,holes?}], optional tolerance
26
+ hermite-dc: optional field (.npy SDF) or dexel (.npz crossings and normals)
27
+ signed-distance-dc: optional field, outerIterations and innerIterations
28
+ extended-mc, mc33, greedy, monotone: no guide
29
+ New methods use uv or STACK3_PYTHON. See the stack3 skill for guide examples.
30
+ view <directory> Open a stack bundle in Blender (use --web for the browser viewer)
31
+ --output scene.blend saves a named scene; add --no-open for headless export
32
+ --no-open alone prints the web preview URL
33
+ project --help Edit a level and control its live viewer and playground
34
+
35
+ Inputs
36
+ PNG atlas Supply --layout top,left,front,rear (add right,bottom for six views)
37
+ JSON manifest Map directions to separate PNG paths under "views"
38
+
39
+ Build options
40
+ --format glb|stack Write a GLB file or a directory with stack.png and stack.json
41
+ Can be omitted when --output ends in .glb
42
+ --output <path> Required output path
43
+ --texture-projection <name> auto (default) or top-contour for GLB output
44
+ --mesh-method <name> marching-cubes (default) or contour for GLB output
45
+ --contour-hub Add a centered round axle measured from TOP and LEFT
46
+ --layers <integer|native> Vertical samples (default 128)
47
+ --spacing <number> Sprite stack spacing multiplier (default 1)
48
+ --profile <name> silhouette, round, or round-base
49
+ --verification <file> Require a matching atlas PASS report before building
50
+ --no-cache Bypass the local build cache
51
+ --resolution <integer|native> Longer horizontal axis samples (default 96)
52
+ --height <number> Asset height in scene units (default 1)
53
+ --pivot ground|center Origin position (default ground)
54
+ --threshold <0–255> Background threshold for opaque PNGs (default 238)
55
+ ```
56
+
57
+ ## Verification
58
+
59
+ ```text
60
+ stack3 verify -f <manifest.yaml> [--output-dir <dir>]
61
+ Print one JSON measurement report to stdout.
62
+ Atlas: projections and landmarks. Assembly: whole and part atlases plus mount measurements.
63
+ A full atlas run reports an acceptance verdict. Use --output-dir to prepare a report for build --verification.
64
+ --output-dir <dir> Also save report.json and annotated PNG overlays
65
+ -f, --file Image and child manifest paths are relative to their YAML file.
66
+ ```
67
+
68
+ ## YAML pipelines
69
+
70
+ ```text
71
+ Usage: stack3 pipeline <render|run> <pipeline.yaml> [-f <values.yaml> ...]
72
+ stack3 pipeline schema [recipe|fragment]
73
+ render Resolve includes and values, then print the validated pipeline YAML.
74
+ run Execute the same resolved pipeline and write its GLB outputs.
75
+ schema Print a standalone JSON Schema. The default is recipe.
76
+ -f, --values Override defaults in order. The last file takes precedence.
77
+
78
+ Nodes: load-stack, reconstruct-stack, extract-mesh, write-glb.
79
+ Run stack3 capabilities --json for backends, guide fields and sample paths.
80
+ ```
81
+
82
+ ## Pipeline capabilities
83
+
84
+ ```text
85
+ Usage: stack3 capabilities [--json]
86
+ List pipeline nodes, mesh methods, backends, schemas and runnable samples.
87
+
88
+ Pipeline nodes: load-stack, reconstruct-stack, extract-mesh, write-glb
89
+ Mesh methods: marching-cubes, surface-nets, voxel, section-loft, heightfield, smooth-loft, revolve, extended-mc, hermite-dc, mc33, branch-loft, path-sweep, section-network, greedy, monotone, signed-distance-dc
90
+
91
+ Geometry and export stages
92
+ Voxel Reconstruction (node) reconstruct-stack, load-stack
93
+ SDF and Normal Estimation (python) hermite-dc, signed-distance-dc
94
+ Triple-Dexel Hermite Data (python) guide.dexel, hermite-dc
95
+ Feature Segmentation and Plane Fitting (python) fitTolerance
96
+ Primitive Fitting (python) fitTolerance, primitives
97
+ Feature Boundary Stitching (python) fitTolerance
98
+ Guided Geometry Regularization (python) regularization.tolerance, regularization.features, regularization.relations
99
+ Procedural Bevel (blender) bevelWidth, bevelSegments
100
+ Selective Rim Bevel after QEM (blender) lodBevel.preTriangleBudget, lodBevel.rims, triangleBudget, bevelWidth, bevelSegments
101
+ Mesh Optimization and LOD (blender) dissolveAngle, triangleBudget
102
+ Multi-view Texture Projection (node or python) extract-mesh
103
+ Weighted Normals (python) extract-mesh, finish
104
+ Ambient Occlusion (blender) aoRadius
105
+ GLB Export and GPU Instancing (node) write-glb, lit, instances
106
+
107
+ JSON Schemas
108
+ stack3 pipeline schema recipe
109
+ stack3 pipeline schema fragment
110
+
111
+ Bundled recipes
112
+ atlas-preview (node)
113
+ references/hard-surface/atlas/preview.pipeline.yaml
114
+ finish-lod (node, python, blender)
115
+ references/hard-surface/finishing/finish-lod.pipeline.yaml
116
+ guided-regularization (node, python)
117
+ references/hard-surface/finishing/regularize.pipeline.yaml
118
+ benchmark-beveled-lod (node, python, blender)
119
+ references/hard-surface/case-studies/benchmark/lod-bevel.pipeline.yaml
120
+ triple-dexel (node, python)
121
+ references/hard-surface/measured-depth/triple-dexel/compare.pipeline.yaml
122
+ signed-distance (node, python, gpytoolbox)
123
+ references/hard-surface/measured-depth/sdf/compare.pipeline.yaml
124
+ ```
125
+
126
+ ## Scene projects
127
+
128
+ ```text
129
+ Usage: stack3 project <verb> [project-file] [options]
130
+
131
+ schema List agent actions and field constraints as JSON
132
+ components [component-id] List built-in script components or inspect one
133
+ init <file> [--name <name>] Create a level project
134
+ get <file> Read JSON hierarchy, settings, and current view state
135
+ import <file> <atlas.png>... Embed PNGs and add a scene object for each
136
+ [--layout top,left,front,rear] Direction order shared by inputs in this command
137
+ [--parent <node-id>] Place the new objects under an existing node
138
+ apply <file> <actions.json|-> Apply an atomic JSON action batch or read it from stdin
139
+ [--revision <number>] Require this revision before applying changes
140
+ preset <file> four-wheel <root-id> Attach WASD Vehicle and four Sprite Stack Wheel components
141
+ [--wheels <fl,fr,rl,rr>] Specify wheel IDs in front-left, front-right, rear-left, rear-right order
142
+ [--revision <number>] Require this revision before applying changes
143
+ preset <file> tracked-tank <root-id> Attach Tracked Drive, Turret Control, and both Track Belt components
144
+ open <file> [--no-open] [--playground] Open the live editor or interactive play view
145
+ export <file> <node-id> --output <path> Export one object's asset with its reconstruction settings
146
+ [--format stack|glb] Overrides the object's output format
147
+ ```
package/README.md CHANGED
@@ -17,11 +17,17 @@ The command grammar is `stack3 <verb> <input> [options]`. Choose the output with
17
17
 
18
18
  | Command | Purpose |
19
19
  | --- | --- |
20
+ | `stack3 help [pipeline\|mesh\|capabilities]` | Show usage and supported commands. |
21
+ | `stack3 capabilities --json` | Inspect methods, guide fields, backends, pipeline nodes, schemas and bundled samples. |
20
22
  | `stack3 example <name>` | Copy the bundled `future-tank` project or `traffic-cone` atlas. Use `--output` to choose a destination. |
21
23
  | `stack3 inspect <input>` | Report mapped and missing directions, image dimensions, and input warnings. |
22
24
  | `stack3 build <input> --output <file.glb>` | Reconstruct a mesh and write a GLB. |
23
25
  | `stack3 build <input> --format stack --output <directory>` | Reconstruct a runtime stack and write its slice data and metadata. |
24
- | `stack3 view <directory>` | Open an exported stack in the local viewer. Add `--no-open` to print the URL without opening a tab. |
26
+ | `stack3 mesh <stack-directory> --output <file.glb>` | Reopen a saved stack and extract a surface from slice alpha (≥128). Use the default `marching-cubes`, another baseline (`surface-nets` or `voxel`), or a part-specific extractor. Run `stack3 mesh --help` for method names and `--guide <part.json>` inputs. Part-specific extractors use uv or a configured `STACK3_PYTHON`. See the [stack3 method and guide reference](https://github.com/ev3rlit/stack3.js/blob/main/skills/stack3/SKILL.md#choose-the-surface-method-per-part). Surface color comes from projections of the stored RGB. |
27
+ | `stack3 pipeline render <pipeline.yaml>` | Resolve includes and values into a validated, executable graph. |
28
+ | `stack3 pipeline run <pipeline.yaml>` | Execute the graph and write its GLB outputs. |
29
+ | `stack3 pipeline schema [recipe\|fragment]` | Print a standalone JSON Schema. Defaults to the root recipe schema. |
30
+ | `stack3 view <directory>` | Open an exported stack in Blender. Use `--output scene.blend` to keep a named scene, or add `--no-open` to that output for headless export. `--web` opens the web viewer; `--no-open` alone still prints its URL. |
25
31
 
26
32
  For an atlas, supply its reading order with `--layout`.
27
33
 
@@ -45,7 +51,7 @@ For individual images, pass a JSON manifest. Paths are relative to that manifest
45
51
 
46
52
  ```sh
47
53
  stack3 build crate-views.json --format stack --output crate-stack/
48
- stack3 view crate-stack/
54
+ stack3 view crate-stack/ --output crate.blend
49
55
  ```
50
56
 
51
57
  | Build option | Default | Effect |
@@ -53,16 +59,18 @@ stack3 view crate-stack/
53
59
  | `--texture-projection` | auto | For GLB output, use `top-contour` to project the TOP panel onto the upper surface while retaining elevation UVs on the walls |
54
60
  | `--mesh-method` | marching-cubes | Choose `contour` for a plate extruded from the FRONT alpha outline |
55
61
  | `--contour-hub` | off | Add a centered, turned hub to a contour mesh using TOP and LEFT |
56
- | `--layers` | 48 | Vertical samples |
62
+ | `--layers` | 128 | Vertical samples (integer ≥ 8 or `native`) |
57
63
  | `--spacing` | 1 | Multiply the gap between stack slices and the exported vertical bounds |
58
64
  | `--profile` | silhouette | Choose `round` or `round-base` to fit elliptical cross-sections |
59
- | `--resolution` | 96 | Samples on the longer horizontal axis, or radial segments for a contour hub |
65
+ | `--resolution` | 96 | Samples on the longer horizontal axis (integer ≥ 16 or `native`), or radial segments for a contour hub |
60
66
  | `--height` | 1 | Asset height in scene units |
61
67
  | `--pivot` | ground | Use the bottom or center as the origin |
62
68
  | `--threshold` | 238 | Background removal threshold for opaque PNGs |
63
69
 
64
70
  Contour extrusion preserves islands and through-holes. FRONT and REAR paint the caps and the other views paint the side walls. The plate uses the full depth unless a round hub is requested. For a hub, provide a solid center in FRONT, a thin blade edge with a projecting axle in TOP and a centered collar in LEFT. Vertical layer count applies to grid reconstruction.
65
71
 
72
+ `inspect` reports `nativeSamples` for X, Y, and Z from the fitted view images. For example, a taller elevation can supply detail above 128 layers. Use `--layers native` for the tallest fitted elevation and `--resolution native` for the pixel span on the longer horizontal axis (minimum 8 and 16 samples respectively). Numeric counts above the source detail are allowed and resample the images. Dense grids require memory proportional to width × depth × layers. Source PNG decoding separately checks 8,192 px per side and 16 MP per file. A generated stack sheet is checked against its manifest dimensions when reopened.
73
+
66
74
  The stack bundle contains `stack.png` and `stack.json`. Its metadata records the atlas layout, slice order, dimensions, spacing, scale, and pivot.
67
75
 
68
76
  Repeated builds reuse the local cache for matching input, format, and settings. Use `--no-cache` to bypass it or `STACK3_CACHE_DIR` to choose its location.
@@ -71,6 +79,145 @@ Repeated builds reuse the local cache for matching input, format, and settings.
71
79
 
72
80
  [CLI requirements and completion check](https://github.com/ev3rlit/stack3.js/blob/main/docs/cli/README.md)
73
81
 
82
+ ## YAML pipelines
83
+
84
+ Get supported backends and sample paths with `stack3 capabilities --json`. The bundled groups cover RGB atlas preview, mesh finishing with LOD and instancing, measured SDF, and Triple-Dexel. Copy a group to a writable workspace before creating outputs there.
85
+
86
+ Use the [pipeline JSON Schema](schema/pipeline.schema.json) for root and rendered recipes and the [fragment JSON Schema](schema/pipeline-fragment.schema.json) for files listed under `includes`. Both ship in the CLI package under `schema/`.
87
+
88
+ ```sh
89
+ stack3 pipeline schema > pipeline.schema.json
90
+ stack3 pipeline schema fragment > pipeline-fragment.schema.json
91
+ ```
92
+
93
+ With YAML Language Server, place this comment on the first line of the recipe and adjust the path to the schema.
94
+
95
+ ```yaml
96
+ # yaml-language-server: $schema=./schema/pipeline.schema.json
97
+ ```
98
+
99
+ The schema describes fields, types, ranges, node-specific options and supported value references. `pipeline render` also checks resolved values, node dependencies and output path collisions. Keys in a `-f` values file depend on the recipe, so the generic schema leaves its values mapping open.
100
+
101
+ Nodes refer to other nodes by ID. Put them all under `nodes` in one pipeline, or use `includes` for reusable fragments. Here `cab.pipeline.yaml` uses a saved stack for both preview and export.
102
+
103
+ ```yaml
104
+ version: 1
105
+ includes: [surfaces.yaml]
106
+ values:
107
+ stack: ./cab-stack
108
+ output: ./dist
109
+ precision: hermite-dc
110
+ nodes:
111
+ - id: source
112
+ type: load-stack
113
+ path: '{{ .Values.stack }}'
114
+ ```
115
+
116
+ `surfaces.yaml` contributes these nodes. `hermite-dc` uses the same Python environment as `stack3 mesh`.
117
+
118
+ ```yaml
119
+ nodes:
120
+ - { id: fast, type: extract-mesh, input: source, method: surface-nets }
121
+ - { id: precise, type: extract-mesh, input: source, method: '{{ .Values.precision }}' }
122
+ - { id: preview, type: write-glb, input: fast, path: '{{ .Values.output }}/preview.glb' }
123
+ - { id: export, type: write-glb, input: precise, path: '{{ .Values.output }}/cab.glb' }
124
+ ```
125
+
126
+ An optional `release.values.yaml` can set `output: ./release`. Multiple `-f` files override earlier values in order. Included defaults are applied before the including file's defaults. A quoted whole-field reference preserves the value's YAML type, so `layers: '{{ .Values.layers }}'` can resolve to an integer. References can also appear inside paths.
127
+
128
+ ```sh
129
+ stack3 pipeline render cab.pipeline.yaml -f release.values.yaml > cab.resolved.yaml
130
+ stack3 pipeline run cab.resolved.yaml
131
+ ```
132
+
133
+ Include paths are relative to the file declaring them. Node paths are relative to the root pipeline and become absolute in the rendered YAML, which can be run from another directory. `render` resolves and validates the graph without opening asset inputs or writing GLBs. `run` shares each node's result across its consumers. If a later node fails, outputs already written are kept.
134
+
135
+ To start from an atlas, use `type: reconstruct-stack` for `source`, set `path` to the PNG and `layout` to `top,left,front,rear`, or set `path` to a JSON view manifest. Optional fields are `layers`, `resolution`, `height`, `pivot`, `threshold`, and `profile`. Use `load-stack` to preserve edits to a saved stack. An `extract-mesh` node accepts the existing stack mesh methods and can take a `guide` path for part-specific methods.
136
+
137
+ ### Hard-surface finishing
138
+
139
+ Add `finish` to an extraction node to fit and optimize a closed surface. Fitting groups connected faces by normal direction, then fits supported planes and optionally spheres or cylinders. Shared vertices are solved together along patch boundaries. Vertices outside those groups follow the extractor. Finishing checks winding, edge incidence, components and Euler characteristic before returning new geometry. A failed topology-changing operation logs the reason and retains the preceding mesh.
140
+
141
+ From a source checkout, run the [concrete barrier recipe](../../examples/hard-surface.pipeline.yaml) to generate a Surface Nets preview, a finished Hermite DC model, a lower-budget GLB, a Carrera comparison and a row of GPU instances.
142
+
143
+ ```sh
144
+ npm run cli -- pipeline run examples/hard-surface.pipeline.yaml
145
+ ```
146
+
147
+ ```yaml
148
+ version: 1
149
+ values:
150
+ stack: ./housing-stack
151
+ bevel: 0.006
152
+ nodes:
153
+ - { id: source, type: load-stack, path: '{{ .Values.stack }}' }
154
+ - id: housing
155
+ type: extract-mesh
156
+ input: source
157
+ method: hermite-dc
158
+ cache: true
159
+ finish:
160
+ fitTolerance: 0.008
161
+ primitives: true
162
+ bevelWidth: '{{ .Values.bevel }}'
163
+ bevelSegments: 2
164
+ dissolveAngle: 0.5
165
+ triangleBudget: 500
166
+ aoRadius: 0.15
167
+ - { id: model, type: write-glb, input: housing, path: ./out/housing.glb, lit: true }
168
+ - { id: row, type: write-glb, input: housing, path: ./out/row.glb, lit: true, instances: [[0, 0, 0], [1.5, 0, 0]] }
169
+ - { id: carrera, type: extract-mesh, input: source, method: signed-distance-dc }
170
+ - { id: comparison, type: write-glb, input: carrera, path: ./out/signed-distance.glb }
171
+ ```
172
+
173
+ - `fitTolerance`, `bevelWidth` and `aoRadius` use scene units. Blender runs headless for bevel, planar dissolve, quadric simplification and AO. Use `BLENDER_BIN` to choose an executable. Each LOD is a GLB from a branch with its own `triangleBudget` target. Re-import or measure thin features at each target budget.
174
+ - Texture projection uses the saved RGB and runs after topology changes. Creases split the area-weighted vertex normals. AO is written as vertex color (`COLOR_0`). `lit: true` selects a diffuse PBR material. `instances` writes `EXT_mesh_gpu_instancing` with per-instance translations in glTF XYZ coordinates.
175
+ - `cache: true` reuses processed geometry across runs using the stack, settings, guide and external field contents. Omit it when comparing different Blender or Python builds. Multiple outputs consuming one node share its in-memory result.
176
+
177
+ ### Guided geometry regularization
178
+
179
+ Use `finish.regularization` to select measured features before optional bevel and QEM. The [regularization recipe](../../skills/stack3/references/hard-surface/finishing/regularize.pipeline.yaml) fits two planes, a bore wall and rim, and a polygonal pocket rim. It also optimizes a perpendicular relation. Regularization alone runs with the existing Python meshing environment.
180
+
181
+ Coordinates are pivot-relative stack XYZ scene units. The `tolerance` controls sample selection and fitting. Each `features` entry has a unique `id` and one of these types.
182
+
183
+ | Type | Fields | Operation |
184
+ | --- | --- | --- |
185
+ | `plane` | `bounds`, `normal` | Select a patch by its bounding box and normal hint, then fit an SVD plane. |
186
+ | `circle` | `center`, `axis`, `radius` | Select a rim from a center and radius hint. Fit its center and radius in the plane perpendicular to the supplied axis. |
187
+ | `cylinder` | `center`, `axis`, `radius`, `bounds` | Fit a center and radius for a bounded cylindrical wall with a fixed axis. |
188
+ | `polygon` | `corners` | Supply ordered XYZ corner hints. Fit supporting lines on the contour's plane and check that adjacent lines meet near the supplied corners. |
189
+
190
+ `bounds` contains minimum and maximum XYZ points. Optional `relations` entries use `type: parallel`, `perpendicular`, or `coplanar` and `features: [idA, idB]` to jointly refine two or more fitted planes. Relations are soft constraints backed by the sampled surface. A joint fit is rejected if its sample residual exceeds `tolerance`. Shared vertices are solved together. Moves longer than twice `tolerance` and moves incident to unsafe faces are discarded. Inspect the fitted and skipped feature IDs, solver diagnostics and actual mesh measurements after the run.
191
+
192
+ ### Selective rim bevel for LODs
193
+
194
+ Set `finish.lodBevel` to run QEM before beveling selected circular rims. Supply `finish.triangleBudget` for the final cap and a smaller `lodBevel.preTriangleBudget` to leave room for bevel faces. `finish.bevelWidth` is required and `finish.bevelSegments` defaults to two.
195
+
196
+ Each `rims` entry supplies an `id`, `axis` (`x`, `y`, or `z`), `center`, `radius`, `radialTolerance`, and `axialTolerance`. Coordinates are pivot-relative stack XYZ scene units. The axis is perpendicular to the rim plane. The remaining center coordinates locate the circle. Both endpoints of a selected crease must lie within the tolerances. Rims run in recipe order. The pipeline fails if a rim has no matching creases, an operation breaks closed topology, or the result exceeds the final budget.
197
+
198
+ The [hard-surface benchmark](../../examples/hard-surface-benchmark/README.md) shows a verified configuration with Triple-Dexel, a 1,900-triangle pre-budget, and two selected rims within a 2,400-triangle final budget.
199
+
200
+ ### Compare the two Dual Contouring methods
201
+
202
+ `hermite-dc` uses boundary crossings and estimated normals. `signed-distance-dc` uses Carrera et al.'s maintained [Gpytoolbox implementation](https://gpytoolbox.org/0.3.8/dual_contouring_of_signed_distance_data/). uv resolves Gpytoolbox 0.3.8 for that method. When using `STACK3_PYTHON`, install Gpytoolbox 0.3.8 in the selected environment.
203
+
204
+ ```sh
205
+ stack3 mesh housing-stack/ --mesh-method hermite-dc --output hermite.glb
206
+ stack3 mesh housing-stack/ --mesh-method signed-distance-dc --output carrera.glb
207
+ ```
208
+
209
+ For a matched-input comparison, pass `--guide field.json` to both methods. A guide like `{"field":"housing.npy"}` reads a finite floating-point array in XYZ order with shape `(width + 2, depth + 2, layers + 2)`. Samples sit at cell centers with one empty layer of padding. Distances are in scene units, negative inside, and their signs must match the saved stack. Without an external field, `signed-distance-dc` estimates distances from occupancy using physical axis spacing. Its guide accepts `outerIterations` and `innerIterations` from 1 to 100. The CLI defaults are 3 and 12 and use Gpytoolbox's automatically selected near-surface samples for repeatable local comparisons.
210
+
211
+ #### Registered triple-dexel input
212
+
213
+ An optional `{"dexel":"triple-dexel.npz"}` guide gives `hermite-dc` crossing locations and outward normals directly. The saved stack supplies the sampled occupancy and RGB. Use an NPZ with scalar `version: 1`, XYZ `grid`, `origin` and `step`, and these arrays for each axis `x`, `y` and `z`:
214
+
215
+ - `<axis>_offsets` indexes each ray in the packed arrays. The transverse coordinates are in XYZ order with the ray axis omitted, flattened in C order. Transverse rays pass through the other axes' cell centers.
216
+ - `<axis>_depth` contains strictly increasing enter/exit pairs on each ray. Rays point in the positive axis direction. Depth is measured from the stack grid's lower plane in scene units.
217
+ - `<axis>_normals` contains one outward XYZ unit vector per crossing.
218
+
219
+ All axes must classify the saved cell centers identically. A sign-changing grid edge must contain one crossing. The CLI reports additional crossings on edges without a sampled sign change. Use a finer grid to resolve thin features that fall entirely inside an edge. Supply either `dexel` or `field` in the guide.
220
+
74
221
  ## Scene projects
75
222
 
76
223
  A scene project stores embedded PNG assets, a hierarchy of nodes, per-object reconstruction settings, camera and renderer settings, and a playback clock. A node can be a group, or an instance of an embedded atlas. Multiple nodes can share the source bytes and use different settings.
@@ -140,3 +287,23 @@ Attach **Add Sprite Stack Wheel** to an atlas-backed child node to opt into whee
140
287
  Each update receives elapsed seconds `dt`, the playback clock `time`, held physical key codes, current field values, the previous JSON `state`, the node’s authored `position` and `rotation`, and its direct `children` with IDs, names, and positions. Return absolute playback offsets relative to the authored pose in `translation` (XYZ units) and `rotation` (XYZ degrees), optional `childRotations` keyed by direct child ID (local XYZ degrees), and the JSON `state` for the next update. Scripts run only during live Play in each browser tab, inside a JavaScript VM with execution and memory limits. Pause freezes the preview, and Reset discards runtime state. Use **Viewport → Follow object** to track a scripted node with the camera.
141
288
 
142
289
  The CLI can attach or edit a component with `script.set` (`nodeId`, `id`, and `patch`), detach it with `script.remove`, and select a camera target with `view.set` (`patch.follow`). See `project schema` for the full action shape.
290
+
291
+ For Blender preview, install Blender and put its executable on your PATH or set `BLENDER_BIN`. The standard macOS app location is detected automatically. The packed scene retains one textured quad per layer. With no output path the preview scene is written to a temporary directory.
292
+
293
+ ## Verify orthographic artwork
294
+
295
+ `stack3 verify -f manifest.yaml` prints one JSON report. An atlas manifest measures projections and landmarks. An assembly manifest also follows the whole and part atlas paths. Its report contains `atlases.whole`, `atlases.parts` keyed by part name, and `results` with each part's mounting measurements. Each manifest supplies its own measurement tolerance. Add `--output-dir qa` to save the same JSON as report.json alongside the annotated overlays. Completed measurements exit zero. Invalid inputs exit nonzero. Read the pixel distances, unsupported sample counts and the applicable tolerance per run. Per-result status describes measurement availability. Run with uv or set STACK3_PYTHON to a Python environment with NumPy, Pillow, headless OpenCV and PyYAML. The verification script declares the tested versions.
296
+
297
+ **Atlas YAML.** Supply all four named views. Each has an image path, optional crop [left, top, width, height], origin [u,v] of the common coordinate system in the cropped panel, and a single positive scale in pixels per common unit. Image and manifest paths are relative to their containing YAML file. Pixel centers have integer coordinates. Positive image u points right and v down. Axis directions for (u,v) are TOP (+x,+y), LEFT (−y,−z), FRONT (+x,−z), REAR (−x,−z). The front points down in TOP and left in LEFT. Determine the registration from known common landmarks or scale evidence. Missing registration yields registration-needed. To segment an opaque white background, set mask to white (foreground requires alpha ≥128 and minimum RGB below threshold, default 238). For transparent images, use alpha (≥128).
298
+
299
+ Each boundary pixel supplies two coordinates. The remaining axis must have a common occupied interval in all other applicable silhouettes. Scanlines use pixel footprints, retain disconnected intervals and holes, and include the opposing elevation when present. A parallel view is checked at the corresponding pixel. tolerancePx defaults to 1. Disjoint-interval gaps use source-panel pixels; a scanline with no foreground has no finite interval gap and reports null. An unsupported parallel pixel has its own distance. Reports group consecutive unsupported samples along closed contour walks; sample counts refer to contour samples, not arc lengths. The overlay highlights these contours and illustrates one set of rays. Counts describe the sampled contours under the declared registration.
300
+
301
+ For landmarks supply entries with an id and a points map of view names to local [u,v] observations. A null observation marks an occlusion. Compare shared axes first, then use compatible pairs to predict an independently observed view. Shared-axis residuals are in the second input panel's pixels, and reprojection errors are in the held-out panel's pixels. The JSON records both.
302
+
303
+ **Assembly YAML.** Set whole to an atlas manifest and map parts by name. Each part supplies its atlas and mounts. Provide two or more distinct TOP pairs and at least one FRONT pair, each with part and whole pixel coordinates. TOP fits one positive uniform scale and planar translation, FRONT fits height. Frames must already share their physical orientation. Anchor residuals are recorded separately from checks. Each check names an id and view and supplies either a held-out part/whole point pair or a visible edge polyline in whole-panel pixels. The latter measures the maximum distance along that marked segment to the projected part outline. Set visible to false for hidden features. The reported transform remains fixed for every check.
304
+
305
+ **Acceptance gate.** A full atlas run adds `acceptance.verdict` to the report. All four checks must pass: registered silhouette dimensions within `tolerancePx`, zero unsupported contour samples at that tolerance, shared and held-out landmark residuals within tolerance with at least one held-out prediction, and at least one camera-axis pair per view within tolerance. Failure takes precedence over missing evidence. Use `axisPairs` to map each view name to a list such as `[{points: [[42, 50], [42, 50]], evidence: "Known vertically aligned upper and lower corners"}]`. Annotate only independently supported point pairs that differ solely along the viewing axis. The geometry of that pair is supplied evidence. Missing evidence gives `UNCONFIRMED`; the PNG alone cannot certify the camera angle. With `--output-dir`, inspect `atlas-guides.png` and the projection and landmark overlays. Exit status still reports execution success.
306
+
307
+ Use `stack3 build INPUT --verification qa/report.json ...` for a guarded build. The CLI requires a complete atlas `PASS` and compares the set of views, original PNG hashes, and prepared pixel data against the report before reading the cache or writing output. Keep `atlas-guides.png` beside `report.json`. Use the same directions and masking for verification and build. If the CLI's atlas split or background mask differs from the verification crop, use identical separate panel PNGs in both manifests.
308
+
309
+ See the [runnable locomotive example and measured outputs](../../samples/inspection/locomotive-verify/README.md).