topotopo 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +40 -10
- package/README.md +475 -111
- package/dist/cli.js +328 -133
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/analysis.d.ts +5 -1
- package/dist/core/analysis.js +8 -3
- package/dist/core/bake.d.ts +16 -8
- package/dist/core/bake.js +165 -29
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +238 -97
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +204 -4
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/imageops.d.ts +6 -0
- package/dist/core/imageops.js +51 -0
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +11 -0
- package/dist/core/materials.js +56 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/packed.js +11 -0
- package/dist/core/particles.d.ts +1 -1
- package/dist/core/particles.js +1 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/rbd.js +13 -1
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scatter.d.ts +1 -1
- package/dist/core/scatter.js +1 -1
- package/dist/core/scene.d.ts +20 -0
- package/dist/core/scene.js +72 -0
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +15 -2
- package/dist/core/snippet-lib.js +40 -14
- package/dist/core/solidify.d.ts +38 -0
- package/dist/core/solidify.js +356 -0
- package/dist/core/tangents.d.ts +54 -0
- package/dist/core/tangents.js +218 -0
- package/dist/core/texcoord.d.ts +4 -0
- package/dist/core/texcoord.js +14 -0
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +32 -0
- package/dist/core/topology.js +238 -7
- package/dist/core/traceimage.d.ts +7 -0
- package/dist/core/traceimage.js +221 -0
- package/dist/core/tritri.d.ts +5 -0
- package/dist/core/tritri.js +120 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +15 -16
- package/dist/core/uv.js +36 -189
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +127 -0
- package/dist/core/uvreport.js +372 -0
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +95 -61
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/inspect.d.ts +84 -1
- package/dist/inspect.js +271 -24
- package/dist/io/common.d.ts +33 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +355 -51
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +149 -14
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +816 -119
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +70 -24
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +207 -108
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +207 -83
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +54 -5
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +22 -10
- package/dist/nodes/curves.js +440 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +13 -39
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.d.ts +1 -0
- package/dist/nodes/imageops.js +203 -0
- package/dist/nodes/index.d.ts +4 -0
- package/dist/nodes/index.js +4 -0
- package/dist/nodes/material.js +91 -23
- package/dist/nodes/measure.js +45 -18
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/rbd.js +1 -1
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.d.ts +1 -0
- package/dist/nodes/scene.js +55 -0
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/solidify.d.ts +1 -0
- package/dist/nodes/solidify.js +52 -0
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +11 -3
- package/dist/nodes/util.d.ts +1 -1
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +6 -2
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +44 -5
- package/dist/render/pbr.d.ts +28 -0
- package/dist/render/pbr.js +378 -0
- package/dist/render/preview.d.ts +69 -0
- package/dist/render/preview.js +26 -0
- package/dist/render/raster.d.ts +78 -7
- package/dist/render/raster.js +600 -145
- package/dist/render/texview.d.ts +7 -1
- package/dist/render/texview.js +34 -2
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/camera.js +1 -1
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +100 -0
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +6 -2
- package/dist/viewer/app/guides.js +123 -1
- package/dist/viewer/app/keymap.js +7 -4
- package/dist/viewer/app/layers.js +5 -5
- package/dist/viewer/app/main.js +186 -53
- package/dist/viewer/app/markers.js +61 -1
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +177 -53
- package/dist/viewer/app/scene.js +35 -6
- package/dist/viewer/app/select.js +5 -4
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +66 -8
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +48 -1
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +24 -11
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +24 -7
- package/dist/viewer/server.js +289 -31
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/web/bake.d.ts +34 -0
- package/dist/web/bake.js +153 -0
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -105
- package/dist/workspace.js +359 -375
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +23 -29
- package/kernels/pkg-simd/README.md +23 -29
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +23 -8
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/shelf/index.json +0 -190
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Reference layers
|
|
1
|
+
// Reference layers: the person's files in inputs/, one outliner row each, shown
|
|
2
2
|
// when their eye is on (remembered in this browser), drawn in a display mode of their own (as the view by default;
|
|
3
3
|
// ghost is one of the modes). PNGs stand as unlit image planes at their pixel aspect, one metre tall, beside the
|
|
4
4
|
// scene. Files dropped on the page are uploaded to inputs/ (POST /api/inputs).
|
|
@@ -148,17 +148,17 @@ export function createLayers(ctx) {
|
|
|
148
148
|
L.list = list;
|
|
149
149
|
const byPath = new Map(list.map((f) => [f.path, f]));
|
|
150
150
|
if (!L.restored) { L.restored = true; for (const p of [...L.shown]) if (!byPath.has(p)) L.shown.delete(p); }
|
|
151
|
-
// a replaced file reloads; a removed one goes away
|
|
151
|
+
// a replaced file reloads; a removed one goes away; an export's sidecar (metadata) is never a layer
|
|
152
152
|
for (const p of [...L.shown]) {
|
|
153
153
|
const f = byPath.get(p);
|
|
154
|
-
if (!f) { L.shown.delete(p); drop(p); continue; }
|
|
154
|
+
if (!f || f.kind === 'metadata') { L.shown.delete(p); drop(p); continue; }
|
|
155
155
|
const l = L.loaded.get(p);
|
|
156
156
|
if (!l || l.stamp !== stampOf(f)) load(p);
|
|
157
157
|
}
|
|
158
158
|
for (const [p] of L.loaded) if (!byPath.has(p)) drop(p);
|
|
159
159
|
for (const m of [L.info, L.errors]) for (const [p, v] of m) if (!byPath.has(p) || v.stamp !== stampOf(byPath.get(p))) m.delete(p);
|
|
160
|
-
for (const id of [...ctx.objects.keys()]) if (id.startsWith('layer:') && !byPath.has(id.slice(6))) ctx.objects.delete(id);
|
|
161
|
-
for (const f of list) entry(f.path);
|
|
160
|
+
for (const id of [...ctx.objects.keys()]) if (id.startsWith('layer:') && (!byPath.has(id.slice(6)) || byPath.get(id.slice(6)).kind === 'metadata')) ctx.objects.delete(id);
|
|
161
|
+
for (const f of list) if (f.kind !== 'metadata') entry(f.path);
|
|
162
162
|
remember(); changed();
|
|
163
163
|
});
|
|
164
164
|
L.loadWhere = async () => {
|
package/dist/viewer/app/main.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
// The viewer page
|
|
1
|
+
// The viewer page: boot, layout, the render loop over the views, the keymap and the mouse,
|
|
2
2
|
// the status bar and the server's event stream. The camera moves only when the person moves it or frames: loading,
|
|
3
3
|
// cooking, saving and placing never frame (the one exception is the very first view, when nothing is remembered).
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import { api } from './api.js';
|
|
5
|
+
import { api, coalesce } from './api.js';
|
|
6
6
|
import { createViews, CAMERA_NAMES, SHADINGS } from './camera.js';
|
|
7
7
|
import { createGrid, createOverlays, cursorText } from './grid.js';
|
|
8
|
-
import { MeshObject, parseGLB, createLights, LINE_MATERIALS } from './scene.js';
|
|
8
|
+
import { MeshObject, parseGLB, createLights, LINE_MATERIALS, recede } from './scene.js';
|
|
9
9
|
import { createLayers } from './layers.js';
|
|
10
|
-
import { createGuides, PLACE_KINDS } from './guides.js';
|
|
10
|
+
import { createGuides, PLACE_KINDS, guideId } from './guides.js';
|
|
11
11
|
import { createSelect } from './select.js';
|
|
12
12
|
import { createOutliner } from './outliner.js';
|
|
13
13
|
import { createProps } from './props.js';
|
|
14
14
|
import { createOutputPanel } from './outputs.js';
|
|
15
|
+
import { createPackagesPanel } from './packages.js';
|
|
15
16
|
import { createSelection, parseId } from './selection.js';
|
|
16
17
|
import { createUndo } from './undo.js';
|
|
17
18
|
import { EDITOR_NAMES } from './markers.js';
|
|
18
19
|
import * as KM from './keymap.js';
|
|
19
20
|
import { fmtStep, fmtSize, fmtNum } from './units.js';
|
|
20
|
-
import {
|
|
21
|
+
import { DISCONNECTED_LINE, RECONNECTED_LINE, messageLife } from './status.js';
|
|
22
|
+
import { compareLine, cookLine, isRunning } from './cooking.js';
|
|
23
|
+
import { pageTitle, defaultGraph, renderWelcome } from './welcome.js';
|
|
24
|
+
import { kindLine } from './output-info.js';
|
|
21
25
|
|
|
22
26
|
const $ = (id) => document.getElementById(id);
|
|
23
27
|
const BG = new THREE.Color('#2b2d31');
|
|
@@ -38,32 +42,71 @@ const ctx = {
|
|
|
38
42
|
on(type, f) { if (!listeners.has(type)) listeners.set(type, new Set()); listeners.get(type).add(f); },
|
|
39
43
|
emit(type) { if (type !== 'hover') version++; for (const f of listeners.get(type) ?? []) f(); for (const f of listeners.get('*') ?? []) f(type); },
|
|
40
44
|
version: () => version,
|
|
41
|
-
|
|
42
|
-
coalesce(fn) {
|
|
43
|
-
let busy = null, again = false;
|
|
44
|
-
return () => {
|
|
45
|
-
if (busy) { again = true; return busy; }
|
|
46
|
-
busy = (async () => { try { do { again = false; await fn(); } while (again); } finally { busy = null; } })();
|
|
47
|
-
return busy;
|
|
48
|
-
};
|
|
49
|
-
},
|
|
45
|
+
coalesce,
|
|
50
46
|
};
|
|
51
47
|
|
|
52
|
-
// -------------------------------------------------------------------------------------------
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
// ------------------------------------------------------------------------------------------- messages
|
|
49
|
+
// What something the person did came to, over the view's lower left; it clears itself (status.js messageLife). The
|
|
50
|
+
// status bar keeps the cook line and what is shown.
|
|
51
|
+
const notesEl = $('notes'), msgEl = $('msg');
|
|
52
|
+
let heldUntil = 0, noteTimer = 0;
|
|
53
|
+
/** A message; `hold` ms keeps it over routine ones (an undo over the save that follows it); '' clears it. */
|
|
56
54
|
ctx.message = (text, kind = '', hold = 0) => {
|
|
57
55
|
const now = performance.now();
|
|
58
|
-
if (!hold && kind !== 'err' && now < heldUntil) return;
|
|
56
|
+
if (text && !hold && kind !== 'err' && now < heldUntil) return;
|
|
59
57
|
heldUntil = hold ? now + hold : 0;
|
|
60
|
-
|
|
58
|
+
clearTimeout(noteTimer);
|
|
59
|
+
msgEl.textContent = text; msgEl.title = text; notesEl.className = kind;
|
|
60
|
+
notesEl.hidden = !text && $('ask').hidden;
|
|
61
|
+
const life = messageLife(text, kind, hold);
|
|
62
|
+
if (text && Number.isFinite(life)) noteTimer = setTimeout(() => { if (!notesEl.matches(':hover')) ctx.message(''); else noteTimer = setTimeout(() => ctx.message(''), 3000); }, life);
|
|
63
|
+
};
|
|
64
|
+
$('msg-close').onclick = () => { $('msg-close').blur(); ctx.message(''); };
|
|
65
|
+
// ------------------------------------------------------------------------------------------- cook state
|
|
66
|
+
// What is cooking for each graph (the server's {cook} events, and /api/graphs), shown in the status bar and above the
|
|
67
|
+
// Controls: the node, the time (counted on here between events), how the last cook ended. Stop stops it. While the
|
|
68
|
+
// before/after of a package update runs (packages.js), the lines show its progress and Stop stops it.
|
|
69
|
+
const cooks = new Map(), cookLines = [$('status-cook'), $('controls-cook')];
|
|
70
|
+
let cookTick = 0;
|
|
71
|
+
ctx.cookState = (graph) => cooks.get(graph)?.state ?? null;
|
|
72
|
+
function setCook(graph, state) { cooks.set(graph, { state, at: performance.now() }); renderCook(); }
|
|
73
|
+
function renderCook() {
|
|
74
|
+
const c = cooks.get(ctx.graph?.name), compare = ctx.packages?.running;
|
|
75
|
+
const line = compare ? compareLine(compare, performance.now() - compare.at) : cookLine(c?.state, c ? performance.now() - c.at : 0);
|
|
76
|
+
for (const el of cookLines) {
|
|
77
|
+
el.className = `cookline ${line.kind}`;
|
|
78
|
+
const t = el.querySelector('.ctext');
|
|
79
|
+
if (t.textContent !== line.text) t.textContent = line.text;
|
|
80
|
+
el.title = line.title;
|
|
81
|
+
}
|
|
82
|
+
$('props').classList.toggle('cooking', line.kind === 'running' || line.kind === 'stopping');
|
|
83
|
+
ctx.packages?.renderLine();
|
|
84
|
+
const running = isRunning(c?.state) || !!compare;
|
|
85
|
+
if (running && !cookTick) cookTick = setInterval(renderCook, 200);
|
|
86
|
+
else if (!running && cookTick) { clearInterval(cookTick); cookTick = 0; }
|
|
87
|
+
}
|
|
88
|
+
ctx.renderCook = renderCook;
|
|
89
|
+
// one Stop, in the status bar
|
|
90
|
+
$('status-cook').querySelector('.cstop').onclick = async (e) => {
|
|
91
|
+
e.currentTarget.blur();
|
|
92
|
+
// the cooks of an update's comparison are not the graph's: they stop on their own
|
|
93
|
+
if (ctx.packages?.running) { ctx.packages.stop(); return; }
|
|
94
|
+
const graph = ctx.graph.name;
|
|
95
|
+
if (!graph) return;
|
|
96
|
+
// at once: the server hears the stop only when the node it is on lets it (see the line's title)
|
|
97
|
+
const c = cooks.get(graph);
|
|
98
|
+
if (c?.state?.running) { c.state = { ...c.state, running: { ...c.state.running, stopping: true } }; renderCook(); }
|
|
99
|
+
const j = await api.stop(graph);
|
|
100
|
+
if (!j.ok) ctx.message(j.error, 'err');
|
|
101
|
+
else ctx.message(j.stopping ? 'stopping: the cook ends when the node it is on has finished' : 'nothing is cooking');
|
|
61
102
|
};
|
|
62
|
-
|
|
103
|
+
|
|
104
|
+
/** A small question with the messages; resolves to the answer. */
|
|
63
105
|
ctx.ask = (text, yes = 'Yes', no = 'No') => new Promise((resolve) => {
|
|
106
|
+
ctx.message('');
|
|
64
107
|
$('ask-text').textContent = text; $('ask-yes').textContent = yes; $('ask-no').textContent = no;
|
|
65
|
-
$('ask').hidden = false;
|
|
66
|
-
const done = (v) => { $('ask').hidden = true; $('ask-yes').onclick = $('ask-no').onclick = null; resolve(v); };
|
|
108
|
+
$('ask').hidden = false; notesEl.hidden = false;
|
|
109
|
+
const done = (v) => { $('ask').hidden = true; notesEl.hidden = !msgEl.textContent; $('ask-yes').onclick = $('ask-no').onclick = null; resolve(v); };
|
|
67
110
|
$('ask-yes').onclick = () => done(true);
|
|
68
111
|
$('ask-no').onclick = () => done(false);
|
|
69
112
|
$('ask-yes').focus();
|
|
@@ -137,12 +180,17 @@ ctx.select = createSelect(ctx);
|
|
|
137
180
|
ctx.surfacePoint = ctx.select.surfacePoint;
|
|
138
181
|
ctx.planePoint = ctx.select.planePoint;
|
|
139
182
|
const outliner = createOutliner(ctx, { scene: $('tree'), inputs: $('inputs-list') });
|
|
183
|
+
ctx.setTabShown = outliner.setTabShown;
|
|
184
|
+
ctx.showTab = (name) => outliner.showTab(name);
|
|
140
185
|
const props = createProps(ctx);
|
|
141
186
|
|
|
142
187
|
// ------------------------------------------------------------------------------------------- graphs and the output
|
|
143
188
|
ctx.graph = {
|
|
144
|
-
|
|
189
|
+
/** the graphs as last read (/api/graphs), and when that read was asked for: values the page sent later stand */
|
|
190
|
+
list: [], fetched: -1e9, name: null, node: null,
|
|
145
191
|
current() { return this.list.find((g) => g.name === this.name) ?? null; },
|
|
192
|
+
/** the Controls for the graph shown, from the list as last read (never as if it had just been read) */
|
|
193
|
+
renderControls() { props.controls.render(this.current(), this.fetched); },
|
|
146
194
|
/** the node whose result is shown: the chosen one, else the graph's output */
|
|
147
195
|
shownNode() { const g = this.current(); return this.node ?? g?.output ?? null; },
|
|
148
196
|
show(node) {
|
|
@@ -158,29 +206,49 @@ const refreshGraphs = ctx.coalesce(async () => {
|
|
|
158
206
|
const list = await api.graphs();
|
|
159
207
|
if (!list) return;
|
|
160
208
|
const G = ctx.graph;
|
|
161
|
-
G.list = list;
|
|
209
|
+
G.list = list; G.fetched = issued;
|
|
162
210
|
const names = list.map((g) => g.name);
|
|
163
211
|
const sel = $('graph');
|
|
164
212
|
// the options are rebuilt only when the graphs change, so an open list stays open
|
|
165
213
|
if (names.join('\n') !== [...sel.options].map((o) => o.value).join('\n')) sel.replaceChildren(...names.map((n) => new Option(n, n)));
|
|
166
|
-
if (!names.includes(G.name)) { G.name = local.get('graph', null); if (!names.includes(G.name)) G.name = names
|
|
214
|
+
if (!names.includes(G.name)) { G.name = local.get('graph', null); if (!names.includes(G.name)) G.name = defaultGraph(ctx.package, names); G.node = null; }
|
|
167
215
|
sel.value = G.name ?? '';
|
|
168
216
|
const g = G.current();
|
|
169
217
|
if (G.node && !g?.nodes.some((n) => n.name === G.node)) G.node = null;
|
|
218
|
+
// the cook states the list carries, unless an event brought a newer one while it was fetched
|
|
219
|
+
for (const x of list) if (x.cook && !((cooks.get(x.name)?.at ?? -1) > issued)) cooks.set(x.name, { state: x.cook, at: performance.now() });
|
|
220
|
+
renderCook();
|
|
170
221
|
props.controls.render(g, issued);
|
|
171
|
-
|
|
172
|
-
if (line) ctx.message(line);
|
|
222
|
+
renderWelcome($('welcome'), ctx.package, !list.length);
|
|
173
223
|
ctx.emit('graphs');
|
|
174
224
|
});
|
|
225
|
+
// the package shown: the tab's title, the graph shown first, the welcome while there is no graph
|
|
226
|
+
ctx.package = null;
|
|
227
|
+
const refreshPackage = async () => {
|
|
228
|
+
const info = await api.package();
|
|
229
|
+
if (!info) return;
|
|
230
|
+
ctx.package = info;
|
|
231
|
+
document.title = pageTitle(info);
|
|
232
|
+
renderWelcome($('welcome'), info, !ctx.graph.list.length);
|
|
233
|
+
};
|
|
175
234
|
$('graph').onchange = (e) => {
|
|
176
235
|
if (ctx.outputs?.active) ctx.outputs.scene();
|
|
177
236
|
ctx.graph.name = e.target.value; ctx.graph.node = null;
|
|
178
237
|
local.set('graph', ctx.graph.name);
|
|
179
|
-
|
|
238
|
+
ctx.graph.renderControls();
|
|
239
|
+
renderCook();
|
|
180
240
|
ctx.emit('graphs');
|
|
181
241
|
loadGeo();
|
|
182
242
|
};
|
|
183
243
|
|
|
244
|
+
// the heightfield layer the scene's output shows in red (the picker in Properties), per graph and node
|
|
245
|
+
const sceneLayers = local.get('scene.layers', {});
|
|
246
|
+
const sceneKey = () => `${ctx.graph.name}/${ctx.graph.shownNode() ?? ''}`;
|
|
247
|
+
ctx.sceneLayer = {
|
|
248
|
+
get: () => sceneLayers[sceneKey()] ?? null,
|
|
249
|
+
set(v) { sceneLayers[sceneKey()] = v; local.set('scene.layers', sceneLayers); loadGeo(); },
|
|
250
|
+
};
|
|
251
|
+
|
|
184
252
|
let firstFrame = !views.placed;
|
|
185
253
|
const loadGeo = ctx.coalesce(async () => {
|
|
186
254
|
if (ctx.outputs?.active) { await ctx.outputs.refresh(); return; }
|
|
@@ -188,12 +256,12 @@ const loadGeo = ctx.coalesce(async () => {
|
|
|
188
256
|
if (!G.name) return;
|
|
189
257
|
const graph = G.name, node = G.node ?? '';
|
|
190
258
|
o.loading = true; ctx.emit('output');
|
|
191
|
-
const r = await api.geo(graph, node);
|
|
259
|
+
const r = await api.geo(graph, node, ctx.sceneLayer.get());
|
|
192
260
|
o.loading = false;
|
|
193
|
-
if (graph !== G.name || node !== (G.node ?? '') || ctx.outputs?.active) return;
|
|
261
|
+
if (graph !== G.name || node !== (G.node ?? '') || ctx.outputs?.active) { ctx.emit('output'); return; }
|
|
194
262
|
if (!r.ok) {
|
|
195
|
-
// the last good geometry stays
|
|
196
|
-
o.error = r.error;
|
|
263
|
+
// the last good geometry stays; a stopped cook is no error (the cook line says where it stopped)
|
|
264
|
+
if (!r.stopped) o.error = r.error;
|
|
197
265
|
ctx.emit('output'); updateCook();
|
|
198
266
|
return;
|
|
199
267
|
}
|
|
@@ -216,21 +284,27 @@ const loadGeo = ctx.coalesce(async () => {
|
|
|
216
284
|
const [info, report] = await Promise.all([api.info(graph, node), api.report(graph)]);
|
|
217
285
|
if (graph !== G.name) return;
|
|
218
286
|
o.summary = info?.summary ?? '';
|
|
287
|
+
o.about = info?.about ?? null;
|
|
219
288
|
o.report = report;
|
|
220
289
|
ctx.emit('output'); updateCook();
|
|
221
290
|
});
|
|
222
291
|
|
|
292
|
+
/** The status bar's right side: what the view shows, its kind and size (a terrain says its samples, not "0 points"). */
|
|
223
293
|
function updateCook() {
|
|
224
|
-
const el = $('cook'), o = ctx.output, g = ctx.graph.current();
|
|
225
|
-
if (
|
|
226
|
-
|
|
294
|
+
const el = $('cook'), o = ctx.output, g = ctx.graph.current(), shown = ctx.outputs?.active;
|
|
295
|
+
if (shown) {
|
|
296
|
+
// an output alone in the view (or a place of an update): its name and what it is
|
|
297
|
+
const what = shown.view === 'image' && shown.width ? `${shown.width} × ${shown.height} px · ${shown.layers?.length ?? 1} layer${(shown.layers?.length ?? 1) === 1 ? '' : 's'}` : kindLine(shown);
|
|
298
|
+
el.textContent = [shown.graph && shown.graph !== shown.label ? `${shown.graph} › ${shown.label}` : shown.label, what].filter(Boolean).join(' · ');
|
|
299
|
+
el.title = el.textContent;
|
|
300
|
+
return;
|
|
227
301
|
}
|
|
228
302
|
if (!g) { el.textContent = ''; return; }
|
|
229
|
-
const m = /geometry: ([\d,]+) points, ([\d,]+) prims/.exec(o.summary ?? '');
|
|
230
303
|
const parts = [`${g.name}/${ctx.graph.shownNode() ?? ''}`];
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
const
|
|
304
|
+
if (o.about) parts.push(kindLine({ kind: o.about.published ?? 'empty', about: o.about.text }));
|
|
305
|
+
// a failed cook of the graph is told by the cook line beside this (its node and message); this tells the rest
|
|
306
|
+
const told = cookLine(ctx.cookState(g.name)).kind === 'failed';
|
|
307
|
+
const err = o.error ?? (told ? null : (o.report?.errors?.length ? o.report.errors[0] : null) ?? g.nodes.find((n) => n.error)?.error);
|
|
234
308
|
el.replaceChildren(document.createTextNode(parts.join(' · ')));
|
|
235
309
|
if (err) { const e = document.createElement('span'); e.className = 'err'; e.textContent = ` · ${String(err).split('\n')[0]}`; el.append(e); el.title = String(err); }
|
|
236
310
|
else el.title = parts.join(' · ');
|
|
@@ -358,6 +432,16 @@ $('view-cam').onchange = (e) => { views.setCam(views.active, e.target.value); sa
|
|
|
358
432
|
$('view-shading').replaceChildren(...SHADINGS.map(([v, t]) => new Option(t, v)));
|
|
359
433
|
$('view-shading').onchange = (e) => { views.slots[views.active].shading = e.target.value; saveViews(); e.target.blur(); ctx.requestRender(); };
|
|
360
434
|
$('quad').onclick = () => { toggleQuad(); $('quad').blur(); };
|
|
435
|
+
// the edge check: an overlay, off until the person turns it on (remembered in this browser)
|
|
436
|
+
MeshObject.edgeCheck = browser.get('edgeCheck', false);
|
|
437
|
+
const syncEdgeCheck = () => { $('edge-check').classList.toggle('on', MeshObject.edgeCheck); $('edge-check').setAttribute('aria-pressed', String(MeshObject.edgeCheck)); };
|
|
438
|
+
$('edge-check').onclick = () => {
|
|
439
|
+
$('edge-check').blur();
|
|
440
|
+
MeshObject.edgeCheck = !MeshObject.edgeCheck; browser.set('edgeCheck', MeshObject.edgeCheck); syncEdgeCheck();
|
|
441
|
+
for (const e of ctx.objects.values()) if (e.mesh) e.mesh.mode = null;
|
|
442
|
+
ctx.emit('output'); ctx.requestRender();
|
|
443
|
+
};
|
|
444
|
+
syncEdgeCheck();
|
|
361
445
|
$('help').onclick = () => { KM.toggleOverlay(document.body, preset); $('help').blur(); };
|
|
362
446
|
function syncTop() {
|
|
363
447
|
const s = views.slots[views.active];
|
|
@@ -367,7 +451,13 @@ function syncTop() {
|
|
|
367
451
|
$('quad').textContent = views.quad ? 'single' : 'quad';
|
|
368
452
|
const mode = ctx.guides.mode;
|
|
369
453
|
$('mode').textContent = mode ? `placing ${EDITOR_NAMES[mode]}` : '';
|
|
454
|
+
for (const b of $('guide-tools').querySelectorAll('button')) b.classList.toggle('on', (PLACE_KINDS[b.dataset.tool] ?? null) === mode);
|
|
370
455
|
}
|
|
456
|
+
for (const b of $('guide-tools').querySelectorAll('button')) b.addEventListener('click', () => {
|
|
457
|
+
// the tools work on the guides, which the scene shows (a result shown alone hides them)
|
|
458
|
+
if (b.dataset.tool === 'selectMode' && ctx.outputs?.active) ctx.outputs.scene();
|
|
459
|
+
run(b.dataset.tool); b.blur();
|
|
460
|
+
});
|
|
371
461
|
function setActive(i) { if (i >= 0 && views.active !== i) { views.active = i; syncTop(); requestOverlays(); } }
|
|
372
462
|
function toggleQuad(at = cursor.slot) {
|
|
373
463
|
if (views.quad && at >= 0) views.active = at;
|
|
@@ -395,7 +485,7 @@ for (const g of document.querySelectorAll('.grip')) {
|
|
|
395
485
|
const move = (ev) => {
|
|
396
486
|
if (kind === 'left') layout.left = Math.round(Math.max(160, Math.min(innerWidth * 0.45, ev.clientX)));
|
|
397
487
|
else if (kind === 'right') layout.right = Math.round(Math.max(220, Math.min(innerWidth * 0.5, innerWidth - ev.clientX)));
|
|
398
|
-
else layout.split = Math.round(Math.max(10, Math.min(
|
|
488
|
+
else layout.split = Math.round(Math.max(10, Math.min(85, ((ev.clientY - props0.top - 60) / Math.max(1, props0.height - 52)) * 100)));
|
|
399
489
|
applyLayout(); ctx.requestRender();
|
|
400
490
|
};
|
|
401
491
|
const up = () => { g.classList.remove('drag'); g.removeEventListener('pointermove', move); g.removeEventListener('pointerup', up); browser.set('layout', layout); };
|
|
@@ -425,11 +515,15 @@ function run(action) {
|
|
|
425
515
|
slot.shading = { displayWire: 'wire', displayShaded: 'shaded', displayShadedWire: 'shadedWire' }[action]; break;
|
|
426
516
|
case 'displayCycle': slot.shading = DISPLAY_CYCLE[(DISPLAY_CYCLE.indexOf(slot.shading) + 1) % 3]; break;
|
|
427
517
|
case 'wireToggle': slot.lastShading = slot.shading === 'wire' ? slot.lastShading : slot.shading; slot.shading = slot.shading === 'wire' ? slot.lastShading ?? 'shaded' : 'wire'; break;
|
|
428
|
-
case 'placeNull': case 'placeCurve': case 'placeArea': case 'placeVolume':
|
|
518
|
+
case 'placeNull': case 'placeCurve': case 'placeArea': case 'placeVolume':
|
|
519
|
+
// guides are drawn in the scene, not over a result shown alone
|
|
520
|
+
if (ctx.outputs?.active) ctx.outputs.scene();
|
|
521
|
+
ctx.guides.setMode(PLACE_KINDS[action]); return syncTop();
|
|
429
522
|
case 'finish': case 'removeLast': ctx.guides.key(action); return;
|
|
430
523
|
case 'cancel': {
|
|
431
524
|
if (document.querySelector('.keymap-overlay')) return KM.toggleOverlay(document.body, preset);
|
|
432
525
|
if (ctx.select.press) return ctx.select.cancel();
|
|
526
|
+
if (drag?.kind === 'guide') { const d = drag; drag = null; ctx.guides.dragEnd(true); try { canvas.releasePointerCapture(d.id); } catch { /* gone */ } return; }
|
|
433
527
|
if (ctx.guides.key('cancel')) return;
|
|
434
528
|
ctx.guides.setMode(null); ctx.selection.clear(); return syncTop();
|
|
435
529
|
}
|
|
@@ -516,8 +610,11 @@ canvas.addEventListener('pointerdown', (e) => {
|
|
|
516
610
|
return;
|
|
517
611
|
}
|
|
518
612
|
if (e.button !== 0) return;
|
|
519
|
-
if (ctx.guides.mode) { drag = { kind: 'place', slot, id: e.pointerId }; ctx.guides.pointerDown(slot, x, y); }
|
|
520
|
-
|
|
613
|
+
if (ctx.guides.mode) { drag = { kind: 'place', slot, id: e.pointerId }; ctx.guides.pointerDown(slot, x, y); return; }
|
|
614
|
+
// a plain press on a guide grabs it (Shift and Ctrl presses add to and take from the selection, as ever)
|
|
615
|
+
const h = !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey ? ctx.guides.handleAt(slot, x, y) : null;
|
|
616
|
+
if (h) { drag = { kind: 'guide', slot, x, y, id: e.pointerId, h }; ctx.guides.dragStart(slot, x, y, h); return; }
|
|
617
|
+
drag = { kind: 'select', slot, id: e.pointerId }; ctx.select.down(slot, x, y, e);
|
|
521
618
|
});
|
|
522
619
|
canvas.addEventListener('pointermove', (e) => {
|
|
523
620
|
const { x, y } = at(e);
|
|
@@ -530,6 +627,7 @@ canvas.addEventListener('pointermove', (e) => {
|
|
|
530
627
|
else views.dolly(drag.slot, Math.exp(-(dx - dy) * 0.006));
|
|
531
628
|
ctx.requestRender();
|
|
532
629
|
} else if (drag.kind === 'place') ctx.guides.pointerMove(drag.slot, x, y);
|
|
630
|
+
else if (drag.kind === 'guide') ctx.guides.dragMove(drag.slot, x, y);
|
|
533
631
|
else ctx.select.move(x, y);
|
|
534
632
|
return;
|
|
535
633
|
}
|
|
@@ -538,7 +636,12 @@ canvas.addEventListener('pointermove', (e) => {
|
|
|
538
636
|
cursor.slot = slot; cursor.x = x; cursor.y = y;
|
|
539
637
|
if (slot >= 0 && views.cam(slot).ortho) requestOverlays();
|
|
540
638
|
if (ctx.guides.mode) { if (slot >= 0) ctx.guides.pointerMove(slot, x, y); }
|
|
541
|
-
else
|
|
639
|
+
else {
|
|
640
|
+
ctx.select.hover(slot, x, y);
|
|
641
|
+
// what a press would grab: a point (CV, null, corner) or a whole guide
|
|
642
|
+
const h = slot >= 0 ? ctx.guides.handleAt(slot, x, y) : null;
|
|
643
|
+
canvas.style.cursor = h ? (h.part === 'body' ? 'move' : 'crosshair') : '';
|
|
644
|
+
}
|
|
542
645
|
});
|
|
543
646
|
const endDrag = (e, cancel = false) => {
|
|
544
647
|
if (!drag || e.pointerId !== drag.id) return;
|
|
@@ -548,8 +651,17 @@ const endDrag = (e, cancel = false) => {
|
|
|
548
651
|
const { x, y } = at(e);
|
|
549
652
|
if (d.kind === 'nav') saveViews();
|
|
550
653
|
else if (d.kind === 'place') { if (!cancel) ctx.guides.pointerUp(d.slot, x, y); }
|
|
654
|
+
else if (d.kind === 'guide') {
|
|
655
|
+
// a press that did not move is a click: it selects the guide
|
|
656
|
+
if (!ctx.guides.dragEnd(cancel) && !cancel) ctx.selection.apply([guideId(d.h.id)]);
|
|
657
|
+
}
|
|
551
658
|
else if (cancel) ctx.select.cancel(); else ctx.select.up(x, y);
|
|
552
659
|
};
|
|
660
|
+
canvas.addEventListener('dblclick', (e) => {
|
|
661
|
+
if (ctx.guides.mode || drag) return;
|
|
662
|
+
const { x, y } = at(e), slot = views.slotAt(x, y);
|
|
663
|
+
if (slot >= 0) ctx.guides.doubleClick(slot, x, y);
|
|
664
|
+
});
|
|
553
665
|
canvas.addEventListener('pointerup', (e) => endDrag(e));
|
|
554
666
|
canvas.addEventListener('pointercancel', (e) => endDrag(e, true));
|
|
555
667
|
canvas.addEventListener('lostpointercapture', (e) => endDrag(e, true));
|
|
@@ -591,15 +703,17 @@ ctx.hideModelPreview = () => { previewSerial++; ctx.previewEmpty = true; ctx.sel
|
|
|
591
703
|
ctx.outputGraph = (item) => {
|
|
592
704
|
if (item.graph && ctx.graph.list.some((g) => g.name === item.graph)) {
|
|
593
705
|
ctx.graph.name = item.graph; ctx.graph.node = item.node; $('graph').value = item.graph;
|
|
594
|
-
|
|
706
|
+
ctx.graph.renderControls();
|
|
595
707
|
}
|
|
596
708
|
};
|
|
597
709
|
ctx.previewOutput = async (item, bytes, update) => {
|
|
598
710
|
const serial = ++previewSerial, src = await parseGLB(bytes);
|
|
599
711
|
if (serial !== previewSerial || ctx.outputs.active?.id !== item.id) { new MeshObject('', src).dispose(); return; }
|
|
600
712
|
const mesh = new MeshObject('out', src); mesh.onReady = () => ctx.requestRender();
|
|
713
|
+
// an update's overlay: the old version's polygons a sliver behind the new one's (no stripes where they meet)
|
|
714
|
+
if (item.overlay) src.traverse((o) => { for (const m of [o.material ?? []].flat()) if (m.name === 'overlay_a') recede(m); });
|
|
601
715
|
ctx.output.mesh?.dispose(); ctx.output.mesh = mesh; ctx.outputRoot.add(mesh.root); ctx.previewEmpty = false;
|
|
602
|
-
ctx.output.summary = item.summary ?? ''; ctx.output.error = item.error ?? null;
|
|
716
|
+
ctx.output.summary = item.summary ?? ''; ctx.output.error = item.error ?? null; ctx.output.about = null;
|
|
603
717
|
ctx.outputGraph(item);
|
|
604
718
|
outEntry(); ctx.selection.clear();
|
|
605
719
|
if (!update || !outputViews.has(item.id)) {
|
|
@@ -610,23 +724,40 @@ ctx.previewOutput = async (item, bytes, update) => {
|
|
|
610
724
|
}
|
|
611
725
|
firstFrame = false; ctx.emit('output'); ctx.requestRender(); syncTop();
|
|
612
726
|
};
|
|
613
|
-
ctx.restoreScene = () => { previewSerial++; ctx.previewEmpty = false; if (sceneView) views.load(sceneView); else firstFrame = true; if (sceneGraph) { ctx.graph.name = sceneGraph.name; ctx.graph.node = sceneGraph.node; $('graph').value = ctx.graph.name;
|
|
727
|
+
ctx.restoreScene = () => { previewSerial++; ctx.previewEmpty = false; if (sceneView) views.load(sceneView); else firstFrame = true; if (sceneGraph) { ctx.graph.name = sceneGraph.name; ctx.graph.node = sceneGraph.node; $('graph').value = ctx.graph.name; ctx.graph.renderControls(); } loadGeo(); ctx.requestRender(); };
|
|
614
728
|
ctx.frameOutput = frameAll;
|
|
729
|
+
/** Show a node of a graph (the Packages tab's "used by"): that graph, the node's result, the Scene tab. */
|
|
730
|
+
ctx.showNode = (graph, node) => {
|
|
731
|
+
if (!ctx.graph.list.some((g) => g.name === graph)) return;
|
|
732
|
+
if (ctx.outputs?.active) ctx.outputs.scene();
|
|
733
|
+
if (ctx.graph.name !== graph) { ctx.graph.name = graph; $('graph').value = graph; local.set('graph', graph); ctx.graph.renderControls(); renderCook(); }
|
|
734
|
+
ctx.graph.show(node);
|
|
735
|
+
ctx.showTab('scene');
|
|
736
|
+
};
|
|
615
737
|
ctx.outputs = createOutputPanel(ctx);
|
|
738
|
+
ctx.packages = createPackagesPanel(ctx, $('packages'));
|
|
616
739
|
|
|
617
740
|
const es = api.events({
|
|
618
741
|
open() {
|
|
619
|
-
ctx.message(connectedLine(ctx.graph.list.length));
|
|
620
742
|
// after a reconnect the server may have restarted: fetch everything again
|
|
621
|
-
if (es.opened) {
|
|
743
|
+
if (es.opened) {
|
|
744
|
+
if (msgEl.textContent === DISCONNECTED_LINE) ctx.message(RECONNECTED_LINE, 'ok');
|
|
745
|
+
refreshPackage().then(refreshGraphs).then(loadGeo); ctx.outputs.refresh(); ctx.packages.refresh(); ctx.layers.refresh(); ctx.layers.loadWhere(); ctx.guides.load();
|
|
746
|
+
}
|
|
622
747
|
es.opened = true;
|
|
623
748
|
},
|
|
624
|
-
error() { ctx.message(
|
|
749
|
+
error() { ctx.message(DISCONNECTED_LINE, 'err'); },
|
|
625
750
|
async message(ev) {
|
|
751
|
+
if (ev.cook !== undefined) { setCook(ev.cook.graph, ev.cook); if (ev.cook.graph === ctx.graph.name) updateCook(); return; }
|
|
626
752
|
if (ev.outputs !== undefined) { ctx.outputs.refresh(); return; }
|
|
627
|
-
|
|
753
|
+
// the scene's result too: a graph that reads inputs/ (the guides in markers.json) cooks again; one that does not
|
|
754
|
+
// answers from its cache
|
|
755
|
+
if (ev.inputs !== undefined) { ctx.layers.refresh(); ctx.outputs.refresh(); if (!ctx.isolated) loadGeo(); return; }
|
|
756
|
+
if (ev.compare !== undefined) { await ctx.packages.onCompare(ev.compare); renderCook(); return; }
|
|
757
|
+
if (ev.packages !== undefined) { ctx.packages.onEvent(ev); return; }
|
|
628
758
|
await refreshGraphs();
|
|
629
|
-
|
|
759
|
+
// after a stop the geometry in view stays: fetching it would cook what was just stopped
|
|
760
|
+
if (ev.graph === ctx.graph.name && !ev.stopped) loadGeo();
|
|
630
761
|
ctx.outputs.refresh();
|
|
631
762
|
},
|
|
632
763
|
});
|
|
@@ -635,8 +766,10 @@ syncTop();
|
|
|
635
766
|
outliner.render();
|
|
636
767
|
props.render();
|
|
637
768
|
ctx.requestRender();
|
|
769
|
+
await refreshPackage();
|
|
638
770
|
await refreshGraphs();
|
|
639
771
|
await ctx.outputs.refresh();
|
|
772
|
+
ctx.packages.refresh();
|
|
640
773
|
loadGeo();
|
|
641
774
|
ctx.layers.refresh();
|
|
642
775
|
ctx.layers.loadWhere();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// input file (help topic "inputs": string attributes name and role, pscale = a null's radius).
|
|
5
5
|
// Plain functions, no DOM and no three.js: tested in Node (test/viewer-logic.ts).
|
|
6
6
|
|
|
7
|
-
/** The roles the LLM reads, and the editor's name for each
|
|
7
|
+
/** The roles the LLM reads, and the editor's name for each. */
|
|
8
8
|
export const MARKER_KINDS = ['site', 'path', 'zone', 'volume'];
|
|
9
9
|
export const EDITOR_NAMES = { site: 'null', path: 'curve', zone: 'area', volume: 'volume' };
|
|
10
10
|
/** [fewest, most] points per kind: a null's point, a curve's CVs, an area's corners, a volume's two ground corners */
|
|
@@ -204,3 +204,63 @@ export function hatchSegments(pts, spacing) {
|
|
|
204
204
|
}
|
|
205
205
|
return out;
|
|
206
206
|
}
|
|
207
|
+
|
|
208
|
+
// ------------------------------------------------------------------ direct edits (dragging in the view)
|
|
209
|
+
// Each takes a marker and returns a new one (the input is left alone), points kept to the millimetre; null when the
|
|
210
|
+
// edit would break the kind's rules (MARKER_POINTS, a volume's corners differing in x and z).
|
|
211
|
+
const mm3 = (p) => [mm(p[0]), mm(p[1]), mm(p[2])];
|
|
212
|
+
const withPoints = (m, points) => ({ ...m, points });
|
|
213
|
+
|
|
214
|
+
/** Point `k` (a null's point, a CV, a volume's ground corner as stored) moved to `p`. */
|
|
215
|
+
export function movePoint(m, k, p) {
|
|
216
|
+
if (!(k >= 0 && k < m.points.length)) return null;
|
|
217
|
+
const points = m.points.map((q, i) => (i === k ? mm3(p) : q.slice()));
|
|
218
|
+
if (m.kind === 'volume' && (points[0][0] === points[1][0] || points[0][2] === points[1][2])) return null;
|
|
219
|
+
return withPoints(m, points);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** The whole guide moved by `d` [dx, dy, dz]. */
|
|
223
|
+
export const translateMarker = (m, d) => withPoints(m, m.points.map((p) => mm3([p[0] + d[0], p[1] + d[1], p[2] + d[2]])));
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The segments of a curve or an area as pairs of point indices: a curve's k → k+1, an area's also its closing edge
|
|
227
|
+
* (last → 0). Nulls and volumes have none.
|
|
228
|
+
*/
|
|
229
|
+
export function segmentsOf(m) {
|
|
230
|
+
if (m.kind !== 'path' && m.kind !== 'zone') return [];
|
|
231
|
+
const n = m.points.length, out = [];
|
|
232
|
+
for (let k = 0; k + 1 < n; k++) out.push([k, k + 1]);
|
|
233
|
+
if (m.kind === 'zone' && n >= 3) out.push([n - 1, 0]);
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** A new CV at `p` on segment `s` (segmentsOf's index): it lands between the segment's two ends. */
|
|
238
|
+
export function insertPoint(m, s, p) {
|
|
239
|
+
const seg = segmentsOf(m)[s];
|
|
240
|
+
if (!seg) return null;
|
|
241
|
+
const points = m.points.map((q) => q.slice());
|
|
242
|
+
// the closing edge of an area (last → 0) takes its new corner at the end
|
|
243
|
+
points.splice(seg[1] === 0 ? points.length : seg[1], 0, mm3(p));
|
|
244
|
+
return withPoints(m, points);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** CV `k` removed; null when the guide would have fewer points than its kind needs (a curve 2, an area 3). */
|
|
248
|
+
export function removePoint(m, k) {
|
|
249
|
+
if (m.kind !== 'path' && m.kind !== 'zone') return null;
|
|
250
|
+
if (!(k >= 0 && k < m.points.length) || m.points.length - 1 < minPoints(m.kind)) return null;
|
|
251
|
+
return withPoints(m, m.points.filter((_, i) => i !== k).map((q) => q.slice()));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** A volume's four ground corners [x, lo y, z], walked around the box: (lo x, lo z), (hi x, lo z), (hi x, hi z), (lo x, hi z). */
|
|
255
|
+
export function volumeCorners(m) {
|
|
256
|
+
const { lo, hi } = boxOf(m);
|
|
257
|
+
return [[lo[0], lo[1], lo[2]], [hi[0], lo[1], lo[2]], [hi[0], lo[1], hi[2]], [lo[0], lo[1], hi[2]]];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** A volume with ground corner `k` (volumeCorners' order) dragged to `p` in x and z; the opposite corner stays. */
|
|
261
|
+
export function resizeVolume(m, k, p) {
|
|
262
|
+
const c = volumeCorners(m), fixed = c[(k + 2) % 4], y = c[0][1];
|
|
263
|
+
const a = mm3([fixed[0], y, fixed[2]]), b = mm3([p[0], y, p[2]]);
|
|
264
|
+
if (a[0] === b[0] || a[2] === b[2]) return null;
|
|
265
|
+
return withPoints(m, [a, b]);
|
|
266
|
+
}
|