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/viewer/app/props.js
CHANGED
|
@@ -8,7 +8,9 @@ import * as M from './markers.js';
|
|
|
8
8
|
import { parseId } from './selection.js';
|
|
9
9
|
import { DISPLAY_MODES, LAYER_MODES } from './scene.js';
|
|
10
10
|
import { fmtLen, fmtNum, fmtSize, fmtCount } from './units.js';
|
|
11
|
-
import { isNum, same, HEX3, fmt, short,
|
|
11
|
+
import { isNum, same, HEX3, fmt, short, kindOf, blank, menuOf, rangeOf, autoStep, snapTo, controlList, baseValue, rowShape, sessionText, serverValueWins } from './vars.js';
|
|
12
|
+
import { fmtDuration } from './cooking.js';
|
|
13
|
+
import { kindLine, layerChoices, shownLayer } from './output-info.js';
|
|
12
14
|
|
|
13
15
|
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text !== undefined) e.textContent = text; return e; };
|
|
14
16
|
const $ = (id) => document.getElementById(id);
|
|
@@ -28,7 +30,7 @@ export function createProps(ctx) {
|
|
|
28
30
|
};
|
|
29
31
|
const xyz = (vals, step = 1) => {
|
|
30
32
|
const box = el('div', 'xyz');
|
|
31
|
-
for (const x of vals) { const f = el('input'); f.readOnly = true; f.value = fmtNum(x, step < 1 ? 3 : 2); f.title = 'read-only
|
|
33
|
+
for (const x of vals) { const f = el('input'); f.readOnly = true; f.value = fmtNum(x, step < 1 ? 3 : 2); f.title = 'read-only'; box.append(f); }
|
|
32
34
|
return box;
|
|
33
35
|
};
|
|
34
36
|
const numberField = (value, onSet, title) => {
|
|
@@ -88,7 +90,7 @@ export function createProps(ctx) {
|
|
|
88
90
|
} else k.append(row('point', xyz(m.points[0])));
|
|
89
91
|
out.push(k);
|
|
90
92
|
// what the agent reads
|
|
91
|
-
const a = group('attributes
|
|
93
|
+
const a = group('attributes your agent reads');
|
|
92
94
|
const t = el('table', 'attrs');
|
|
93
95
|
for (const r of M.markerAttributes(m)) {
|
|
94
96
|
const tr = el('tr');
|
|
@@ -125,13 +127,22 @@ export function createProps(ctx) {
|
|
|
125
127
|
const g = group('output');
|
|
126
128
|
const graph = ctx.graph.current();
|
|
127
129
|
g.append(row('graph', graph?.name ?? ''), row('node', ctx.graph.shownNode() ?? ''), displayRow(DISPLAY_MODES, o.display, (m) => o.setDisplay(m)));
|
|
130
|
+
// what it is (the server's decision from the cooked geometry), and a heightfield's layer drawn in red
|
|
131
|
+
if (o.about) g.append(row('is', kindLine({ kind: o.about.published ?? 'empty', about: o.about.text, size: o.about.size })));
|
|
132
|
+
if (o.about?.heightfield && !ctx.isolated) {
|
|
133
|
+
const s = el('select');
|
|
134
|
+
for (const c of layerChoices(o.about.heightfield)) s.append(new Option(c.label, c.value));
|
|
135
|
+
s.value = shownLayer(o.about.heightfield, ctx.sceneLayer.get());
|
|
136
|
+
s.onchange = () => { ctx.sceneLayer.set(s.value); s.blur(); };
|
|
137
|
+
g.append(row('layer in red', s, 'the heightfield layer drawn in red over the terrain: 0..1 layers as they are, others from their minimum to their maximum'));
|
|
138
|
+
}
|
|
128
139
|
if (o.report?.cooked) g.append(row('cook', `${fmtNum(o.report.ms, 0)} ms${o.report.ok ? '' : ' · failed'}`));
|
|
129
140
|
const ec = o.mesh?.edgeCounts();
|
|
130
|
-
if (ec) g.append(row('edges', `${fmtCount(ec.open)} open · ${fmtCount(ec.nonManifold)} non-manifold · ${fmtCount(ec.flipped)} flipped`, '
|
|
141
|
+
if (ec) g.append(row('edges', `${fmtCount(ec.open)} open · ${fmtCount(ec.nonManifold)} non-manifold · ${fmtCount(ec.flipped)} flipped`, 'the edge check in the top bar draws them: pink open, yellow non-manifold, violet winding flips'));
|
|
142
|
+
// the whole summary, folded: the line above says what it is
|
|
143
|
+
if (o.summary) { const f = el('details', 'fold'); f.append(el('summary', '', 'Geometry details'), summaryBlock(o.summary)); g.append(f); }
|
|
144
|
+
else g.append(el('div', 'hint', o.error ?? '…'));
|
|
131
145
|
out.push(g);
|
|
132
|
-
const sg = group('summary');
|
|
133
|
-
sg.append(o.summary ? summaryBlock(o.summary) : el('div', 'hint', o.error ?? '…'));
|
|
134
|
-
out.push(sg);
|
|
135
146
|
return out;
|
|
136
147
|
}
|
|
137
148
|
function piece(e, k) {
|
|
@@ -188,17 +199,24 @@ export function createProps(ctx) {
|
|
|
188
199
|
|
|
189
200
|
// ---------------------------------------------------------------------------------------------- the Controls
|
|
190
201
|
// One control per declared param (graph.params), then the undeclared vars. Values are POSTed to /api/vars (sliders at
|
|
191
|
-
// most every 100 ms, plus once on release)
|
|
192
|
-
//
|
|
202
|
+
// most every 100 ms, plus once on release); the server cooks the latest one and stops the cook of the one before.
|
|
203
|
+
// Rows are kept and updated in place: a row is built again only when its shape changes (vars.js rowShape), and never
|
|
204
|
+
// while it is dragged, so the panel keeps its layout and scroll position through reloads and cooks. A finished change
|
|
205
|
+
// (release, Enter, a pick) is one undo step.
|
|
206
|
+
// Over a graph file (`topotopo view`, mode "file") the values are session values over the file: a mark shows each one
|
|
207
|
+
// that differs from the file, ↺ goes back to the file's value, Reset all does so for all of them, and Save values
|
|
208
|
+
// writes them into the file's vars. In a package the values edit the stored graph and ↺ goes to the declared default.
|
|
193
209
|
function createControls(ctx) {
|
|
194
210
|
const box = $('controls'), count = $('controls-count');
|
|
211
|
+
const bar = $('controls-session'), barText = bar.querySelector('.stext'), saveBtn = $('vars-save'), resetBtn = $('vars-reset');
|
|
195
212
|
const ctl = {
|
|
196
|
-
graph: null,
|
|
213
|
+
graph: null, mode: 'package', file: null, graphVars: {}, rows: new Map(), active: null, deferred: null, saving: false,
|
|
197
214
|
pending: {}, timer: 0, lastSend: -1e9, seq: 0,
|
|
198
215
|
// var → id of its newest POST not answered yet / time its newest POST was answered: older server state is ignored
|
|
199
216
|
unacked: new Map(), ackAt: new Map(),
|
|
200
217
|
// var → its value when the change being made began (the undo step's "before")
|
|
201
218
|
begin: new Map(), values: new Map(),
|
|
219
|
+
sub: el('div', 'sub'), none: el('div', 'none'),
|
|
202
220
|
};
|
|
203
221
|
addEventListener('pointerup', () => endDrag(), true);
|
|
204
222
|
addEventListener('pointercancel', () => endDrag(), true);
|
|
@@ -252,18 +270,19 @@ function createControls(ctx) {
|
|
|
252
270
|
return { set, get };
|
|
253
271
|
},
|
|
254
272
|
select(name, vd, value, cw) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const byIndex = isNum(value) && !opts.includes(String(value));
|
|
273
|
+
// an entry stands for its option (numeric options give numbers); a number var with text options holds the index
|
|
274
|
+
const menu = menuOf(vd, value), opts = menu.texts;
|
|
258
275
|
const s = el('select');
|
|
259
276
|
for (const o of opts) s.append(new Option(o, o));
|
|
260
|
-
|
|
277
|
+
// a value outside the options (set by an agent or by hand) is shown as an extra entry while it holds
|
|
278
|
+
let outside;
|
|
279
|
+
const get = () => { const v = menu.valueOf(s.value); return v === undefined ? outside : v; };
|
|
261
280
|
const set = (v) => {
|
|
262
|
-
const k =
|
|
281
|
+
const k = menu.textOf(v);
|
|
263
282
|
if (k === undefined) return;
|
|
264
|
-
// a value outside the options (set by an agent or by hand) is shown as an extra entry while it holds
|
|
265
283
|
for (const o of [...s.options]) if (!opts.includes(o.value) && o.value !== k) o.remove();
|
|
266
284
|
if (![...s.options].some((o) => o.value === k)) s.append(new Option(k, k));
|
|
285
|
+
outside = opts.includes(k) ? undefined : v;
|
|
267
286
|
s.value = k;
|
|
268
287
|
};
|
|
269
288
|
s.onchange = () => { queueVar(name, get(), true); s.blur(); };
|
|
@@ -330,79 +349,180 @@ function createControls(ctx) {
|
|
|
330
349
|
},
|
|
331
350
|
};
|
|
332
351
|
|
|
333
|
-
|
|
352
|
+
/** One control row: its widget, the mark that it differs from the graph file, and ↺. */
|
|
353
|
+
function controlRow(name, vd, value, shape) {
|
|
334
354
|
const declared = !!vd;
|
|
335
355
|
vd = vd ?? {};
|
|
336
|
-
|
|
337
|
-
if (value === undefined) value = def !== undefined ? def : blank(vd);
|
|
356
|
+
if (value === undefined) value = declared && vd.default !== undefined ? vd.default : blank(vd);
|
|
338
357
|
const label = (typeof vd.label === 'string' && vd.label) || name;
|
|
339
|
-
const wrap = el('div', 'ctl'), cw = el('div', 'cw');
|
|
358
|
+
const wrap = el('div', 'ctl'), cw = el('div', 'cw'), mark = el('span', 'cmark');
|
|
340
359
|
wrap.title = [label !== name ? name : '', declared ? vd.desc : 'not declared in the graph\'s "params"'].filter(Boolean).join(' — ');
|
|
341
360
|
const w = WIDGETS[kindOf(declared ? vd : null, value)](name, vd, value, cw);
|
|
342
|
-
const reset = el('button', 'ib'
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
wrap.append(el('span', 'cl', label), cw, reset);
|
|
361
|
+
const reset = el('button', 'ib', '↺');
|
|
362
|
+
reset.onclick = () => { reset.blur(); resetVars([name]); };
|
|
363
|
+
wrap.append(mark, el('span', 'cl', label), cw, reset);
|
|
346
364
|
const r = {
|
|
347
|
-
|
|
365
|
+
el: wrap, name, shape,
|
|
366
|
+
/** what ↺ goes back to (vars.js baseValue), undefined: nothing */
|
|
367
|
+
base: undefined,
|
|
348
368
|
set(v) { w.set(v); r.sync(); },
|
|
349
369
|
get: () => w.get(),
|
|
350
370
|
typing: () => w.typing?.() ?? false,
|
|
351
|
-
|
|
371
|
+
/** differs from the graph file (marked) */
|
|
372
|
+
changed: () => ctl.mode === 'file' && r.base !== undefined && !same(ctl.values.get(name), r.base),
|
|
373
|
+
sync() {
|
|
374
|
+
const changed = r.changed();
|
|
375
|
+
wrap.classList.toggle('changed', changed);
|
|
376
|
+
mark.title = changed ? `differs from ${ctl.file ?? 'the graph'}, where it is ${short(r.base)}` : '';
|
|
377
|
+
reset.classList.toggle('gone', r.base === undefined);
|
|
378
|
+
reset.disabled = r.base === undefined || same(w.get(), r.base);
|
|
379
|
+
reset.title = r.base === undefined ? '' : ctl.mode === 'file' ? `back to ${short(r.base)}, the value in ${ctl.file ?? 'the graph'}` : `reset ${name} to ${short(r.base)}`;
|
|
380
|
+
},
|
|
352
381
|
};
|
|
353
|
-
r.sync();
|
|
354
|
-
ctl.rows.set(name, r);
|
|
355
382
|
ctl.values.set(name, value);
|
|
356
|
-
return
|
|
383
|
+
return r;
|
|
357
384
|
}
|
|
358
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Show a graph's controls. Rows are kept in place: a row whose shape changed is built again (after the drag when it
|
|
388
|
+
* is the one being dragged), rows of vars that went away are removed, new ones are added in order.
|
|
389
|
+
*/
|
|
359
390
|
function render(g, issued = performance.now()) {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const sig = g ? JSON.stringify([g.name, params, other.map((k) => [k, jsonKind(vars[k]), Array.isArray(vars[k]) ? vars[k].length : 0])]) : '';
|
|
363
|
-
if (sig === ctl.sig) return applyValues(vars, issued);
|
|
364
|
-
// the set of params changed: rebuild, but not under a slider being dragged
|
|
365
|
-
if (ctl.active && g?.name === ctl.graph) { ctl.deferred = [g, issued]; return; }
|
|
366
|
-
if (ctl.graph !== (g?.name ?? null)) {
|
|
391
|
+
const name = g?.name ?? null;
|
|
392
|
+
if (ctl.graph !== name) {
|
|
367
393
|
if (ctl.graph) flushVars();
|
|
368
394
|
ctl.pending = {}; ctl.unacked.clear(); ctl.ackAt.clear(); ctl.begin.clear(); ctl.values.clear();
|
|
395
|
+
for (const r of ctl.rows.values()) r.el.remove();
|
|
396
|
+
ctl.rows.clear(); ctl.deferred = null;
|
|
397
|
+
ctl.graph = name;
|
|
369
398
|
}
|
|
370
|
-
ctl.
|
|
371
|
-
|
|
399
|
+
ctl.mode = g?.mode ?? 'package'; ctl.file = g?.file ?? null;
|
|
400
|
+
const params = g?.params ?? {}, vars = g?.vars ?? {};
|
|
401
|
+
ctl.graphVars = g?.graphVars ?? vars;
|
|
402
|
+
const { declared, other } = controlList(params, vars);
|
|
372
403
|
count.textContent = declared.length + other.length || '';
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
404
|
+
let deferred = false;
|
|
405
|
+
const wanted = new Set(), els = [];
|
|
406
|
+
const place = (k, vd) => {
|
|
407
|
+
wanted.add(k);
|
|
408
|
+
// a row the person is changing keeps the value it shows; the shape is the server's otherwise
|
|
409
|
+
const local = ctl.rows.has(k) && holding(k, issued);
|
|
410
|
+
let v = local ? ctl.values.get(k) : vars[k];
|
|
411
|
+
if (v === undefined) v = vd?.default !== undefined ? vd.default : blank(vd ?? {});
|
|
412
|
+
const shape = rowShape(vd, v);
|
|
413
|
+
let r = ctl.rows.get(k);
|
|
414
|
+
if (r && r.shape !== shape) {
|
|
415
|
+
if (ctl.active === k) deferred = true;
|
|
416
|
+
else { const n = controlRow(k, vd, v, shape); r.el.replaceWith(n.el); ctl.rows.set(k, n); r = n; }
|
|
417
|
+
}
|
|
418
|
+
if (!r) { r = controlRow(k, vd, v, shape); ctl.rows.set(k, r); }
|
|
419
|
+
r.base = baseValue(ctl.mode, vd, ctl.graphVars, k);
|
|
420
|
+
els.push(r.el);
|
|
421
|
+
};
|
|
422
|
+
for (const k of declared) place(k, params[k] ?? {});
|
|
423
|
+
if (other.length) { ctl.sub.textContent = declared.length ? 'other vars' : 'vars (none declared in "params")'; els.push(ctl.sub); }
|
|
424
|
+
for (const k of other) place(k, null);
|
|
425
|
+
if (!els.length) { ctl.none.textContent = g ? 'none — this graph exposes no vars' : 'none'; els.push(ctl.none); }
|
|
426
|
+
// in order, moving only what is out of place (the scroll position and an open menu stay)
|
|
427
|
+
let prev = null;
|
|
428
|
+
for (const e of els) { const at = prev ? prev.nextSibling : box.firstChild; if (e !== at) box.insertBefore(e, at); prev = e; }
|
|
429
|
+
for (const [k, r] of ctl.rows) {
|
|
430
|
+
if (wanted.has(k)) continue;
|
|
431
|
+
if (ctl.active === k) { deferred = true; continue; }
|
|
432
|
+
r.el.remove(); ctl.rows.delete(k); ctl.values.delete(k);
|
|
378
433
|
}
|
|
434
|
+
for (const e of [ctl.sub, ctl.none]) if (!els.includes(e)) e.remove();
|
|
435
|
+
ctl.deferred = deferred ? [g, issued] : null;
|
|
436
|
+
applyValues(vars, issued);
|
|
437
|
+
for (const r of ctl.rows.values()) r.sync();
|
|
438
|
+
renderBar();
|
|
379
439
|
}
|
|
380
440
|
|
|
441
|
+
/** The person has a change of var k on the way, is dragging it or typing in it: the server's value waits. */
|
|
442
|
+
const typing = (k) => !!ctl.rows.get(k)?.typing();
|
|
443
|
+
const holding = (k, issued) => !serverValueWins({ pending: ctl.pending, unacked: ctl.unacked, ackAt: ctl.ackAt, active: ctl.active, typing }, k, issued);
|
|
444
|
+
|
|
381
445
|
/** Server state into the controls, except where the person has edits on the way or is dragging/typing. */
|
|
382
446
|
function applyValues(vars, issued) {
|
|
383
447
|
for (const [k, r] of ctl.rows) {
|
|
384
|
-
if (
|
|
385
|
-
const v = k in vars ? vars[k] : r.
|
|
448
|
+
if (holding(k, issued)) continue;
|
|
449
|
+
const v = k in vars ? vars[k] : r.base;
|
|
450
|
+
if (v === undefined) continue;
|
|
386
451
|
r.set(v);
|
|
387
452
|
ctl.values.set(k, v);
|
|
453
|
+
r.sync();
|
|
388
454
|
}
|
|
455
|
+
renderBar();
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** The line above the Controls over a graph file: how many values differ from it, Save values, Reset all. */
|
|
459
|
+
function renderBar() {
|
|
460
|
+
// over a graph file, with values to save or reset
|
|
461
|
+
const file = ctl.mode === 'file';
|
|
462
|
+
bar.hidden = !file || !ctl.rows.size;
|
|
463
|
+
if (bar.hidden) return;
|
|
464
|
+
const changed = [...ctl.rows.values()].filter((r) => r.changed()).length;
|
|
465
|
+
barText.textContent = sessionText(changed, ctl.file);
|
|
466
|
+
// a viewer that cannot write the file (it does not name one) offers no Save
|
|
467
|
+
saveBtn.hidden = !ctl.file;
|
|
468
|
+
saveBtn.disabled = !changed || ctl.saving;
|
|
469
|
+
saveBtn.title = ctl.file ? `write the ${changed || ''} changed value${changed === 1 ? '' : 's'} into "vars" of ${ctl.file}`.replace(' ', ' ') : '';
|
|
470
|
+
resetBtn.disabled = !changed;
|
|
471
|
+
resetBtn.title = `every value back to ${ctl.file ?? 'the graph'}'s`;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** ↺ and Reset all: the vars back to their base value (over a graph file: the file's, one undo step for all). */
|
|
475
|
+
function resetVars(names) {
|
|
476
|
+
const rows = names.map((k) => ctl.rows.get(k)).filter((r) => r && r.base !== undefined && !same(ctl.values.get(r.name), r.base));
|
|
477
|
+
if (!rows.length) return;
|
|
478
|
+
const graph = ctl.graph, before = new Map(rows.map((r) => [r.name, ctl.values.get(r.name)])), after = new Map(rows.map((r) => [r.name, r.base]));
|
|
479
|
+
// over a graph file null drops the session value; in a package the default is stored
|
|
480
|
+
for (const r of rows) { r.set(r.base); queueVar(r.name, ctl.mode === 'file' ? null : r.base, false, true, r.base); }
|
|
481
|
+
const apply = (m) => {
|
|
482
|
+
if (ctl.graph !== graph) { api.vars(graph, Object.fromEntries(m)); return; }
|
|
483
|
+
for (const [k, v] of m) if (ctl.rows.has(k)) { ctl.rows.get(k).set(v); queueVar(k, v, false, true); }
|
|
484
|
+
flushVars();
|
|
485
|
+
};
|
|
486
|
+
ctx.undo.push({ label: rows.length === 1 ? `${rows[0].name} = ${short(rows[0].base)}` : `reset ${rows.length} values`, undo: () => apply(before), redo: () => apply(after) });
|
|
487
|
+
flushVars();
|
|
389
488
|
}
|
|
489
|
+
resetBtn.onclick = () => { resetBtn.blur(); resetVars([...ctl.rows.values()].filter((r) => r.changed()).map((r) => r.name)); };
|
|
490
|
+
saveBtn.onclick = async () => {
|
|
491
|
+
saveBtn.blur();
|
|
492
|
+
const graph = ctl.graph, values = Object.fromEntries([...ctl.rows.values()].filter((r) => r.changed()).map((r) => [r.name, ctl.values.get(r.name)]));
|
|
493
|
+
if (!graph || !Object.keys(values).length) return;
|
|
494
|
+
ctl.saving = true; renderBar();
|
|
495
|
+
// values still on their way go first; the save carries what the controls show
|
|
496
|
+
flushVars();
|
|
497
|
+
const j = await api.saveVars(graph, values);
|
|
498
|
+
ctl.saving = false;
|
|
499
|
+
if (graph !== ctl.graph) return;
|
|
500
|
+
if (!j.ok) { ctx.message(j.error, 'err', 8000); renderBar(); return; }
|
|
501
|
+
ctl.graphVars = j.graphVars ?? ctl.graphVars;
|
|
502
|
+
for (const [k, r] of ctl.rows) { if (Object.hasOwn(ctl.graphVars, k)) r.base = ctl.graphVars[k]; r.sync(); }
|
|
503
|
+
renderBar();
|
|
504
|
+
ctx.message(`saved ${j.saved.length} value${j.saved.length === 1 ? '' : 's'} to ${j.file}: ${j.saved.join(', ')}`, 'ok', 5000);
|
|
505
|
+
};
|
|
390
506
|
|
|
391
|
-
/**
|
|
392
|
-
|
|
507
|
+
/**
|
|
508
|
+
* A change from a control; `final` ends the change (one undo step from its start). `undoing` skips the record.
|
|
509
|
+
* `shown` is what the control shows when `value` is not it (null: back to the graph file's value).
|
|
510
|
+
*/
|
|
511
|
+
function queueVar(name, value, final = false, undoing = false, shown = value) {
|
|
393
512
|
if (!undoing && !ctl.begin.has(name)) ctl.begin.set(name, ctl.values.get(name));
|
|
394
513
|
ctl.pending[name] = value;
|
|
395
|
-
ctl.values.set(name,
|
|
514
|
+
ctl.values.set(name, shown);
|
|
396
515
|
ctl.rows.get(name)?.sync();
|
|
516
|
+
renderBar();
|
|
397
517
|
if (final) {
|
|
398
518
|
const before = ctl.begin.get(name), graph = ctl.graph;
|
|
399
519
|
ctl.begin.delete(name);
|
|
400
|
-
if (!undoing && !same(before,
|
|
520
|
+
if (!undoing && !same(before, shown)) {
|
|
401
521
|
const apply = (v) => {
|
|
402
522
|
if (ctl.graph === graph && ctl.rows.has(name)) { ctl.rows.get(name).set(v); queueVar(name, v, true, true); }
|
|
403
523
|
else api.vars(graph, { [name]: v });
|
|
404
524
|
};
|
|
405
|
-
ctx.undo.push({ label: `${name} = ${short(
|
|
525
|
+
ctx.undo.push({ label: `${name} = ${short(shown)}`, undo: () => apply(before), redo: () => apply(shown) });
|
|
406
526
|
}
|
|
407
527
|
return flushVars();
|
|
408
528
|
}
|
|
@@ -411,6 +531,7 @@ function createControls(ctx) {
|
|
|
411
531
|
else if (!ctl.timer) ctl.timer = setTimeout(flushVars, wait);
|
|
412
532
|
}
|
|
413
533
|
|
|
534
|
+
/** Send the changes on the way; the answer comes once a cook has applied them (or a stop ended it). */
|
|
414
535
|
async function flushVars() {
|
|
415
536
|
clearTimeout(ctl.timer); ctl.timer = 0;
|
|
416
537
|
const vars = ctl.pending, graph = ctl.graph;
|
|
@@ -423,9 +544,12 @@ function createControls(ctx) {
|
|
|
423
544
|
const now = performance.now();
|
|
424
545
|
for (const k in vars) if (ctl.unacked.get(k) === id) { ctl.unacked.delete(k); ctl.ackAt.set(k, now); }
|
|
425
546
|
if (graph !== ctl.graph) return;
|
|
426
|
-
const what = Object.entries(vars).map(([k, v]) => `${k} = ${short(v)}`).join(', ');
|
|
427
|
-
|
|
547
|
+
const what = Object.entries(vars).map(([k, v]) => `${k} = ${v === null ? short(ctl.values.get(k)) : short(v)}`).join(', ');
|
|
548
|
+
// the cook's own state (time, failing node, where it stopped) is in the status bar; this says what was sent
|
|
549
|
+
if (j.stopped) ctx.message(`${what} set · its cook was stopped at ${j.stopped}`);
|
|
550
|
+
else if (j.ok) ctx.message(`${what} · cooked in ${fmtDuration(j.ms)}`, 'ok');
|
|
428
551
|
else ctx.message(`${j.vars ? `${what} applied, cook failed` : `${what} not applied`} — ${(j.errors ?? []).join('; ') || 'unknown error'}`, 'err');
|
|
552
|
+
if (j.graphVars) ctl.graphVars = j.graphVars;
|
|
429
553
|
if (j.vars) applyValues(j.vars, now);
|
|
430
554
|
}
|
|
431
555
|
return { render, flush: flushVars };
|
package/dist/viewer/app/scene.js
CHANGED
|
@@ -39,6 +39,26 @@ export function nudge(material) {
|
|
|
39
39
|
return material;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Push a surface a sliver away from the camera (0.2 % of the distance in persp), so another one lying in the same plane
|
|
44
|
+
* wins the depth test: an update's overlay draws the old version's polygons ("overlay_a") behind the new one's.
|
|
45
|
+
*/
|
|
46
|
+
export function recede(material) {
|
|
47
|
+
if (material.userData.recede) return material;
|
|
48
|
+
material.userData.recede = true;
|
|
49
|
+
const prev = material.onBeforeCompile;
|
|
50
|
+
material.onBeforeCompile = (sh, r) => {
|
|
51
|
+
prev?.call(material, sh, r);
|
|
52
|
+
sh.vertexShader = sh.vertexShader.replace('#include <project_vertex>', `#include <project_vertex>
|
|
53
|
+
{ if (isPerspectiveMatrix(projectionMatrix)) mvPosition.xyz *= 1.002; else mvPosition.z -= 6e-5 * (-2.0 / projectionMatrix[2][2]);
|
|
54
|
+
gl_Position = projectionMatrix * mvPosition; }`);
|
|
55
|
+
};
|
|
56
|
+
const key = material.customProgramCacheKey?.bind(material);
|
|
57
|
+
material.customProgramCacheKey = () => `${key ? key() : ''}|recede`;
|
|
58
|
+
material.needsUpdate = true;
|
|
59
|
+
return material;
|
|
60
|
+
}
|
|
61
|
+
|
|
42
62
|
/** Backfaces tinted blue as the render tool tints them (src/render/raster.ts): colour × 0.35 + (0.12, 0.22, 0.6). */
|
|
43
63
|
export function backTint(material) {
|
|
44
64
|
// Authored two-sided surfaces (cards, cloth, etc.) have intentional backfaces.
|
|
@@ -142,6 +162,8 @@ const boxCorners = (b) => Array.from({ length: 8 }, (_, k) => new THREE.Vector3(
|
|
|
142
162
|
* drawables: each connected part of a mesh, each instance of an instanced mesh, each polyline, each point cloud.
|
|
143
163
|
*/
|
|
144
164
|
export class MeshObject {
|
|
165
|
+
/** the edge check: open, non-manifold and flipped edges drawn over meshes (off by default; the top bar turns it on) */
|
|
166
|
+
static edgeCheck = false;
|
|
145
167
|
constructor(id, src, { picture = false } = {}) {
|
|
146
168
|
this.id = id;
|
|
147
169
|
this.picture = picture;
|
|
@@ -349,7 +371,10 @@ export class MeshObject {
|
|
|
349
371
|
}
|
|
350
372
|
part.wire.visible = on;
|
|
351
373
|
}
|
|
352
|
-
/**
|
|
374
|
+
/**
|
|
375
|
+
* The render tool's open / non-manifold / flipped edges of a mesh (not of instances), found after the first frame: their
|
|
376
|
+
* counts always (Properties), drawn while the edge check is on (MeshObject.edgeCheck, the top bar's toggle).
|
|
377
|
+
*/
|
|
353
378
|
edges(part, on) {
|
|
354
379
|
// a picture is an image, not a surface: no edges to check
|
|
355
380
|
if (part.type !== 'mesh' || this.picture || (!on && !part.edgeObj)) return;
|
|
@@ -357,7 +382,7 @@ export class MeshObject {
|
|
|
357
382
|
part.edgeObj = null;
|
|
358
383
|
setTimeout(() => { if (!this.disposed) { this.findEdges(part); this.mode = null; this.onReady?.(); } }, 0);
|
|
359
384
|
}
|
|
360
|
-
if (part.edgeObj) part.edgeObj.visible = on;
|
|
385
|
+
if (part.edgeObj) part.edgeObj.visible = on && MeshObject.edgeCheck;
|
|
361
386
|
}
|
|
362
387
|
findEdges(part) {
|
|
363
388
|
this.analyse();
|
|
@@ -505,10 +530,10 @@ export class MeshObject {
|
|
|
505
530
|
}
|
|
506
531
|
|
|
507
532
|
// --------------------------------------------------------------------------------------------- loading GLBs
|
|
508
|
-
// meshopt for the
|
|
533
|
+
// meshopt for the web app's baked preview.glb (the live routes send plain GLB)
|
|
509
534
|
const loader = new GLTFLoader().setMeshoptDecoder(MeshoptDecoder);
|
|
510
|
-
/** Parse a GLB buffer into a three.js scene, or throw. */
|
|
511
|
-
export const parseGLB = (buf) => new Promise((resolve, reject) => loader.parse(buf,
|
|
535
|
+
/** Parse a GLB buffer (or a glTF document, its other files read from `base`) into a three.js scene, or throw. */
|
|
536
|
+
export const parseGLB = (buf, base = '') => new Promise((resolve, reject) => loader.parse(buf, base, (g) => resolve(g.scene), reject));
|
|
512
537
|
/** A PNG arrives as flat quads with unlit materials named "image:<name>" (src/render/texview.ts): a picture. */
|
|
513
538
|
export function isPicture(root) {
|
|
514
539
|
let meshes = 0, all = true;
|
|
@@ -36,13 +36,14 @@ export function createSelect(ctx) {
|
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* Where a guide lands under a viewport point: the surface of the output or of a reference layer (not pictures,
|
|
39
|
-
* not the markers file), else the slot's construction plane. {point, surface} or null.
|
|
39
|
+
* not the markers file), else the slot's construction plane. {point, surface} or null. `layersOnly`: the reference
|
|
40
|
+
* layers alone (a dragged guide must not land on what the graph builds from it).
|
|
40
41
|
*/
|
|
41
|
-
S.surfacePoint = (slot, x, y) => {
|
|
42
|
+
S.surfacePoint = (slot, x, y, { layersOnly = false } = {}) => {
|
|
42
43
|
const rc = ctx.views.ray(slot, x, y);
|
|
43
44
|
let best = null;
|
|
44
45
|
for (const e of meshEntries()) {
|
|
45
|
-
if (e.surface === false || e.mesh.bboxMode) continue;
|
|
46
|
+
if (e.surface === false || e.mesh.bboxMode || (layersOnly && e.kind !== 'layer')) continue;
|
|
46
47
|
const h = e.mesh.pick(rc, 0);
|
|
47
48
|
if (h && h.dist < (best?.dist ?? Infinity)) best = h;
|
|
48
49
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
// The
|
|
2
|
-
// Plain functions, tested in Node (test/viewer-logic.ts).
|
|
1
|
+
// The page's messages: what something the person did came to, in a small area over the view that clears itself, so
|
|
2
|
+
// the status bar keeps only the cook line and what is shown. Plain functions, tested in Node (test/viewer-logic.ts).
|
|
3
3
|
|
|
4
|
-
/** While the event stream is
|
|
5
|
-
export const
|
|
6
|
-
/**
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
/** The line when the event stream (re)connects: the hint while there is no graph, else the live line. */
|
|
10
|
-
export const connectedLine = (graphCount) => (graphCount ? LIVE_LINE : NO_GRAPHS_LINE);
|
|
4
|
+
/** While the event stream is down: it stays until the page reconnects. */
|
|
5
|
+
export const DISCONNECTED_LINE = 'the viewer server is not answering (stopped?): this page reconnects when it runs again';
|
|
6
|
+
/** When the event stream comes back. */
|
|
7
|
+
export const RECONNECTED_LINE = 'connected again';
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Whichever of the two runs last at startup, the page ends on the line that fits the workspace.
|
|
10
|
+
* How long a message stays (ms), Infinity until another replaces it: an error 12 s, work in progress ("busy") until its
|
|
11
|
+
* result replaces it, the disconnected line until the page reconnects, others 6 s; `hold` makes it at least that long.
|
|
16
12
|
*/
|
|
17
|
-
export function
|
|
18
|
-
if (!
|
|
19
|
-
|
|
13
|
+
export function messageLife(text, kind = '', hold = 0) {
|
|
14
|
+
if (!text) return 0;
|
|
15
|
+
if (kind === 'busy' || text === DISCONNECTED_LINE) return Infinity;
|
|
16
|
+
return Math.max(hold, kind === 'err' ? 12000 : 6000);
|
|
20
17
|
}
|
|
@@ -32,6 +32,12 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
32
32
|
#top .tb select { color: var(--text); max-width: 180px; }
|
|
33
33
|
#top .readout { font: var(--mono); color: var(--dim); min-width: 84px; }
|
|
34
34
|
#top .mode { color: var(--sel); }
|
|
35
|
+
#top button.tb.on { border-color: var(--sel); color: var(--sel); }
|
|
36
|
+
#top .tools { gap: 0; }
|
|
37
|
+
#top .tools button { margin-left: -1px; border-radius: 0; }
|
|
38
|
+
#top .tools button:first-of-type { margin-left: 4px; border-radius: 3px 0 0 3px; }
|
|
39
|
+
#top .tools button:last-of-type { border-radius: 0 3px 3px 0; }
|
|
40
|
+
#top .tools button.on { border-color: var(--sel); color: var(--sel); position: relative; }
|
|
35
41
|
.grow { flex: 1; }
|
|
36
42
|
|
|
37
43
|
/* panels */
|
|
@@ -42,8 +48,9 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
42
48
|
.phead .count { margin-left: auto; letter-spacing: 0; }
|
|
43
49
|
.pscroll { overflow: auto; min-height: 0; }
|
|
44
50
|
#tree { flex: 1; }
|
|
45
|
-
|
|
46
|
-
#controls { flex: 1; }
|
|
51
|
+
/* the Controls first, as tall as they need up to the split; Properties below, scrolling */
|
|
52
|
+
#controls { flex: 0 1 auto; max-height: var(--split); min-height: 32px; }
|
|
53
|
+
#props-scroll { flex: 1; }
|
|
47
54
|
.grip { position: absolute; z-index: 5; }
|
|
48
55
|
.grip.v { top: 0; bottom: 0; width: 6px; cursor: col-resize; }
|
|
49
56
|
#outliner .grip.v { right: -3px; }
|
|
@@ -63,6 +70,10 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
63
70
|
.row.part { border-left-color: rgba(240, 160, 48, 0.5); }
|
|
64
71
|
.row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
65
72
|
.row .mt { color: var(--dim); font-size: 11px; white-space: nowrap; }
|
|
73
|
+
/* a node of a package with an update (in the accent colour), or one followed this session (in the guides' colour) */
|
|
74
|
+
.row .pmark { flex: none; color: var(--sel); font-size: 11px; white-space: nowrap; cursor: pointer; }
|
|
75
|
+
.row .pmark:hover { text-decoration: underline; }
|
|
76
|
+
.row .pmark.live { color: var(--guide); }
|
|
66
77
|
.row .err { color: var(--err); }
|
|
67
78
|
.row.err .nm { color: var(--err); }
|
|
68
79
|
.row .eye { flex: 0 0 16px; width: 16px; height: 16px; padding: 0; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--dim); }
|
|
@@ -97,6 +108,17 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
97
108
|
.vw .lbl { position: absolute; transform: translate(8px, -50%); padding: 0 4px; font: var(--font); color: var(--text); background: rgba(31, 33, 36, 0.78); border-radius: 2px; white-space: nowrap; }
|
|
98
109
|
.vw .lbl.sel { color: var(--sel); }
|
|
99
110
|
.vw .lbl.dimen { transform: translate(-50%, -130%); font: var(--mono); color: var(--sel); }
|
|
111
|
+
/* while there is no graph: the package's name, what to do, TopoTopo's built-in packages (welcome.js) */
|
|
112
|
+
#welcome { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 24px; overflow: auto; background: rgba(43, 45, 49, 0.82); }
|
|
113
|
+
.welcome-box { max-width: 560px; padding: 20px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; font-size: 13px; line-height: 1.5; }
|
|
114
|
+
.welcome-box h1 { margin: 0; font-size: 20px; font-weight: 600; }
|
|
115
|
+
.welcome-box h2 { margin: 16px 0 6px; font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
|
|
116
|
+
.welcome-box p { margin: 8px 0; }
|
|
117
|
+
.welcome-box code { font: var(--mono); color: var(--text); background: var(--bg); padding: 1px 4px; border-radius: 2px; overflow-wrap: anywhere; }
|
|
118
|
+
.welcome-sub { color: var(--dim); font: var(--mono); overflow-wrap: anywhere; }
|
|
119
|
+
.welcome-lead { font-size: 14px; color: var(--sel); }
|
|
120
|
+
.welcome-builtin { margin: 0; padding-left: 18px; }
|
|
121
|
+
.welcome-builtin li { margin: 4px 0; }
|
|
100
122
|
#boxsel { position: absolute; border: 1px dashed var(--sel); background: rgba(240, 160, 48, 0.06); pointer-events: none; }
|
|
101
123
|
#viewport.placing #gl { cursor: crosshair; }
|
|
102
124
|
#viewport.nav #gl { cursor: move; }
|
|
@@ -120,6 +142,9 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
120
142
|
.attrs td { padding: 1px 4px 1px 0; vertical-align: top; overflow-wrap: anywhere; }
|
|
121
143
|
.attrs td:first-child { color: var(--dim); white-space: nowrap; }
|
|
122
144
|
.summary { margin: 0; font: var(--mono); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
145
|
+
/* the geometry summary, folded under its one-line kind */
|
|
146
|
+
.fold > summary { cursor: pointer; color: var(--dim); font-size: 11px; user-select: none; margin: 4px 0; }
|
|
147
|
+
.fold > summary:hover { color: var(--text); }
|
|
123
148
|
.hint { color: var(--dim); font-size: 11px; overflow-wrap: anywhere; }
|
|
124
149
|
.bad { border-color: var(--err) !important; }
|
|
125
150
|
.danger:hover { border-color: var(--err); color: var(--err); }
|
|
@@ -128,7 +153,37 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
128
153
|
#controls { padding: 4px 6px 8px; }
|
|
129
154
|
.ctl { display: flex; align-items: center; gap: 4px; min-height: 26px; padding: 1px 2px; }
|
|
130
155
|
.ctl:hover { background: var(--hover-bg); }
|
|
131
|
-
.ctl > .cl { flex: 0 0
|
|
156
|
+
.ctl > .cl { flex: 0 0 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
157
|
+
/* a value that differs from the graph file: a bar before its name, the name in the accent colour */
|
|
158
|
+
.ctl > .cmark { flex: 0 0 3px; width: 3px; height: 16px; border-radius: 1px; }
|
|
159
|
+
.ctl.changed > .cmark { background: var(--sel); }
|
|
160
|
+
.ctl.changed > .cl { color: var(--sel); }
|
|
161
|
+
/* above the controls: the cook state (always one line, so nothing below moves) and, over a graph file, the session */
|
|
162
|
+
#controls-bar { position: relative; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 3px 8px 4px; border-bottom: 1px solid var(--line); }
|
|
163
|
+
#controls-bar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
|
|
164
|
+
/* while a cook runs: a still accent line. Nothing on the page moves on its own while a cook runs (an animation repaints
|
|
165
|
+
the page every frame, which takes the processor from the cook); the time the cook line counts shows it is alive */
|
|
166
|
+
#props.cooking #controls-bar::after { background: var(--sel); opacity: .7; }
|
|
167
|
+
#controls-bar .cookline { height: 20px; }
|
|
168
|
+
.sessionline { display: flex; align-items: center; gap: 6px; height: 22px; }
|
|
169
|
+
.sessionline .stext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
|
|
170
|
+
.sessionline button { flex: none; padding: 0 8px; height: 20px; }
|
|
171
|
+
.sessionline button:disabled { opacity: .45; cursor: default; }
|
|
172
|
+
/* the cook state: what cooks and for how long, how the last cook ended */
|
|
173
|
+
.cookline { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; color: var(--dim); }
|
|
174
|
+
.cookline .ctext { overflow: hidden; text-overflow: ellipsis; min-width: 0; font: var(--mono); }
|
|
175
|
+
.cookline .cdot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
|
|
176
|
+
.cookline .cstop { display: none; flex: none; padding: 0 8px; height: 18px; line-height: 1; }
|
|
177
|
+
.cookline.running, .cookline.stopping { color: var(--sel); }
|
|
178
|
+
.cookline.running .cdot, .cookline.stopping .cdot { background: var(--sel); }
|
|
179
|
+
.cookline.running .cstop { display: inline-block; }
|
|
180
|
+
.cookline.failed { color: var(--err); }
|
|
181
|
+
.cookline.failed .cdot { background: var(--err); }
|
|
182
|
+
.cookline.stopped { color: var(--text); }
|
|
183
|
+
.cookline.stopped .cdot { background: var(--dim); border-radius: 1px; }
|
|
184
|
+
.cookline.ok .cdot { background: var(--ok); }
|
|
185
|
+
.cookline.none .cdot { visibility: hidden; }
|
|
186
|
+
#status .cookline { max-width: 60%; }
|
|
132
187
|
.ctl > .cw { flex: 1; display: flex; gap: 4px; align-items: center; min-width: 0; }
|
|
133
188
|
.cw input { padding: 1px 4px; }
|
|
134
189
|
.cw input[type=range] { flex: 1; min-width: 40px; padding: 0; border: 0; background: none; accent-color: var(--sel); }
|
|
@@ -147,15 +202,18 @@ input:focus, select:focus { outline: 1px solid var(--faint); outline-offset: -1p
|
|
|
147
202
|
|
|
148
203
|
/* status bar */
|
|
149
204
|
#status { grid-area: status; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; color: var(--dim); }
|
|
150
|
-
#msg { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
|
151
|
-
#msg.err { color: var(--err); }
|
|
152
|
-
#msg.ok { color: var(--ok); }
|
|
153
|
-
#msg.busy { color: var(--sel); }
|
|
154
205
|
#cook { overflow: hidden; text-overflow: ellipsis; min-width: 0; font: var(--mono); }
|
|
155
206
|
#cook .err { color: var(--err); }
|
|
207
|
+
/* messages: over the view's lower left, clearing themselves (status.js) */
|
|
208
|
+
#notes { position: absolute; left: 8px; bottom: 8px; z-index: 5; display: flex; align-items: flex-start; gap: 6px; max-width: min(640px, calc(100% - 96px)); padding: 5px 4px 5px 10px; background: rgba(38, 40, 44, 0.94); border: 1px solid var(--line); border-radius: 3px; color: var(--text); }
|
|
209
|
+
#msg { min-width: 0; overflow-wrap: anywhere; white-space: pre-line; max-height: 6.5em; overflow: hidden; }
|
|
210
|
+
#notes.err { border-color: var(--err); } #notes.err #msg { color: var(--err); }
|
|
211
|
+
#notes.ok #msg { color: var(--ok); }
|
|
212
|
+
#notes.busy #msg { color: var(--sel); }
|
|
156
213
|
#ask { display: flex; gap: 6px; align-items: center; color: var(--text); }
|
|
157
214
|
#ask[hidden] { display: none; }
|
|
158
215
|
#ask button { padding: 0 8px; }
|
|
216
|
+
#msg-close { flex: none; width: 18px; height: 18px; }
|
|
159
217
|
|
|
160
218
|
/* drop zone */
|
|
161
219
|
#drop { position: fixed; inset: 8px; z-index: 20; display: none; align-items: center; justify-content: center; text-align: center; border: 2px dashed var(--sel); background: rgba(240, 160, 48, 0.06); color: var(--sel); font-size: 15px; pointer-events: none; }
|