topotopo 0.4.0 → 0.5.0
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 +323 -146
- 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 +196 -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 +44 -5
- package/dist/render/preview.d.ts +15 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +66 -5
- package/dist/render/raster.js +506 -138
- 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 +17 -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,146 @@ 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
|
+
' [--transparent] (PNG with alpha) [--no-grid] [--sockets] (scene empties as labelled dots with orient axes)',
|
|
124
|
+
' [--underlay ref.png] (a reference PNG behind the 3D views) [--underlay-opacity 0.5] [--underlay-fit bounds|width|height|view]',
|
|
65
125
|
' [--textures] (base colour maps on meshes) [--texture name|image/layer|material] (adds the texture view)',
|
|
66
126
|
' [--max-triangles 600000] (packed instances drawn; above it an evenly spread subset)',
|
|
67
|
-
'
|
|
68
|
-
'
|
|
127
|
+
' [--heightfield-res 256|full] (heightfields: quads drawn per side, default 256, said in the footer when a field has more; full = every sample)',
|
|
128
|
+
' [--heightfield-layer flow] (heightfields: the layer drawn in red, default mask; none draws none)',
|
|
69
129
|
' [--no-view-labels] (no view name labels or axis gizmo, e.g. for thumbnails)',
|
|
70
|
-
'
|
|
130
|
+
' several renders per cook: repeat --render; the options after a --render apply to that render (up to the next --render),',
|
|
131
|
+
' options before the first --render apply to every render. Example (both 1200x600):',
|
|
132
|
+
' --size 1200x600 --render side.png --views front --underlay ref.png --render beauty.png --views front_left --shading pbr',
|
|
133
|
+
' side.png: the front view over the reference; beauty.png: a pbr three-quarter view. Options after the last of several',
|
|
134
|
+
' --render apply to it alone (a warning says so)',
|
|
135
|
+
' export options (every option of the export tool; booleans as --name / --no-name):',
|
|
136
|
+
' [--compress none|meshopt|draco] [--quantize] [--tangents auto|preserve|none] [--pcg | --pcg-struct] [--attributes P,N,pscale] [--up-axis y|z] [--scale 100]',
|
|
137
|
+
' [--custom-attribs | --no-custom-attribs] (extra numeric attributes; glTF and USD default off, PLY on) [--materials | --no-materials]',
|
|
138
|
+
' [--vertex-colors | --no-vertex-colors] (glTF: also write Cd as COLOR_0 on prims with a named material; default off)',
|
|
139
|
+
' [--split-by-name | --no-split-by-name] [--precision 32|64] (geo) [--layer height] [--height-min 0] [--height-max 100] [--heightfield 0]',
|
|
71
140
|
' [--instancing packed|expand] (packed instances: glb/usda/geo keep them by default)',
|
|
72
141
|
' [--instances rows|expand] [--no-meshes] (csv/points.json of packed instances: one row per instance + meshes sidecar + GLBs)',
|
|
73
142
|
' export formats: .glb .gltf .obj .usda .ply .stl .json .geo (Houdini) .csv .points.json; heightfields .png (png16) .r16,',
|
|
74
143
|
' --format mask_png --layers a,b, --format unreal_landscape (a directory bundle; --tile-size 1008 for tiled Landscape);',
|
|
75
144
|
' images: --format textures --export out/maps (one PNG per image; --layers a,b or * for extra layers)',
|
|
145
|
+
' every export records how it was made (graph, graph hash, output, node, frame, fps, vars, seeds, every option with its default, version)',
|
|
146
|
+
' in its sidecar; replay: --output/--node, --frame, --fps, --var per var, --format and each option as its flag',
|
|
147
|
+
' (heightmap .json, <name>.meshes.json, landscape.json) or in <file>.source.json beside it; --help-topic export',
|
|
76
148
|
' 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
|
|
149
|
+
` ${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)`,
|
|
150
|
+
` ${prog} mcp [--package dir] [--viewer] (the MCP server over stdio, for MCP clients)`,
|
|
151
|
+
` ${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)`,
|
|
152
|
+
` ${prog} web [--port 7340] [--library <folder>] [--no-bake] (the web app: the registered workspaces and every library's packages, stable links for a board)`,
|
|
153
|
+
` ${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)`,
|
|
154
|
+
` ${prog} edit [folder] [--port 7341] (the live viewer on a package, default the current folder's)`,
|
|
155
|
+
' a package and the packages it uses (a folder named must exist; default: the current folder\'s package; kinds: ' + KINDS.join(', ') + '; --help-topic packages):',
|
|
156
|
+
...PACKAGE_COMMANDS.map((c) => ` ${prog} ${c.usage} (${c.what})`),
|
|
157
|
+
' Godot (exit 0 ok, 1 an output or package failed, 2 usage or setup; --help-topic godot):',
|
|
158
|
+
...GODOT_COMMANDS.map((c) => ` ${prog} ${c.usage} (${c.what})`),
|
|
83
159
|
].join('\n'));
|
|
84
160
|
process.exit(0);
|
|
85
161
|
}
|
|
162
|
+
if (argv.includes('--help-topic')) {
|
|
163
|
+
// the MCP help topics (src/mcp/docs.ts), the same text the help tool returns
|
|
164
|
+
const name = opt('--help-topic');
|
|
165
|
+
const topics = ['overview', ...topicList()];
|
|
166
|
+
if (name === undefined || name.startsWith('-'))
|
|
167
|
+
fail(`--help-topic needs a topic: ${topics.join(', ')}`);
|
|
168
|
+
const text = topicText(name);
|
|
169
|
+
if (text === null) {
|
|
170
|
+
const s = didYouMean(name, topics);
|
|
171
|
+
fail(`unknown topic "${name}"${s.length ? ` (did you mean ${s.join(', ')}?)` : ''}; topics: ${topics.join(', ')}`);
|
|
172
|
+
}
|
|
173
|
+
console.log(text);
|
|
174
|
+
process.exit(0);
|
|
175
|
+
}
|
|
86
176
|
if (argv.includes('--catalog') || opt('--help-node')) {
|
|
87
|
-
// node types
|
|
177
|
+
// node types, the current folder's assets, the outputs of the packages its package uses, and those of TopoTopo's own
|
|
178
|
+
// packages (house, stairs, …) it does not use yet
|
|
88
179
|
const engine = new Engine(createNodeHost({ baseDir: process.cwd() }));
|
|
89
180
|
await engine.init();
|
|
90
|
-
const
|
|
181
|
+
const pk = openPackages(engine, process.cwd());
|
|
182
|
+
const defs = [...allNodeDefs(), ...engine.assetsIn().map((x) => x.def), ...engine.packageDefs()];
|
|
91
183
|
if (argv.includes('--catalog'))
|
|
92
|
-
console.log(catalogText(defs));
|
|
184
|
+
console.log(catalogText(defs, { cli: true }));
|
|
93
185
|
else {
|
|
94
|
-
const
|
|
95
|
-
|
|
186
|
+
const name = opt('--help-node');
|
|
187
|
+
// an output of a package this one does not use yet is read where its library holds it (nothing is copied)
|
|
188
|
+
const d = defs.find((x) => x.type === name) ?? (name.includes('/') ? engine.resolveDef(name) ?? pk.describe(name) ?? undefined : undefined);
|
|
189
|
+
// a package output this folder cannot cook as it is (one of TopoTopo's own it does not use, a folder in no package)
|
|
190
|
+
const why = name.includes('/') && !engine.resolveDef(name) ? engine.packageIssue(name) : null;
|
|
191
|
+
const said = why ? `${why.error}${why.hint ? ` (${why.hint})` : ''}` : '';
|
|
192
|
+
console.log(d ? `${nodeDoc(d)}${said ? `\nin this folder: ${said}` : ''}` : said || `unknown node "${name}" (see --catalog)`);
|
|
96
193
|
}
|
|
97
194
|
process.exit(0);
|
|
98
195
|
}
|
|
196
|
+
/** --follow owner/name (repeatable): packages whose working folders a cook uses instead of their copies. */
|
|
197
|
+
const followArgs = argv.flatMap((x, i) => (x === '--follow' ? [argv[i + 1]] : []));
|
|
198
|
+
if (followArgs.some((f) => f === undefined || f.startsWith('--')))
|
|
199
|
+
fail('--follow needs a package: --follow owner/name');
|
|
99
200
|
if (argv[0] === 'view') {
|
|
100
|
-
// `topotopo view <graph.json> [--port 7341]`: cook the file, serve the live 3D viewer
|
|
201
|
+
// `topotopo view <graph.json> [--port 7341]`: cook the file, serve the live 3D viewer and follow its saves; the values
|
|
202
|
+
// tuned on the page are session values over the file, written into it on request (src/viewer/graph-file.ts)
|
|
101
203
|
const file = argv[1];
|
|
102
204
|
if (!file || file.startsWith('-'))
|
|
103
|
-
fail(`usage: ${prog} view <graph.json> [--port 7341]`);
|
|
205
|
+
fail(`usage: ${prog} view <graph.json> [--port 7341] [--follow owner/name]`);
|
|
104
206
|
if (!fs.existsSync(file))
|
|
105
207
|
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); });
|
|
208
|
+
const { viewGraphFile } = await import('./viewer/graph-file.js');
|
|
209
|
+
try {
|
|
210
|
+
await viewGraphFile(file, { name: graphName(file), port: opt('--port') !== undefined ? Number(opt('--port')) : undefined, follow: followArgs });
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
fail(`${prog} view: ${e.message}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else if (['web', 'library', 'edit', 'workspace', 'init', 'libraries', 'use', 'remove', 'packages', 'publish', 'search', 'outdated', 'check', 'update'].includes(argv[0])) {
|
|
217
|
+
// the web app, its libraries and its editor; a package and the packages it uses (src/packages/commands.ts). A command that ends
|
|
218
|
+
// gives its exit code; the web app and the editor keep running
|
|
219
|
+
const { commands } = await import('./packages/commands.js');
|
|
220
|
+
const code = await commands[argv[0]](argv.slice(1), prog);
|
|
221
|
+
if (typeof code === 'number')
|
|
222
|
+
process.exit(code);
|
|
156
223
|
}
|
|
157
|
-
else if (argv[0] === '
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
await
|
|
224
|
+
else if (argv[0] === 'cook' || argv[0] === 'godot') {
|
|
225
|
+
// a package's published outputs cooked into a Godot project, and the Godot plugin's setup and status
|
|
226
|
+
// (src/host/godot.ts, src/host/cook.ts): exit 0, 1 (an output or package failed), 2 (usage, setup or protocol)
|
|
227
|
+
const { cookCommand, godotCommand } = await import('./host/godot.js');
|
|
228
|
+
const { consoleIo } = await import('./packages/commands.js');
|
|
229
|
+
process.exit(await (argv[0] === 'cook' ? cookCommand : godotCommand)(argv.slice(1), consoleIo));
|
|
162
230
|
}
|
|
163
231
|
else if (argv[0] === 'mcp') {
|
|
164
|
-
// `topotopo mcp [--
|
|
232
|
+
// `topotopo mcp [--package dir] [--viewer]`: the MCP server over stdio; src/mcp/server.ts reads the remaining
|
|
165
233
|
// arguments from process.argv and runs until the client closes stdin
|
|
166
234
|
process.argv.splice(2, 1);
|
|
167
235
|
await import('./mcp/server.js');
|
|
@@ -208,9 +276,76 @@ async function cook() {
|
|
|
208
276
|
catch (e) {
|
|
209
277
|
fail(`${prog}: ${file} is not valid JSON: ${e.message}`);
|
|
210
278
|
}
|
|
279
|
+
// --var name=value (repeatable): the graph's vars for this run; exports record the result, so a manifest replays
|
|
280
|
+
const varArgs = argv.flatMap((x, i) => (x === '--var' ? [argv[i + 1]] : []));
|
|
281
|
+
if (varArgs.some((v) => v === undefined || v.startsWith('--')))
|
|
282
|
+
fail('--var needs name=value (e.g. --var relief=8)');
|
|
283
|
+
try {
|
|
284
|
+
graph = withVars(graph, varArgs.map(parseVarArg));
|
|
285
|
+
}
|
|
286
|
+
catch (e) {
|
|
287
|
+
fail(`--var: ${e.message}`);
|
|
288
|
+
}
|
|
289
|
+
// --output name: a named output (graph.outputs) instead of the default output
|
|
290
|
+
const outputName = opt('--output');
|
|
291
|
+
if (argv.includes('--output') && (outputName === undefined || outputName.startsWith('--')))
|
|
292
|
+
fail('--output needs the name of one of the graph\'s outputs');
|
|
293
|
+
if (outputName !== undefined && opt('--node') !== undefined)
|
|
294
|
+
fail('use either --node or --output, not both');
|
|
295
|
+
let target = opt('--node');
|
|
296
|
+
if (target !== undefined && graph?.nodes && !Object.hasOwn(graph.nodes, target) && graph?.outputs && Object.hasOwn(graph.outputs, target))
|
|
297
|
+
fail(`--node: ${file} has no node "${target}", but an output of that name: --output ${target}`);
|
|
298
|
+
if (outputName !== undefined) {
|
|
299
|
+
const outs = graph?.outputs && typeof graph.outputs === 'object' ? graph.outputs : {};
|
|
300
|
+
const o = Object.hasOwn(outs, outputName) ? outs[outputName] : undefined;
|
|
301
|
+
if (!o || typeof o.node !== 'string') {
|
|
302
|
+
const names = Object.keys(outs), s = didYouMean(outputName, names);
|
|
303
|
+
const isNode = !!graph?.nodes && typeof graph.nodes === 'object' && Object.hasOwn(graph.nodes, outputName);
|
|
304
|
+
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)'}`);
|
|
305
|
+
}
|
|
306
|
+
target = o.node;
|
|
307
|
+
}
|
|
211
308
|
const engine = new Engine(createNodeHost({ baseDir: path.dirname(path.resolve(file)) }));
|
|
212
309
|
await engine.init();
|
|
213
|
-
|
|
310
|
+
// the packages the file's package uses: one the graph names for the first time is added (said), and
|
|
311
|
+
// --follow uses a package's working folder for this run. A graph that does not validate as a dry run sees it adds
|
|
312
|
+
// nothing: its errors are said and the run ends. --locked (a build machine) adds nothing and changes no file: a
|
|
313
|
+
// package it does not use, or a copy missing or edited by hand, fails the run instead.
|
|
314
|
+
let pk;
|
|
315
|
+
try {
|
|
316
|
+
pk = openPackages(engine, path.dirname(path.resolve(file)), { follow: followArgs });
|
|
317
|
+
}
|
|
318
|
+
catch (e) {
|
|
319
|
+
fail(`--follow: ${e.message}`);
|
|
320
|
+
}
|
|
321
|
+
const dry = pk.dryRun(graph);
|
|
322
|
+
const invalid = engine.validate(graph, '', { ...engine.root, id: dry.id, packages: dry.resolver }).errors;
|
|
323
|
+
if (invalid.length)
|
|
324
|
+
fail(invalid.map((e) => `error [${e.node}] ${e.message}${e.hint ? ` (hint: ${e.hint})` : ''}`).join('\n'));
|
|
325
|
+
if (argv.includes('--locked')) {
|
|
326
|
+
const unlocked = pk.locked(graph);
|
|
327
|
+
if (unlocked.length)
|
|
328
|
+
fail(unlocked.map((x) => `--locked: ${x}`).join('\n'));
|
|
329
|
+
}
|
|
330
|
+
else
|
|
331
|
+
for (const n of pk.addFor(graph))
|
|
332
|
+
console.log(n);
|
|
333
|
+
for (const p of pk.check())
|
|
334
|
+
console.error(`warning: ${p}`);
|
|
335
|
+
for (const f of pk.following())
|
|
336
|
+
console.log(`following ${f.package}: its working folder ${f.dir} instead of its copy, for renders and inspect (exports use the published copy)`);
|
|
337
|
+
// the packages shown live (--follow, a workspace that follows its own) are for looking: an export cooks with their
|
|
338
|
+
// published copies (a cook of its own when the graph names one) and says so
|
|
339
|
+
const exportNote = pk.publishedNote(graph);
|
|
340
|
+
const exportScope = exportNote ? pk.published() : null;
|
|
341
|
+
const forExport = async (r, node = r.target) => {
|
|
342
|
+
if (!exportScope)
|
|
343
|
+
return r;
|
|
344
|
+
const e = await engine.cook(graph, { target: node, frame: r.frame, fps: r.fps, scope: exportScope });
|
|
345
|
+
if (!e.ok || !e.geo)
|
|
346
|
+
fail(`export: with the published copies, ${node} does not cook (${e.errors.map((x) => `${x.node}: ${x.message}`).join('; ') || 'no geometry'}); nothing was written`);
|
|
347
|
+
return e;
|
|
348
|
+
};
|
|
214
349
|
const fps = opt('--fps') !== undefined ? Number(opt('--fps')) : undefined;
|
|
215
350
|
const framesArg = opt('--frames');
|
|
216
351
|
const frameArg = opt('--frame');
|
|
@@ -221,26 +356,64 @@ async function cook() {
|
|
|
221
356
|
const single = frameArg !== undefined ? Number(frameArg) : undefined;
|
|
222
357
|
if (single !== undefined && !Number.isFinite(single))
|
|
223
358
|
fail(`--frame expects a number, got "${frameArg}"`);
|
|
359
|
+
// --inspect <detail>: checked before cooking
|
|
360
|
+
const INSPECT_DETAILS = ['summary', 'attributes', 'topology', 'all', 'uv', 'budget', 'scene'];
|
|
361
|
+
const inspectDetail = opt('--inspect');
|
|
362
|
+
if (argv.includes('--inspect') && (inspectDetail === undefined || !INSPECT_DETAILS.includes(inspectDetail))) {
|
|
363
|
+
const s = inspectDetail ? didYouMean(inspectDetail, INSPECT_DETAILS) : [];
|
|
364
|
+
fail(`--inspect needs one of ${INSPECT_DETAILS.join(', ')}${inspectDetail ? `, got "${inspectDetail}"${s.length ? ` (did you mean ${s.join(', ')}?)` : ''}` : ''}`);
|
|
365
|
+
}
|
|
366
|
+
const uvRes = opt('--uv-resolution') !== undefined ? Number(opt('--uv-resolution')) : undefined;
|
|
367
|
+
/** The --inspect report of a cook: text, or the uv / budget / scene report as JSON with --json. */
|
|
368
|
+
async function inspectText(r) {
|
|
369
|
+
const geo = r.geo, json = argv.includes('--json');
|
|
370
|
+
if (inspectDetail === 'scene') {
|
|
371
|
+
// the glb export with the export options given, read back
|
|
372
|
+
const res = await serializeExport(geo, 'glb', 'scene.glb', exportArgs(), engine.host);
|
|
373
|
+
const glb = res.files.find((f) => /\.glb$/i.test(f.path));
|
|
374
|
+
if (!glb)
|
|
375
|
+
return 'scene: the glb export wrote no file';
|
|
376
|
+
const rep = glbSceneReport(glb.bytes);
|
|
377
|
+
const warn = res.warnings.map((w) => `warning: ${w}`);
|
|
378
|
+
return json ? JSON.stringify(rep, null, 2) : [...sceneReportText(rep), ...warn].join('\n');
|
|
379
|
+
}
|
|
380
|
+
if (inspectDetail === 'uv' && json)
|
|
381
|
+
return JSON.stringify(uvReport(geo, { resolution: uvRes }), null, 2);
|
|
382
|
+
if (inspectDetail === 'budget' && json)
|
|
383
|
+
return JSON.stringify(budgetReport(geo, nodeBudgetInput(graph, r.results)), null, 2);
|
|
384
|
+
return inspect(geo, { detail: inspectDetail, uvResolution: uvRes, nodes: inspectDetail === 'budget' ? nodeBudgetInput(graph, r.results) : undefined });
|
|
385
|
+
}
|
|
224
386
|
function report(r) {
|
|
225
387
|
for (const e of r.errors)
|
|
226
388
|
console.error(`error [${e.node}] ${e.message}${e.hint ? ` (hint: ${e.hint})` : ''}`);
|
|
227
389
|
for (const w of r.warnings)
|
|
228
390
|
console.error(`warning [${w.node}] ${w.message}`);
|
|
229
391
|
}
|
|
392
|
+
/** Every render flag (renderFlags reads them, plus --views, --color-by, --checker). */
|
|
393
|
+
const RENDER_FLAGS = ['--wireframe', '--hard-angle', '--section', '--clip', '--glyphs', '--glyph-attrib', '--glyph-scale', '--max-glyphs', '--labels', '--max-labels',
|
|
394
|
+
'--shading', '--ao-radius', '--size', '--render-scale', '--azimuth', '--elevation', '--zoom', '--look-at', '--ortho-scale', '--texture', '--max-triangles', '--exposure',
|
|
395
|
+
'--heightfield-res', '--heightfield-layer', '--underlay', '--underlay-opacity', '--underlay-fit', '--legend', '--points', '--annotate', '--textures', '--transparent',
|
|
396
|
+
'--sockets', '--no-view-labels', '--no-grid', '--views', '--color-by', '--checker'];
|
|
230
397
|
/** Render overlay flags → render tool arguments → RenderOptions (src/render/options.ts). */
|
|
231
398
|
function renderFlags(get, has) {
|
|
232
399
|
const a = {};
|
|
233
400
|
for (const [f, k] of [['--wireframe', 'wireframe'], ['--hard-angle', 'hard_angle'], ['--section', 'section'], ['--clip', 'clip'], ['--glyphs', 'glyphs'],
|
|
234
401
|
['--glyph-attrib', 'glyph_attrib'], ['--glyph-scale', 'glyph_scale'], ['--max-glyphs', 'max_glyphs'], ['--labels', 'labels'], ['--max-labels', 'max_labels'],
|
|
235
402
|
['--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']
|
|
403
|
+
['--zoom', 'zoom'], ['--look-at', 'look_at'], ['--ortho-scale', 'ortho_scale'], ['--texture', 'texture'], ['--max-triangles', 'max_triangles'], ['--exposure', 'exposure'],
|
|
404
|
+
['--heightfield-res', 'heightfield_res'], ['--heightfield-layer', 'heightfield_layer'], ['--underlay-opacity', 'underlay_opacity'], ['--underlay-fit', 'underlay_fit']])
|
|
237
405
|
if (get(f) !== undefined)
|
|
238
406
|
a[k] = get(f);
|
|
239
|
-
for (const [f, k] of [['--legend', 'legend'], ['--points', 'points'], ['--annotate', 'annotate'], ['--textures', 'textures']])
|
|
407
|
+
for (const [f, k] of [['--legend', 'legend'], ['--points', 'points'], ['--annotate', 'annotate'], ['--textures', 'textures'], ['--transparent', 'transparent'], ['--sockets', 'sockets']])
|
|
240
408
|
if (has(f))
|
|
241
409
|
a[k] = true;
|
|
242
410
|
if (has('--no-view-labels'))
|
|
243
411
|
a.view_labels = false;
|
|
412
|
+
if (has('--no-grid'))
|
|
413
|
+
a.grid = false;
|
|
414
|
+
// a reference image path is relative to the current folder, as the output paths are
|
|
415
|
+
if (get('--underlay') !== undefined)
|
|
416
|
+
a.underlay = path.resolve(get('--underlay'));
|
|
244
417
|
try {
|
|
245
418
|
return renderArgs(a);
|
|
246
419
|
}
|
|
@@ -252,6 +425,13 @@ async function cook() {
|
|
|
252
425
|
// --render; options before the first --render apply to all of them. With one --render this is the old behaviour.
|
|
253
426
|
const renderAt = argv.flatMap((x, i) => (x === '--render' ? [i] : []));
|
|
254
427
|
const sharedArgs = argv.slice(0, renderAt.length ? renderAt[0] : argv.length);
|
|
428
|
+
// with several renders, options after the last --render belong to that render only: say so (a person who meant them
|
|
429
|
+
// for every render puts them before the first --render)
|
|
430
|
+
if (renderAt.length > 1) {
|
|
431
|
+
const last = argv.slice(renderAt[renderAt.length - 1] + 2).filter((x) => RENDER_FLAGS.includes(x));
|
|
432
|
+
if (last.length)
|
|
433
|
+
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`);
|
|
434
|
+
}
|
|
255
435
|
const renders = renderAt.map((start, n) => {
|
|
256
436
|
const seg = argv.slice(start, n + 1 < renderAt.length ? renderAt[n + 1] : argv.length);
|
|
257
437
|
if (!seg[1] || seg[1].startsWith('--'))
|
|
@@ -262,9 +442,9 @@ async function cook() {
|
|
|
262
442
|
async function writeOutputs(r, frame) {
|
|
263
443
|
const geo = r.geo;
|
|
264
444
|
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 =
|
|
445
|
+
// Receipts for the viewer's saved files, only for files inside the package's exports/ (exportsFolderFor): a run whose
|
|
446
|
+
// output goes elsewhere leaves no exports/ folder behind (the viewer lists that folder's files without receipts too).
|
|
447
|
+
const exportsDir = exportsFolderFor(file);
|
|
268
448
|
const record = (paths, format) => {
|
|
269
449
|
const inside = paths.every((p) => { const rel = path.relative(exportsDir, path.resolve(p)); return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel); });
|
|
270
450
|
if (inside)
|
|
@@ -293,40 +473,30 @@ async function cook() {
|
|
|
293
473
|
const fmt = ({ png: 'png16', raw: 'r16' }[raw] ?? raw);
|
|
294
474
|
if (!EXPORT_FORMATS.includes(fmt))
|
|
295
475
|
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}` : ''}`);
|
|
476
|
+
// the export tool's options (the MCP export tool and export targets use the same names and code)
|
|
477
|
+
const a = exportArgs();
|
|
478
|
+
const x = await forExport(r);
|
|
479
|
+
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 });
|
|
480
|
+
const res = await serializeExport(x.geo, fmt, p, a, engine.host, source);
|
|
481
|
+
for (const w of res.warnings)
|
|
482
|
+
console.warn(`warning: ${w}`);
|
|
483
|
+
writeExportFiles(res.files);
|
|
484
|
+
if (res.files.length)
|
|
485
|
+
record(res.files.map((f) => f.path), fmt);
|
|
486
|
+
const files = res.files.filter((f) => f.path !== res.sourceManifest);
|
|
487
|
+
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}` : ''}`);
|
|
488
|
+
if (exportNote)
|
|
489
|
+
console.log(exportNote);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/** The export flags given, as the export tool's options (snake_case, as export targets and the MCP export tool name them). */
|
|
493
|
+
function exportArgs() {
|
|
494
|
+
// every option of the export tool has a flag: --name value, booleans --name / --no-name (io/targets.ts)
|
|
495
|
+
try {
|
|
496
|
+
return exportOptionsFromFlags(argv);
|
|
497
|
+
}
|
|
498
|
+
catch (e) {
|
|
499
|
+
return fail(`export: ${e.message}`);
|
|
330
500
|
}
|
|
331
501
|
}
|
|
332
502
|
if (framesArg) {
|
|
@@ -337,8 +507,8 @@ async function cook() {
|
|
|
337
507
|
return;
|
|
338
508
|
const cooked = [...r.results.values()].filter((n) => !n.cached && !n.error).length;
|
|
339
509
|
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(
|
|
510
|
+
if (inspectDetail)
|
|
511
|
+
console.log(await inspectText(r));
|
|
342
512
|
await writeOutputs(r, f);
|
|
343
513
|
}, { target, fps });
|
|
344
514
|
console.log(`cooked ${file} frames ${range.start}-${range.end}${range.step !== 1 ? `:${range.step}` : ''}: ${res.frames - res.failed.length}/${res.frames} ok`);
|
|
@@ -350,37 +520,44 @@ async function cook() {
|
|
|
350
520
|
report(r);
|
|
351
521
|
if (!r.ok || !r.geo)
|
|
352
522
|
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 }));
|
|
523
|
+
const vars = varArgs.length ? ` with ${varArgs.map((v) => v.trim()).join(', ')}` : '';
|
|
524
|
+
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`);
|
|
525
|
+
// without --inspect the short summary; --inspect <detail> the report (src/inspect.ts, io/inspect-scene.ts)
|
|
526
|
+
console.log(inspectDetail ? await inspectText(r) : summarize(r.geo));
|
|
358
527
|
await writeOutputs(r);
|
|
359
528
|
if (argv.includes('--export-all'))
|
|
360
529
|
await exportAll();
|
|
361
530
|
}
|
|
362
|
-
/** --export-all: every published output with an export target (io/targets.ts), into exports/
|
|
531
|
+
/** --export-all: every published output with an export target (io/targets.ts), into the package's exports/ (exportsFolderFor). */
|
|
363
532
|
async function exportAll() {
|
|
364
|
-
const name = graphName(file), exportsDir =
|
|
533
|
+
const name = graphName(file), exportsDir = exportsFolderFor(file);
|
|
365
534
|
const published = publishedOutputs(name, graph, engine.findOutput(graph).name);
|
|
366
535
|
if (!published.some((p) => p.target))
|
|
367
536
|
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
537
|
const prepared = [];
|
|
538
|
+
// a target the export refuses (its path written with a prefix that is gone) fails the run before anything cooks
|
|
539
|
+
const refused = published.find((p) => p.target?.refused);
|
|
540
|
+
if (refused)
|
|
541
|
+
fail(`--export-all: "${refused.label}": ${prefixGone(refused.target.refused)}; nothing was written`);
|
|
369
542
|
for (const p of published) {
|
|
370
543
|
if (!p.target)
|
|
371
544
|
continue;
|
|
372
|
-
const r = await engine.cook(graph, { target: p.node, frame: single, fps });
|
|
545
|
+
const r = await engine.cook(graph, { target: p.node, frame: single, fps, ...(exportScope ? { scope: exportScope } : {}) });
|
|
373
546
|
report(r);
|
|
374
547
|
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));
|
|
548
|
+
fail(`--export-all: "${p.label}" did not cook${exportScope ? ' with the published copies' : ''}; nothing was written`);
|
|
549
|
+
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
550
|
}
|
|
378
551
|
writeTargets(prepared, exportsDir);
|
|
552
|
+
// paths as the person finds them from where they ran the command
|
|
553
|
+
const rel = (f) => path.relative(process.cwd(), f) || f;
|
|
379
554
|
for (const p of prepared)
|
|
380
|
-
console.log(`exported ${p.label} → ${path.join(
|
|
555
|
+
console.log(`exported ${p.label} → ${rel(path.join(p.root, ...p.target.path.split('/')))} — ${p.summary}${p.sourceFile ? `; source: ${rel(p.sourceFile)}` : ''}`);
|
|
381
556
|
const skipped = published.filter((p) => !p.target).map((p) => p.label);
|
|
382
557
|
if (skipped.length)
|
|
383
558
|
console.log(`no export target (skipped): ${skipped.join(', ')}`);
|
|
559
|
+
if (exportNote)
|
|
560
|
+
console.log(exportNote);
|
|
384
561
|
}
|
|
385
562
|
// stop the kernel worker threads (idle ones would not hold the process, but a clean exit should not wait on them)
|
|
386
563
|
await engine.host.pool?.close();
|