topotopo 0.3.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 +40 -10
- package/README.md +475 -111
- package/dist/cli.js +328 -133
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/analysis.d.ts +5 -1
- package/dist/core/analysis.js +8 -3
- package/dist/core/bake.d.ts +16 -8
- package/dist/core/bake.js +165 -29
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +238 -97
- 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 +204 -4
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/imageops.d.ts +6 -0
- package/dist/core/imageops.js +51 -0
- 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 +11 -0
- package/dist/core/materials.js +56 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/packed.js +11 -0
- package/dist/core/particles.d.ts +1 -1
- package/dist/core/particles.js +1 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/rbd.js +13 -1
- 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/scatter.d.ts +1 -1
- package/dist/core/scatter.js +1 -1
- package/dist/core/scene.d.ts +20 -0
- package/dist/core/scene.js +72 -0
- 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 +15 -2
- package/dist/core/snippet-lib.js +40 -14
- package/dist/core/solidify.d.ts +38 -0
- package/dist/core/solidify.js +356 -0
- package/dist/core/tangents.d.ts +54 -0
- package/dist/core/tangents.js +218 -0
- package/dist/core/texcoord.d.ts +4 -0
- package/dist/core/texcoord.js +14 -0
- 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 +32 -0
- package/dist/core/topology.js +238 -7
- package/dist/core/traceimage.d.ts +7 -0
- package/dist/core/traceimage.js +221 -0
- package/dist/core/tritri.d.ts +5 -0
- package/dist/core/tritri.js +120 -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 +15 -16
- package/dist/core/uv.js +36 -189
- 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 +127 -0
- package/dist/core/uvreport.js +372 -0
- 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 +95 -61
- 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 +5 -3
- package/dist/index.js +3 -2
- package/dist/inspect.d.ts +84 -1
- package/dist/inspect.js +271 -24
- package/dist/io/common.d.ts +33 -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 +355 -51
- 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 +149 -14
- 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 +816 -119
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +70 -24
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +207 -108
- 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 +207 -83
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +54 -5
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +22 -10
- package/dist/nodes/curves.js +440 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +13 -39
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.d.ts +1 -0
- package/dist/nodes/imageops.js +203 -0
- package/dist/nodes/index.d.ts +4 -0
- package/dist/nodes/index.js +4 -0
- package/dist/nodes/material.js +91 -23
- package/dist/nodes/measure.js +45 -18
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/rbd.js +1 -1
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.d.ts +1 -0
- package/dist/nodes/scene.js +55 -0
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/solidify.d.ts +1 -0
- package/dist/nodes/solidify.js +52 -0
- 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 +11 -3
- package/dist/nodes/util.d.ts +1 -1
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +6 -2
- 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/pbr.d.ts +28 -0
- package/dist/render/pbr.js +378 -0
- package/dist/render/preview.d.ts +69 -0
- package/dist/render/preview.js +26 -0
- package/dist/render/raster.d.ts +78 -7
- package/dist/render/raster.js +600 -145
- package/dist/render/texview.d.ts +7 -1
- package/dist/render/texview.js +34 -2
- 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/camera.js +1 -1
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +100 -0
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +6 -2
- package/dist/viewer/app/guides.js +123 -1
- package/dist/viewer/app/keymap.js +7 -4
- package/dist/viewer/app/layers.js +5 -5
- package/dist/viewer/app/main.js +186 -53
- package/dist/viewer/app/markers.js +61 -1
- 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 +177 -53
- package/dist/viewer/app/scene.js +35 -6
- package/dist/viewer/app/select.js +5 -4
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +66 -8
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +48 -1
- 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 +24 -11
- 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 +24 -7
- package/dist/viewer/server.js +289 -31
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/web/bake.d.ts +34 -0
- package/dist/web/bake.js +153 -0
- 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 -105
- package/dist/workspace.js +359 -375
- 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 +23 -29
- package/kernels/pkg-simd/README.md +23 -29
- 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 +23 -8
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/shelf/index.json +0 -190
package/dist/cli.js
CHANGED
|
@@ -1,24 +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] [--legend] [--size 800] [--render-scale 2] [--
|
|
7
|
-
// [--
|
|
8
|
-
// [--
|
|
9
|
-
// [--
|
|
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]
|
|
9
|
+
// [--compress meshopt] [--quantize] [--tangents auto|preserve|none] [--pcg | --pcg-struct] [--attributes P,N,pscale] [--up-axis z] [--scale 100]
|
|
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
|
|
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]
|
|
22
56
|
// Installed from npm the same commands are `topotopo …` (package.json bin → dist/cli.js, built by npm run build).
|
|
23
57
|
import fs from 'node:fs';
|
|
24
58
|
import path from 'node:path';
|
|
@@ -26,18 +60,29 @@ import zlib from 'node:zlib';
|
|
|
26
60
|
import './nodes/index.js';
|
|
27
61
|
import { Engine } from './graph/engine.js';
|
|
28
62
|
import { allNodeDefs } from './graph/registry.js';
|
|
63
|
+
import { KINDS } from './graph/outputs.js';
|
|
29
64
|
import { createNodeHost } from './host/node.js';
|
|
30
|
-
import {
|
|
65
|
+
import { renderGeometryAsync } from './render/raster.js';
|
|
31
66
|
import { parseViews } from './render/raster.js';
|
|
32
67
|
import { renderArgs } from './render/options.js';
|
|
33
68
|
import { encodePNG } from './render/png.js';
|
|
34
69
|
import { EXPORT_FORMATS, exportFormatFromPath } from './io/export.js';
|
|
35
|
-
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';
|
|
36
76
|
import { ArtifactStore } from './host/artifacts.js';
|
|
37
|
-
import { prepareTarget, writeTargets } from './host/export-targets.js';
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
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';
|
|
82
|
+
import { uvReport } from './core/uvreport.js';
|
|
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';
|
|
41
86
|
const argv = process.argv.slice(2);
|
|
42
87
|
const opt = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : undefined; };
|
|
43
88
|
const fail = (msg) => { console.error(msg); process.exit(1); };
|
|
@@ -45,111 +90,146 @@ const fail = (msg) => { console.error(msg); process.exit(1); };
|
|
|
45
90
|
const graphName = (file) => path.basename(file).replace(/\.json$/i, '').replace(/[^A-Za-z0-9_-]/g, '_').replace(/^[^A-Za-z]/, 'g$&') || 'graph';
|
|
46
91
|
// the command as the user typed it: the sources from a clone, or the package's bin (dist/cli.js)
|
|
47
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);
|
|
48
95
|
if (argv.includes('-v') || argv.includes('-V') || argv.includes('--version')) {
|
|
49
|
-
|
|
50
|
-
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
51
|
-
console.log(`topotopo ${pkg.version}`);
|
|
96
|
+
console.log(`topotopo ${TOPOTOPO_VERSION}`);
|
|
52
97
|
process.exit(0);
|
|
53
98
|
}
|
|
54
99
|
if (!argv.length || argv.includes('-h') || argv.includes('--help')) {
|
|
55
100
|
console.log([
|
|
56
|
-
`usage: ${prog} <graph.json> [--node n] [--frame N | --frames A-B[:step]] [--fps 24]`,
|
|
57
|
-
' [--render out.png] [--views quad|quad_uv|turntable|persp|front,top|persp,uv|persp,section] [--checker] [--color-by attr] [--export out.glb]
|
|
58
|
-
' [--
|
|
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)',
|
|
59
116
|
' render overlays: [--wireframe all|hard|boundary|groups] [--hard-angle 30] [--section y:0.5] [--clip x:0.5[:abs]]',
|
|
60
117
|
' [--glyphs N|up|orient|v] [--glyph-attrib a] [--labels groups,pieces,points,prims,attrib:name] [--legend] [--points]',
|
|
61
|
-
' [--shading flat|matcap|ao] [--
|
|
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]',
|
|
62
125
|
' [--textures] (base colour maps on meshes) [--texture name|image/layer|material] (adds the texture view)',
|
|
63
126
|
' [--max-triangles 600000] (packed instances drawn; above it an evenly spread subset)',
|
|
64
|
-
'
|
|
65
|
-
'
|
|
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)',
|
|
66
129
|
' [--no-view-labels] (no view name labels or axis gizmo, e.g. for thumbnails)',
|
|
67
|
-
'
|
|
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]',
|
|
68
140
|
' [--instancing packed|expand] (packed instances: glb/usda/geo keep them by default)',
|
|
69
141
|
' [--instances rows|expand] [--no-meshes] (csv/points.json of packed instances: one row per instance + meshes sidecar + GLBs)',
|
|
70
142
|
' export formats: .glb .gltf .obj .usda .ply .stl .json .geo (Houdini) .csv .points.json; heightfields .png (png16) .r16,',
|
|
71
143
|
' --format mask_png --layers a,b, --format unreal_landscape (a directory bundle; --tile-size 1008 for tiled Landscape);',
|
|
72
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',
|
|
73
148
|
' with --frames, output paths may use {frame} or {frame:04}; otherwise out.0001.png style names are written',
|
|
74
|
-
` ${prog} --catalog | --help-node <type> | --version`,
|
|
75
|
-
` ${prog} mcp [--
|
|
76
|
-
` ${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)`,
|
|
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})`),
|
|
77
159
|
].join('\n'));
|
|
78
160
|
process.exit(0);
|
|
79
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
|
+
}
|
|
80
176
|
if (argv.includes('--catalog') || opt('--help-node')) {
|
|
81
|
-
// 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
|
|
82
179
|
const engine = new Engine(createNodeHost({ baseDir: process.cwd() }));
|
|
83
180
|
await engine.init();
|
|
84
|
-
const
|
|
181
|
+
const pk = openPackages(engine, process.cwd());
|
|
182
|
+
const defs = [...allNodeDefs(), ...engine.assetsIn().map((x) => x.def), ...engine.packageDefs()];
|
|
85
183
|
if (argv.includes('--catalog'))
|
|
86
|
-
console.log(catalogText(defs));
|
|
184
|
+
console.log(catalogText(defs, { cli: true }));
|
|
87
185
|
else {
|
|
88
|
-
const
|
|
89
|
-
|
|
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)`);
|
|
90
193
|
}
|
|
91
194
|
process.exit(0);
|
|
92
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');
|
|
93
200
|
if (argv[0] === 'view') {
|
|
94
|
-
// `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)
|
|
95
203
|
const file = argv[1];
|
|
96
204
|
if (!file || file.startsWith('-'))
|
|
97
|
-
fail(`usage: ${prog} view <graph.json> [--port 7341]`);
|
|
205
|
+
fail(`usage: ${prog} view <graph.json> [--port 7341] [--follow owner/name]`);
|
|
98
206
|
if (!fs.existsSync(file))
|
|
99
207
|
fail(`${prog}: no such graph file "${file}"`);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const r = await ws.cook(name);
|
|
123
|
-
console.log(`${r.ok ? 'cooked' : 'FAILED'} ${name} in ${r.ms.toFixed(0)} ms${r.ok ? '' : ': ' + r.errors.map((e) => `${e.node}: ${e.message}`).join('; ')}`);
|
|
124
|
-
ws.bump(name);
|
|
125
|
-
};
|
|
126
|
-
await load();
|
|
127
|
-
// an export target set on the page goes into the graph file, the only source here: only "export" keys change
|
|
128
|
-
const persistGraph = (g) => {
|
|
129
|
-
if (g !== name)
|
|
130
|
-
return;
|
|
131
|
-
const spec = ws.getGraph(name), raw = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
132
|
-
if (spec.export === undefined)
|
|
133
|
-
delete raw.export;
|
|
134
|
-
else
|
|
135
|
-
raw.export = spec.export;
|
|
136
|
-
for (const [id, o] of Object.entries(spec.outputs ?? {})) {
|
|
137
|
-
if (!raw.outputs?.[id])
|
|
138
|
-
continue;
|
|
139
|
-
if (o.export === undefined)
|
|
140
|
-
delete raw.outputs[id].export;
|
|
141
|
-
else
|
|
142
|
-
raw.outputs[id].export = o.export;
|
|
143
|
-
}
|
|
144
|
-
fs.writeFileSync(file, JSON.stringify(raw, null, 2) + '\n');
|
|
145
|
-
};
|
|
146
|
-
const v = await startViewer(ws, opt('--port') !== undefined ? Number(opt('--port')) : undefined, { inputsWhere: `beside ${path.basename(file)}`, persistGraph });
|
|
147
|
-
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)`);
|
|
148
|
-
let timer;
|
|
149
|
-
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);
|
|
223
|
+
}
|
|
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));
|
|
150
230
|
}
|
|
151
231
|
else if (argv[0] === 'mcp') {
|
|
152
|
-
// `topotopo mcp [--
|
|
232
|
+
// `topotopo mcp [--package dir] [--viewer]`: the MCP server over stdio; src/mcp/server.ts reads the remaining
|
|
153
233
|
// arguments from process.argv and runs until the client closes stdin
|
|
154
234
|
process.argv.splice(2, 1);
|
|
155
235
|
await import('./mcp/server.js');
|
|
@@ -196,9 +276,76 @@ async function cook() {
|
|
|
196
276
|
catch (e) {
|
|
197
277
|
fail(`${prog}: ${file} is not valid JSON: ${e.message}`);
|
|
198
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
|
+
}
|
|
199
308
|
const engine = new Engine(createNodeHost({ baseDir: path.dirname(path.resolve(file)) }));
|
|
200
309
|
await engine.init();
|
|
201
|
-
|
|
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
|
+
};
|
|
202
349
|
const fps = opt('--fps') !== undefined ? Number(opt('--fps')) : undefined;
|
|
203
350
|
const framesArg = opt('--frames');
|
|
204
351
|
const frameArg = opt('--frame');
|
|
@@ -209,26 +356,64 @@ async function cook() {
|
|
|
209
356
|
const single = frameArg !== undefined ? Number(frameArg) : undefined;
|
|
210
357
|
if (single !== undefined && !Number.isFinite(single))
|
|
211
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
|
+
}
|
|
212
386
|
function report(r) {
|
|
213
387
|
for (const e of r.errors)
|
|
214
388
|
console.error(`error [${e.node}] ${e.message}${e.hint ? ` (hint: ${e.hint})` : ''}`);
|
|
215
389
|
for (const w of r.warnings)
|
|
216
390
|
console.error(`warning [${w.node}] ${w.message}`);
|
|
217
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'];
|
|
218
397
|
/** Render overlay flags → render tool arguments → RenderOptions (src/render/options.ts). */
|
|
219
398
|
function renderFlags(get, has) {
|
|
220
399
|
const a = {};
|
|
221
400
|
for (const [f, k] of [['--wireframe', 'wireframe'], ['--hard-angle', 'hard_angle'], ['--section', 'section'], ['--clip', 'clip'], ['--glyphs', 'glyphs'],
|
|
222
401
|
['--glyph-attrib', 'glyph_attrib'], ['--glyph-scale', 'glyph_scale'], ['--max-glyphs', 'max_glyphs'], ['--labels', 'labels'], ['--max-labels', 'max_labels'],
|
|
223
402
|
['--shading', 'shading'], ['--ao-radius', 'ao_radius'], ['--size', 'size'], ['--render-scale', 'scale'], ['--azimuth', 'azimuth'], ['--elevation', 'elevation'],
|
|
224
|
-
['--zoom', 'zoom'], ['--look-at', 'look_at'], ['--ortho-scale', 'ortho_scale'], ['--texture', 'texture'], ['--max-triangles', 'max_triangles']]
|
|
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']])
|
|
225
405
|
if (get(f) !== undefined)
|
|
226
406
|
a[k] = get(f);
|
|
227
|
-
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']])
|
|
228
408
|
if (has(f))
|
|
229
409
|
a[k] = true;
|
|
230
410
|
if (has('--no-view-labels'))
|
|
231
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'));
|
|
232
417
|
try {
|
|
233
418
|
return renderArgs(a);
|
|
234
419
|
}
|
|
@@ -240,6 +425,13 @@ async function cook() {
|
|
|
240
425
|
// --render; options before the first --render apply to all of them. With one --render this is the old behaviour.
|
|
241
426
|
const renderAt = argv.flatMap((x, i) => (x === '--render' ? [i] : []));
|
|
242
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
|
+
}
|
|
243
435
|
const renders = renderAt.map((start, n) => {
|
|
244
436
|
const seg = argv.slice(start, n + 1 < renderAt.length ? renderAt[n + 1] : argv.length);
|
|
245
437
|
if (!seg[1] || seg[1].startsWith('--'))
|
|
@@ -250,9 +442,9 @@ async function cook() {
|
|
|
250
442
|
async function writeOutputs(r, frame) {
|
|
251
443
|
const geo = r.geo;
|
|
252
444
|
const at = (p) => (frame === undefined ? p : framePath(p, frame));
|
|
253
|
-
// Receipts for the viewer's saved files, only for files inside exports/
|
|
254
|
-
// elsewhere leaves no exports/ folder behind (the viewer lists that folder's files without receipts too).
|
|
255
|
-
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);
|
|
256
448
|
const record = (paths, format) => {
|
|
257
449
|
const inside = paths.every((p) => { const rel = path.relative(exportsDir, path.resolve(p)); return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel); });
|
|
258
450
|
if (inside)
|
|
@@ -267,7 +459,7 @@ async function cook() {
|
|
|
267
459
|
if (get('--texture') !== undefined)
|
|
268
460
|
views = !views && v === undefined ? ro.views : views && views.includes('texture') ? views : [...(views ?? parseViews('quad')), 'texture'];
|
|
269
461
|
const title = path.basename(file, '.json') + (r.frame !== 1 ? ` @ frame ${r.frame}` : '');
|
|
270
|
-
const img =
|
|
462
|
+
const img = await renderGeometryAsync(geo, { ...ro, views, colorBy: get('--color-by') ?? null, checker: has('--checker'), title }, (t) => engine.host.readFile(t));
|
|
271
463
|
const p = at(out);
|
|
272
464
|
fs.mkdirSync(path.dirname(path.resolve(p)), { recursive: true });
|
|
273
465
|
fs.writeFileSync(p, encodePNG(img.rgba, img.width, img.height, (d) => zlib.deflateSync(d)));
|
|
@@ -281,37 +473,30 @@ async function cook() {
|
|
|
281
473
|
const fmt = ({ png: 'png16', raw: 'r16' }[raw] ?? raw);
|
|
282
474
|
if (!EXPORT_FORMATS.includes(fmt))
|
|
283
475
|
fail(`unknown export format "${fmt}" (${EXPORT_FORMATS.join(', ')}); pass --format`);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
for (const f of files) {
|
|
309
|
-
fs.mkdirSync(path.dirname(path.resolve(f.path)), { recursive: true });
|
|
310
|
-
fs.writeFileSync(f.path, f.bytes);
|
|
311
|
-
}
|
|
312
|
-
if (files.length)
|
|
313
|
-
record(files.map((f) => f.path), fmt);
|
|
314
|
-
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}`);
|
|
315
500
|
}
|
|
316
501
|
}
|
|
317
502
|
if (framesArg) {
|
|
@@ -322,8 +507,8 @@ async function cook() {
|
|
|
322
507
|
return;
|
|
323
508
|
const cooked = [...r.results.values()].filter((n) => !n.cached && !n.error).length;
|
|
324
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`);
|
|
325
|
-
if (
|
|
326
|
-
console.log(
|
|
510
|
+
if (inspectDetail)
|
|
511
|
+
console.log(await inspectText(r));
|
|
327
512
|
await writeOutputs(r, f);
|
|
328
513
|
}, { target, fps });
|
|
329
514
|
console.log(`cooked ${file} frames ${range.start}-${range.end}${range.step !== 1 ? `:${range.step}` : ''}: ${res.frames - res.failed.length}/${res.frames} ok`);
|
|
@@ -335,34 +520,44 @@ async function cook() {
|
|
|
335
520
|
report(r);
|
|
336
521
|
if (!r.ok || !r.geo)
|
|
337
522
|
process.exit(1);
|
|
338
|
-
|
|
339
|
-
console.log(
|
|
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));
|
|
340
527
|
await writeOutputs(r);
|
|
341
528
|
if (argv.includes('--export-all'))
|
|
342
529
|
await exportAll();
|
|
343
530
|
}
|
|
344
|
-
/** --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). */
|
|
345
532
|
async function exportAll() {
|
|
346
|
-
const name = graphName(file), exportsDir =
|
|
533
|
+
const name = graphName(file), exportsDir = exportsFolderFor(file);
|
|
347
534
|
const published = publishedOutputs(name, graph, engine.findOutput(graph).name);
|
|
348
535
|
if (!published.some((p) => p.target))
|
|
349
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"`);
|
|
350
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`);
|
|
351
542
|
for (const p of published) {
|
|
352
543
|
if (!p.target)
|
|
353
544
|
continue;
|
|
354
|
-
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 } : {}) });
|
|
355
546
|
report(r);
|
|
356
547
|
if (!r.ok || !r.geo)
|
|
357
|
-
fail(`--export-all: "${p.label}" did not cook; nothing was written`);
|
|
358
|
-
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) }));
|
|
359
550
|
}
|
|
360
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;
|
|
361
554
|
for (const p of prepared)
|
|
362
|
-
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)}` : ''}`);
|
|
363
556
|
const skipped = published.filter((p) => !p.target).map((p) => p.label);
|
|
364
557
|
if (skipped.length)
|
|
365
558
|
console.log(`no export target (skipped): ${skipped.join(', ')}`);
|
|
559
|
+
if (exportNote)
|
|
560
|
+
console.log(exportNote);
|
|
366
561
|
}
|
|
367
562
|
// stop the kernel worker threads (idle ones would not hold the process, but a clean exit should not wait on them)
|
|
368
563
|
await engine.host.pool?.close();
|