topotopo 0.4.0 → 0.5.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/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +327 -147
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/bake.d.ts +14 -3
- package/dist/core/bake.js +153 -4
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +76 -3
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +203 -3
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +7 -0
- package/dist/core/materials.js +45 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scene.js +2 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +14 -1
- package/dist/core/snippet-lib.js +39 -13
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +5 -1
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +10 -0
- package/dist/core/topology.js +168 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +4 -18
- package/dist/core/uv.js +35 -188
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +61 -0
- package/dist/core/uvreport.js +207 -143
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +66 -62
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +80 -2
- package/dist/inspect.js +265 -30
- package/dist/io/common.d.ts +25 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +134 -47
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +148 -13
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +786 -143
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +56 -27
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +198 -103
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +151 -47
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +51 -3
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +21 -9
- package/dist/nodes/curves.js +433 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +12 -38
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.js +16 -19
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/material.js +89 -24
- package/dist/nodes/measure.js +43 -17
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.js +4 -2
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +6 -2
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +5 -1
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +57 -5
- package/dist/render/preview.d.ts +17 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +74 -5
- package/dist/render/raster.js +527 -143
- package/dist/render/texview.d.ts +6 -0
- package/dist/render/texview.js +27 -0
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +27 -7
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +5 -1
- package/dist/viewer/app/guides.js +122 -0
- package/dist/viewer/app/keymap.js +6 -3
- package/dist/viewer/app/layers.js +4 -4
- package/dist/viewer/app/main.js +185 -52
- package/dist/viewer/app/markers.js +60 -0
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +176 -52
- package/dist/viewer/app/scene.js +30 -5
- package/dist/viewer/app/select.js +4 -3
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +65 -7
- package/dist/viewer/app/vars.js +47 -0
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +23 -10
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +14 -9
- package/dist/viewer/server.js +266 -28
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/{gallery → web}/bake.d.ts +4 -4
- package/dist/{gallery → web}/bake.js +24 -15
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -118
- package/dist/workspace.js +358 -460
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +2 -1
- package/kernels/pkg-simd/README.md +2 -1
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +13 -8
- package/dist/gallery/app/gallery.css +0 -100
- package/dist/gallery/app/gallery.js +0 -80
- package/dist/gallery/cli.d.ts +0 -4
- package/dist/gallery/cli.js +0 -157
- package/dist/gallery/library.d.ts +0 -124
- package/dist/gallery/library.js +0 -366
- package/dist/gallery/pages.d.ts +0 -94
- package/dist/gallery/pages.js +0 -148
- package/dist/gallery/server.d.ts +0 -21
- package/dist/gallery/server.js +0 -391
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/dist/mcp/library.d.ts +0 -12
- package/dist/mcp/library.js +0 -159
- package/shelf/index.json +0 -190
package/dist/cli.js
CHANGED
|
@@ -1,26 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Command line: cook a graph JSON file, then render / export / inspect.
|
|
3
|
-
// node src/cli.ts <graph.json> [--node name] [--frame N | --frames A-B[:step]] [--fps 24]
|
|
4
|
-
// [--render out.png] [--views quad|quad_uv|turntable|persp|front,top|persp,uv|persp,section] [--checker] [--color-by attr]
|
|
3
|
+
// node src/cli.ts <graph.json> [--node name | --output name] [--var name=value]… [--frame N | --frames A-B[:step]] [--fps 24]
|
|
4
|
+
// [--render out.png] [--views quad|quad_uv|turntable|persp|front_left|front,top|persp,uv|persp,section] [--checker] [--color-by attr]
|
|
5
5
|
// [--wireframe all|hard|boundary|groups] [--section y:0.5] [--clip x:0.5] [--glyphs N|up|orient|v] [--labels groups,pieces,points,prims,attrib:name]
|
|
6
|
-
// [--shading flat|matcap|ao|pbr] [--exposure 0] [--legend] [--size 800] [--render-scale 2] [--
|
|
6
|
+
// [--shading flat|matcap|ao|pbr] [--exposure 0] [--legend] [--size 800|1600x600] [--render-scale 2] [--heightfield-res 256|full]
|
|
7
|
+
// [--transparent] [--no-grid] [--underlay ref.png [--underlay-opacity 0.5] [--underlay-fit bounds|width|height|view]] [--sockets]
|
|
8
|
+
// [--heightfield-layer mask|<layer>|none] [--export out.glb]
|
|
7
9
|
// [--compress meshopt] [--quantize] [--tangents auto|preserve|none] [--pcg | --pcg-struct] [--attributes P,N,pscale] [--up-axis z] [--scale 100]
|
|
8
|
-
// [--instancing packed|expand] [--instances rows|expand] [--no-meshes]
|
|
9
|
-
// [--
|
|
10
|
+
// [--instancing packed|expand] [--instances rows|expand] [--no-meshes] [--custom-attribs | --no-custom-attribs] [--vertex-colors] [--no-materials]
|
|
11
|
+
// [--split-by-name | --no-split-by-name] [--precision 32|64] [--height-min 0 --height-max 100] [--heightfield 0]
|
|
12
|
+
// (every option of the export tool has a flag; booleans take --name / --no-name)
|
|
13
|
+
// [--inspect summary|attributes|topology|all|uv|budget|scene [--uv-resolution 1024] [--json]]
|
|
14
|
+
// --output picks a named output (the graph's "outputs"); --var overrides a graph var for this run (src/graph/vars.ts).
|
|
10
15
|
// --export formats: .glb .gltf .obj .usda .ply .stl .json .geo (Houdini) .csv .points.json
|
|
11
16
|
// Packed instances to .csv/.points.json: one row per instance + <name>.meshes.json + <name>_meshes/<Mesh>.glb.
|
|
12
17
|
// Heightfields: --export terrain.png (16-bit heightmap + terrain.json sidecar for Unreal), .r16/.raw, or
|
|
13
18
|
// --format mask_png --layers mask,flow; --layer picks the layer;
|
|
14
19
|
// --format unreal_landscape --export out/level (a directory: heightmap, layers, manifest, objects.glb,
|
|
15
20
|
// instance stream).
|
|
21
|
+
// Every export records how it was made (src/io/source.ts) in its sidecar or manifest, or in <file>.source.json.
|
|
16
22
|
// With --frames, --render/--export paths may contain {frame} or {frame:04} (zero-padded);
|
|
17
23
|
// without a pattern a .0001-style frame number is inserted before the extension.
|
|
18
|
-
// node src/cli.ts --catalog | --help-node scatter | --version
|
|
19
|
-
// node src/cli.ts mcp [--
|
|
24
|
+
// node src/cli.ts --catalog | --help-node scatter | --help-topic export | --version
|
|
25
|
+
// node src/cli.ts mcp [--package dir] [--viewer] the MCP server (src/mcp/server.ts) over stdio
|
|
20
26
|
// node src/cli.ts view <graph.json> [--port 7341] live 3D viewer in the browser, re-cooks on every save;
|
|
21
27
|
// files dropped on the page go to inputs/ beside the graph file
|
|
22
|
-
// node src/cli.ts
|
|
23
|
-
// node src/cli.ts library add|list|new|bake …
|
|
28
|
+
// node src/cli.ts web [--port 7340] [--library dir] the web app for the workspaces and libraries (src/packages/commands.ts)
|
|
29
|
+
// node src/cli.ts library add|remove|list|new|bake … registered libraries and packages; edit [folder] opens the
|
|
30
|
+
// live viewer on a package
|
|
31
|
+
// The workspace around packages (src/workspace.ts), a package and the packages it uses (src/packages/commands.ts,
|
|
32
|
+
// src/packages/registry.ts, src/packages/update.ts):
|
|
33
|
+
// node src/cli.ts workspace [folder]
|
|
34
|
+
// node src/cli.ts workspace init [folder] [--name n] [--engine godot:<path>|unreal:<path>|none] [--library <name or folder>] [--follow | --no-follow]
|
|
35
|
+
// node src/cli.ts workspace library add|remove <name or folder> [--workspace <folder>]
|
|
36
|
+
// node src/cli.ts workspace add|list [folder]
|
|
37
|
+
// node src/cli.ts init [folder] [--name owner/name]
|
|
38
|
+
// node src/cli.ts use owner/name [folder] [--version 1.1]
|
|
39
|
+
// node src/cli.ts remove owner/name [folder]
|
|
40
|
+
// node src/cli.ts packages [owner/name] [folder]
|
|
41
|
+
// node src/cli.ts publish [folder] --note "..." [--big] [--dry-run]
|
|
42
|
+
// node src/cli.ts search [words] [folder] [--kind k] [--tag t]
|
|
43
|
+
// node src/cli.ts outdated [folder]
|
|
44
|
+
// node src/cli.ts check [folder]
|
|
45
|
+
// node src/cli.ts update owner/name [folder] [--to 1.4] [--render <folder>]
|
|
46
|
+
// node src/cli.ts update owner/name [folder] --from 1.3 --to 1.4 --apply
|
|
47
|
+
// A graph-file cook adds a package its graph names for the first time (and says so); --locked fails instead, for a
|
|
48
|
+
// build machine. --follow owner/name on a cook or view uses a package's working folder instead of its copy, for
|
|
49
|
+
// looking: exports use the published copy.
|
|
50
|
+
// A package's published outputs cooked into a Godot project, and the Godot plugin (src/host/godot.ts, src/host/cook.ts;
|
|
51
|
+
// integrations/godot/PROTOCOL.md):
|
|
52
|
+
// node src/cli.ts cook <.topo | package folder | folder>... --for godot [--into <folder>] [--flat] [--skip a,b] [--instancing packed|expand] [--adopt] [--force] [--no-cache] [--timeout <s>] [--report <file>] [--progress json] [--quiet]
|
|
53
|
+
// node src/cli.ts cook --jobs <jobs.json> [--force] [--no-cache] [--progress json]
|
|
54
|
+
// node src/cli.ts godot setup <godot project folder> [--no-enable]
|
|
55
|
+
// node src/cli.ts godot status <godot project folder> [--strict] [--json]
|
|
24
56
|
// Installed from npm the same commands are `topotopo …` (package.json bin → dist/cli.js, built by npm run build).
|
|
25
57
|
import fs from 'node:fs';
|
|
26
58
|
import path from 'node:path';
|
|
@@ -28,19 +60,29 @@ import zlib from 'node:zlib';
|
|
|
28
60
|
import './nodes/index.js';
|
|
29
61
|
import { Engine } from './graph/engine.js';
|
|
30
62
|
import { allNodeDefs } from './graph/registry.js';
|
|
63
|
+
import { KINDS } from './graph/outputs.js';
|
|
31
64
|
import { createNodeHost } from './host/node.js';
|
|
32
65
|
import { renderGeometryAsync } from './render/raster.js';
|
|
33
66
|
import { parseViews } from './render/raster.js';
|
|
34
67
|
import { renderArgs } from './render/options.js';
|
|
35
68
|
import { encodePNG } from './render/png.js';
|
|
36
69
|
import { EXPORT_FORMATS, exportFormatFromPath } from './io/export.js';
|
|
37
|
-
import {
|
|
70
|
+
import { exportSource } from './io/source.js';
|
|
71
|
+
import { packagesUsed } from './graph/packages.js';
|
|
72
|
+
import { PACKAGE_COMMANDS } from './packages/commands.js';
|
|
73
|
+
import { GODOT_COMMANDS } from './host/godot-commands.js';
|
|
74
|
+
import { setProgram } from './package.js';
|
|
75
|
+
import { openPackages } from './packages/registry.js';
|
|
38
76
|
import { ArtifactStore } from './host/artifacts.js';
|
|
39
|
-
import { prepareTarget, writeTargets } from './host/export-targets.js';
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
77
|
+
import { exportsFolderFor, prepareTarget, serializeExport, writeExportFiles, writeTargets } from './host/export-targets.js';
|
|
78
|
+
import { TOPOTOPO_VERSION } from './host/version.js';
|
|
79
|
+
import { exportOptionsFromFlags, prefixGone, publishedOutputs } from './io/targets.js';
|
|
80
|
+
import { budgetReport, inspect, nodeBudgetInput, summarize } from './inspect.js';
|
|
81
|
+
import { glbSceneReport, sceneReportText } from './io/inspect-scene.js';
|
|
42
82
|
import { uvReport } from './core/uvreport.js';
|
|
43
|
-
import {
|
|
83
|
+
import { didYouMean } from './graph/params.js';
|
|
84
|
+
import { parseVarArg, withVars } from './graph/vars.js';
|
|
85
|
+
import { catalogText, nodeDoc, topicList, topicText } from './mcp/docs.js';
|
|
44
86
|
const argv = process.argv.slice(2);
|
|
45
87
|
const opt = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : undefined; };
|
|
46
88
|
const fail = (msg) => { console.error(msg); process.exit(1); };
|
|
@@ -48,120 +90,147 @@ const fail = (msg) => { console.error(msg); process.exit(1); };
|
|
|
48
90
|
const graphName = (file) => path.basename(file).replace(/\.json$/i, '').replace(/[^A-Za-z0-9_-]/g, '_').replace(/^[^A-Za-z]/, 'g$&') || 'graph';
|
|
49
91
|
// the command as the user typed it: the sources from a clone, or the package's bin (dist/cli.js)
|
|
50
92
|
const prog = import.meta.url.endsWith('.ts') ? 'node src/cli.ts' : 'topotopo';
|
|
93
|
+
// the hints of every command name it so
|
|
94
|
+
setProgram(prog);
|
|
51
95
|
if (argv.includes('-v') || argv.includes('-V') || argv.includes('--version')) {
|
|
52
|
-
|
|
53
|
-
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
54
|
-
console.log(`topotopo ${pkg.version}`);
|
|
96
|
+
console.log(`topotopo ${TOPOTOPO_VERSION}`);
|
|
55
97
|
process.exit(0);
|
|
56
98
|
}
|
|
57
99
|
if (!argv.length || argv.includes('-h') || argv.includes('--help')) {
|
|
58
100
|
console.log([
|
|
59
|
-
`usage: ${prog} <graph.json> [--node n] [--frame N | --frames A-B[:step]] [--fps 24]`,
|
|
60
|
-
' [--render out.png] [--views quad|quad_uv|turntable|persp|front,top|persp,uv|persp,section] [--checker] [--color-by attr] [--export out.glb]
|
|
61
|
-
' [--
|
|
101
|
+
`usage: ${prog} <graph.json> [--node n | --output name] [--var name=value]… [--frame N | --frames A-B[:step]] [--fps 24]`,
|
|
102
|
+
' [--render out.png] [--views quad|quad_uv|turntable|persp|front_left|front,top|persp,uv|persp,section] [--checker] [--color-by attr] [--export out.glb]',
|
|
103
|
+
' [--inspect summary|attributes|topology|all|uv|budget|scene] [--uv-resolution 1024] [--json]',
|
|
104
|
+
' summary: one screen (counts, triangles, bbox in mm, parts, materials, images, uv state, closed or open edges)',
|
|
105
|
+
' topology: a closed solid or why not (open edges after welding seam splits, non-manifold, flipped, inward), with where',
|
|
106
|
+
' uv: overlaps (in-tile, tiling, across LODs), utilization, texel density; budget: triangles per part, per LOD and per node',
|
|
107
|
+
' scene: the glb export read back (nodes and parents, meshes, materials, maps, images; takes the export options)',
|
|
108
|
+
' --json: the uv, budget or scene report as JSON',
|
|
109
|
+
' [--output name] (a named output, the graph\'s "outputs", instead of the default; render, export and inspect it)',
|
|
110
|
+
' [--var name=value] (override a graph var for this run; repeat it; numbers, true/false and JSON values are parsed, other text is a string)',
|
|
111
|
+
' [--export-all] (every output with an export target in the graph, into exports/ of its package folder)',
|
|
112
|
+
' relative paths in the graph (file nodes, maps) read from its package folder: the nearest folder with a .topo file at or',
|
|
113
|
+
' above the graph file, else the graph file\'s folder; --render/--export/--underlay paths are relative to the current folder',
|
|
114
|
+
' [--follow owner/name] (show that package\'s working folder, where the package finds it, instead of its copy, for this run: renders and inspect use it, exports the published copy; repeat it)',
|
|
115
|
+
' [--locked] (a build machine: a package the graph names that the package does not use, or a copy missing or edited by hand, fails the run instead of being added)',
|
|
62
116
|
' render overlays: [--wireframe all|hard|boundary|groups] [--hard-angle 30] [--section y:0.5] [--clip x:0.5[:abs]]',
|
|
63
117
|
' [--glyphs N|up|orient|v] [--glyph-attrib a] [--labels groups,pieces,points,prims,attrib:name] [--legend] [--points]',
|
|
64
|
-
' [--shading flat|matcap|ao|pbr] [--exposure 0] [--size 800] [--render-scale 2]
|
|
118
|
+
' [--shading flat|matcap|ao|pbr] [--exposure 0] [--size 800|1600x600] [--render-scale 2]',
|
|
119
|
+
' views: persp front back left right top bottom front_left front_right back_left back_right uv section texture persp@<az>',
|
|
120
|
+
' framing: every 3D view fits the bounds; [--zoom 1] is relative to that fit (above 1 only with --look-at or --ortho-scale)',
|
|
121
|
+
' [--azimuth 35] (degrees around +Y: 0 = camera on +Z at the front, 90 = on +X, the right side) [--elevation 25] (degrees above the horizon)',
|
|
122
|
+
' [--look-at x,y,z] (world metres, Y up, +Z front) [--ortho-scale 0.5] (metres across an ortho view)',
|
|
123
|
+
' [--bounds x0,y0,z0,x1,y1,z1] (world metres: every 3D view frames these corners instead of the own box of the geometry, so a sequence shares one camera)',
|
|
124
|
+
' [--transparent] (PNG with alpha) [--no-grid] [--sockets] (scene empties as labelled dots with orient axes)',
|
|
125
|
+
' [--underlay ref.png] (a reference PNG behind the 3D views) [--underlay-opacity 0.5] [--underlay-fit bounds|width|height|view]',
|
|
65
126
|
' [--textures] (base colour maps on meshes) [--texture name|image/layer|material] (adds the texture view)',
|
|
66
127
|
' [--max-triangles 600000] (packed instances drawn; above it an evenly spread subset)',
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
' [--no-view-labels] (no view name labels or axis gizmo, e.g. for thumbnails)',
|
|
70
|
-
'
|
|
128
|
+
' [--heightfield-res 256|full] (heightfields: quads drawn per side, default 256, said in the footer when a field has more; full = every sample)',
|
|
129
|
+
' [--heightfield-layer flow] (heightfields: the layer drawn in red, default mask; none draws none)',
|
|
130
|
+
' [--no-view-labels] (no view name labels or axis gizmo, e.g. for thumbnails) [--no-footer] (no footer strip: the image is the tiles only)',
|
|
131
|
+
' several renders per cook: repeat --render; the options after a --render apply to that render (up to the next --render),',
|
|
132
|
+
' options before the first --render apply to every render. Example (both 1200x600):',
|
|
133
|
+
' --size 1200x600 --render side.png --views front --underlay ref.png --render beauty.png --views front_left --shading pbr',
|
|
134
|
+
' side.png: the front view over the reference; beauty.png: a pbr three-quarter view. Options after the last of several',
|
|
135
|
+
' --render apply to it alone (a warning says so)',
|
|
136
|
+
' export options (every option of the export tool; booleans as --name / --no-name):',
|
|
137
|
+
' [--compress none|meshopt|draco] [--quantize] [--tangents auto|preserve|none] [--pcg | --pcg-struct] [--attributes P,N,pscale] [--up-axis y|z] [--scale 100]',
|
|
138
|
+
' [--custom-attribs | --no-custom-attribs] (extra numeric attributes; glTF and USD default off, PLY on) [--materials | --no-materials]',
|
|
139
|
+
' [--vertex-colors | --no-vertex-colors] (glTF: also write Cd as COLOR_0 on prims with a named material; default off)',
|
|
140
|
+
' [--split-by-name | --no-split-by-name] [--precision 32|64] (geo) [--layer height] [--height-min 0] [--height-max 100] [--heightfield 0]',
|
|
71
141
|
' [--instancing packed|expand] (packed instances: glb/usda/geo keep them by default)',
|
|
72
142
|
' [--instances rows|expand] [--no-meshes] (csv/points.json of packed instances: one row per instance + meshes sidecar + GLBs)',
|
|
73
143
|
' export formats: .glb .gltf .obj .usda .ply .stl .json .geo (Houdini) .csv .points.json; heightfields .png (png16) .r16,',
|
|
74
144
|
' --format mask_png --layers a,b, --format unreal_landscape (a directory bundle; --tile-size 1008 for tiled Landscape);',
|
|
75
145
|
' images: --format textures --export out/maps (one PNG per image; --layers a,b or * for extra layers)',
|
|
146
|
+
' every export records how it was made (graph, graph hash, output, node, frame, fps, vars, seeds, every option with its default, version)',
|
|
147
|
+
' in its sidecar; replay: --output/--node, --frame, --fps, --var per var, --format and each option as its flag',
|
|
148
|
+
' (heightmap .json, <name>.meshes.json, landscape.json) or in <file>.source.json beside it; --help-topic export',
|
|
76
149
|
' with --frames, output paths may use {frame} or {frame:04}; otherwise out.0001.png style names are written',
|
|
77
|
-
` ${prog} --catalog | --help-node <type> | --version`,
|
|
78
|
-
` ${prog} mcp [--
|
|
79
|
-
` ${prog} view <graph.json> [--port 7341] (live 3D viewer in the browser; re-cooks when the file is saved; files dropped on the page go to inputs/ beside it)`,
|
|
80
|
-
` ${prog}
|
|
81
|
-
` ${prog} library add <name> <folder> | list | new <library> <folder/name> [--title t] [--tags a,b] | bake <
|
|
82
|
-
` ${prog} edit
|
|
150
|
+
` ${prog} --catalog | --help-node <type> | --help-topic <name> | --version (in a package: the outputs of the packages it uses too, --help-node owner/name/output)`,
|
|
151
|
+
` ${prog} mcp [--package dir] [--viewer] (the MCP server over stdio, for MCP clients)`,
|
|
152
|
+
` ${prog} view <graph.json> [--port 7341] [--follow owner/name] (live 3D viewer in the browser; re-cooks when the file is saved; files dropped on the page go to inputs/ beside it)`,
|
|
153
|
+
` ${prog} web [--port 7340] [--library <folder>] [--no-bake] (the web app: the registered workspaces and every library's packages, stable links for a board)`,
|
|
154
|
+
` ${prog} library add <name> <folder> | remove <name> | list | new <library or workspace> <folder/name> [--title t] [--tags a,b] | bake <package>|--stale|--all (registered libraries)`,
|
|
155
|
+
` ${prog} edit [folder] [--port 7341] (the live viewer on a package, default the current folder's)`,
|
|
156
|
+
' a package and the packages it uses (a folder named must exist; default: the current folder\'s package; kinds: ' + KINDS.join(', ') + '; --help-topic packages):',
|
|
157
|
+
...PACKAGE_COMMANDS.map((c) => ` ${prog} ${c.usage} (${c.what})`),
|
|
158
|
+
' Godot (exit 0 ok, 1 an output or package failed, 2 usage or setup; --help-topic godot):',
|
|
159
|
+
...GODOT_COMMANDS.map((c) => ` ${prog} ${c.usage} (${c.what})`),
|
|
83
160
|
].join('\n'));
|
|
84
161
|
process.exit(0);
|
|
85
162
|
}
|
|
163
|
+
if (argv.includes('--help-topic')) {
|
|
164
|
+
// the MCP help topics (src/mcp/docs.ts), the same text the help tool returns
|
|
165
|
+
const name = opt('--help-topic');
|
|
166
|
+
const topics = ['overview', ...topicList()];
|
|
167
|
+
if (name === undefined || name.startsWith('-'))
|
|
168
|
+
fail(`--help-topic needs a topic: ${topics.join(', ')}`);
|
|
169
|
+
const text = topicText(name);
|
|
170
|
+
if (text === null) {
|
|
171
|
+
const s = didYouMean(name, topics);
|
|
172
|
+
fail(`unknown topic "${name}"${s.length ? ` (did you mean ${s.join(', ')}?)` : ''}; topics: ${topics.join(', ')}`);
|
|
173
|
+
}
|
|
174
|
+
console.log(text);
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
86
177
|
if (argv.includes('--catalog') || opt('--help-node')) {
|
|
87
|
-
// node types
|
|
178
|
+
// node types, the current folder's assets, the outputs of the packages its package uses, and those of TopoTopo's own
|
|
179
|
+
// packages (house, stairs, …) it does not use yet
|
|
88
180
|
const engine = new Engine(createNodeHost({ baseDir: process.cwd() }));
|
|
89
181
|
await engine.init();
|
|
90
|
-
const
|
|
182
|
+
const pk = openPackages(engine, process.cwd());
|
|
183
|
+
const defs = [...allNodeDefs(), ...engine.assetsIn().map((x) => x.def), ...engine.packageDefs()];
|
|
91
184
|
if (argv.includes('--catalog'))
|
|
92
|
-
console.log(catalogText(defs));
|
|
185
|
+
console.log(catalogText(defs, { cli: true }));
|
|
93
186
|
else {
|
|
94
|
-
const
|
|
95
|
-
|
|
187
|
+
const name = opt('--help-node');
|
|
188
|
+
// an output of a package this one does not use yet is read where its library holds it (nothing is copied)
|
|
189
|
+
const d = defs.find((x) => x.type === name) ?? (name.includes('/') ? engine.resolveDef(name) ?? pk.describe(name) ?? undefined : undefined);
|
|
190
|
+
// a package output this folder cannot cook as it is (one of TopoTopo's own it does not use, a folder in no package)
|
|
191
|
+
const why = name.includes('/') && !engine.resolveDef(name) ? engine.packageIssue(name) : null;
|
|
192
|
+
const said = why ? `${why.error}${why.hint ? ` (${why.hint})` : ''}` : '';
|
|
193
|
+
console.log(d ? `${nodeDoc(d)}${said ? `\nin this folder: ${said}` : ''}` : said || `unknown node "${name}" (see --catalog)`);
|
|
96
194
|
}
|
|
97
195
|
process.exit(0);
|
|
98
196
|
}
|
|
197
|
+
/** --follow owner/name (repeatable): packages whose working folders a cook uses instead of their copies. */
|
|
198
|
+
const followArgs = argv.flatMap((x, i) => (x === '--follow' ? [argv[i + 1]] : []));
|
|
199
|
+
if (followArgs.some((f) => f === undefined || f.startsWith('--')))
|
|
200
|
+
fail('--follow needs a package: --follow owner/name');
|
|
99
201
|
if (argv[0] === 'view') {
|
|
100
|
-
// `topotopo view <graph.json> [--port 7341]`: cook the file, serve the live 3D viewer
|
|
202
|
+
// `topotopo view <graph.json> [--port 7341]`: cook the file, serve the live 3D viewer and follow its saves; the values
|
|
203
|
+
// tuned on the page are session values over the file, written into it on request (src/viewer/graph-file.ts)
|
|
101
204
|
const file = argv[1];
|
|
102
205
|
if (!file || file.startsWith('-'))
|
|
103
|
-
fail(`usage: ${prog} view <graph.json> [--port 7341]`);
|
|
206
|
+
fail(`usage: ${prog} view <graph.json> [--port 7341] [--follow owner/name]`);
|
|
104
207
|
if (!fs.existsSync(file))
|
|
105
208
|
fail(`${prog}: no such graph file "${file}"`);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
spec = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
122
|
-
}
|
|
123
|
-
catch (e) {
|
|
124
|
-
console.error(`${file}: ${e.message} (keeping the last good version)`);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
ws.setGraph(name, spec);
|
|
128
|
-
const r = await ws.cook(name);
|
|
129
|
-
console.log(`${r.ok ? 'cooked' : 'FAILED'} ${name} in ${r.ms.toFixed(0)} ms${r.ok ? '' : ': ' + r.errors.map((e) => `${e.node}: ${e.message}`).join('; ')}`);
|
|
130
|
-
ws.bump(name);
|
|
131
|
-
};
|
|
132
|
-
await load();
|
|
133
|
-
// an export target set on the page goes into the graph file, the only source here: only "export" keys change
|
|
134
|
-
const persistGraph = (g) => {
|
|
135
|
-
if (g !== name)
|
|
136
|
-
return;
|
|
137
|
-
const spec = ws.getGraph(name), raw = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
138
|
-
if (spec.export === undefined)
|
|
139
|
-
delete raw.export;
|
|
140
|
-
else
|
|
141
|
-
raw.export = spec.export;
|
|
142
|
-
for (const [id, o] of Object.entries(spec.outputs ?? {})) {
|
|
143
|
-
if (!raw.outputs?.[id])
|
|
144
|
-
continue;
|
|
145
|
-
if (o.export === undefined)
|
|
146
|
-
delete raw.outputs[id].export;
|
|
147
|
-
else
|
|
148
|
-
raw.outputs[id].export = o.export;
|
|
149
|
-
}
|
|
150
|
-
fs.writeFileSync(file, JSON.stringify(raw, null, 2) + '\n');
|
|
151
|
-
};
|
|
152
|
-
const v = await startViewer(ws, opt('--port') !== undefined ? Number(opt('--port')) : undefined, { inputsWhere: `beside ${path.basename(file)}`, persistGraph });
|
|
153
|
-
console.log(`view: ${v.url} (watching ${file}; files dropped on the page go to ${path.join(path.dirname(file), 'inputs') + path.sep}; Ctrl+C to stop)`);
|
|
154
|
-
let timer;
|
|
155
|
-
fs.watch(file, () => { clearTimeout(timer); timer = setTimeout(() => { load().catch((e) => console.error(String(e))); }, 150); });
|
|
209
|
+
const { viewGraphFile } = await import('./viewer/graph-file.js');
|
|
210
|
+
try {
|
|
211
|
+
await viewGraphFile(file, { name: graphName(file), port: opt('--port') !== undefined ? Number(opt('--port')) : undefined, follow: followArgs });
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
fail(`${prog} view: ${e.message}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (['web', 'library', 'edit', 'workspace', 'init', 'libraries', 'use', 'remove', 'packages', 'publish', 'search', 'outdated', 'check', 'update'].includes(argv[0])) {
|
|
218
|
+
// the web app, its libraries and its editor; a package and the packages it uses (src/packages/commands.ts). A command that ends
|
|
219
|
+
// gives its exit code; the web app and the editor keep running
|
|
220
|
+
const { commands } = await import('./packages/commands.js');
|
|
221
|
+
const code = await commands[argv[0]](argv.slice(1), prog);
|
|
222
|
+
if (typeof code === 'number')
|
|
223
|
+
process.exit(code);
|
|
156
224
|
}
|
|
157
|
-
else if (argv[0] === '
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
await
|
|
225
|
+
else if (argv[0] === 'cook' || argv[0] === 'godot') {
|
|
226
|
+
// a package's published outputs cooked into a Godot project, and the Godot plugin's setup and status
|
|
227
|
+
// (src/host/godot.ts, src/host/cook.ts): exit 0, 1 (an output or package failed), 2 (usage, setup or protocol)
|
|
228
|
+
const { cookCommand, godotCommand } = await import('./host/godot.js');
|
|
229
|
+
const { consoleIo } = await import('./packages/commands.js');
|
|
230
|
+
process.exit(await (argv[0] === 'cook' ? cookCommand : godotCommand)(argv.slice(1), consoleIo));
|
|
162
231
|
}
|
|
163
232
|
else if (argv[0] === 'mcp') {
|
|
164
|
-
// `topotopo mcp [--
|
|
233
|
+
// `topotopo mcp [--package dir] [--viewer]`: the MCP server over stdio; src/mcp/server.ts reads the remaining
|
|
165
234
|
// arguments from process.argv and runs until the client closes stdin
|
|
166
235
|
process.argv.splice(2, 1);
|
|
167
236
|
await import('./mcp/server.js');
|
|
@@ -208,9 +277,76 @@ async function cook() {
|
|
|
208
277
|
catch (e) {
|
|
209
278
|
fail(`${prog}: ${file} is not valid JSON: ${e.message}`);
|
|
210
279
|
}
|
|
280
|
+
// --var name=value (repeatable): the graph's vars for this run; exports record the result, so a manifest replays
|
|
281
|
+
const varArgs = argv.flatMap((x, i) => (x === '--var' ? [argv[i + 1]] : []));
|
|
282
|
+
if (varArgs.some((v) => v === undefined || v.startsWith('--')))
|
|
283
|
+
fail('--var needs name=value (e.g. --var relief=8)');
|
|
284
|
+
try {
|
|
285
|
+
graph = withVars(graph, varArgs.map(parseVarArg));
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
fail(`--var: ${e.message}`);
|
|
289
|
+
}
|
|
290
|
+
// --output name: a named output (graph.outputs) instead of the default output
|
|
291
|
+
const outputName = opt('--output');
|
|
292
|
+
if (argv.includes('--output') && (outputName === undefined || outputName.startsWith('--')))
|
|
293
|
+
fail('--output needs the name of one of the graph\'s outputs');
|
|
294
|
+
if (outputName !== undefined && opt('--node') !== undefined)
|
|
295
|
+
fail('use either --node or --output, not both');
|
|
296
|
+
let target = opt('--node');
|
|
297
|
+
if (target !== undefined && graph?.nodes && !Object.hasOwn(graph.nodes, target) && graph?.outputs && Object.hasOwn(graph.outputs, target))
|
|
298
|
+
fail(`--node: ${file} has no node "${target}", but an output of that name: --output ${target}`);
|
|
299
|
+
if (outputName !== undefined) {
|
|
300
|
+
const outs = graph?.outputs && typeof graph.outputs === 'object' ? graph.outputs : {};
|
|
301
|
+
const o = Object.hasOwn(outs, outputName) ? outs[outputName] : undefined;
|
|
302
|
+
if (!o || typeof o.node !== 'string') {
|
|
303
|
+
const names = Object.keys(outs), s = didYouMean(outputName, names);
|
|
304
|
+
const isNode = !!graph?.nodes && typeof graph.nodes === 'object' && Object.hasOwn(graph.nodes, outputName);
|
|
305
|
+
fail(`--output: ${file} has no output "${outputName}"${isNode ? `, but a node of that name: --node ${outputName}` : s.length ? ` (did you mean ${s.join(', ')}?)` : ''}; ${names.length ? `its outputs: ${names.join(', ')}` : 'it publishes no "outputs" (--node picks any node)'}`);
|
|
306
|
+
}
|
|
307
|
+
target = o.node;
|
|
308
|
+
}
|
|
211
309
|
const engine = new Engine(createNodeHost({ baseDir: path.dirname(path.resolve(file)) }));
|
|
212
310
|
await engine.init();
|
|
213
|
-
|
|
311
|
+
// the packages the file's package uses: one the graph names for the first time is added (said), and
|
|
312
|
+
// --follow uses a package's working folder for this run. A graph that does not validate as a dry run sees it adds
|
|
313
|
+
// nothing: its errors are said and the run ends. --locked (a build machine) adds nothing and changes no file: a
|
|
314
|
+
// package it does not use, or a copy missing or edited by hand, fails the run instead.
|
|
315
|
+
let pk;
|
|
316
|
+
try {
|
|
317
|
+
pk = openPackages(engine, path.dirname(path.resolve(file)), { follow: followArgs });
|
|
318
|
+
}
|
|
319
|
+
catch (e) {
|
|
320
|
+
fail(`--follow: ${e.message}`);
|
|
321
|
+
}
|
|
322
|
+
const dry = pk.dryRun(graph);
|
|
323
|
+
const invalid = engine.validate(graph, '', { ...engine.root, id: dry.id, packages: dry.resolver }).errors;
|
|
324
|
+
if (invalid.length)
|
|
325
|
+
fail(invalid.map((e) => `error [${e.node}] ${e.message}${e.hint ? ` (hint: ${e.hint})` : ''}`).join('\n'));
|
|
326
|
+
if (argv.includes('--locked')) {
|
|
327
|
+
const unlocked = pk.locked(graph);
|
|
328
|
+
if (unlocked.length)
|
|
329
|
+
fail(unlocked.map((x) => `--locked: ${x}`).join('\n'));
|
|
330
|
+
}
|
|
331
|
+
else
|
|
332
|
+
for (const n of pk.addFor(graph))
|
|
333
|
+
console.log(n);
|
|
334
|
+
for (const p of pk.check())
|
|
335
|
+
console.error(`warning: ${p}`);
|
|
336
|
+
for (const f of pk.following())
|
|
337
|
+
console.log(`following ${f.package}: its working folder ${f.dir} instead of its copy, for renders and inspect (exports use the published copy)`);
|
|
338
|
+
// the packages shown live (--follow, a workspace that follows its own) are for looking: an export cooks with their
|
|
339
|
+
// published copies (a cook of its own when the graph names one) and says so
|
|
340
|
+
const exportNote = pk.publishedNote(graph);
|
|
341
|
+
const exportScope = exportNote ? pk.published() : null;
|
|
342
|
+
const forExport = async (r, node = r.target) => {
|
|
343
|
+
if (!exportScope)
|
|
344
|
+
return r;
|
|
345
|
+
const e = await engine.cook(graph, { target: node, frame: r.frame, fps: r.fps, scope: exportScope });
|
|
346
|
+
if (!e.ok || !e.geo)
|
|
347
|
+
fail(`export: with the published copies, ${node} does not cook (${e.errors.map((x) => `${x.node}: ${x.message}`).join('; ') || 'no geometry'}); nothing was written`);
|
|
348
|
+
return e;
|
|
349
|
+
};
|
|
214
350
|
const fps = opt('--fps') !== undefined ? Number(opt('--fps')) : undefined;
|
|
215
351
|
const framesArg = opt('--frames');
|
|
216
352
|
const frameArg = opt('--frame');
|
|
@@ -221,26 +357,66 @@ async function cook() {
|
|
|
221
357
|
const single = frameArg !== undefined ? Number(frameArg) : undefined;
|
|
222
358
|
if (single !== undefined && !Number.isFinite(single))
|
|
223
359
|
fail(`--frame expects a number, got "${frameArg}"`);
|
|
360
|
+
// --inspect <detail>: checked before cooking
|
|
361
|
+
const INSPECT_DETAILS = ['summary', 'attributes', 'topology', 'all', 'uv', 'budget', 'scene'];
|
|
362
|
+
const inspectDetail = opt('--inspect');
|
|
363
|
+
if (argv.includes('--inspect') && (inspectDetail === undefined || !INSPECT_DETAILS.includes(inspectDetail))) {
|
|
364
|
+
const s = inspectDetail ? didYouMean(inspectDetail, INSPECT_DETAILS) : [];
|
|
365
|
+
fail(`--inspect needs one of ${INSPECT_DETAILS.join(', ')}${inspectDetail ? `, got "${inspectDetail}"${s.length ? ` (did you mean ${s.join(', ')}?)` : ''}` : ''}`);
|
|
366
|
+
}
|
|
367
|
+
const uvRes = opt('--uv-resolution') !== undefined ? Number(opt('--uv-resolution')) : undefined;
|
|
368
|
+
/** The --inspect report of a cook: text, or the uv / budget / scene report as JSON with --json. */
|
|
369
|
+
async function inspectText(r) {
|
|
370
|
+
const geo = r.geo, json = argv.includes('--json');
|
|
371
|
+
if (inspectDetail === 'scene') {
|
|
372
|
+
// the glb export with the export options given, read back
|
|
373
|
+
const res = await serializeExport(geo, 'glb', 'scene.glb', exportArgs(), engine.host);
|
|
374
|
+
const glb = res.files.find((f) => /\.glb$/i.test(f.path));
|
|
375
|
+
if (!glb)
|
|
376
|
+
return 'scene: the glb export wrote no file';
|
|
377
|
+
const rep = glbSceneReport(glb.bytes);
|
|
378
|
+
const warn = res.warnings.map((w) => `warning: ${w}`);
|
|
379
|
+
return json ? JSON.stringify(rep, null, 2) : [...sceneReportText(rep), ...warn].join('\n');
|
|
380
|
+
}
|
|
381
|
+
if (inspectDetail === 'uv' && json)
|
|
382
|
+
return JSON.stringify(uvReport(geo, { resolution: uvRes }), null, 2);
|
|
383
|
+
if (inspectDetail === 'budget' && json)
|
|
384
|
+
return JSON.stringify(budgetReport(geo, nodeBudgetInput(graph, r.results)), null, 2);
|
|
385
|
+
return inspect(geo, { detail: inspectDetail, uvResolution: uvRes, nodes: inspectDetail === 'budget' ? nodeBudgetInput(graph, r.results) : undefined });
|
|
386
|
+
}
|
|
224
387
|
function report(r) {
|
|
225
388
|
for (const e of r.errors)
|
|
226
389
|
console.error(`error [${e.node}] ${e.message}${e.hint ? ` (hint: ${e.hint})` : ''}`);
|
|
227
390
|
for (const w of r.warnings)
|
|
228
391
|
console.error(`warning [${w.node}] ${w.message}`);
|
|
229
392
|
}
|
|
393
|
+
/** Every render flag (renderFlags reads them, plus --views, --color-by, --checker). */
|
|
394
|
+
const RENDER_FLAGS = ['--wireframe', '--hard-angle', '--section', '--clip', '--glyphs', '--glyph-attrib', '--glyph-scale', '--max-glyphs', '--labels', '--max-labels',
|
|
395
|
+
'--shading', '--ao-radius', '--size', '--render-scale', '--azimuth', '--elevation', '--zoom', '--look-at', '--bounds', '--ortho-scale', '--texture', '--max-triangles', '--exposure',
|
|
396
|
+
'--heightfield-res', '--heightfield-layer', '--underlay', '--underlay-opacity', '--underlay-fit', '--legend', '--points', '--annotate', '--textures', '--transparent',
|
|
397
|
+
'--sockets', '--no-view-labels', '--no-footer', '--no-grid', '--views', '--color-by', '--checker'];
|
|
230
398
|
/** Render overlay flags → render tool arguments → RenderOptions (src/render/options.ts). */
|
|
231
399
|
function renderFlags(get, has) {
|
|
232
400
|
const a = {};
|
|
233
401
|
for (const [f, k] of [['--wireframe', 'wireframe'], ['--hard-angle', 'hard_angle'], ['--section', 'section'], ['--clip', 'clip'], ['--glyphs', 'glyphs'],
|
|
234
402
|
['--glyph-attrib', 'glyph_attrib'], ['--glyph-scale', 'glyph_scale'], ['--max-glyphs', 'max_glyphs'], ['--labels', 'labels'], ['--max-labels', 'max_labels'],
|
|
235
403
|
['--shading', 'shading'], ['--ao-radius', 'ao_radius'], ['--size', 'size'], ['--render-scale', 'scale'], ['--azimuth', 'azimuth'], ['--elevation', 'elevation'],
|
|
236
|
-
['--zoom', 'zoom'], ['--look-at', 'look_at'], ['--ortho-scale', 'ortho_scale'], ['--texture', 'texture'], ['--max-triangles', 'max_triangles'], ['--exposure', 'exposure']
|
|
404
|
+
['--zoom', 'zoom'], ['--look-at', 'look_at'], ['--bounds', 'bounds'], ['--ortho-scale', 'ortho_scale'], ['--texture', 'texture'], ['--max-triangles', 'max_triangles'], ['--exposure', 'exposure'],
|
|
405
|
+
['--heightfield-res', 'heightfield_res'], ['--heightfield-layer', 'heightfield_layer'], ['--underlay-opacity', 'underlay_opacity'], ['--underlay-fit', 'underlay_fit']])
|
|
237
406
|
if (get(f) !== undefined)
|
|
238
407
|
a[k] = get(f);
|
|
239
|
-
for (const [f, k] of [['--legend', 'legend'], ['--points', 'points'], ['--annotate', 'annotate'], ['--textures', 'textures']])
|
|
408
|
+
for (const [f, k] of [['--legend', 'legend'], ['--points', 'points'], ['--annotate', 'annotate'], ['--textures', 'textures'], ['--transparent', 'transparent'], ['--sockets', 'sockets']])
|
|
240
409
|
if (has(f))
|
|
241
410
|
a[k] = true;
|
|
242
411
|
if (has('--no-view-labels'))
|
|
243
412
|
a.view_labels = false;
|
|
413
|
+
if (has('--no-grid'))
|
|
414
|
+
a.grid = false;
|
|
415
|
+
if (has('--no-footer'))
|
|
416
|
+
a.footer = false;
|
|
417
|
+
// a reference image path is relative to the current folder, as the output paths are
|
|
418
|
+
if (get('--underlay') !== undefined)
|
|
419
|
+
a.underlay = path.resolve(get('--underlay'));
|
|
244
420
|
try {
|
|
245
421
|
return renderArgs(a);
|
|
246
422
|
}
|
|
@@ -252,6 +428,13 @@ async function cook() {
|
|
|
252
428
|
// --render; options before the first --render apply to all of them. With one --render this is the old behaviour.
|
|
253
429
|
const renderAt = argv.flatMap((x, i) => (x === '--render' ? [i] : []));
|
|
254
430
|
const sharedArgs = argv.slice(0, renderAt.length ? renderAt[0] : argv.length);
|
|
431
|
+
// with several renders, options after the last --render belong to that render only: say so (a person who meant them
|
|
432
|
+
// for every render puts them before the first --render)
|
|
433
|
+
if (renderAt.length > 1) {
|
|
434
|
+
const last = argv.slice(renderAt[renderAt.length - 1] + 2).filter((x) => RENDER_FLAGS.includes(x));
|
|
435
|
+
if (last.length)
|
|
436
|
+
console.error(`warning: ${last.join(' ')} after the last --render apply to ${argv[renderAt[renderAt.length - 1] + 1]} only; options before the first --render apply to every render`);
|
|
437
|
+
}
|
|
255
438
|
const renders = renderAt.map((start, n) => {
|
|
256
439
|
const seg = argv.slice(start, n + 1 < renderAt.length ? renderAt[n + 1] : argv.length);
|
|
257
440
|
if (!seg[1] || seg[1].startsWith('--'))
|
|
@@ -262,9 +445,9 @@ async function cook() {
|
|
|
262
445
|
async function writeOutputs(r, frame) {
|
|
263
446
|
const geo = r.geo;
|
|
264
447
|
const at = (p) => (frame === undefined ? p : framePath(p, frame));
|
|
265
|
-
// Receipts for the viewer's saved files, only for files inside exports/
|
|
266
|
-
// elsewhere leaves no exports/ folder behind (the viewer lists that folder's files without receipts too).
|
|
267
|
-
const exportsDir =
|
|
448
|
+
// Receipts for the viewer's saved files, only for files inside the package's exports/ (exportsFolderFor): a run whose
|
|
449
|
+
// output goes elsewhere leaves no exports/ folder behind (the viewer lists that folder's files without receipts too).
|
|
450
|
+
const exportsDir = exportsFolderFor(file);
|
|
268
451
|
const record = (paths, format) => {
|
|
269
452
|
const inside = paths.every((p) => { const rel = path.relative(exportsDir, path.resolve(p)); return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel); });
|
|
270
453
|
if (inside)
|
|
@@ -293,40 +476,30 @@ async function cook() {
|
|
|
293
476
|
const fmt = ({ png: 'png16', raw: 'r16' }[raw] ?? raw);
|
|
294
477
|
if (!EXPORT_FORMATS.includes(fmt))
|
|
295
478
|
fail(`unknown export format "${fmt}" (${EXPORT_FORMATS.join(', ')}); pass --format`);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
texturePath: (t) => { const abs = host.resolvePath(t); return /^[a-z][a-z0-9+.-]*:\/\//i.test(abs) ? abs : path.relative(outDir, abs).split(path.sep).join('/'); },
|
|
321
|
-
warn: (m) => console.warn(`warning: ${m}`),
|
|
322
|
-
});
|
|
323
|
-
for (const f of files) {
|
|
324
|
-
fs.mkdirSync(path.dirname(path.resolve(f.path)), { recursive: true });
|
|
325
|
-
fs.writeFileSync(f.path, f.bytes);
|
|
326
|
-
}
|
|
327
|
-
if (files.length)
|
|
328
|
-
record(files.map((f) => f.path), fmt);
|
|
329
|
-
console.log(`exported ${files.length === 1 ? files[0].path : files.map((f) => f.path).join(', ')}${files.length > 1 || fmt !== 'glb' ? ` — ${summary}` : ''}`);
|
|
479
|
+
// the export tool's options (the MCP export tool and export targets use the same names and code)
|
|
480
|
+
const a = exportArgs();
|
|
481
|
+
const x = await forExport(r);
|
|
482
|
+
const source = exportSource({ graph: graphName(file), spec: graph, node: r.target, output: outputName, frame: r.frame, fps: r.fps, format: fmt, options: a, packages: packagesUsed(engine, graph, exportScope ?? engine.root), version: TOPOTOPO_VERSION });
|
|
483
|
+
const res = await serializeExport(x.geo, fmt, p, a, engine.host, source);
|
|
484
|
+
for (const w of res.warnings)
|
|
485
|
+
console.warn(`warning: ${w}`);
|
|
486
|
+
writeExportFiles(res.files);
|
|
487
|
+
if (res.files.length)
|
|
488
|
+
record(res.files.map((f) => f.path), fmt);
|
|
489
|
+
const files = res.files.filter((f) => f.path !== res.sourceManifest);
|
|
490
|
+
console.log(`exported ${files.length === 1 ? files[0].path : files.map((f) => f.path).join(', ')}${files.length > 1 || fmt !== 'glb' ? ` — ${res.summary}` : ''}${res.sourceFile ? `; source: ${res.sourceFile}` : ''}`);
|
|
491
|
+
if (exportNote)
|
|
492
|
+
console.log(exportNote);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/** The export flags given, as the export tool's options (snake_case, as export targets and the MCP export tool name them). */
|
|
496
|
+
function exportArgs() {
|
|
497
|
+
// every option of the export tool has a flag: --name value, booleans --name / --no-name (io/targets.ts)
|
|
498
|
+
try {
|
|
499
|
+
return exportOptionsFromFlags(argv);
|
|
500
|
+
}
|
|
501
|
+
catch (e) {
|
|
502
|
+
return fail(`export: ${e.message}`);
|
|
330
503
|
}
|
|
331
504
|
}
|
|
332
505
|
if (framesArg) {
|
|
@@ -337,8 +510,8 @@ async function cook() {
|
|
|
337
510
|
return;
|
|
338
511
|
const cooked = [...r.results.values()].filter((n) => !n.cached && !n.error).length;
|
|
339
512
|
console.log(`frame ${f}: ${r.target} in ${r.ms.toFixed(0)} ms (${cooked} node(s) cooked) — ${r.geo.numPoints} points, ${r.geo.numPrims} prims`);
|
|
340
|
-
if (
|
|
341
|
-
console.log(
|
|
513
|
+
if (inspectDetail)
|
|
514
|
+
console.log(await inspectText(r));
|
|
342
515
|
await writeOutputs(r, f);
|
|
343
516
|
}, { target, fps });
|
|
344
517
|
console.log(`cooked ${file} frames ${range.start}-${range.end}${range.step !== 1 ? `:${range.step}` : ''}: ${res.frames - res.failed.length}/${res.frames} ok`);
|
|
@@ -350,37 +523,44 @@ async function cook() {
|
|
|
350
523
|
report(r);
|
|
351
524
|
if (!r.ok || !r.geo)
|
|
352
525
|
process.exit(1);
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
console.log(inspect(r.geo, { detail: opt('--inspect') ?? 'summary', uvResolution: opt('--uv-resolution') !== undefined ? Number(opt('--uv-resolution')) : undefined }));
|
|
526
|
+
const vars = varArgs.length ? ` with ${varArgs.map((v) => v.trim()).join(', ')}` : '';
|
|
527
|
+
console.log(`cooked ${file} → ${outputName !== undefined ? `output "${outputName}" (${r.target})` : r.target}${r.frame !== 1 ? ` at frame ${r.frame}` : ''}${vars} in ${r.ms.toFixed(0)} ms`);
|
|
528
|
+
// without --inspect the short summary; --inspect <detail> the report (src/inspect.ts, io/inspect-scene.ts)
|
|
529
|
+
console.log(inspectDetail ? await inspectText(r) : summarize(r.geo));
|
|
358
530
|
await writeOutputs(r);
|
|
359
531
|
if (argv.includes('--export-all'))
|
|
360
532
|
await exportAll();
|
|
361
533
|
}
|
|
362
|
-
/** --export-all: every published output with an export target (io/targets.ts), into exports/
|
|
534
|
+
/** --export-all: every published output with an export target (io/targets.ts), into the package's exports/ (exportsFolderFor). */
|
|
363
535
|
async function exportAll() {
|
|
364
|
-
const name = graphName(file), exportsDir =
|
|
536
|
+
const name = graphName(file), exportsDir = exportsFolderFor(file);
|
|
365
537
|
const published = publishedOutputs(name, graph, engine.findOutput(graph).name);
|
|
366
538
|
if (!published.some((p) => p.target))
|
|
367
539
|
fail(`--export-all: no output of ${file} has an export target; add "export": "glb" to the graph (default output) or to an entry of "outputs"`);
|
|
368
540
|
const prepared = [];
|
|
541
|
+
// a target the export refuses (its path written with a prefix that is gone) fails the run before anything cooks
|
|
542
|
+
const refused = published.find((p) => p.target?.refused);
|
|
543
|
+
if (refused)
|
|
544
|
+
fail(`--export-all: "${refused.label}": ${prefixGone(refused.target.refused)}; nothing was written`);
|
|
369
545
|
for (const p of published) {
|
|
370
546
|
if (!p.target)
|
|
371
547
|
continue;
|
|
372
|
-
const r = await engine.cook(graph, { target: p.node, frame: single, fps });
|
|
548
|
+
const r = await engine.cook(graph, { target: p.node, frame: single, fps, ...(exportScope ? { scope: exportScope } : {}) });
|
|
373
549
|
report(r);
|
|
374
550
|
if (!r.ok || !r.geo)
|
|
375
|
-
fail(`--export-all: "${p.label}" did not cook; nothing was written`);
|
|
376
|
-
prepared.push(await prepareTarget(r.geo, name, p, exportsDir, engine.host));
|
|
551
|
+
fail(`--export-all: "${p.label}" did not cook${exportScope ? ' with the published copies' : ''}; nothing was written`);
|
|
552
|
+
prepared.push(await prepareTarget(r.geo, name, p, exportsDir, engine.host, { frame: r.frame, fps: r.fps, packages: packagesUsed(engine, graph, exportScope ?? engine.root) }));
|
|
377
553
|
}
|
|
378
554
|
writeTargets(prepared, exportsDir);
|
|
555
|
+
// paths as the person finds them from where they ran the command
|
|
556
|
+
const rel = (f) => path.relative(process.cwd(), f) || f;
|
|
379
557
|
for (const p of prepared)
|
|
380
|
-
console.log(`exported ${p.label} → ${path.join(
|
|
558
|
+
console.log(`exported ${p.label} → ${rel(path.join(p.root, ...p.target.path.split('/')))} — ${p.summary}${p.sourceFile ? `; source: ${rel(p.sourceFile)}` : ''}`);
|
|
381
559
|
const skipped = published.filter((p) => !p.target).map((p) => p.label);
|
|
382
560
|
if (skipped.length)
|
|
383
561
|
console.log(`no export target (skipped): ${skipped.join(', ')}`);
|
|
562
|
+
if (exportNote)
|
|
563
|
+
console.log(exportNote);
|
|
384
564
|
}
|
|
385
565
|
// stop the kernel worker threads (idle ones would not hold the process, but a clean exit should not wait on them)
|
|
386
566
|
await engine.host.pool?.close();
|