topotopo 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +327 -147
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/bake.d.ts +14 -3
- package/dist/core/bake.js +153 -4
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +76 -3
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +203 -3
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +7 -0
- package/dist/core/materials.js +45 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scene.js +2 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +14 -1
- package/dist/core/snippet-lib.js +39 -13
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +5 -1
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +10 -0
- package/dist/core/topology.js +168 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +4 -18
- package/dist/core/uv.js +35 -188
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +61 -0
- package/dist/core/uvreport.js +207 -143
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +66 -62
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +80 -2
- package/dist/inspect.js +265 -30
- package/dist/io/common.d.ts +25 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +134 -47
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +148 -13
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +786 -143
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +56 -27
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +198 -103
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +151 -47
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +51 -3
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +21 -9
- package/dist/nodes/curves.js +433 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +12 -38
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.js +16 -19
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/material.js +89 -24
- package/dist/nodes/measure.js +43 -17
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.js +4 -2
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +6 -2
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +5 -1
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +57 -5
- package/dist/render/preview.d.ts +17 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +74 -5
- package/dist/render/raster.js +527 -143
- package/dist/render/texview.d.ts +6 -0
- package/dist/render/texview.js +27 -0
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +27 -7
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +5 -1
- package/dist/viewer/app/guides.js +122 -0
- package/dist/viewer/app/keymap.js +6 -3
- package/dist/viewer/app/layers.js +4 -4
- package/dist/viewer/app/main.js +185 -52
- package/dist/viewer/app/markers.js +60 -0
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +176 -52
- package/dist/viewer/app/scene.js +30 -5
- package/dist/viewer/app/select.js +4 -3
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +65 -7
- package/dist/viewer/app/vars.js +47 -0
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +23 -10
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +14 -9
- package/dist/viewer/server.js +266 -28
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/{gallery → web}/bake.d.ts +4 -4
- package/dist/{gallery → web}/bake.js +24 -15
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -118
- package/dist/workspace.js +358 -460
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +2 -1
- package/kernels/pkg-simd/README.md +2 -1
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +13 -8
- package/dist/gallery/app/gallery.css +0 -100
- package/dist/gallery/app/gallery.js +0 -80
- package/dist/gallery/cli.d.ts +0 -4
- package/dist/gallery/cli.js +0 -157
- package/dist/gallery/library.d.ts +0 -124
- package/dist/gallery/library.js +0 -366
- package/dist/gallery/pages.d.ts +0 -94
- package/dist/gallery/pages.js +0 -148
- package/dist/gallery/server.d.ts +0 -21
- package/dist/gallery/server.js +0 -391
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/dist/mcp/library.d.ts +0 -12
- package/dist/mcp/library.js +0 -159
- package/shelf/index.json +0 -190
package/dist/mcp/tools.js
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import zlib from 'node:zlib';
|
|
5
|
-
import {
|
|
5
|
+
import { Session, EditRejected } from '../session.js';
|
|
6
6
|
import { allNodeDefs } from '../graph/registry.js';
|
|
7
7
|
import { didYouMean } from '../graph/params.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { catalogText, nodeDoc, topicList, topicText, INSTRUCTIONS } from './docs.js';
|
|
9
|
+
import { nodeBudgetInput, summarize, inspect } from '../inspect.js';
|
|
10
|
+
import { glbSceneReport, sceneReportText } from '../io/inspect-scene.js';
|
|
11
11
|
import { renderGeometryAsync } from '../render/raster.js';
|
|
12
12
|
import { renderArgs } from '../render/options.js';
|
|
13
13
|
import { encodePNG } from '../render/png.js';
|
|
14
14
|
import { EXPORT_FORMATS, exportFormatFromPath } from '../io/export.js';
|
|
15
|
-
import { publishedOutputs } from '../io/targets.js';
|
|
15
|
+
import { exportToolOptions, publishedOutputs } from '../io/targets.js';
|
|
16
|
+
import { kindMismatch, outputKind } from '../io/kinds.js';
|
|
17
|
+
import { exportSource } from '../io/source.js';
|
|
18
|
+
import { packageAt, packagesUsed } from '../graph/packages.js';
|
|
16
19
|
import { ArtifactStore } from '../host/artifacts.js';
|
|
17
20
|
import { prepareTarget, serializeExport, writeExportFiles, writeTargets } from '../host/export-targets.js';
|
|
21
|
+
import { TOPOTOPO_VERSION } from '../host/version.js';
|
|
18
22
|
import { evalGroup } from '../core/groups.js';
|
|
19
23
|
import { Geometry } from '../core/geometry.js';
|
|
20
24
|
import { verifyTools } from './verify.js';
|
|
@@ -22,7 +26,7 @@ import { inputsTool } from './inputs.js';
|
|
|
22
26
|
const text = (t, isError = false) => ({ content: [{ type: 'text', text: t }], ...(isError ? { isError } : {}) });
|
|
23
27
|
/** " at frame N" when the cook was not at frame 1. */
|
|
24
28
|
const atFrame = (r) => (r.frame !== 1 ? ` at frame ${r.frame}` : '');
|
|
25
|
-
function reportText(name, r, extraNotes = []) {
|
|
29
|
+
function reportText(name, r, extraNotes = [], extraWarnings = []) {
|
|
26
30
|
const lines = [];
|
|
27
31
|
const nodes = [...r.results.values()];
|
|
28
32
|
const cooked = nodes.filter((n) => !n.cached && !n.error).length;
|
|
@@ -34,8 +38,10 @@ function reportText(name, r, extraNotes = []) {
|
|
|
34
38
|
lines.push(` [${e.node}] ${e.message}${e.hint ? `\n hint: ${e.hint}` : ''}`);
|
|
35
39
|
for (const n of [...r.notes, ...extraNotes])
|
|
36
40
|
lines.push(`note: ${n}`);
|
|
37
|
-
if (r.warnings.length) {
|
|
41
|
+
if (r.warnings.length || extraWarnings.length) {
|
|
38
42
|
lines.push('warnings:');
|
|
43
|
+
for (const w of extraWarnings)
|
|
44
|
+
lines.push(` ${w}`);
|
|
39
45
|
for (const w of r.warnings.slice(0, 15))
|
|
40
46
|
lines.push(` [${w.node}] ${w.message}`);
|
|
41
47
|
if (r.warnings.length > 15)
|
|
@@ -65,25 +71,33 @@ async function pngContent(g, o, host) {
|
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* Write every file of an export (heightmap sidecars and layers, instance-stream sidecar and mesh GLBs, the Unreal
|
|
68
|
-
* Landscape bundle, or the single file of other formats)
|
|
69
|
-
* written relative to the output file. Returns the report
|
|
74
|
+
* Landscape bundle, or the single file of other formats) and the record of how it was made (`source`, io/source.ts).
|
|
75
|
+
* Textures are read through the host; USD texture paths are written relative to the output file. Returns the report
|
|
76
|
+
* text.
|
|
70
77
|
*/
|
|
71
|
-
export async function writeExport(geo, format, p, a, host, record) {
|
|
72
|
-
const res = await serializeExport(geo, format, p, a, host);
|
|
78
|
+
export async function writeExport(geo, format, p, a, host, record, source) {
|
|
79
|
+
const res = await serializeExport(geo, format, p, a, host, source);
|
|
73
80
|
writeExportFiles(res.files);
|
|
74
81
|
if (res.files.length)
|
|
75
82
|
record?.(res.files.map((f) => f.path));
|
|
76
|
-
return exportReport(res.files, res.outDir, format, res.summary, res.warnings);
|
|
83
|
+
return exportReport(res.files, res.outDir, format, res.summary, res.warnings, res.sourceFile, res.sourceManifest);
|
|
77
84
|
}
|
|
78
|
-
/**
|
|
79
|
-
|
|
85
|
+
/**
|
|
86
|
+
* "wrote <file or N files in dir> (format, KB): summary", where the export's source is recorded, then any warnings. A
|
|
87
|
+
* standalone <file>.source.json is named on its own line, not in the file list.
|
|
88
|
+
*/
|
|
89
|
+
function exportReport(all, outDir, format, summary, warnings, sourceFile, sourceManifest) {
|
|
90
|
+
const files = all.filter((f) => f.path !== sourceManifest);
|
|
80
91
|
const total = files.reduce((s, f) => s + f.bytes.byteLength, 0);
|
|
81
92
|
const rel = (f) => path.relative(outDir, f).split(path.sep).join('/');
|
|
82
93
|
const list = files.length === 1 ? files[0].path : `${files.length} files in ${outDir}: ${files.slice(0, 12).map((f) => rel(f.path)).join(', ')}${files.length > 12 ? ', …' : ''}`;
|
|
83
|
-
return `wrote ${list} (${format}, ${(total / 1024).toFixed(1)} KB): ${summary}${warnings.length ? '\nwarnings:\n ' + warnings.join('\n ') : ''}`;
|
|
94
|
+
return `wrote ${list} (${format}, ${(total / 1024).toFixed(1)} KB): ${summary}${sourceFile ? `\nsource recorded in ${rel(sourceFile)} (graph, vars, seeds, frame; help topic "export")` : ''}${warnings.length ? '\nwarnings:\n ' + warnings.join('\n ') : ''}`;
|
|
84
95
|
}
|
|
85
|
-
function renderOpts(a, g, label) {
|
|
96
|
+
function renderOpts(a, g, label, dir) {
|
|
86
97
|
const ro = renderArgs(a); // views (presets, persp@az, section), overlays, shading, labels … (src/render/options.ts)
|
|
98
|
+
// a reference image is a path relative to the package, as save_to is
|
|
99
|
+
if (ro.underlay)
|
|
100
|
+
ro.underlay = path.resolve(dir, ro.underlay);
|
|
87
101
|
let highlight = null;
|
|
88
102
|
if (a.highlight) {
|
|
89
103
|
const cls = a.highlight_class === 'point' ? 'point' : 'prim';
|
|
@@ -93,22 +107,28 @@ function renderOpts(a, g, label) {
|
|
|
93
107
|
}
|
|
94
108
|
return {
|
|
95
109
|
...ro, wireframe: ro.wireframe ?? 'auto', colorBy: ro.colorBy ?? null, highlight,
|
|
96
|
-
points: ro.points ?? 'auto',
|
|
110
|
+
points: ro.points ?? 'auto', target: ro.target ?? null, title: label, checker: !!ro.checker,
|
|
97
111
|
};
|
|
98
112
|
}
|
|
99
113
|
const RENDER_PROPS = {
|
|
100
|
-
views: { description: 'views: "quad" (persp+front+right+top, default), "quad_uv" (persp + uv side by side), "turntable" (persp at azimuth 0/90/180/270), a single view, or a list of persp/front/back/left/right/top/bottom/uv/section/texture/persp@<azimuth
|
|
114
|
+
views: { description: 'views: "quad" (persp+front+right+top, default), "quad_uv" (persp + uv side by side), "turntable" (persp at azimuth 0/90/180/270), a single view, or a list of persp/front/back/left/right/top/bottom/front_left/front_right/back_left/back_right/uv/section/texture/persp@<azimuth> (front_left … are persp views at azimuth -45/45/-135/135). Every 3D view fits the bounds. "texture" draws images flat (see texture). "uv" draws the 0..1 UV square (UDIM tiles, 0.1 grid): polygons filled by chart/island colour, island borders yellow, overlaps red. "section" slices along section_axis and looks along it: the cut filled red (blue = inside-out solid), open sheets as yellow lines, the far half ghosted', anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }] },
|
|
101
115
|
checker: { type: 'boolean', description: 'shade 3D views with an 8×8 uv checker (light cells tinted red along u, green along v) to see stretch, seams and flips' },
|
|
102
|
-
size: {
|
|
103
|
-
|
|
116
|
+
size: { description: 'pixels per view: n (square; default 512 for several views, 800 for one) or "WxH" / [w, h] (e.g. "1600x600" for a long prop: the views fit the bounds to that aspect); scale 2 doubles it', anyOf: [{ type: 'number' }, { type: 'string' }, { type: 'array', items: { type: 'number' } }] },
|
|
117
|
+
transparent: { type: 'boolean', description: 'transparent background: pixels without surface, line or point get alpha 0 (PNG with alpha); no ground grid or axis gizmo; the footer stays opaque' },
|
|
118
|
+
grid: { type: 'boolean', description: 'the persp ground grid on y = 0 (default true, false with transparent)' },
|
|
119
|
+
underlay: { type: 'string', description: 'a reference image (PNG, path relative to the package) drawn behind the 3D views, e.g. a side photo behind views:"front"' },
|
|
120
|
+
underlay_opacity: { type: 'number', description: 'underlay opacity 0..1 (default 0.5)' },
|
|
121
|
+
underlay_fit: { type: 'string', enum: ['bounds', 'width', 'height', 'view'], description: 'where the underlay goes: "bounds" (default: fitted into the rectangle the bounds cover in each view, keeping its aspect, so a reference cropped to the object lines up with it), "width" (its width spans the width of the bounds), "height" (its height spans their height), "view" (the whole view)' },
|
|
122
|
+
sockets: { type: 'boolean', description: 'draw scene empties (scene_null sockets) as dots with their name and orient axes (X red, Y green, Z blue), through surfaces; without it pbr renders hide them' },
|
|
123
|
+
color_by: { type: 'string', description: 'colour by attribute (e.g. "height", "class", "N", "P.y"); ints/strings get categorical colours; under shading "pbr" the colours tint the shaded material' },
|
|
104
124
|
highlight: { type: 'string', description: 'group pattern to highlight in orange (e.g. "front", "@P.y>1")' },
|
|
105
125
|
highlight_class: { type: 'string', enum: ['prim', 'point'] },
|
|
106
|
-
wireframe: { description: 'true/false/"auto" (polygon edges
|
|
126
|
+
wireframe: { description: 'true/false/"auto" (polygon edges; auto, the default, draws them below 6,000 polygons but never under shading "pbr" or textures:true, and the footer says EDGES AUTO when it does), or a crisp 1 px edge overlay: "all" (every edge: topology density), "hard" (dihedral > hard_angle in cyan + crease/hard/sharp edge groups), "boundary" (open edges pink, non-manifold yellow, winding flips violet), "groups" (each edge group in its colour, with legend), "none"', anyOf: [{ type: 'boolean' }, { type: 'string', enum: ['auto', 'none', 'all', 'hard', 'boundary', 'groups'] }] },
|
|
107
127
|
points: { type: 'boolean', description: 'draw all points, sized by pscale when present (default: only loose points)' },
|
|
108
|
-
azimuth: { type: 'number', description: 'persp camera azimuth degrees (default 35)' },
|
|
109
|
-
elevation: { type: 'number', description: 'persp camera elevation degrees (default 25)' },
|
|
110
|
-
zoom: { type: 'number', description: '
|
|
111
|
-
target: { type: 'array', items: { type: 'number' }, description: 'look-at point
|
|
128
|
+
azimuth: { type: 'number', description: 'persp camera azimuth in degrees around +Y (default 35): 0 = camera on +Z looking at the front, 90 = on +X (right side), 180 = back, -90 = left' },
|
|
129
|
+
elevation: { type: 'number', description: 'persp camera elevation in degrees above the horizon (default 25; 90 looks straight down)' },
|
|
130
|
+
zoom: { type: 'number', description: 'relative to the fit: 1 (default) = the bounds fill the view with a small margin, 0.5 = half that size. Above 1 it magnifies around look_at and crops: only with look_at or ortho_scale, else it is held at 1 (a note says so)' },
|
|
131
|
+
target: { type: 'array', items: { type: 'number' }, description: 'look-at point [x,y,z] (same as look_at)' },
|
|
112
132
|
hard_angle: { type: 'number', description: 'wireframe "hard": dihedral angle threshold in degrees (default 30)' },
|
|
113
133
|
point_numbers: { type: 'boolean', description: 'label visible point numbers (the first max_labels points)' },
|
|
114
134
|
prim_numbers: { type: 'boolean', description: 'label visible prim numbers at prim centroids (the first max_labels prims)' },
|
|
@@ -125,6 +145,8 @@ const RENDER_PROPS = {
|
|
|
125
145
|
glyph_scale: { type: 'number', description: 'glyph length in world units (default 5% of the bbox diagonal)' },
|
|
126
146
|
max_glyphs: { type: 'number', description: 'evenly subsample to at most this many glyphs (default 400)' },
|
|
127
147
|
max_triangles: { type: 'number', description: 'packed instances: draw up to this many expanded triangles (default 600000, max 50M); above it an evenly spread subset is drawn and a note says so' },
|
|
148
|
+
heightfield_res: { description: 'heightfields: the most quads drawn per side (default 256: a 513 × 513 field draws at 257 × 257, and the footer and a note say so), or "full" for every sample', anyOf: [{ type: 'number', minimum: 1 }, { type: 'string', enum: ['full'] }] },
|
|
149
|
+
heightfield_layer: { type: 'string', description: 'heightfields: the layer drawn in red over the shaded terrain (default "mask"; e.g. "flow", "sediment", "path"; "none" for none). 0..1 layers show as they are, others from their min to their max; the footer legend names it, and a note says when a field has no such layer' },
|
|
128
150
|
label_groups: { type: 'boolean', description: 'name each point/prim group on a visible member near its centroid, outline prim groups / mark group points in the label colour, legend with counts' },
|
|
129
151
|
label_pieces: { type: 'boolean', description: 'number connected pieces (#0, #1, … in connectivity order)' },
|
|
130
152
|
label_attrib: { type: 'string', description: 'label each distinct value of a string/int attribute (e.g. "name") on its elements; colours match color_by' },
|
|
@@ -132,8 +154,10 @@ const RENDER_PROPS = {
|
|
|
132
154
|
shading: { type: 'string', enum: ['default', 'flat', 'matcap', 'ao', 'pbr'], description: 'flat: facets (ignores N); matcap: clay that reads form; ao: screen-space ambient occlusion darkens creases and cavities; pbr: the exported metallic-roughness material (base colour, normal, orm/roughness maps, emissive, unlit) under a fixed studio light rig, deterministic' },
|
|
133
155
|
exposure: { type: 'number', description: 'shading "pbr": exposure in stops (default 0)' },
|
|
134
156
|
ao_radius: { type: 'number', description: 'shading "ao": sample radius in pixels (default 10)' },
|
|
135
|
-
look_at: { type: 'array', items: { type: 'number' }, description: 'look-at point [x,y,z] (
|
|
136
|
-
|
|
157
|
+
look_at: { type: 'array', items: { type: 'number' }, description: 'look-at point [x, y, z] in world metres (x right, y up, z towards the front; default the bbox centre): the view centres on it and still fits the bounds; with zoom > 1 it zooms into that point' },
|
|
158
|
+
bounds: { type: 'array', items: { type: 'array', items: { type: 'number' } }, description: 'world-space [[x0, y0, z0], [x1, y1, z1]] (min then max, metres, Y up): every 3D view frames these bounds instead of the box of the geometry, so renders of different geometries share one camera (timelapse frames, turntable azimuths)' },
|
|
159
|
+
footer: { type: 'boolean', description: 'false leaves out the footer strip (the image is exactly the tiles; annotate is then ignored); default true' },
|
|
160
|
+
ortho_scale: { type: 'number', description: 'ortho and section views: the world width in metres across a view (default: fit the bounds), e.g. 0.5 shows 50 cm across' },
|
|
137
161
|
scale: { type: 'number', description: '2 (up to 4) for a 2× image: tiles, text, lines and markers scaled' },
|
|
138
162
|
annotate: { type: 'boolean', description: 'second footer line naming the active overlays plus geometry notes (pieces, open edges, back-facing %); default on whenever an overlay option is used' },
|
|
139
163
|
view_labels: { type: 'boolean', description: 'false hides the name label of every view and the persp axis gizmo (clean thumbnails); default true' },
|
|
@@ -145,11 +169,32 @@ export function makeTools(ws, opts = {}) {
|
|
|
145
169
|
// would pile up in exports/renders (save_to keeps a copy elsewhere).
|
|
146
170
|
const renderDestination = (name, node) => path.join(ws.exportDir, 'renders', `${name}-${node}`.replace(/[^A-Za-z0-9_.-]/g, '_') + '.png');
|
|
147
171
|
const engine = ws.engine;
|
|
172
|
+
/**
|
|
173
|
+
* The named outputs of a cooked graph that cook to another kind than their author pinned ("kind" in its outputs, help
|
|
174
|
+
* topic "packages"), each said as a warning: publishing the package would block on them.
|
|
175
|
+
*/
|
|
176
|
+
const kindWarnings = async (name, r, frame) => {
|
|
177
|
+
const out = [];
|
|
178
|
+
if (!r.ok)
|
|
179
|
+
return out;
|
|
180
|
+
for (const [id, o] of Object.entries(ws.graphs.get(name)?.outputs ?? {})) {
|
|
181
|
+
if (!o || typeof o.kind !== 'string')
|
|
182
|
+
continue;
|
|
183
|
+
const c = o.node === r.target ? r : await ws.cook(name, o.node, frame);
|
|
184
|
+
// an output that does not cook says so when it is cooked
|
|
185
|
+
if (!c.ok || !c.geo)
|
|
186
|
+
continue;
|
|
187
|
+
const said = kindMismatch(o.kind, outputKind(c.geo));
|
|
188
|
+
if (said)
|
|
189
|
+
out.push(`[output "${id}"] ${said}`);
|
|
190
|
+
}
|
|
191
|
+
return out;
|
|
192
|
+
};
|
|
148
193
|
/** The text (+ optional render) of a cook report. */
|
|
149
194
|
const reportResult = async (name, r, a, extraNotes = []) => {
|
|
150
|
-
const content = [{ type: 'text', text: reportText(name, r, extraNotes) }];
|
|
195
|
+
const content = [{ type: 'text', text: reportText(name, r, extraNotes, await kindWarnings(name, r, a.frame)) }];
|
|
151
196
|
if (r.geo && a.render) {
|
|
152
|
-
const ro = renderOpts(typeof a.render === 'object' ? a.render : {}, r.geo, `${name}/${r.target}${atFrame(r)}
|
|
197
|
+
const ro = renderOpts(typeof a.render === 'object' ? a.render : {}, r.geo, `${name}/${r.target}${atFrame(r)}`, ws.dir);
|
|
153
198
|
const { img, notes, png } = await pngContent(r.geo, ro, engine.host);
|
|
154
199
|
const renderPath = renderDestination(name, r.target);
|
|
155
200
|
fs.mkdirSync(path.dirname(renderPath), { recursive: true });
|
|
@@ -166,15 +211,19 @@ export function makeTools(ws, opts = {}) {
|
|
|
166
211
|
ws.bump(name);
|
|
167
212
|
return reportResult(name, r, a, extraNotes);
|
|
168
213
|
};
|
|
169
|
-
const resolveNodeGeo = async (a) => {
|
|
214
|
+
const resolveNodeGeo = async (a, forExport = false) => {
|
|
170
215
|
const name = a.graph ?? a.name ?? 'main'; // `name` is what build/edit call it; accept both
|
|
171
216
|
const g = ws.getGraph(name);
|
|
172
217
|
const target = a.node || undefined;
|
|
173
|
-
|
|
218
|
+
// an export uses the published copies of the packages the session shows live (following is for looking)
|
|
219
|
+
const scope = forExport && ws.packages?.publishedNote?.(g) ? ws.packages.published?.() : null;
|
|
220
|
+
const r = await engine.cook(g, { target, frame: a.frame, ...(scope ? { scope } : {}) });
|
|
174
221
|
if (!r.ok || !r.geo)
|
|
175
222
|
throw new Error(reportText(name, r));
|
|
176
|
-
return { r, name, geo: r.geo };
|
|
223
|
+
return { r, name, geo: r.geo, scope };
|
|
177
224
|
};
|
|
225
|
+
/** What an export of a graph made while following says (the published versions it used), on a line of its own. */
|
|
226
|
+
const publishedLine = (spec) => { const n = ws.packages?.publishedNote?.(spec); return n ? `\n${n}` : ''; };
|
|
178
227
|
/** export without a path: the graph's targets (the default output's, a named one's, or all), inside exports/ */
|
|
179
228
|
const exportTargets = async (a) => {
|
|
180
229
|
const name = a.graph ?? a.name ?? 'main', spec = ws.getGraph(name);
|
|
@@ -184,7 +233,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
184
233
|
if (!a.all) {
|
|
185
234
|
const p = a.output === undefined ? published[0] : published.find((x) => x.output === a.output);
|
|
186
235
|
if (!p)
|
|
187
|
-
return text(`graph "${name}" publishes no output "${a.output}" (outputs: ${published.
|
|
236
|
+
return text(`graph "${name}" publishes no output "${a.output}" (outputs: ${published.filter((x) => x.output !== null).map((x) => `${x.output}${x.default ? ' (default)' : ''}`).join(', ') || 'none'})`, true);
|
|
188
237
|
if (!p.target)
|
|
189
238
|
return text(`${a.output === undefined ? 'the default output' : `output "${a.output}"`} of "${name}" has no export target: set one with ${hint(a.output)}, or pass path`, true);
|
|
190
239
|
chosen = [p];
|
|
@@ -194,20 +243,20 @@ export function makeTools(ws, opts = {}) {
|
|
|
194
243
|
return text(`no output of "${name}" has an export target: set one with ${hint(undefined)}, or pass path`, true);
|
|
195
244
|
const prepared = [];
|
|
196
245
|
for (const p of targets) {
|
|
197
|
-
const r = await ws.cook(name, p.node, a.frame);
|
|
246
|
+
const r = await ws.cook(name, p.node, a.frame, { kind: 'export' });
|
|
198
247
|
if (!r.ok || !r.geo)
|
|
199
248
|
return text(reportText(name, r), true);
|
|
200
|
-
prepared.push(await prepareTarget(r.geo, name, p, ws.exportDir, engine.host));
|
|
249
|
+
prepared.push(await prepareTarget(r.geo, name, p, ws.exportDir, engine.host, { frame: r.frame, fps: r.fps, packages: packagesUsed(engine, spec, ws.packages?.published?.() ?? engine.root) }));
|
|
201
250
|
}
|
|
202
251
|
writeTargets(prepared, ws.exportDir);
|
|
203
252
|
const skipped = chosen.filter((p) => !p.target).map((p) => p.label);
|
|
204
|
-
return text(prepared.map((p) => exportReport(p.files,
|
|
205
|
-
+ (skipped.length ? `\nno export target (skipped): ${skipped.join(', ')}` : ''));
|
|
253
|
+
return text(prepared.map((p) => exportReport(p.files, p.root, p.target.format, `${p.label}: ${p.summary}`, p.warnings, p.sourceFile, p.sourceManifest)).join('\n')
|
|
254
|
+
+ (skipped.length ? `\nno export target (skipped): ${skipped.join(', ')}` : '') + publishedLine(spec));
|
|
206
255
|
};
|
|
207
256
|
const tools = [
|
|
208
257
|
{
|
|
209
258
|
name: 'catalog',
|
|
210
|
-
description: 'List available node types grouped by category (generate, curve, transform, deform, attribute, measure, group, topology, copy, solid, sdf, heightfield, uv, code, flow, io, pcg,
|
|
259
|
+
description: 'List available node types grouped by category (generate, curve, transform, deform, attribute, measure, group, topology, copy, solid, sdf, heightfield, uv, code, flow, io, pcg, asset = package assets, package = package outputs, "owner/name/output": those the package uses, and TopoTopo\'s own, ready-made walls, houses, roofs, stairs, rocks, trees, props and roads such as "topotopo/architecture/house" or "topotopo/nature/rock", which a graph\'s first use adds to the package). Optional filter by category or search text. Building a landscape or scene for a person? Call inputs {action:"list"} first: the meshes, guide curves and masks they dropped into the package.',
|
|
211
260
|
inputSchema: {
|
|
212
261
|
type: 'object',
|
|
213
262
|
properties: {
|
|
@@ -217,27 +266,31 @@ export function makeTools(ws, opts = {}) {
|
|
|
217
266
|
},
|
|
218
267
|
},
|
|
219
268
|
run: async (a) => {
|
|
220
|
-
const cat = catalogText([...allNodeDefs(), ...
|
|
269
|
+
const cat = catalogText([...allNodeDefs(), ...engine.assetsIn().map((x) => x.def), ...engine.packageDefs()], { category: a.category, search: a.search, deprecated: a.include_deprecated });
|
|
221
270
|
const nIn = ws.listInputs().length;
|
|
222
|
-
|
|
271
|
+
// the package outputs listed cannot be used where the server's folder is in no package: say why, and how that changes
|
|
272
|
+
const notice = (!a.category || a.category === 'package') ? ws.packages?.notice() : null;
|
|
273
|
+
return text(`${cat}${notice ? `\nPACKAGES: ${notice}` : ''}\nHUMAN INPUT: ${nIn ? `${nIn} file${nIn === 1 ? '' : 's'} in` : 'nothing yet in'} the package inputs/ folder (meshes, guide curves and points, blockouts, PNG masks people drop in). Building a landscape or scene: inputs {action:"list"} first, then read them with file nodes (help topic "inputs").`);
|
|
223
274
|
},
|
|
224
275
|
},
|
|
225
276
|
{
|
|
226
277
|
name: 'help',
|
|
227
|
-
description: `Exact docs for node types (params with types, defaults, ranges, aliases; inputs; examples) and concept topics: ${topicList().join(', ')}. Call before using unfamiliar nodes.`,
|
|
278
|
+
description: `Exact docs for node types (params with types, defaults, ranges, aliases; inputs; examples; a package output "owner/name/output": its params, inputs, version and note, also one search found that the package does not use yet) and concept topics: ${topicList().join(', ')}. Call before using unfamiliar nodes.`,
|
|
228
279
|
inputSchema: { type: 'object', properties: { nodes: { type: 'array', items: { type: 'string' }, description: 'node type names' }, topic: { type: 'string', description: `one of: ${topicList().join(', ')}, overview` } } },
|
|
229
280
|
run: async (a) => {
|
|
230
281
|
const out = [];
|
|
231
|
-
if (a.topic)
|
|
232
|
-
|
|
233
|
-
out.push(INSTRUCTIONS);
|
|
234
|
-
else if (TOPICS[a.topic])
|
|
235
|
-
out.push(TOPICS[a.topic]);
|
|
236
|
-
else
|
|
237
|
-
out.push(`unknown topic "${a.topic}". Topics: overview, ${topicList().join(', ')}`);
|
|
238
|
-
}
|
|
282
|
+
if (a.topic)
|
|
283
|
+
out.push(topicText(String(a.topic)) ?? `unknown topic "${a.topic}". Topics: overview, ${topicList().join(', ')}`);
|
|
239
284
|
for (const n of a.nodes ?? []) {
|
|
240
285
|
const d = engine.resolveDef(n);
|
|
286
|
+
if (!d && String(n).includes('/')) {
|
|
287
|
+
const p = engine.packageIssue(String(n));
|
|
288
|
+
// a package this package does not use yet (TopoTopo's own, or one search found in a library it lists): its
|
|
289
|
+
// docs, read where its library holds it, and what naming it does here
|
|
290
|
+
const offered = engine.packageDefs().find((x) => x.type === n) ?? ws.packages?.describe(String(n)) ?? undefined;
|
|
291
|
+
out.push(offered ? `${nodeDoc(offered)}\nin this package: ${p.error}${p.hint ? ` (hint: ${p.hint})` : ''}` : `${p.error}${p.hint ? `\n hint: ${p.hint}` : ''}`);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
241
294
|
if (!d) {
|
|
242
295
|
const s = didYouMean(n, engine.allTypeNames());
|
|
243
296
|
out.push(`unknown node "${n}"${s.length ? ` — did you mean ${s.join(', ')}?` : ''}`);
|
|
@@ -257,7 +310,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
257
310
|
type: 'object',
|
|
258
311
|
required: ['graph'],
|
|
259
312
|
properties: {
|
|
260
|
-
graph: { type: 'object', description: '{"nodes": {name: {"type", "in", "params"}}, "output": name, "outputs": {id: {"node": name, "label": "Published result", "export": "glb"}}, "export": "glb", "vars": {...}, "params": {var: {"type", "desc", "min", "max", "options", "label", "step"}}}. Publish intended deliverables in outputs; output remains the default. "export" (on the graph for the default output, or on a named output) is where it exports: a format, or {format, path?, ...export options}, written inside exports/ by the viewer\'s Export buttons and export {output} / {all:true}.' },
|
|
313
|
+
graph: { type: 'object', description: '{"nodes": {name: {"type", "in", "params"}}, "output": name, "outputs": {id: {"node": name, "label": "Published result", "export": "glb", "publish": false (not published), "kind": "mesh" (pinned: build warns and publishing blocks when it cooks to another kind), "tags": ["conifer", "low-poly"], "description": "what it is"}}, "export": "glb", "vars": {...}, "params": {var: {"type", "desc", "min", "max", "options", "label", "step"}}}. Publish intended deliverables in outputs; output remains the default. A node "type" "owner/name/output" is an output of a package (help topic "packages"). "export" (on the graph for the default output, or on a named output) is where it exports: a format, or {format, path?, ...export options}, written inside exports/ by the viewer\'s Export buttons and export {output} / {all:true}.' },
|
|
261
314
|
name: { type: 'string', description: 'graph name (default "main")' },
|
|
262
315
|
mode: { type: 'string', enum: ['replace', 'merge'] },
|
|
263
316
|
dry_run: { type: 'boolean' },
|
|
@@ -270,20 +323,26 @@ export function makeTools(ws, opts = {}) {
|
|
|
270
323
|
let spec = a.graph;
|
|
271
324
|
if (typeof spec === 'string')
|
|
272
325
|
spec = JSON.parse(spec);
|
|
273
|
-
spec =
|
|
326
|
+
spec = spec;
|
|
274
327
|
if (a.mode === 'merge' && ws.graphs.has(name))
|
|
275
328
|
spec = ws.mergeGraph(name, spec);
|
|
276
329
|
if (a.dry_run) {
|
|
277
|
-
|
|
330
|
+
// a package the graph names for the first time: checked against the version a build adds, nothing copied
|
|
331
|
+
const dry = ws.dryScope(spec);
|
|
332
|
+
const d = engine.dryRun(spec, undefined, dry.scope);
|
|
333
|
+
const first = dry.notes.map((n) => `\nnote: ${n}`).join('');
|
|
278
334
|
return text(d.errors.length
|
|
279
|
-
? `✗ ${d.errors.length} error(s):\n` + d.errors.map((e) => ` [${e.node}] ${e.message}${e.hint ? `\n hint: ${e.hint}` : ''}`).join('\n')
|
|
280
|
-
: `✓ valid: ${Object.keys(spec.nodes).length} nodes, output "${d.output}"` + (d.notes.length ? '\nnotes: ' + d.notes.join('; ') : ''), d.errors.length > 0);
|
|
335
|
+
? `✗ ${d.errors.length} error(s):\n` + d.errors.map((e) => ` [${e.node}] ${e.message}${e.hint ? `\n hint: ${e.hint}` : ''}`).join('\n') + first
|
|
336
|
+
: `✓ valid: ${Object.keys(spec.nodes).length} nodes, output "${d.output}"` + (d.notes.length ? '\nnotes: ' + d.notes.join('; ') : '') + first, d.errors.length > 0);
|
|
281
337
|
}
|
|
282
|
-
|
|
338
|
+
// validated as a dry run sees it: a graph that is not saved adds no package and writes nothing
|
|
339
|
+
const v = engine.validate(spec, '', ws.dryScope(spec).scope);
|
|
283
340
|
if (v.errors.length)
|
|
284
341
|
return text(`✗ graph not saved — ${v.errors.length} error(s):\n` + v.errors.map((e) => ` [${e.node}] ${e.message}${e.hint ? `\n hint: ${e.hint}` : ''}`).join('\n'), true);
|
|
342
|
+
// packages the graph names for the first time join the package
|
|
343
|
+
const added = ws.packages?.addFor(spec) ?? [];
|
|
285
344
|
ws.setGraph(name, spec);
|
|
286
|
-
return cookAndReport(name, a);
|
|
345
|
+
return cookAndReport(name, a, added);
|
|
287
346
|
},
|
|
288
347
|
},
|
|
289
348
|
{
|
|
@@ -315,16 +374,17 @@ export function makeTools(ws, opts = {}) {
|
|
|
315
374
|
},
|
|
316
375
|
{
|
|
317
376
|
name: 'inspect',
|
|
318
|
-
description: 'Inspect any node\'s output as text: summary;
|
|
377
|
+
description: 'Inspect any node\'s output as text: detail "summary" (default: one screen: counts, triangles, bbox in mm, parts, materials and maps, images, uv state, closed or open edges after welding seam splits); "budget" (triangles per part (prim "name", each an exported mesh) split per LOD (_lodN names), and per node (what each adds), sorted, with totals); "scene" (the glb export read back: nodes and parents, sockets, meshes and triangles, materials and maps, images; export_options as for export); "attributes" (min/max/mean, unique strings), "topology" (a closed solid or why not: open edges counted after welding the vertex splits of uv/normal seams, non-manifold edges, flipped faces, inward pieces, degenerate faces, each with the part (prim name/group) and world position of the first one and the fix; pieces, volume, area, genus, render/export triangle health), "elements" (list values for a range), "all", or "uv" (exact uv overlaps split into in-tile (atlas) overlap, tiling overlap (charts across tile borders: a repeating texture, flagged tiling) and overlap across LODs (_lodN names), each listed with parts and positions; collapsed / non-finite / out-of-tile triangles, charts, utilization, per-piece texel density with resolution; json:true appends the machine-readable report).',
|
|
319
378
|
inputSchema: {
|
|
320
379
|
type: 'object',
|
|
321
380
|
properties: {
|
|
322
381
|
graph: { type: 'string', description: 'graph name (default "main")' },
|
|
323
382
|
node: { type: 'string', description: 'node to inspect (default: graph output)' },
|
|
324
|
-
detail: { type: 'string', enum: ['summary', 'attributes', 'topology', 'elements', 'all', 'uv'] },
|
|
383
|
+
detail: { type: 'string', enum: ['summary', 'attributes', 'topology', 'elements', 'all', 'uv', 'budget', 'scene'] },
|
|
384
|
+
export_options: { type: 'object', description: 'detail "scene": export options as the export tool takes them (up_axis, scale, split_by_name, materials, custom_attribs, tangents, instancing, compress …)' },
|
|
325
385
|
uv_attrib: { type: 'string', description: 'detail "uv": the uv attribute (default "uv")' },
|
|
326
386
|
resolution: { description: 'detail "uv": texture size in texels for texel density, n or [width, height]', anyOf: [{ type: 'number' }, { type: 'array', items: { type: 'number' } }] },
|
|
327
|
-
json: { type: 'boolean', description: 'detail "uv": append the report as JSON' },
|
|
387
|
+
json: { type: 'boolean', description: 'detail "uv", "budget" or "scene": append the report as JSON' },
|
|
328
388
|
class: { type: 'string', enum: ['point', 'prim', 'vertex', 'detail', 'edge'], description: 'element class; "edge" lists unique edges (point pair, length, polygon count, dihedral angle, edge groups)' },
|
|
329
389
|
attribs: { type: 'array', items: { type: 'string' } },
|
|
330
390
|
start: { type: 'number' }, count: { type: 'number' },
|
|
@@ -337,7 +397,17 @@ export function makeTools(ws, opts = {}) {
|
|
|
337
397
|
const node = r.target;
|
|
338
398
|
const res = r.results.get(node);
|
|
339
399
|
const head = `${name}/${node}${atFrame(r)}${res ? ` (${res.cached ? 'cached' : res.ms.toFixed(0) + ' ms'})` : ''}`;
|
|
340
|
-
|
|
400
|
+
if (a.detail === 'scene') {
|
|
401
|
+
// the glb export with these options, read back from its bytes (io/inspect-scene.ts)
|
|
402
|
+
const ex = await serializeExport(geo, 'glb', path.join(ws.exportDir, 'scene.glb'), exportToolOptions(a.export_options ?? {}), engine.host);
|
|
403
|
+
const glb = ex.files.find((f) => /\.glb$/i.test(f.path));
|
|
404
|
+
if (!glb)
|
|
405
|
+
return text(`${head}\nscene: the glb export wrote no file`, true);
|
|
406
|
+
const rep = glbSceneReport(glb.bytes);
|
|
407
|
+
return text([head, ...sceneReportText(rep), ...ex.warnings.map((w) => `warning: ${w}`), ...(a.json ? ['scene (JSON):', JSON.stringify(rep)] : [])].join('\n'));
|
|
408
|
+
}
|
|
409
|
+
const nodes = a.detail === 'budget' ? nodeBudgetInput(ws.getGraph(name), r.results) : undefined;
|
|
410
|
+
return text(head + '\n' + inspect(geo, { detail: a.detail, cls: a.class, attribs: a.attribs, start: a.start, count: a.count, group: a.group, uvAttrib: a.uv_attrib, uvResolution: a.resolution, json: a.json, nodes }));
|
|
341
411
|
},
|
|
342
412
|
},
|
|
343
413
|
{
|
|
@@ -348,13 +418,13 @@ export function makeTools(ws, opts = {}) {
|
|
|
348
418
|
properties: {
|
|
349
419
|
graph: { type: 'string', description: 'graph name (default "main")' }, node: { type: 'string', description: 'node to look at (default: the graph output)' },
|
|
350
420
|
...RENDER_PROPS,
|
|
351
|
-
save_to: { type: 'string', description: 'also write the PNG to this path (relative to the
|
|
421
|
+
save_to: { type: 'string', description: 'also write the PNG to this path (relative to the package)' },
|
|
352
422
|
...FRAME_PROP,
|
|
353
423
|
},
|
|
354
424
|
},
|
|
355
425
|
run: async (a) => {
|
|
356
426
|
const { geo, name, r } = await resolveNodeGeo(a);
|
|
357
|
-
const { img, notes, png } = await pngContent(geo, renderOpts(a, geo, `${name}/${r.target}${atFrame(r)}
|
|
427
|
+
const { img, notes, png } = await pngContent(geo, renderOpts(a, geo, `${name}/${r.target}${atFrame(r)}`, ws.dir), engine.host);
|
|
358
428
|
const content = [img];
|
|
359
429
|
const info = [];
|
|
360
430
|
{
|
|
@@ -373,7 +443,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
373
443
|
},
|
|
374
444
|
{
|
|
375
445
|
name: 'export',
|
|
376
|
-
description: 'Write a node\'s output to a file: .glb/.gltf (glTF via gltf-transform: materials + texture maps, vertex colours, uv, custom attributes, EXT_mesh_gpu_instancing with per-instance attributes, meshopt compression; best for Unreal/Blender/web), .obj, .usda (PointInstancer with per-instance primvars, UsdPreviewSurface materials), .ply, .stl, .geo (Houdini JSON geometry, every attribute and group, packed prims as PackedGeometry), .csv (point stream; pcg:true for Unreal PCG columns; packed instances = one row per instance + Mesh column + .meshes.json sidecar + one GLB per source), .points.json, .json (lossless topotopo). Relative paths go into the
|
|
446
|
+
description: 'Write a node\'s output to a file: .glb/.gltf (glTF via gltf-transform: materials + texture maps, vertex colours, uv, custom attributes, EXT_mesh_gpu_instancing with per-instance attributes, meshopt compression; best for Unreal/Blender/web), .obj, .usda (PointInstancer with per-instance primvars, UsdPreviewSurface materials), .ply, .stl, .geo (Houdini JSON geometry, every attribute and group, packed prims as PackedGeometry), .csv (point stream; pcg:true for Unreal PCG columns; packed instances = one row per instance + Mesh column + .meshes.json sidecar + one GLB per source), .points.json, .json (lossless topotopo). Relative paths go into the package. help {topic:"export"} for details. Heightfields: png16 (.png, 16-bit Unreal Landscape heightmap) or r16 (.r16/.raw) plus a .json sidecar with the height range and the Unreal scale/location, mask_png (8-bit weight layers; param layers), unreal_landscape (a directory: heightmap, every layer, manifest with the exact Landscape import settings, objects.glb and the instance stream). Textures: glb/gltf embed the image textures of materials (texture_to_material) as PNG, usda writes them to <name>_textures/ next to the file, format textures writes every image as <path>/<image>.png (layers: extra layers, or ["*"]). Every export records how it was made (graph, vars, seeds, frame, version) in its sidecar or in <file>.source.json next to it (help topic "export").',
|
|
377
447
|
inputSchema: {
|
|
378
448
|
type: 'object',
|
|
379
449
|
properties: {
|
|
@@ -391,8 +461,9 @@ export function makeTools(ws, opts = {}) {
|
|
|
391
461
|
up_axis: { type: 'string', enum: ['y', 'z'] },
|
|
392
462
|
scale: { type: 'number', description: 'multiply positions (100 = metres → centimetres; pcg csv defaults to 100)' },
|
|
393
463
|
split_by_name: { type: 'boolean', description: 'separate meshes per prim "name" (default true)' },
|
|
394
|
-
custom_attribs: { type: 'boolean', description: 'glTF/PLY/USD: include extra numeric attributes (glTF _NAME accessors; default true for
|
|
464
|
+
custom_attribs: { type: 'boolean', description: 'glTF/PLY/USD: include extra numeric attributes (glTF _NAME vertex and per-instance accessors, PLY properties, USD primvars; default false for glb/gltf/usda, true for ply). The CLI flag is --custom-attribs / --no-custom-attribs' },
|
|
395
465
|
materials: { type: 'boolean', description: 'glTF: write materials from the prim "material" attribute + table (default true)' },
|
|
466
|
+
vertex_colors: { type: 'boolean', description: 'glTF: also write Cd as COLOR_0 on prims that have a named material (default false: the material decides their colour; prims without one keep their Cd)' },
|
|
396
467
|
compress: { type: 'string', enum: ['none', 'meshopt', 'draco'], description: 'glTF: meshopt = EXT_meshopt_compression + quantization; draco needs the optional draco3dgltf package' },
|
|
397
468
|
quantize: { type: 'boolean', description: 'glTF: KHR_mesh_quantization (smaller, lossy) without compression' },
|
|
398
469
|
tangents: { type: 'string', enum: ['auto', 'preserve', 'none'], description: 'glTF TANGENT: auto (default) = MikkTSpace for normal-mapped materials, a valid supplied "tangent" attribute elsewhere; preserve = the supplied attribute wherever it exists (malformed = error); none = never' },
|
|
@@ -409,19 +480,23 @@ export function makeTools(ws, opts = {}) {
|
|
|
409
480
|
run: async (a) => {
|
|
410
481
|
if (a.path === undefined)
|
|
411
482
|
return exportTargets(a);
|
|
412
|
-
const { geo, name, r } = await resolveNodeGeo(a);
|
|
483
|
+
const { geo, name, r, scope } = await resolveNodeGeo(a, true);
|
|
413
484
|
const p = path.resolve(ws.dir, a.path);
|
|
414
485
|
const fmt0 = String(a.format ?? exportFormatFromPath(p)).toLowerCase();
|
|
415
486
|
const ext = ({ png: 'png16', raw: 'r16' }[fmt0] ?? fmt0);
|
|
416
487
|
if (!EXPORT_FORMATS.includes(ext))
|
|
417
488
|
throw new Error(`unknown format "${ext}"; use ${EXPORT_FORMATS.map((f) => (f === 'pointsjson' ? '.points.json' : '.' + f)).join(' ')}`);
|
|
418
|
-
const
|
|
419
|
-
|
|
489
|
+
const source = exportSource({
|
|
490
|
+
graph: name, spec: ws.getGraph(name), node: r.target, frame: r.frame, fps: r.fps,
|
|
491
|
+
format: ext, options: exportToolOptions(a), packages: packagesUsed(engine, ws.getGraph(name), scope ?? engine.root), version: TOPOTOPO_VERSION,
|
|
492
|
+
});
|
|
493
|
+
const report = await writeExport(geo, ext, p, a, engine.host, (files) => new ArtifactStore(ws.exportDir).record(files, { graph: name, node: r.target, format: ext }), source);
|
|
494
|
+
return text(`${report}\n(from ${name}/${r.target}${atFrame(r)}: ${geo.numPoints} points, ${geo.numPrims} prims)${publishedLine(ws.getGraph(name))}`);
|
|
420
495
|
},
|
|
421
496
|
},
|
|
422
497
|
{
|
|
423
498
|
name: 'graphs',
|
|
424
|
-
description: 'Manage
|
|
499
|
+
description: 'Manage package graphs: list (with node counts), get (full JSON), delete, rename, duplicate. Graphs persist as JSON files in the package graphs/ folder.',
|
|
425
500
|
inputSchema: {
|
|
426
501
|
type: 'object',
|
|
427
502
|
required: ['action'],
|
|
@@ -431,11 +506,11 @@ export function makeTools(ws, opts = {}) {
|
|
|
431
506
|
switch (a.action) {
|
|
432
507
|
case 'list': {
|
|
433
508
|
if (!ws.graphs.size)
|
|
434
|
-
return text(`no graphs yet (
|
|
509
|
+
return text(`no graphs yet (package ${ws.dir}). Use build.`);
|
|
435
510
|
return text([...ws.graphs].map(([k, g]) => {
|
|
436
511
|
const r = ws.lastReport.get(k);
|
|
437
512
|
return `${k}: ${Object.keys(g.nodes).length} nodes, output ${g.output ?? '(auto)'}${r ? `, last cook ${r.ok ? 'ok' : 'FAILED'}${r.geo ? ` (${r.geo.numPoints} pts, ${r.geo.numPrims} prims)` : ''}` : ''}`;
|
|
438
|
-
}).join('\n') + `\
|
|
513
|
+
}).join('\n') + `\nfolder: ${ws.dir}`);
|
|
439
514
|
}
|
|
440
515
|
case 'get': return text(JSON.stringify(ws.getGraph(a.name ?? 'main'), null, 1));
|
|
441
516
|
case 'delete':
|
|
@@ -457,77 +532,95 @@ export function makeTools(ws, opts = {}) {
|
|
|
457
532
|
},
|
|
458
533
|
{
|
|
459
534
|
name: 'assets',
|
|
460
|
-
description: 'Reusable custom node types built from graphs (like HDAs). save {name, from_graph | graph, description, params:{var:{desc,min,max}}}: the graph\'s vars become parameters and its "input" nodes become inputs. list, get, delete.
|
|
535
|
+
description: 'Reusable custom node types built from graphs (like HDAs), the package\'s own (assets/). save {name, from_graph | graph, description, params:{var:{desc,min,max}}}: the graph\'s vars become parameters and its "input" nodes become inputs. list, get, delete. fork {name: "owner/name/output", to?} copies the graph of a package output, TopoTopo\'s own included ("topotopo/architecture/stairs" …), into the package\'s assets as "to" (default: the output\'s name), an asset to edit and use like any other; get shows its graph, save writes it back.',
|
|
461
536
|
inputSchema: {
|
|
462
537
|
type: 'object',
|
|
463
538
|
required: ['action'],
|
|
464
539
|
properties: {
|
|
465
540
|
action: { type: 'string', enum: ['save', 'list', 'get', 'delete', 'fork'] },
|
|
466
|
-
name: { type: 'string'
|
|
541
|
+
name: { type: 'string', description: 'the asset; fork: the package output to copy, "owner/name/output" (or "owner/name" for its default output)' },
|
|
542
|
+
from_graph: { type: 'string' }, graph: { type: 'object' },
|
|
467
543
|
description: { type: 'string' }, params: { type: 'object' },
|
|
468
|
-
to: { type: 'string', description: 'fork: name of the
|
|
544
|
+
to: { type: 'string', description: 'fork: name of the asset to create (default: the output\'s name)' },
|
|
469
545
|
},
|
|
470
546
|
},
|
|
471
547
|
run: async (a) => {
|
|
472
548
|
const assetOf = (n) => {
|
|
473
|
-
const x = engine.
|
|
549
|
+
const x = engine.asset(n);
|
|
474
550
|
if (!x) {
|
|
475
|
-
const s = didYouMean(String(n),
|
|
551
|
+
const s = didYouMean(String(n), engine.assetsIn().map((x) => x.name));
|
|
476
552
|
throw new Error(`no asset "${n}"${s.length ? ` — did you mean ${s.join(', ')}?` : ''}`);
|
|
477
553
|
}
|
|
478
554
|
return x;
|
|
479
555
|
};
|
|
556
|
+
/**
|
|
557
|
+
* An asset's name and graph checked as a dry run sees the graph, before it adds a package or writes a file:
|
|
558
|
+
* throws as registering it would.
|
|
559
|
+
*/
|
|
560
|
+
const validAsset = (n, g) => {
|
|
561
|
+
if (!/^[A-Za-z_][\w]*$/.test(n))
|
|
562
|
+
throw new Error(`asset name must be an identifier, got "${n}"`);
|
|
563
|
+
const v = engine.validate(g, '', ws.dryScope(g).scope);
|
|
564
|
+
if (v.errors.length)
|
|
565
|
+
throw new Error(`asset graph invalid: ${v.errors.map((e) => `${e.node}: ${e.message}`).join('; ')}`);
|
|
566
|
+
};
|
|
480
567
|
switch (a.action) {
|
|
481
568
|
case 'list': {
|
|
482
|
-
|
|
483
|
-
|
|
569
|
+
const all = engine.assetsIn();
|
|
570
|
+
if (!all.length)
|
|
571
|
+
return text('no assets yet (assets {action:"save"} makes one of a graph; fork copies a package output\'s graph, catalog {category:"package"} lists them)');
|
|
484
572
|
const line = (x) => ` ${x.name} — ${x.def.summary}; params: ${Object.keys(x.def.params).join(', ') || 'none'}; inputs: ${x.def.inputs.length}`;
|
|
485
|
-
|
|
486
|
-
const out = [];
|
|
487
|
-
if (mine.length)
|
|
488
|
-
out.push(`[asset] workspace assets (${mine.length})`, ...mine.map(line));
|
|
489
|
-
if (shelf.length)
|
|
490
|
-
out.push(`[shelf] shipped assets (${shelf.length}; read-only, fork to edit)`, ...shelf.map(line));
|
|
491
|
-
return text(out.join('\n'));
|
|
573
|
+
return text([`[asset] package assets (${all.length})`, ...all.map(line)].join('\n'));
|
|
492
574
|
}
|
|
493
575
|
case 'get': {
|
|
494
576
|
const x = assetOf(a.name);
|
|
495
577
|
return text(nodeDoc(x.def) + '\n\n' + JSON.stringify(x.graph, null, 1));
|
|
496
578
|
}
|
|
497
579
|
case 'delete': {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
throw new Error(`"${a.name}" is a shelf asset and cannot be deleted; fork it to edit a copy: assets {action:"fork", name:"${a.name}"}`);
|
|
501
|
-
engine.assets.delete(a.name);
|
|
580
|
+
assetOf(a.name);
|
|
581
|
+
engine.root.assets.delete(a.name);
|
|
502
582
|
const f = path.join(ws.assetDir, a.name + '.json');
|
|
503
583
|
if (fs.existsSync(f))
|
|
504
584
|
fs.unlinkSync(f);
|
|
505
|
-
|
|
506
|
-
if (shipped) {
|
|
507
|
-
engine.registerAsset(a.name, shipped, { category: 'shelf' });
|
|
508
|
-
engine.cache.clear();
|
|
509
|
-
}
|
|
510
|
-
return text(`deleted asset "${a.name}"${shipped ? '; restored the shelf asset of that name' : ''}`);
|
|
585
|
+
return text(`deleted asset "${a.name}"`);
|
|
511
586
|
}
|
|
512
587
|
case 'fork': {
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
588
|
+
const name = String(a.name ?? '');
|
|
589
|
+
if (!name.includes('/'))
|
|
590
|
+
throw new Error(`fork copies a package output's graph into the package's assets: name one, "owner/name/output" (catalog {category:"package"} lists them, TopoTopo's own as "topotopo/architecture/stairs" …)${engine.asset(name) ? `; "${name}" is an asset of the package already: get shows its graph` : ''}`);
|
|
591
|
+
// an output the package uses, or one of TopoTopo's own it does not use yet
|
|
592
|
+
const all = engine.packageDefs(), o = (engine.resolveDef(name) ?? all.find((x) => x.type === name))?.package;
|
|
593
|
+
if (!o) {
|
|
594
|
+
const s = didYouMean(name, all.map((x) => x.type)), p = engine.packageIssue(name);
|
|
595
|
+
throw new Error(s.length ? `no package output "${name}" — did you mean ${s.join(', ')}?` : `${p.error}${p.hint ? ` (hint: ${p.hint})` : ''}`);
|
|
596
|
+
}
|
|
597
|
+
const to = String(a.to ?? o.output ?? o.package.split('/')[1]);
|
|
598
|
+
// the asset cooks the output's node; it publishes nothing and exports nowhere of its own
|
|
599
|
+
const g = { ...structuredClone(o.spec), output: o.node };
|
|
600
|
+
delete g.outputs;
|
|
601
|
+
delete g.export;
|
|
602
|
+
// the package's other outputs its graph names join the package (first use), once it validates
|
|
603
|
+
validAsset(to, g);
|
|
604
|
+
const added = ws.packages?.addFor(g) ?? [];
|
|
605
|
+
const def = engine.registerAsset(to, g);
|
|
606
|
+
fs.writeFileSync(path.join(ws.assetDir, to + '.json'), JSON.stringify(g, null, 2));
|
|
607
|
+
return text(`forked ${name} (${packageAt(o)}) into asset "${to}" of the package (assets/${to}.json; use {"type": "${to}"}): its vars are the params, its "input" nodes the inputs. ` +
|
|
608
|
+
`assets {action:"get", name:"${to}"} shows its graph; change it and write it back with assets {action:"save", name:"${to}", graph}. Relative paths in it now read the package's files.` +
|
|
609
|
+
`${added.map((n) => `\nnote: ${n}`).join('')}\n\n${nodeDoc(def)}`);
|
|
519
610
|
}
|
|
520
611
|
case 'save': {
|
|
521
612
|
if (!a.name)
|
|
522
613
|
throw new Error('"name" is required');
|
|
523
|
-
const g =
|
|
614
|
+
const g = structuredClone(a.graph ?? ws.getGraph(a.from_graph ?? 'main'));
|
|
524
615
|
if (a.description)
|
|
525
616
|
g.description = a.description;
|
|
526
617
|
if (a.params)
|
|
527
618
|
g.params = { ...(g.params ?? {}), ...a.params };
|
|
619
|
+
validAsset(String(a.name), g);
|
|
620
|
+
const added = ws.packages?.addFor(g) ?? [];
|
|
528
621
|
const def = engine.registerAsset(a.name, g);
|
|
529
622
|
fs.writeFileSync(path.join(ws.assetDir, a.name + '.json'), JSON.stringify(g, null, 2));
|
|
530
|
-
return text(`saved asset "${a.name}" (use {"type": "${a.name}"})\n\n${nodeDoc(def)}`);
|
|
623
|
+
return text(`saved asset "${a.name}" (use {"type": "${a.name}"})${added.map((n) => `\nnote: ${n}`).join('')}\n\n${nodeDoc(def)}`);
|
|
531
624
|
}
|
|
532
625
|
}
|
|
533
626
|
return text('unknown action', true);
|
|
@@ -538,7 +631,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
538
631
|
if (opts.onPreview) {
|
|
539
632
|
tools.push({
|
|
540
633
|
name: 'preview',
|
|
541
|
-
description: 'Start (or get the URL of) the live viewer for humans: an editor viewport of the
|
|
634
|
+
description: 'Start (or get the URL of) the live viewer for humans: an editor viewport of the package (graph menu, an outliner with the graph\'s nodes, single and quad views, the graph\'s params as Controls, input layers and guides) that updates after every build/edit. Returns the URL to open in a browser.',
|
|
542
635
|
inputSchema: { type: 'object', properties: {} },
|
|
543
636
|
run: async () => text(`live preview: ${await opts.onPreview()} (updates automatically on every build/edit; click a node in the outliner to see its result)`),
|
|
544
637
|
});
|
|
@@ -558,6 +651,8 @@ export function makeTools(ws, opts = {}) {
|
|
|
558
651
|
for (const t of tools) {
|
|
559
652
|
const run = t.run;
|
|
560
653
|
t.run = async (args) => {
|
|
654
|
+
// what changed on disk since the last call (a followed working folder, the manifest): every tool sees it
|
|
655
|
+
ws.packages?.refresh();
|
|
561
656
|
const result = await run(args);
|
|
562
657
|
const note = inputsNote(t.name);
|
|
563
658
|
if (note)
|