scadify 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -1,80 +1,80 @@
1
- # scadify
2
-
3
- Geometry as code: deterministic 3D solids generated from tiny JSON recipes with OpenSCAD inside, compiled on demand to clean meshes and exported as glb, gltf, stl, 3mf, usdz, usda or scad. The same recipe, seed and params give byte-for-byte identical output on the same platform. One runtime dependency (`openscad-wasm-prebuilt`, in-process OpenSCAD + Manifold); everything else is Node stdlib. Node ≥ 18.
4
-
5
- ## The pattern
6
-
7
- A **recipe** is a small JSON file in `store/` (one per ref). It is the only thing stored; meshes are derived and disposable. Same recipe + params + seed ⇒ same bytes on the same platform.
8
-
9
- ```jsonc
10
- { "kind": "scad", // "scad": the program is the source | "csg": a boolean tree of primitives
11
- "title": "demo-tray", "units": "dm", "seed": 7,
12
- "program": "module tray(){ ... }",
13
- "parts": { "tray": "tray();", "standoffs": "standoffs();" }, // one mesh/node per part
14
- "params": { "wall_h": 12 }, // passed as -D, so they override program defaults
15
- "tints": { "tray": "#3f6fb0" } } // optional #rrggbb per part
16
- ```
17
-
18
- `kind:"csg"` uses `tree` (or `parts`) instead of `program`: nodes `{op, ...}` with ops `cube cylinder sphere translate rotate scale mirror union difference intersection hull`; transforms/booleans take `children`. A number may be `{"param":"name"}`. A csg recipe transpiles to `.scad` (`export_solid format=scad`). `seed` is injected as the OpenSCAD variable `seed`. Parts are emitted in sorted-name order.
19
-
20
- **Units.** `units` is one of `mm`, `cm`, `dm`, `m` (metres per unit 0.001, 0.01, 0.1, 1) and defaults to `dm` when omitted, so architectural models land at true size (1 unit = 10 cm). Recipe coordinates are in that unit. Exports are normalized so imports land at true size with scale 1: GLB and USD are written in **metres** (`metersPerUnit` 1), STL and 3MF in **millimetres**. Previews render the raw recipe coordinates.
21
-
22
- ## Tools (stdio MCP, hand-rolled JSON-RPC; `node src/scadify-cli.mjs`)
23
-
24
- | tool | does |
25
- |---|---|
26
- | `mint_solid {recipe}` | store a recipe → `{ref}` (`slug-<hash8>`; identical content is idempotent) |
27
- | `list_solids` / `get_solid {ref}` | list refs / return the recipe |
28
- | `update_solid {ref, params?, program?, parts?, tree?, title?, seed?, tints?}` | edit in place (params merge, rest replace; ref is stable) |
29
- | `export_solid {ref, format}` | compile + write `out/<ref>.<format>`, `format` = `glb gltf stl 3mf usdz usda scad json` → `{path, format, sizeBytes, sha256, ref}` |
30
- | `render_turntable {ref, frames=8 (3–36), size=256, elevation_deg=25}` | PNG frames from the in-Node software rasterizer (transparent background) |
31
- | `render_shot {ref, angle_deg=0, elevation_deg=26, size=512, background='#0C1019'}` | exactly one PNG; angle 0 = model front (-y), camera orbits +z; `background` is `#rrggbb` or `transparent` → `{path, size}` |
32
- | `render_standard {ref, size=1024, background='#0C1019'}` | standard preview: one square PNG, front-on shot (0°, 8° up) left and angled-high shot (30°, 32° up) right → `{path, size, panels}` |
33
- | `measure_solid {ref}` | bbox, size, volume, area, triangle count, mesh checksum |
34
-
35
- Env: `SCADIFY_STORE`, `SCADIFY_OUT` override the `store/` and `out/` dirs. The bin also has a one-shot CLI: `scadify tools`, `scadify call <tool> --json '{...}'`.
36
-
37
- ## Output notes
38
-
39
- - **GLB/glTF**: mesh only. One flat node per part, one mesh/material (PBR baseColor from the tint). No cameras, lights, ground plane, transforms, or hierarchy. Node, mesh and material names are the part names (a numeric suffix only if a name repeats). Coordinates are in **metres**, **z-up** (not glTF's y-up convention); glTF has no ratified units extension, so this is declared in `asset.extras` (`units: "m"`, `metersPerUnit: 1`, `sourceUnits` = the recipe's unit, `upAxis`). A strict y-up viewer will show the model lying on its side.
40
- - **USDA/USDZ**: `upAxis="Z"`, coordinates in metres with `metersPerUnit = 1`, one Xform per part named after the part and holding a Mesh of the same name, UsdPreviewSurface materials; USDZ is a stored zip with 64-byte-aligned payload. The editing/postprocess path.
41
- - **STL** (binary) and **3MF** (`unit="millimeter"`, one object per part) for print. Both are always written in millimetres: coordinates are converted from the recipe unit (×1, ×10, ×100, ×1000 for mm, cm, dm, m) so a slicer reads true size. **SCAD** is the assembled program.
42
- - Not verified here: opening the files in third-party viewers (Blender, Quick Look, a slicer). Tests re-read each format structurally only.
43
-
44
- ## Examples
45
-
46
- `examples/` ships three showcase solids. Each is a single JSON file: the `program` is plain OpenSCAD (loops, `rands(…, seed)`, list comprehensions, an in-language geodesic sphere), and `parts` are the unit of tinting. Any of them mints, compiles, exports and renders with the identical loop:
47
-
48
- ```bash
49
- npm install
50
- REF=$(node src/scadify-cli.mjs call mint_solid --json "{\"recipe\": $(cat examples/domed-citadel.json)}" | node -pe 'JSON.parse(require("fs").readFileSync(0)).ref')
51
- for f in glb stl usdz; do node src/scadify-cli.mjs call export_solid --json "{\"ref\":\"$REF\",\"format\":\"$f\"}"; done
52
- node src/scadify-cli.mjs call render_turntable --json "{\"ref\":\"$REF\",\"frames\":8,\"size\":256}"
53
- node src/scadify-cli.mjs call measure_solid --json "{\"ref\":\"$REF\"}"
54
- ```
55
-
56
- Files land in `out/`. `npm test` runs the suite (node:test).
57
-
58
- ### Temple ruins — `examples/temple-ruins.json`
59
-
60
- A ruined stepped temple: hex peristyle with broken columns, crumbled cella, fallen drums and rubble. 8 parts, ~1.2k tris. `seed` drives the crumble and scatter.
61
-
62
- ![temple ruins preview](docs/previews/temple-ruins.png)
63
-
64
- ### Newton Cenotaph — `examples/newton-cenotaph.json`
65
-
66
- Boullée's cenotaph: a hollow **geodesic sphere** (generated in OpenSCAD) on stepped drums with cypress rings. `variant: 2` (default) opens a front cutaway to the navy-lined, gold-starred interior; set `variant: 1` for the closed shell with star openings. `freq` tunes the sphere (6 ≈ 9.3k tris).
67
-
68
- ![newton cenotaph preview](docs/previews/newton-cenotaph.png)
69
-
70
- ### Domed citadel — `examples/domed-citadel.json`
71
-
72
- A monumental domed building: fluted terrace, 32-bay two-storey drum with pointed-arch bays and slit windows, portico + grand stair, and a ribbed geodesic dome whose facets are three-colour raised panels. 12 parts, ~26.9k tris, `dome_freq` controls the dome.
73
-
74
- ![domed citadel preview](docs/previews/domed-citadel.png)
75
-
76
- Units are per recipe (`mm`/`cm`/`dm`/`m`, default `dm`; the three examples are `dm`), z-up, front faces −y. The preview renders are unit-independent. The same `seed` re-mints byte-identical geometry on the same platform.
77
-
78
- ## Claude plugin
79
-
80
- `.claude-plugin/plugin.json` declares the stdio server as an `mcpServers` component (`node ${CLAUDE_PLUGIN_ROOT}/src/scadify-cli.mjs`); there is no top-level `bin/`. The plugin needs `openscad-wasm-prebuilt` installed alongside (`npm install`, or bundle `node_modules/`).
1
+ # scadify
2
+
3
+ Geometry as code: deterministic 3D solids generated from tiny JSON recipes with OpenSCAD inside, compiled on demand to clean meshes and exported as glb, gltf, stl, 3mf, usdz, usda or scad. The same recipe, seed and params give byte-for-byte identical output on the same platform. One runtime dependency (`openscad-wasm-prebuilt`, in-process OpenSCAD + Manifold); everything else is Node stdlib. Node ≥ 18.
4
+
5
+ ## The pattern
6
+
7
+ A **recipe** is a small JSON file in `store/` (one per ref). It is the only thing stored; meshes are derived and disposable. Same recipe + params + seed ⇒ same bytes on the same platform.
8
+
9
+ ```jsonc
10
+ { "kind": "scad", // "scad": the program is the source | "csg": a boolean tree of primitives
11
+ "title": "demo-tray", "units": "dm", "seed": 7,
12
+ "program": "module tray(){ ... }",
13
+ "parts": { "tray": "tray();", "standoffs": "standoffs();" }, // one mesh/node per part
14
+ "params": { "wall_h": 12 }, // passed as -D, so they override program defaults
15
+ "tints": { "tray": "#3f6fb0" } } // optional #rrggbb per part
16
+ ```
17
+
18
+ `kind:"csg"` uses `tree` (or `parts`) instead of `program`: nodes `{op, ...}` with ops `cube cylinder sphere translate rotate scale mirror union difference intersection hull`; transforms/booleans take `children`. A number may be `{"param":"name"}`. A csg recipe transpiles to `.scad` (`export_solid format=scad`). `seed` is injected as the OpenSCAD variable `seed`. Parts are emitted in sorted-name order.
19
+
20
+ **Units.** `units` is one of `mm`, `cm`, `dm`, `m` (metres per unit 0.001, 0.01, 0.1, 1) and defaults to `dm` when omitted, so architectural models land at true size (1 unit = 10 cm). Recipe coordinates are in that unit. Exports are normalized so imports land at true size with scale 1: GLB and USD are written in **metres** (`metersPerUnit` 1), STL and 3MF in **millimetres**. Previews render the raw recipe coordinates.
21
+
22
+ ## Tools (stdio MCP, hand-rolled JSON-RPC; `node src/scadify-cli.mjs`)
23
+
24
+ | tool | does |
25
+ |---|---|
26
+ | `mint_solid {recipe}` | store a recipe → `{ref}` (`slug-<hash8>`; identical content is idempotent) |
27
+ | `list_solids` / `get_solid {ref}` | list refs / return the recipe |
28
+ | `update_solid {ref, params?, program?, parts?, tree?, title?, seed?, tints?}` | edit in place (params merge, rest replace; ref is stable) |
29
+ | `export_solid {ref, format}` | compile + write `out/<ref>.<format>`, `format` = `glb usdz gltf usda stl 3mf scad json` (prefer glb/usdz; stl/3mf only for printing) → `{path, format, sizeBytes, sha256, ref}` |
30
+ | `render_turntable {ref, frames=8 (3–36), size=256, elevation_deg=25}` | PNG frames from the in-Node software rasterizer (transparent background) |
31
+ | `render_shot {ref, angle_deg=0, elevation_deg=26, size=512, background='#0C1019'}` | exactly one PNG; angle 0 = model front (-y), camera orbits +z; `background` is `#rrggbb` or `transparent` → `{path, size}` |
32
+ | `render_standard {ref, size=1024, background='#0C1019'}` | standard preview: one square PNG, front-on shot (0°, 8° up) left and angled-high shot (30°, 32° up) right → `{path, size, panels}` |
33
+ | `measure_solid {ref}` | bbox, size, volume, area, triangle count, mesh checksum |
34
+
35
+ Env: `SCADIFY_STORE`, `SCADIFY_OUT` override the `store/` and `out/` dirs. The bin also has a one-shot CLI: `scadify tools`, `scadify call <tool> --json '{...}'`.
36
+
37
+ ## Output notes
38
+
39
+ - **GLB/glTF**: mesh only. One flat node per part, one mesh/material (PBR baseColor from the tint). No cameras, lights, ground plane, transforms, or hierarchy. Node, mesh and material names are the part names (a numeric suffix only if a name repeats). Coordinates are in **metres**, converted to glTF's **y-up** convention ((x, y, z) → (x, z, −y); the model front −y faces +Z), so Godot, Blender, three.js etc. import it upright. glTF has no ratified units extension, so units are declared in `asset.extras` (`units: "m"`, `metersPerUnit: 1`, `sourceUnits` = the recipe's unit, `upAxis: "Y"`).
40
+ - **USDA/USDZ**: `upAxis="Z"`, coordinates in metres with `metersPerUnit = 1`, one Xform per part named after the part and holding a Mesh of the same name, UsdPreviewSurface materials; USDZ is a stored zip with 64-byte-aligned payload. The editing/postprocess path.
41
+ - **STL** (binary) and **3MF** (`unit="millimeter"`, one object per part) for print. Both are always written in millimetres: coordinates are converted from the recipe unit (×1, ×10, ×100, ×1000 for mm, cm, dm, m) so a slicer reads true size. **SCAD** is the assembled program.
42
+ - Not verified here: opening the files in third-party viewers (Blender, Quick Look, a slicer). Tests re-read each format structurally only.
43
+
44
+ ## Examples
45
+
46
+ `examples/` ships three showcase solids. Each is a single JSON file: the `program` is plain OpenSCAD (loops, `rands(…, seed)`, list comprehensions, an in-language geodesic sphere), and `parts` are the unit of tinting. Any of them mints, compiles, exports and renders with the identical loop:
47
+
48
+ ```bash
49
+ npm install
50
+ REF=$(node src/scadify-cli.mjs call mint_solid --json "{\"recipe\": $(cat examples/domed-citadel.json)}" | node -pe 'JSON.parse(require("fs").readFileSync(0)).ref')
51
+ for f in glb usdz; do node src/scadify-cli.mjs call export_solid --json "{\"ref\":\"$REF\",\"format\":\"$f\"}"; done
52
+ node src/scadify-cli.mjs call render_turntable --json "{\"ref\":\"$REF\",\"frames\":8,\"size\":256}"
53
+ node src/scadify-cli.mjs call measure_solid --json "{\"ref\":\"$REF\"}"
54
+ ```
55
+
56
+ Files land in `out/`. `npm test` runs the suite (node:test).
57
+
58
+ ### Temple ruins — `examples/temple-ruins.json`
59
+
60
+ A ruined stepped temple: hex peristyle with broken columns, crumbled cella, fallen drums and rubble. 8 parts, ~1.2k tris. `seed` drives the crumble and scatter.
61
+
62
+ ![temple ruins preview](docs/previews/temple-ruins.png)
63
+
64
+ ### Newton Cenotaph — `examples/newton-cenotaph.json`
65
+
66
+ Boullée's cenotaph: a hollow **geodesic sphere** (generated in OpenSCAD) on stepped drums with cypress rings. `variant: 2` (default) opens a front cutaway to the navy-lined, gold-starred interior; set `variant: 1` for the closed shell with star openings. `freq` tunes the sphere (6 ≈ 9.3k tris).
67
+
68
+ ![newton cenotaph preview](docs/previews/newton-cenotaph.png)
69
+
70
+ ### Domed citadel — `examples/domed-citadel.json`
71
+
72
+ A monumental domed building: fluted terrace, 32-bay two-storey drum with pointed-arch bays and slit windows, portico + grand stair, and a ribbed geodesic dome whose facets are three-colour raised panels. 12 parts, ~26.9k tris, `dome_freq` controls the dome.
73
+
74
+ ![domed citadel preview](docs/previews/domed-citadel.png)
75
+
76
+ Units are per recipe (`mm`/`cm`/`dm`/`m`, default `dm`; the three examples are `dm`), z-up, front faces −y. The preview renders are unit-independent. The same `seed` re-mints byte-identical geometry on the same platform.
77
+
78
+ ## Claude plugin
79
+
80
+ `.claude-plugin/plugin.json` declares the stdio server as an `mcpServers` component (`node ${CLAUDE_PLUGIN_ROOT}/src/scadify-cli.mjs`); there is no top-level `bin/`. The plugin needs `openscad-wasm-prebuilt` installed alongside (`npm install`, or bundle `node_modules/`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scadify",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Deterministic recipes -> clean 3D solids (OpenSCAD/Manifold WASM), exported to GLB/STL/3MF/USDZ.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,8 +1,16 @@
1
1
  // Clean GLB: mesh only. Flat tree = one node per part (mesh under it). No cameras, lights, ground, hierarchy.
2
- // Coordinates are written in METRES (recipe units scaled by the unit's metres-per-unit), z-up; asset.extras records units 'm' / metersPerUnit 1
2
+ // Coordinates are written in METRES (recipe units scaled by the unit's metres-per-unit) and converted from the recipe's z-up to glTF's
3
+ // y-up (x, y, z) -> (x, z, -y): up stays up, the model front (-y) faces glTF +Z. A proper rotation, so triangle winding is unchanged.
4
+ // asset.extras records units 'm' / metersPerUnit 1
3
5
  // since glTF has no ratified units extension. Node, mesh and material names are the part names.
4
6
  import { positionsInMeters, uniqueNames } from './common.js';
5
7
 
8
+ function zUpToYUp(pos) {
9
+ const out = new Float32Array(pos.length);
10
+ for (let i = 0; i < pos.length; i += 3) { out[i] = pos[i]; out[i + 1] = pos[i + 2]; out[i + 2] = -pos[i + 1]; }
11
+ return out;
12
+ }
13
+
6
14
  const hex = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
7
15
  const pad4 = (b, fill = 0) => (b.length % 4 ? Buffer.concat([b, Buffer.alloc(4 - (b.length % 4), fill)]) : b);
8
16
 
@@ -12,7 +20,7 @@ function build(recipe, mesh) {
12
20
  const view = (b, target) => { const bb = pad4(b); bufferViews.push({ buffer: 0, byteOffset: len, byteLength: b.length, target }); bufs.push(bb); len += bb.length; return bufferViews.length - 1; };
13
21
  const names = uniqueNames(mesh.parts.map((p) => p.name));
14
22
  for (const [pi, part] of mesh.parts.entries()) {
15
- const p = { ...part, positions: positionsInMeters(part.positions, recipe) }; const name = names[pi];
23
+ const p = { ...part, positions: zUpToYUp(positionsInMeters(part.positions, recipe)) }; const name = names[pi];
16
24
  const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];
17
25
  for (let i = 0; i < p.positions.length; i += 3) for (let a = 0; a < 3; a++) { min[a] = Math.min(min[a], p.positions[i + a]); max[a] = Math.max(max[a], p.positions[i + a]); }
18
26
  const pv = view(Buffer.from(p.positions.buffer, p.positions.byteOffset, p.positions.byteLength), 34962);
@@ -24,7 +32,7 @@ function build(recipe, mesh) {
24
32
  nodes.push({ name, mesh: meshes.length - 1 });
25
33
  }
26
34
  const json = {
27
- asset: { version: '2.0', generator: 'scadify', extras: { units: 'm', metersPerUnit: 1, sourceUnits: recipe.units, upAxis: 'Z', title: recipe.title } },
35
+ asset: { version: '2.0', generator: 'scadify', extras: { units: 'm', metersPerUnit: 1, sourceUnits: recipe.units, upAxis: 'Y', title: recipe.title } },
28
36
  scene: 0, scenes: [{ name: recipe.title, nodes: nodes.map((_, i) => i) }],
29
37
  nodes, meshes, materials, accessors, bufferViews, buffers: [{ byteLength: len }],
30
38
  };
package/src/mcp.js CHANGED
@@ -15,7 +15,7 @@ import { canonical } from './recipe.js';
15
15
 
16
16
  const VERSION = '0.1.0';
17
17
  export const FORMATS = {
18
- glb: emitGLB, gltf: emitGLTF, stl: emitSTL, '3mf': emit3MF, usdz: emitUSDZ, usda: emitUSDA, scad: emitSCAD,
18
+ glb: emitGLB, usdz: emitUSDZ, gltf: emitGLTF, usda: emitUSDA, stl: emitSTL, '3mf': emit3MF, scad: emitSCAD,
19
19
  json: (recipe) => JSON.stringify(JSON.parse(canonical(recipe)), null, 2) + '\n',
20
20
  };
21
21
 
@@ -30,7 +30,7 @@ export const TOOLS = [
30
30
  { name: 'list_solids', description: 'List stored solid refs and titles.', inputSchema: { type: 'object', properties: {} } },
31
31
  { name: 'get_solid', description: 'Return the stored recipe JSON.', inputSchema: { type: 'object', properties: refProp, required: ['ref'] } },
32
32
  { name: 'update_solid', description: 'Edit a stored recipe in place: params merge; program/parts/tree/title/seed/tints replace.', inputSchema: { type: 'object', properties: { ...refProp, params: { type: 'object' }, program: { type: 'string' }, parts: { type: 'object' }, tree: { type: 'object' }, title: { type: 'string' }, seed: { type: 'integer' }, tints: { type: 'object' } }, required: ['ref'] } },
33
- { name: 'export_solid', description: 'Compile deterministically and write a file. Returns { path, format, sizeBytes, sha256, ref }.', inputSchema: { type: 'object', properties: { ...refProp, format: { enum: Object.keys(FORMATS) } }, required: ['ref', 'format'] } },
33
+ { name: 'export_solid', description: 'Compile deterministically and write a file. Default to glb (game engines / viewers, y-up metres) and usdz (editing / DCC, z-up metres). Only use stl or 3mf when the user explicitly asks for 3D printing or those formats. Returns { path, format, sizeBytes, sha256, ref }.', inputSchema: { type: 'object', properties: { ...refProp, format: { enum: Object.keys(FORMATS), description: 'Prefer glb or usdz; stl/3mf only for printing on request.' } }, required: ['ref', 'format'] } },
34
34
  { name: 'render_turntable', description: 'Render 3-36 turntable PNG frames in-process (software rasterizer). Returns frame paths.', inputSchema: { type: 'object', properties: { ...refProp, frames: { type: 'integer', minimum: 3, maximum: 36 }, size: { type: 'integer', minimum: 32, maximum: 1024 }, elevation_deg: { type: 'number' } }, required: ['ref'] } },
35
35
  { name: 'render_shot', description: 'Render exactly one PNG from a chosen azimuth + elevation (software rasterizer). angle_deg 0 = the model front (-y); positive turns the camera around +z. Returns { path, size }.', inputSchema: { type: 'object', properties: { ...refProp, angle_deg: { type: 'number' }, elevation_deg: { type: 'number', minimum: -89, maximum: 89 }, size: { type: 'integer', minimum: 32, maximum: 1024 }, background: { type: 'string', description: "#rrggbb or 'transparent' (default #0C1019)" } }, required: ['ref'] } },
36
36
  { name: 'render_standard', description: 'Standard preview: one square PNG with a front-on shot (left) and an angled-high shot (right) side by side on the studio background. Returns { path, size, panels }.', inputSchema: { type: 'object', properties: { ...refProp, size: { type: 'integer', minimum: 64, maximum: 2048 }, background: { type: 'string', description: "#rrggbb or 'transparent' (default #0C1019)" } }, required: ['ref'] } },
@@ -101,7 +101,7 @@ test('units: glb/usd are written in metres (metersPerUnit 1); stl/3mf in millime
101
101
  const glb = readFileSync((await h.export_solid({ ref, format: 'glb' })).path);
102
102
  const g = JSON.parse(glb.toString('utf8', 20, 20 + glb.readUInt32LE(12)));
103
103
  assert.equal(g.asset.extras.units, 'm'); assert.equal(g.asset.extras.metersPerUnit, 1); assert.equal(g.asset.extras.sourceUnits, units);
104
- near(g.accessors[0].max[2], 30 * mpu, 1e-5); near(g.accessors[0].max[0] - g.accessors[0].min[0], 10 * mpu, 1e-5); // metres
104
+ near(g.accessors[0].max[1], 30 * mpu, 1e-5); near(g.accessors[0].max[0] - g.accessors[0].min[0], 10 * mpu, 1e-5); // metres
105
105
  const usda = readFileSync((await h.export_solid({ ref, format: 'usda' })).path, 'utf8');
106
106
  assert.match(usda, /metersPerUnit = 1\n/);
107
107
  const ext = usda.match(/float3\[\] extent = \[\([^)]*\), \(([^)]*)\)\]/)[1].split(',').map(Number); near(ext[2], 30 * mpu, 1e-5);
@@ -146,8 +146,8 @@ test('every format: export, re-read, assert structure', async () => {
146
146
  assert.equal(g.nodes.length, 2); assert.equal(g.meshes.length, 2); assert.deepEqual(g.nodes.map((n) => n.name).sort(), ['standoffs', 'tray']);
147
147
  for (const n of g.nodes) { assert.ok(!n.children && !n.camera && !n.matrix && !n.translation && !n.skin); }
148
148
  for (const k of ['cameras', 'skins', 'animations', 'extensions', 'extensionsUsed']) assert.equal(g[k], undefined, k);
149
- assert.equal(g.asset.extras.units, 'm'); assert.equal(g.asset.extras.metersPerUnit, 1); assert.equal(g.asset.extras.sourceUnits, 'dm'); assert.equal(g.asset.extras.upAxis, 'Z');
150
- const ti = g.nodes.findIndex((n) => n.name === 'tray'); const tray = g.accessors[g.meshes[g.nodes[ti].mesh].primitives[0].attributes.POSITION]; near(tray.max[0] - tray.min[0], 4); near(tray.max[2] - tray.min[2], 1.2); // 40 x 12 dm in metres
149
+ assert.equal(g.asset.extras.units, 'm'); assert.equal(g.asset.extras.metersPerUnit, 1); assert.equal(g.asset.extras.sourceUnits, 'dm'); assert.equal(g.asset.extras.upAxis, 'Y');
150
+ const ti = g.nodes.findIndex((n) => n.name === 'tray'); const tray = g.accessors[g.meshes[g.nodes[ti].mesh].primitives[0].attributes.POSITION]; near(tray.max[0] - tray.min[0], 4); near(tray.max[1] - tray.min[1], 1.2); // 40 x 12 dm (height on glTF +Y) in metres
151
151
  assert.deepEqual(g.materials[g.meshes[g.nodes[ti].mesh].primitives[0].material].pbrMetallicRoughness.baseColorFactor.slice(0, 3).map((x) => +x.toFixed(2)), [0.25, 0.44, 0.69]);
152
152
  const gltf = JSON.parse(readFileSync(out.gltf.path, 'utf8')); assert.equal(gltf.nodes.length, 2);
153
153
  // STL: binary, count matches, bbox