topotopo 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +323 -146
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/bake.d.ts +14 -3
- package/dist/core/bake.js +153 -4
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +76 -3
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +203 -3
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +7 -0
- package/dist/core/materials.js +45 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scene.js +2 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +14 -1
- package/dist/core/snippet-lib.js +39 -13
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +5 -1
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +10 -0
- package/dist/core/topology.js +168 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +4 -18
- package/dist/core/uv.js +35 -188
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +61 -0
- package/dist/core/uvreport.js +207 -143
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +66 -62
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +80 -2
- package/dist/inspect.js +265 -30
- package/dist/io/common.d.ts +25 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +134 -47
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +148 -13
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +786 -143
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +56 -27
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +196 -103
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +151 -47
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +51 -3
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +21 -9
- package/dist/nodes/curves.js +433 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +12 -38
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.js +16 -19
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/material.js +89 -24
- package/dist/nodes/measure.js +43 -17
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.js +4 -2
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +6 -2
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +5 -1
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +44 -5
- package/dist/render/preview.d.ts +15 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +66 -5
- package/dist/render/raster.js +506 -138
- package/dist/render/texview.d.ts +6 -0
- package/dist/render/texview.js +27 -0
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +27 -7
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +5 -1
- package/dist/viewer/app/guides.js +122 -0
- package/dist/viewer/app/keymap.js +6 -3
- package/dist/viewer/app/layers.js +4 -4
- package/dist/viewer/app/main.js +185 -52
- package/dist/viewer/app/markers.js +60 -0
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +176 -52
- package/dist/viewer/app/scene.js +30 -5
- package/dist/viewer/app/select.js +4 -3
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +65 -7
- package/dist/viewer/app/vars.js +47 -0
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +23 -10
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +14 -9
- package/dist/viewer/server.js +266 -28
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/{gallery → web}/bake.d.ts +4 -4
- package/dist/{gallery → web}/bake.js +24 -15
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -118
- package/dist/workspace.js +358 -460
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +2 -1
- package/kernels/pkg-simd/README.md +2 -1
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +17 -8
- package/dist/gallery/app/gallery.css +0 -100
- package/dist/gallery/app/gallery.js +0 -80
- package/dist/gallery/cli.d.ts +0 -4
- package/dist/gallery/cli.js +0 -157
- package/dist/gallery/library.d.ts +0 -124
- package/dist/gallery/library.js +0 -366
- package/dist/gallery/pages.d.ts +0 -94
- package/dist/gallery/pages.js +0 -148
- package/dist/gallery/server.d.ts +0 -21
- package/dist/gallery/server.js +0 -391
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/dist/mcp/library.d.ts +0 -12
- package/dist/mcp/library.js +0 -159
- package/shelf/index.json +0 -190
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
// The Outputs tab: each graph's published outputs as cards (click one to see it alone, its textures below it)
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// The Outputs tab: each graph's published outputs as cards (click one to see it alone, its textures below it). A card
|
|
2
|
+
// says what the output is (a mesh, a heightfield, packed instances … and its size: the server decides it from the
|
|
3
|
+
// cooked geometry) and has two buttons: Download gets the export as a browser download (the file itself, or a zip of
|
|
4
|
+
// its files) and Export writes it to its target in exports/, the files graph export targets and agents use. Both offer
|
|
5
|
+
// the formats that write the output (export-popover.js); a first Export stores its target in the graph, later clicks
|
|
6
|
+
// write it again. Export all writes every target. Files saved in exports/ are cards too, downloaded as they are.
|
|
4
7
|
import { createImageView } from './image-view.js';
|
|
5
8
|
import { fmtBytes } from './units.js';
|
|
6
|
-
import { exportPopover, defaultPath } from './export-popover.js';
|
|
9
|
+
import { exportPopover, defaultPath, downloadSpec, filenameOf, inFolder } from './export-popover.js';
|
|
10
|
+
import { kindLine, detailLine, kindBadge, kindTagsLine, liveText, layerChoices, shownLayer } from './output-info.js';
|
|
7
11
|
import { inputImageURL } from './layers.js';
|
|
8
12
|
|
|
9
13
|
const url = (route, item, more = {}) => `/api/output/${route}?` + new URLSearchParams({ id: item.id, rev: item.revision, ...more });
|
|
@@ -14,6 +18,8 @@ const post = async (route, body) => {
|
|
|
14
18
|
if (!r.ok || !j.ok) throw new Error(j.error ?? `${route} failed (${r.status})`);
|
|
15
19
|
return j;
|
|
16
20
|
};
|
|
21
|
+
/** The browser saves `href` (a route, or a blob's URL) as `name`. */
|
|
22
|
+
const save = (href, name) => { const a = document.createElement('a'); a.href = href; a.download = name; document.body.append(a); a.click(); a.remove(); };
|
|
17
23
|
/** "just now", "5 min ago", "3 h ago", else the date */
|
|
18
24
|
export function ago(ms, now = Date.now()) {
|
|
19
25
|
const s = Math.max(0, (now - ms) / 1000);
|
|
@@ -30,31 +36,59 @@ export function targetSpec(item, choice, formats) {
|
|
|
30
36
|
const custom = choice.path !== defaultPath(stem, choice.format, formats);
|
|
31
37
|
return !custom && !Object.keys(keep).length ? choice.format : { format: choice.format, ...(custom ? { path: choice.path } : {}), ...keep };
|
|
32
38
|
}
|
|
33
|
-
|
|
34
39
|
export function createOutputPanel(ctx) {
|
|
35
40
|
const host = document.getElementById('outputs'), details = document.getElementById('output-details');
|
|
36
41
|
const image = createImageView(document.getElementById('viewport'), ctx.message);
|
|
37
42
|
let list = [], formats = [], selected = null, directory = '', sequence = 0, lastList = '', initial = true, refreshing = null, refreshAgain = false, busy = false;
|
|
43
|
+
// a result shown alone that is no card of this tab (a place of an update's before/after, packages.js)
|
|
44
|
+
let other = null;
|
|
38
45
|
const P = { active: null };
|
|
39
|
-
const bar = document.createElement('div'), all = text('button', 'Export all'
|
|
40
|
-
bar.className = 'outputs-bar'; bar.append(all, barNote);
|
|
46
|
+
const bar = document.createElement('div'), all = text('button', 'Export all'), barNote = text('span', '', 'dim');
|
|
47
|
+
bar.className = 'outputs-bar'; bar.append(all, barNote, ctx.thumbSizeButton());
|
|
41
48
|
const live = document.createElement('div'), saved = document.createElement('details'), savedRows = document.createElement('div');
|
|
42
49
|
saved.className = 'saved-outputs'; saved.open = ctx.store.get('outputs.savedOpen', false);
|
|
43
50
|
saved.append(text('summary', 'Saved files'), savedRows); saved.ontoggle = () => ctx.store.set('outputs.savedOpen', saved.open);
|
|
44
|
-
const empty = text('div', '
|
|
51
|
+
const empty = text('div', 'No outputs yet: the results of the package\'s graphs show here once your agent has built one.', 'empty');
|
|
45
52
|
const cards = new Map(), groups = new Map(); let input = null;
|
|
46
53
|
host.append(bar, empty, live, saved);
|
|
47
54
|
Object.defineProperty(P, 'count', { get: () => list.filter((v) => v.exportable).length });
|
|
55
|
+
// the heightfield layer each output shows in red, remembered in this browser
|
|
56
|
+
const chosenLayers = ctx.store.get('outputs.layers', {});
|
|
57
|
+
P.layerOf = (item) => shownLayer(item.heightfield, chosenLayers[item.id]);
|
|
48
58
|
|
|
59
|
+
/** Where an export target's files go, in full: the person finds them there. */
|
|
60
|
+
// a target Export refuses (item.target.refused says why) is shown as the graph writes it
|
|
61
|
+
const targetFile = (item) => (item.target.refused ? item.target.path : inFolder(directory, item.target.path));
|
|
49
62
|
function showDetails(item) {
|
|
50
63
|
details.replaceChildren(); details.hidden = !item;
|
|
51
64
|
if (!item) return;
|
|
52
|
-
details.append(text('strong', item.label)
|
|
53
|
-
if (item.
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
details.append(text('strong', item.label));
|
|
66
|
+
if (item.details) { item.details(details); return; }
|
|
67
|
+
const what = kindLine(item);
|
|
68
|
+
if (what) details.append(text('p', what, 'output-kind'));
|
|
69
|
+
if (item.warning) details.append(text('p', item.warning, 'warn'));
|
|
70
|
+
if (item.heightfield && item.view === 'model' && !item.inputPath) {
|
|
71
|
+
// the terrain coloured by one of its layers, in red over the height ramp
|
|
72
|
+
const choice = document.createElement('select'); choice.setAttribute('aria-label', 'Layer drawn in red');
|
|
73
|
+
for (const o of layerChoices(item.heightfield)) choice.append(new Option(o.label, o.value));
|
|
74
|
+
choice.value = P.layerOf(item);
|
|
75
|
+
choice.onchange = () => { chosenLayers[item.id] = choice.value; ctx.store.set('outputs.layers', chosenLayers); choice.blur(); P.select(item.id, true); };
|
|
76
|
+
const row = document.createElement('label'); row.className = 'layer-pick'; row.title = 'the heightfield layer drawn in red over the terrain: 0..1 layers as they are, others from their minimum to their maximum';
|
|
77
|
+
row.append(text('span', 'Layer in red', 'dim'), choice);
|
|
78
|
+
details.append(row);
|
|
79
|
+
}
|
|
80
|
+
if (item.error) details.append(text('p', item.error, 'err'));
|
|
81
|
+
else if (item.summary) { const f = document.createElement('details'); f.className = 'fold'; f.append(text('summary', 'Geometry details'), text('pre', item.summary, 'summary')); details.append(f); }
|
|
82
|
+
if (item.exportable) details.append(text('p', item.target ? `Export writes ${targetFile(item)} (${item.target.format})` : 'Export asks for a format and a file in exports/ the first time; Download gives you a copy without that', 'dim'));
|
|
83
|
+
if (item.target?.refused) details.append(text('p', item.target.refused, 'warn'));
|
|
84
|
+
if (item.live?.length) details.append(text('p', liveText(item), 'live'));
|
|
85
|
+
if (item.files) {
|
|
86
|
+
if (item.origin === 'saved' && !item.parent) details.append(text('p', `in ${directory}`, 'dim'));
|
|
87
|
+
for (const f of item.files) {
|
|
88
|
+
const a = text('a', `${f.name} · ${f.about ? f.about + ' · ' : ''}${fmtBytes(f.size)}`); a.href = url('file', item, { file: f.id, download: '1' }); a.download = f.name; details.append(a);
|
|
89
|
+
}
|
|
56
90
|
}
|
|
57
|
-
if (item.files?.length > 1) { const a = text('a',
|
|
91
|
+
if (item.files?.length > 1) { const a = text('a', `Download all as ${item.download?.zip ? item.download.name : item.label + '.zip'}`); a.href = url('zip', item); a.download = item.download?.name ?? item.label + '.zip'; details.append(a); }
|
|
58
92
|
}
|
|
59
93
|
const targetLine = (item) => !item.target ? 'no export target'
|
|
60
94
|
: `${item.target.path}${item.saved ? ` · saved ${ago(item.saved.at)} · ${fmtBytes(item.saved.size)}` : ' · not exported yet'}`;
|
|
@@ -70,10 +104,29 @@ export function createOutputPanel(ctx) {
|
|
|
70
104
|
ctx.message(`exporting ${item.label}…`, 'busy');
|
|
71
105
|
try {
|
|
72
106
|
const j = await post('export', { id: item.id, ...(choice ? { export: targetSpec(item, choice, formats) } : {}) });
|
|
73
|
-
ctx.message(`exported ${item.label} →
|
|
107
|
+
ctx.message(`exported ${item.label} → ${j.file ?? 'exports/' + j.path}${j.files > 1 ? ` (${j.files} files)` : ''}${j.warnings?.length ? ' · ' + j.warnings.join('; ') : ''}`, j.warnings?.length ? 'err' : 'ok', 7000);
|
|
74
108
|
} catch (e) { ctx.message(e.message, 'err', 10000); }
|
|
75
109
|
finally { busy = false; await P.refresh(); render(); }
|
|
76
110
|
}
|
|
111
|
+
/** A card's Download: a published output in a format of choice, a texture as a PNG, a saved file as it is. */
|
|
112
|
+
async function downloadItem(item, button) {
|
|
113
|
+
if (!item.exportable) {
|
|
114
|
+
if (item.generated && item.view === 'image') save(url('image', item, { mode: 'RGBA', download: '1' }), item.label + '.png');
|
|
115
|
+
else if (item.download) save(item.download.zip ? url('zip', item) : url('file', item, { download: '1' }), item.download.name);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const choice = await exportPopover({ anchor: button, item, formats, directory, mode: 'download' });
|
|
119
|
+
if (!choice) return;
|
|
120
|
+
ctx.message(`preparing the download of ${item.label}…`, 'busy');
|
|
121
|
+
try {
|
|
122
|
+
const r = await fetch('/api/output/download', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: item.id, export: downloadSpec(item, choice.format) }) });
|
|
123
|
+
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error ?? `download failed (${r.status})`);
|
|
124
|
+
const blob = await r.blob(), name = filenameOf(r.headers.get('content-disposition')) ?? `${item.label}.zip`, n = Number(r.headers.get('x-file-count') ?? 1);
|
|
125
|
+
const href = URL.createObjectURL(blob);
|
|
126
|
+
save(href, name); setTimeout(() => URL.revokeObjectURL(href), 60000);
|
|
127
|
+
ctx.message(`downloaded ${name} · ${fmtBytes(blob.size)}${n > 1 ? ` · ${n} files` : ''}`, 'ok', 7000);
|
|
128
|
+
} catch (e) { ctx.message(e.message, 'err', 10000); }
|
|
129
|
+
}
|
|
77
130
|
async function clearTarget(item) {
|
|
78
131
|
try { await post('export', { id: item.id, export: null }); ctx.message(`${item.label} has no export target now`); }
|
|
79
132
|
catch (e) { ctx.message(e.message, 'err', 10000); }
|
|
@@ -85,13 +138,16 @@ export function createOutputPanel(ctx) {
|
|
|
85
138
|
try {
|
|
86
139
|
const j = await post('export-all', {});
|
|
87
140
|
const warnings = j.written.flatMap((w) => w.warnings ?? []);
|
|
88
|
-
ctx.message(`exported ${j.written.length} output${j.written.length === 1 ? '' : 's'}${j.skipped.length ? ` · ${j.skipped.length} without a target (their Export button sets one)` : ''}${warnings.length ? ' · ' + warnings.join('; ') : ''}`, warnings.length ? 'err' : 'ok', 8000);
|
|
141
|
+
ctx.message(`exported ${j.written.length} output${j.written.length === 1 ? '' : 's'} into ${directory}${j.skipped.length ? ` · ${j.skipped.length} without a target (their Export button sets one)` : ''}${warnings.length ? ' · ' + warnings.join('; ') : ''}`, warnings.length ? 'err' : 'ok', 8000);
|
|
89
142
|
} catch (e) { ctx.message(e.message, 'err', 10000); }
|
|
90
143
|
finally { busy = false; await P.refresh(); render(); }
|
|
91
144
|
};
|
|
92
145
|
|
|
93
146
|
function render() {
|
|
94
147
|
const used = new Set(), usedGroups = new Set(), grouped = new Map();
|
|
148
|
+
// the package's default graph first
|
|
149
|
+
const first = ctx.package?.package?.graph;
|
|
150
|
+
if (first && list.some((v) => v.origin === 'published' && v.graph === first)) grouped.set(first, []);
|
|
95
151
|
for (const item of list) {
|
|
96
152
|
const name = item.origin === 'published' ? item.graph ?? 'Outputs' : '__saved';
|
|
97
153
|
if (!grouped.has(name)) grouped.set(name, []); grouped.get(name).push(item);
|
|
@@ -99,16 +155,19 @@ export function createOutputPanel(ctx) {
|
|
|
99
155
|
const published = list.filter((v) => v.exportable), withTarget = published.filter((v) => v.target);
|
|
100
156
|
all.disabled = busy || !withTarget.length;
|
|
101
157
|
all.textContent = busy ? 'Exporting…' : 'Export all';
|
|
102
|
-
all.title = withTarget.length ? `write every output that has an export target (${withTarget.length}) into
|
|
103
|
-
barNote.textContent = published.length ? `${withTarget.length} of ${published.length} with
|
|
104
|
-
bar
|
|
158
|
+
all.title = withTarget.length ? `write every output that has an export target (${withTarget.length}) into ${directory}` : 'export an output with its button first: that sets its target';
|
|
159
|
+
barNote.textContent = published.length ? `${withTarget.length} of ${published.length} with an export target` : '';
|
|
160
|
+
// the bar holds the thumbnail size while there are cards; Export all while some are published
|
|
161
|
+
all.hidden = barNote.hidden = !published.length; bar.hidden = !list.length; empty.hidden = !!list.length;
|
|
105
162
|
for (const [name, entries] of grouped) {
|
|
106
163
|
let group = groups.get(name);
|
|
107
164
|
if (!group) {
|
|
108
|
-
const box = document.createElement('div'), rows = document.createElement('div');
|
|
109
|
-
if (name !== '__saved') box.append(
|
|
110
|
-
box.append(rows); group = { box, rows }; groups.set(name, group);
|
|
165
|
+
const box = document.createElement('div'), rows = document.createElement('div'), head = text('div', name, 'output-group');
|
|
166
|
+
if (name !== '__saved') box.append(head);
|
|
167
|
+
box.append(rows); group = { box, rows, head }; groups.set(name, group);
|
|
111
168
|
}
|
|
169
|
+
// a graph whose one result is named after it needs no heading of its own
|
|
170
|
+
group.head.hidden = entries.filter((v) => !v.parent).length === 1 && entries[0].label === name;
|
|
112
171
|
usedGroups.add(name);
|
|
113
172
|
const parent = name === '__saved' ? savedRows : live;
|
|
114
173
|
if (group.box.parentElement !== parent) parent.append(group.box);
|
|
@@ -121,12 +180,19 @@ export function createOutputPanel(ctx) {
|
|
|
121
180
|
used.add(item.id); let card = cards.get(item.id);
|
|
122
181
|
if (!card) {
|
|
123
182
|
const row = document.createElement('div'); row.className = 'output-card'; row.tabIndex = 0; row.setAttribute('role', 'button'); row.dataset.output = item.id;
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
body
|
|
129
|
-
|
|
183
|
+
// the picture keeps what it showed while the result cooks again; a mark over it says it is cooking
|
|
184
|
+
const pic = text('span', '', 'output-pic'), thumb = document.createElement('img'); thumb.loading = 'lazy'; thumb.alt = '';
|
|
185
|
+
const icon = text('span', 'FILE', 'file-icon'), cooking = text('span', 'cooking…', 'output-cooking');
|
|
186
|
+
pic.append(thumb, icon, cooking);
|
|
187
|
+
const body = text('span', '', 'output-body'), head = text('span', '', 'output-head'), label = text('span', '', 'output-label');
|
|
188
|
+
const badges = text('span', '', 'output-badges'), info = text('small', '', 'dim'), tags = text('span', '', 'output-tags');
|
|
189
|
+
const target = text('button', '', 'output-target'), actions = text('span', '', 'output-actions');
|
|
190
|
+
const down = text('button', 'Download', 'primary output-download'), go = text('button', 'Export', 'output-export');
|
|
191
|
+
target.title = 'change where this output exports'; go.type = target.type = down.type = 'button';
|
|
192
|
+
head.append(label, badges);
|
|
193
|
+
actions.append(down, go); body.append(head, info, tags, target, actions); row.append(pic, body);
|
|
194
|
+
card = { row, thumb, icon, label, badges, info, tags, target, down, go, item }; cards.set(item.id, card);
|
|
195
|
+
down.onclick = () => downloadItem(card.item, down);
|
|
130
196
|
go.onclick = () => exportItem(card.item, go);
|
|
131
197
|
target.onclick = () => exportItem(card.item, go, true);
|
|
132
198
|
row.onclick = (e) => { if (!e.target.closest('input,button')) P.select(card.item.id); };
|
|
@@ -135,17 +201,44 @@ export function createOutputPanel(ctx) {
|
|
|
135
201
|
thumb.onerror = () => { thumb.hidden = true; icon.hidden = false; };
|
|
136
202
|
}
|
|
137
203
|
card.item = item;
|
|
138
|
-
const { row, thumb, icon, label, info, target, go } = card;
|
|
204
|
+
const { row, thumb, icon, label, badges, info, tags, target, down, go } = card;
|
|
205
|
+
const what = kindLine(item), detail = detailLine(item);
|
|
139
206
|
row.classList.toggle('selected', item.id === selected); row.classList.toggle('child', !!item.parent);
|
|
140
|
-
row.
|
|
207
|
+
row.classList.toggle('cooking', item.status === 'loading'); row.classList.toggle('stale', !!item.stale && item.status !== 'loading');
|
|
208
|
+
row.setAttribute('aria-label', `${item.label} — ${what || item.view}`); row.setAttribute('aria-pressed', String(item.id === selected));
|
|
141
209
|
go.hidden = target.hidden = !item.exportable; go.disabled = busy || item.status === 'loading';
|
|
142
|
-
go.title = item.target ? `write
|
|
210
|
+
go.title = item.target ? `write ${targetFile(item)} again (overwrites it)` : `choose a format and a file in ${directory || 'exports/'}, then export`;
|
|
143
211
|
go.setAttribute('aria-label', `Export ${item.label}`);
|
|
212
|
+
// Download: every card that has something to give (a published output, a texture, saved files)
|
|
213
|
+
down.hidden = !(item.exportable || (item.generated && item.view === 'image') || item.download);
|
|
214
|
+
down.disabled = item.exportable && (item.status !== 'ready' || !item.formats?.length);
|
|
215
|
+
down.title = item.exportable ? (item.formats?.length ? 'choose a format and download the export (its files as one zip when there are several)' : item.status === 'ready' ? 'no format writes this output' : 'cooking…')
|
|
216
|
+
: item.download ? `download ${item.download.name}` : `download ${item.label}.png`;
|
|
217
|
+
down.setAttribute('aria-label', `Download ${item.label}`);
|
|
144
218
|
target.textContent = item.exportable ? targetLine(item) : ''; target.classList.toggle('unset', !item.target);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
219
|
+
// while it cooks the card keeps its picture and its lines (the mark over the picture says it is cooking)
|
|
220
|
+
const src = ['model', 'image'].includes(item.view) ? item.view === 'image' && !item.generated ? url('file', item) : url('thumb', item) : '';
|
|
221
|
+
if (item.status !== 'loading' && thumb.dataset.source !== src) { thumb.dataset.source = src; thumb.hidden = !src; icon.hidden = !!src; if (src) thumb.src = src; }
|
|
222
|
+
if (item.status === 'loading' && !thumb.dataset.source) { thumb.hidden = true; icon.hidden = false; }
|
|
223
|
+
icon.textContent = item.view === 'model' ? '3D' : item.view === 'image' ? 'IMG' : (item.kind === 'metadata' ? 'JSON' : (item.files?.[0]?.name.split('.').pop() ?? 'file').toUpperCase().slice(0, 5));
|
|
224
|
+
label.textContent = item.label;
|
|
225
|
+
// the default output, and the kind in the words everything uses
|
|
226
|
+
const marks = [];
|
|
227
|
+
// the default among a graph's several results
|
|
228
|
+
if (item.default && entries.filter((v) => !v.parent && v.exportable).length > 1) { const b = text('span', 'default', 'badge default'); b.title = 'the graph\'s default output: what the graph shows and exports when no output is named'; marks.push(b); }
|
|
229
|
+
const kind = kindBadge(item);
|
|
230
|
+
if (kind) { const b = text('span', kind, 'badge kind'); b.title = 'what it is'; marks.push(b); }
|
|
231
|
+
// it uses a package shown live: unpublished edits on show (its exports use the published version)
|
|
232
|
+
if (item.live?.length) { const b = text('span', 'unpublished edits', 'badge live'); b.title = liveText(item); marks.push(b); }
|
|
233
|
+
badges.replaceChildren(...marks);
|
|
234
|
+
tags.replaceChildren(...(item.tags ?? []).map((t) => text('span', t, 'tag')));
|
|
235
|
+
tags.title = item.tags?.length ? kindTagsLine(item) : '';
|
|
236
|
+
tags.hidden = !item.tags?.length;
|
|
237
|
+
// an output that is not the kind its graph pins says so (publishing the package would block on it); one
|
|
238
|
+
// whose cook was stopped shows the last finished result
|
|
239
|
+
const warned = !item.error && item.warning;
|
|
240
|
+
info.textContent = item.error ?? (item.stale ? `out of date: its cook was stopped · ${detail}` : warned ? `not a "${item.pinned}" · ${detail}` : detail || (item.status === 'loading' ? 'cooking…' : ''));
|
|
241
|
+
info.className = item.error ? 'err' : warned || item.stale ? 'warn' : 'dim'; info.title = item.error ?? (warned ? `${what}\n${item.warning}` : item.stale ? 'its cook was stopped: the card shows the last finished result; change a value to cook it again' : what);
|
|
149
242
|
const next = previous ? previous.nextSibling : group.rows.firstChild; if (row !== next) group.rows.insertBefore(row, next); previous = row;
|
|
150
243
|
}
|
|
151
244
|
}
|
|
@@ -165,46 +258,57 @@ export function createOutputPanel(ctx) {
|
|
|
165
258
|
const close = () => { menu?.remove(); menu = null; removeEventListener('pointerdown', outside, true); removeEventListener('blur', close); previous?.focus(); };
|
|
166
259
|
const outside = (e) => { if (!menu?.contains(e.target)) close(); }; dismissMenu = close;
|
|
167
260
|
const add = (label, action) => { const button = text('button', label); button.setAttribute('role', 'menuitem'); button.onclick = () => { close(); action(); }; menu.append(button); };
|
|
168
|
-
const
|
|
261
|
+
const card = cards.get(item.id);
|
|
169
262
|
add(item.origin === 'saved' ? 'Open' : 'Preview', () => P.select(item.id));
|
|
170
|
-
if (item.
|
|
263
|
+
if (item.view === 'model') add('Frame', async () => { await P.select(item.id); ctx.frameOutput(); });
|
|
171
264
|
if (item.exportable) {
|
|
172
|
-
|
|
173
|
-
add(item.target ? `Export to ${item.target.path}` : 'Export…', () => exportItem(item, go));
|
|
174
|
-
add('Change export target…', () => exportItem(item, go, true));
|
|
265
|
+
if (item.formats?.length) add('Download…', () => downloadItem(item, card?.down));
|
|
266
|
+
add(item.target ? `Export to ${item.target.path}` : 'Export…', () => exportItem(item, card?.go));
|
|
267
|
+
add('Change export target…', () => exportItem(item, card?.go, true));
|
|
175
268
|
if (item.target) add('Remove export target', () => clearTarget(item));
|
|
176
|
-
} else if (item.generated && item.
|
|
177
|
-
else if (item.
|
|
269
|
+
} else if (item.generated && item.view === 'image') add('Download PNG', () => downloadItem(item));
|
|
270
|
+
else if (item.download) add(item.download.zip ? `Download ${item.download.name}` : 'Download', () => downloadItem(item));
|
|
178
271
|
document.body.append(menu); menu.style.left = Math.max(4, Math.min(x, innerWidth - menu.offsetWidth - 4)) + 'px'; menu.style.top = Math.max(4, Math.min(y, innerHeight - menu.offsetHeight - 4)) + 'px';
|
|
179
272
|
menu.onkeydown = (e) => { const buttons = [...menu.children], i = buttons.indexOf(document.activeElement); if (e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); close(); } else if (['ArrowDown', 'ArrowUp'].includes(e.key)) { e.preventDefault(); buttons[(i + (e.key === 'ArrowDown' ? 1 : buttons.length - 1)) % buttons.length].focus(); } };
|
|
180
273
|
menu.firstChild.focus(); addEventListener('pointerdown', outside, true); addEventListener('blur', close);
|
|
181
274
|
}
|
|
182
275
|
P.select = async (id, update = false) => {
|
|
183
|
-
const item = input?.id === id ? input : list.find((v) => v.id === id); if (!item) return;
|
|
276
|
+
const item = input?.id === id ? input : other?.id === id ? other : list.find((v) => v.id === id); if (!item) return;
|
|
184
277
|
const changedSelection = selected !== id;
|
|
185
278
|
if (!update) ctx.rememberOutputView?.(selected);
|
|
186
279
|
const seq = ++sequence;
|
|
187
280
|
if (changedSelection) { image.hide(); ctx.hideModelPreview(); }
|
|
188
281
|
selected = id; P.active = item; ctx.isolated = true; ctx.guides.setMode(null);
|
|
189
282
|
render(); showDetails(item);
|
|
190
|
-
|
|
283
|
+
// it shows once it has cooked (the card says it is cooking)
|
|
284
|
+
if (item.status === 'loading') { ctx.emit('output'); return; }
|
|
191
285
|
if (item.status === 'error') { ctx.message(item.error, 'err'); return; }
|
|
192
286
|
await ctx.outputGraph?.(item);
|
|
193
287
|
if (seq !== sequence) return;
|
|
194
|
-
if (item.
|
|
288
|
+
if (item.view === 'image') { ctx.hideModelPreview(); image.show(item); ctx.emit('output'); return; }
|
|
195
289
|
image.hide();
|
|
196
|
-
if (item.
|
|
290
|
+
if (item.view !== 'model') { ctx.hideModelPreview(); ctx.message(`${item.label}: ${kindLine(item) || 'a file'} · Download gets it`); return; }
|
|
197
291
|
try {
|
|
198
|
-
|
|
199
|
-
if (
|
|
200
|
-
|
|
292
|
+
let bytes;
|
|
293
|
+
if (item.load) bytes = await item.load();
|
|
294
|
+
else {
|
|
295
|
+
const r = await fetch(url('geo', item, item.heightfield ? { heightfield_layer: P.layerOf(item) } : {}));
|
|
296
|
+
if (!r.ok) throw new Error((await r.json()).error);
|
|
297
|
+
bytes = await r.arrayBuffer();
|
|
298
|
+
}
|
|
299
|
+
if (seq !== sequence) return;
|
|
201
300
|
await ctx.previewOutput(item, bytes, update);
|
|
202
|
-
ctx.message(item.label);
|
|
203
301
|
} catch (e) { if (seq === sequence) ctx.message(e.message, 'err'); }
|
|
204
302
|
};
|
|
303
|
+
/**
|
|
304
|
+
* Show a result that is no card here alone in the view, as a card is (packages.js: a place of a before/after):
|
|
305
|
+
* {id, label, view: 'model', status, revision, load() → GLB bytes, details(el) → what the details say, message?}.
|
|
306
|
+
* `update`: the same result again (another side of it), which keeps its camera.
|
|
307
|
+
*/
|
|
308
|
+
P.isolate = (item, update = false) => { other = item; return P.select(item.id, update); };
|
|
205
309
|
P.scene = () => {
|
|
206
310
|
sequence++; initial = false; ctx.rememberOutputView?.(selected); selected = null; P.active = null;
|
|
207
|
-
image.hide(); ctx.isolated = false; showDetails(null); render(); ctx.restoreScene();
|
|
311
|
+
image.hide(); ctx.isolated = false; showDetails(null); render(); ctx.restoreScene(); ctx.emit('output');
|
|
208
312
|
};
|
|
209
313
|
P.refresh = async () => {
|
|
210
314
|
if (refreshing) { refreshAgain = true; return refreshing; }
|
|
@@ -215,20 +319,30 @@ export function createOutputPanel(ctx) {
|
|
|
215
319
|
const signature = JSON.stringify(j.items);
|
|
216
320
|
if (signature === lastList) return;
|
|
217
321
|
lastList = signature; const before = P.active; list = j.items;
|
|
218
|
-
const after = input?.id === selected ? input : list.find((v) => v.id === selected); render(); ctx.emit('outputs');
|
|
322
|
+
const after = input?.id === selected ? input : other?.id === selected ? other : list.find((v) => v.id === selected); render(); ctx.emit('outputs');
|
|
219
323
|
if (after && (after.revision !== before?.revision || after.status !== before?.status)) await P.select(after.id, true);
|
|
220
324
|
else if (after) { P.active = after; showDetails(after); }
|
|
221
325
|
else if (selected && !after) P.scene();
|
|
222
|
-
else if (initial && list.length) {
|
|
326
|
+
else if (initial && list.length) {
|
|
327
|
+
// first the graph the page shows (the package's default graph), its default output
|
|
328
|
+
initial = false;
|
|
329
|
+
const top = list.filter((v) => v.generated && !v.parent), main = top.find((v) => v.graph === ctx.graph.name && v.output === null) ?? top.find((v) => v.graph === ctx.graph.name) ?? top[0];
|
|
330
|
+
if (main) await P.select(main.id);
|
|
331
|
+
}
|
|
223
332
|
} catch (e) { ctx.message(e.message, 'err'); }
|
|
224
333
|
finally { refreshing = null; if (refreshAgain) { refreshAgain = false; void P.refresh(); } }
|
|
225
334
|
})();
|
|
226
335
|
return refreshing;
|
|
227
336
|
};
|
|
228
|
-
|
|
337
|
+
// Scene: back to the whole scene, the graph's output (not a node shown on its own) with the layers and guides
|
|
338
|
+
document.getElementById('scene-view').onclick = (e) => {
|
|
339
|
+
e.currentTarget.blur();
|
|
340
|
+
if (P.active) P.scene();
|
|
341
|
+
if (ctx.graph.node) ctx.graph.show(ctx.graph.current()?.output ?? null);
|
|
342
|
+
};
|
|
229
343
|
P.openInput = async (path, update = false) => {
|
|
230
344
|
const f = ctx.layers.list.find((v) => v.path === path); if (!f) return;
|
|
231
|
-
input = { id: 'input:' + path, inputPath: path, label: path, kind: 'image', status: 'ready', revision: `${f.mtime}:${f.size}`, sourceURL: inputImageURL(f), summary: ctx.layers.info.get(path)?.summary ?? ctx.layers.fileText(f) };
|
|
345
|
+
input = { id: 'input:' + path, inputPath: path, label: path, view: 'image', kind: 'image', status: 'ready', revision: `${f.mtime}:${f.size}`, sourceURL: inputImageURL(f), summary: ctx.layers.info.get(path)?.summary ?? ctx.layers.fileText(f) };
|
|
232
346
|
await P.select(input.id, update);
|
|
233
347
|
};
|
|
234
348
|
ctx.on('layers', () => {
|