topotopo 0.1.0 → 0.3.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/README.md +61 -12
- package/dist/cli.js +161 -23
- package/dist/graph/engine.js +18 -1
- package/dist/graph/params.d.ts +7 -1
- package/dist/graph/params.js +21 -8
- package/dist/graph/types.d.ts +28 -2
- package/dist/host/artifacts.d.ts +21 -0
- package/dist/host/artifacts.js +58 -0
- package/dist/host/export-targets.d.ts +33 -0
- package/dist/host/export-targets.js +84 -0
- package/dist/host/export_scene.py +200 -0
- package/dist/host/node.d.ts +8 -0
- package/dist/host/node.js +114 -0
- package/dist/host/types.d.ts +5 -0
- package/dist/inspect.js +5 -2
- package/dist/io/common.d.ts +6 -0
- package/dist/io/export.js +7 -4
- package/dist/io/gltf.d.ts +1 -1
- package/dist/io/gltf.js +167 -32
- package/dist/io/heightmap.d.ts +1 -1
- package/dist/io/import.d.ts +2 -2
- package/dist/io/import.js +10 -3
- package/dist/io/png-decode.d.ts +5 -2
- package/dist/io/png-decode.js +10 -3
- package/dist/io/targets.d.ts +31 -0
- package/dist/io/targets.js +75 -0
- package/dist/io/textures.d.ts +31 -2
- package/dist/io/textures.js +66 -18
- package/dist/io/unreal.js +22 -5
- package/dist/mcp/docs.d.ts +9 -2
- package/dist/mcp/docs.js +126 -2
- package/dist/mcp/inputs.d.ts +28 -0
- package/dist/mcp/inputs.js +377 -0
- package/dist/mcp/server.js +4 -1
- package/dist/mcp/tools.d.ts +1 -1
- package/dist/mcp/tools.js +118 -51
- package/dist/nodes/code.js +34 -6
- package/dist/nodes/copy.js +14 -4
- package/dist/nodes/flow.js +136 -35
- package/dist/nodes/heightfield.js +67 -11
- package/dist/nodes/texture.d.ts +1 -1
- package/dist/nodes/texture.js +61 -5
- package/dist/render/options.js +2 -1
- package/dist/render/raster.d.ts +2 -0
- package/dist/render/raster.js +3 -3
- package/dist/render/texview.d.ts +9 -1
- package/dist/render/texview.js +43 -2
- package/dist/viewer/app/api.js +64 -0
- package/dist/viewer/app/camera.js +250 -0
- package/dist/viewer/app/export-popover.js +68 -0
- package/dist/viewer/app/grid.js +217 -0
- package/dist/viewer/app/guides.js +402 -0
- package/dist/viewer/app/image-view.js +114 -0
- package/dist/viewer/app/keymap.js +199 -0
- package/dist/viewer/app/layers.js +244 -0
- package/dist/viewer/app/main.js +646 -0
- package/dist/viewer/app/markers.js +206 -0
- package/dist/viewer/app/mesh.js +172 -0
- package/dist/viewer/app/outliner.js +225 -0
- package/dist/viewer/app/outputs.css +73 -0
- package/dist/viewer/app/outputs.js +240 -0
- package/dist/viewer/app/props.js +432 -0
- package/dist/viewer/app/scene.js +529 -0
- package/dist/viewer/app/select.js +153 -0
- package/dist/viewer/app/selection.js +79 -0
- package/dist/viewer/app/status.js +20 -0
- package/dist/viewer/app/style.css +173 -0
- package/dist/viewer/app/undo.js +49 -0
- package/dist/viewer/app/units.js +51 -0
- package/dist/viewer/app/vars.js +64 -0
- package/dist/viewer/index.html +67 -184
- package/dist/viewer/outputs.d.ts +54 -0
- package/dist/viewer/outputs.js +436 -0
- package/dist/viewer/server.d.ts +47 -1
- package/dist/viewer/server.js +480 -17
- package/dist/workspace.d.ts +60 -4
- package/dist/workspace.js +131 -5
- package/package.json +9 -3
- package/shelf/brick_wall.json +1 -1
- package/shelf/wall_segment.json +2 -2
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// Guides: what a person places in the view to direct the agent ("village here", "road along here", "keep this area
|
|
2
|
+
// empty"). The page edits the list and POSTs all of it; src/viewer/server.ts checks it with parseMarkers (this module,
|
|
3
|
+
// so the page and the server share one set of rules) and writes inputs/markers.json, which agents read like any
|
|
4
|
+
// input file (help topic "inputs": string attributes name and role, pscale = a null's radius).
|
|
5
|
+
// Plain functions, no DOM and no three.js: tested in Node (test/viewer-logic.ts).
|
|
6
|
+
|
|
7
|
+
/** The roles the LLM reads, and the editor's name for each (docs/design/viewer.md section 7). */
|
|
8
|
+
export const MARKER_KINDS = ['site', 'path', 'zone', 'volume'];
|
|
9
|
+
export const EDITOR_NAMES = { site: 'null', path: 'curve', zone: 'area', volume: 'volume' };
|
|
10
|
+
/** [fewest, most] points per kind: a null's point, a curve's CVs, an area's corners, a volume's two ground corners */
|
|
11
|
+
export const MARKER_POINTS = { site: [1, 1], path: [2, Infinity], zone: [3, Infinity], volume: [2, 2] };
|
|
12
|
+
export const DEFAULT_RADIUS = 5, DEFAULT_HEIGHT = 10;
|
|
13
|
+
|
|
14
|
+
/** A marker list that breaks a rule; the server answers it with 400 and the message. */
|
|
15
|
+
export class MarkerError extends Error {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A marker list (the POST /api/markers body, or the stored list) checked and normalised: names trimmed and unique
|
|
19
|
+
* (ignoring case), the defaults filled in, ids given to markers without one. Throws MarkerError naming the problem.
|
|
20
|
+
*/
|
|
21
|
+
export function parseMarkers(body) {
|
|
22
|
+
const list = body?.markers;
|
|
23
|
+
if (!Array.isArray(list)) throw new MarkerError('the body must be {"markers": [{id, kind, name, points, radius?, height?}, ...]}');
|
|
24
|
+
const bad = (i, msg) => new MarkerError(`markers[${i}]: ${msg}`);
|
|
25
|
+
const names = new Map(), ids = new Set();
|
|
26
|
+
const out = list.map((m, i) => {
|
|
27
|
+
if (!m || typeof m !== 'object' || Array.isArray(m)) throw bad(i, 'must be an object {id, kind, name, points}');
|
|
28
|
+
const kind = m.kind;
|
|
29
|
+
if (!MARKER_KINDS.includes(kind)) throw bad(i, `kind ${JSON.stringify(m.kind)}: use ${MARKER_KINDS.join(', ')}`);
|
|
30
|
+
const name = typeof m.name === 'string' ? m.name.normalize('NFC').trim() : '';
|
|
31
|
+
if (!name || name.length > 100 || /[\u0000-\u001f\u007f]/.test(name)) throw bad(i, `${m.name === undefined ? 'no name' : `name ${JSON.stringify(m.name)}`}: give 1 to 100 printable characters`);
|
|
32
|
+
const key = name.toLowerCase();
|
|
33
|
+
if (names.has(key)) throw bad(i, `name "${name}" is taken by markers[${names.get(key)}]: names must be unique`);
|
|
34
|
+
names.set(key, i);
|
|
35
|
+
if (m.id !== undefined) {
|
|
36
|
+
if (typeof m.id !== 'string' || !m.id || m.id.length > 64) throw bad(i, 'id must be a string of 1 to 64 characters');
|
|
37
|
+
if (ids.has(m.id)) throw bad(i, `id "${m.id}" is used twice`);
|
|
38
|
+
ids.add(m.id);
|
|
39
|
+
}
|
|
40
|
+
const [lo, hi] = MARKER_POINTS[kind];
|
|
41
|
+
if (!Array.isArray(m.points) || m.points.length < lo || m.points.length > hi)
|
|
42
|
+
throw bad(i, `a ${kind} needs ${lo === hi ? lo : `${lo} or more`} point${lo === 1 ? '' : 's'} [x, y, z] (got ${Array.isArray(m.points) ? m.points.length : JSON.stringify(m.points)})`);
|
|
43
|
+
const points = m.points.map((p, k) => {
|
|
44
|
+
if (!Array.isArray(p) || p.length !== 3 || !p.every((x) => typeof x === 'number' && Number.isFinite(x))) throw bad(i, `points[${k}] must be [x, y, z] in metres (got ${JSON.stringify(p)})`);
|
|
45
|
+
return [p[0], p[1], p[2]];
|
|
46
|
+
});
|
|
47
|
+
const size = (v, what, def) => {
|
|
48
|
+
if (v === undefined || v === null) return def;
|
|
49
|
+
if (typeof v !== 'number' || !Number.isFinite(v) || v <= 0) throw bad(i, `${what} must be a number of metres above 0 (got ${JSON.stringify(v)})`);
|
|
50
|
+
return v;
|
|
51
|
+
};
|
|
52
|
+
const r = { id: m.id, kind, name, points };
|
|
53
|
+
if (kind === 'site') r.radius = size(m.radius, 'radius', DEFAULT_RADIUS);
|
|
54
|
+
if (kind === 'volume') {
|
|
55
|
+
r.height = size(m.height, 'height', DEFAULT_HEIGHT);
|
|
56
|
+
if (points[0][0] === points[1][0] || points[0][2] === points[1][2]) throw bad(i, 'a volume\'s two corners must differ in x and in z');
|
|
57
|
+
}
|
|
58
|
+
return r;
|
|
59
|
+
});
|
|
60
|
+
let n = 0;
|
|
61
|
+
for (const m of out) if (m.id === undefined) { do m.id = `m${++n}`; while (ids.has(m.id)); ids.add(m.id); }
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The list as POST /api/markers takes it, in the key order the server stores. */
|
|
66
|
+
export const markersBody = (list) => JSON.stringify({ markers: list.map(({ id, kind, name, points, radius, height }) =>
|
|
67
|
+
({ id, kind, name, points, ...(kind === 'site' ? { radius } : {}), ...(kind === 'volume' ? { height } : {}) })) });
|
|
68
|
+
|
|
69
|
+
/** A deep copy of a list (undo snapshots). */
|
|
70
|
+
export const cloneMarkers = (list) => list.map((m) => ({ ...m, points: m.points.map((p) => [p[0], p[1], p[2]]) }));
|
|
71
|
+
|
|
72
|
+
/** The next free default name for a kind, as Houdini names new objects: null1, curve2, area1, volume3. */
|
|
73
|
+
export function nextName(list, kind) {
|
|
74
|
+
const base = EDITOR_NAMES[kind] ?? kind;
|
|
75
|
+
const re = new RegExp(`^${base}\\s*(\\d+)$`, 'i');
|
|
76
|
+
let n = 0;
|
|
77
|
+
for (const m of list) { const r = re.exec(m.name); if (r) n = Math.max(n, Number(r[1])); }
|
|
78
|
+
let name;
|
|
79
|
+
do name = `${base}${++n}`; while (list.some((m) => m.name.toLowerCase() === name));
|
|
80
|
+
return name;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A new name for marker `id` checked by the server's rules: {name} or {error}. */
|
|
84
|
+
export function checkName(list, id, raw) {
|
|
85
|
+
const name = String(raw ?? '').normalize('NFC').trim();
|
|
86
|
+
if (!name) return { error: 'a guide needs a name' };
|
|
87
|
+
if (name.length > 100 || /[\u0000-\u001f\u007f]/.test(name)) return { error: 'give 1 to 100 printable characters' };
|
|
88
|
+
const clash = list.find((o) => o.id !== id && o.name.toLowerCase() === name.toLowerCase());
|
|
89
|
+
if (clash) return { error: `"${name}" is taken by another guide: names must be unique` };
|
|
90
|
+
return { name };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Coordinates are kept to the millimetre. */
|
|
94
|
+
export const mm = (x) => Math.round(x * 1000) / 1000;
|
|
95
|
+
/** How many points a finished guide of this kind needs. */
|
|
96
|
+
export const minPoints = (kind) => MARKER_POINTS[kind]?.[0] ?? 1;
|
|
97
|
+
|
|
98
|
+
/** A volume's box as the server builds it: the lower corner's y, up by height. */
|
|
99
|
+
export function boxOf(m) {
|
|
100
|
+
const [a, c] = m.points;
|
|
101
|
+
const lo = [Math.min(a[0], c[0]), Math.min(a[1], c[1]), Math.min(a[2], c[2])];
|
|
102
|
+
return { lo, hi: [Math.max(a[0], c[0]), lo[1] + (m.height ?? DEFAULT_HEIGHT), Math.max(a[2], c[2])] };
|
|
103
|
+
}
|
|
104
|
+
export const pathLength = (pts) => pts.slice(1).reduce((s, p, k) => s + Math.hypot(p[0] - pts[k][0], p[1] - pts[k][1], p[2] - pts[k][2]), 0);
|
|
105
|
+
/** The area of a polygon seen from above (x, z), m². */
|
|
106
|
+
export const topArea = (pts) => Math.abs(pts.reduce((s, p, k) => { const q = pts[(k + 1) % pts.length]; return s + p[0] * q[2] - q[0] * p[2]; }, 0)) / 2;
|
|
107
|
+
export function insideTop(x, z, pts) {
|
|
108
|
+
let inside = false;
|
|
109
|
+
for (let i = 0, j = pts.length - 1; i < pts.length; j = i++) {
|
|
110
|
+
const [xi, , zi] = pts[i], [xj, , zj] = pts[j];
|
|
111
|
+
if ((zi > z) !== (zj > z) && x < ((xj - xi) * (z - zi)) / (zj - zi) + xi) inside = !inside;
|
|
112
|
+
}
|
|
113
|
+
return inside;
|
|
114
|
+
}
|
|
115
|
+
export const centroid = (pts) => [0, 1, 2].map((a) => pts.reduce((s, p) => s + p[a], 0) / Math.max(1, pts.length));
|
|
116
|
+
|
|
117
|
+
/** The point halfway along a polyline. */
|
|
118
|
+
export function halfway(P) {
|
|
119
|
+
let left = pathLength(P) / 2;
|
|
120
|
+
for (let k = 1; k < P.length; k++) {
|
|
121
|
+
const a = P[k - 1], b = P[k], d = Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
|
|
122
|
+
if (d > 0 && d >= left) { const t = left / d; return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t]; }
|
|
123
|
+
left -= d;
|
|
124
|
+
}
|
|
125
|
+
return P[P.length - 1].slice();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Where a guide's transform sits: a null's point, a curve's or an area's CV centre, a volume's box centre. */
|
|
129
|
+
export function pivotOf(m) {
|
|
130
|
+
if (m.kind === 'site') return m.points[0].slice();
|
|
131
|
+
if (m.kind === 'volume') { const { lo, hi } = boxOf(m); return [0, 1, 2].map((a) => (lo[a] + hi[a]) / 2); }
|
|
132
|
+
return centroid(m.points);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The bounds framing a guide shows: a null with its radius, the CVs, the box. */
|
|
136
|
+
export function boundsOf(m) {
|
|
137
|
+
if (m.kind === 'volume') return boxOf(m);
|
|
138
|
+
if (m.kind === 'site') {
|
|
139
|
+
const [x, y, z] = m.points[0], r = m.radius ?? DEFAULT_RADIUS;
|
|
140
|
+
return { lo: [x - r, y - r * 0.1, z - r], hi: [x + r, y + r * 0.1, z + r] };
|
|
141
|
+
}
|
|
142
|
+
const lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity];
|
|
143
|
+
for (const p of m.points) for (let a = 0; a < 3; a++) { lo[a] = Math.min(lo[a], p[a]); hi[a] = Math.max(hi[a], p[a]); }
|
|
144
|
+
return { lo, hi };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The attributes the LLM reads for a guide in inputs/markers.json, as the server writes them (markersGeometry in
|
|
149
|
+
* src/viewer/server.ts): rows {cls, name, type, value}.
|
|
150
|
+
*/
|
|
151
|
+
export function markerAttributes(m) {
|
|
152
|
+
if (m.kind === 'site') {
|
|
153
|
+
return [
|
|
154
|
+
{ cls: 'point', name: 'name', type: 'string', value: m.name },
|
|
155
|
+
{ cls: 'point', name: 'role', type: 'string', value: 'site' },
|
|
156
|
+
{ cls: 'point', name: 'pscale', type: 'float', value: m.radius ?? DEFAULT_RADIUS },
|
|
157
|
+
{ cls: 'point', name: 'orient', type: 'float4', value: [0, 0, 0, 1] },
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
return [
|
|
161
|
+
{ cls: 'prim', name: 'name', type: 'string', value: m.name },
|
|
162
|
+
{ cls: 'prim', name: 'role', type: 'string', value: m.kind },
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The elements a guide becomes in inputs/markers.json: {points, prims, text}. */
|
|
167
|
+
export function markerElements(m) {
|
|
168
|
+
const n = m.points.length;
|
|
169
|
+
if (m.kind === 'site') return { points: 1, prims: 0, text: '1 point' };
|
|
170
|
+
if (m.kind === 'path') return { points: n, prims: 1, text: `1 open polyline, ${n} points` };
|
|
171
|
+
if (m.kind === 'zone') return { points: n, prims: 1, text: `1 closed polygon facing up, ${n} points` };
|
|
172
|
+
return { points: 8, prims: 6, text: '1 closed box: 6 quads facing out, 8 points' };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** A group pattern picking one guide out of inputs/markers.json (patterns split on spaces: "?" matches one). */
|
|
176
|
+
export const groupOf = (m) => `@name=${m.name.replace(/\s/g, '?')}`;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The diagonal hatch inside an area: segments [[x, y, z], [x, y, z]] of lines at 45° in x, z, `spacing` apart,
|
|
180
|
+
* clipped to the polygon (even-odd), each end at the height of the edge it meets.
|
|
181
|
+
*/
|
|
182
|
+
export function hatchSegments(pts, spacing) {
|
|
183
|
+
const n = pts.length, out = [];
|
|
184
|
+
if (n < 3 || !(spacing > 0)) return out;
|
|
185
|
+
// lines u = x + z = const, walked along v = x - z
|
|
186
|
+
const U = pts.map((p) => p[0] + p[2]), V = pts.map((p) => p[0] - p[2]);
|
|
187
|
+
const u0 = Math.min(...U), u1 = Math.max(...U);
|
|
188
|
+
if ((u1 - u0) / spacing > 2000) spacing = (u1 - u0) / 2000;
|
|
189
|
+
for (let u = Math.ceil(u0 / spacing) * spacing; u <= u1; u += spacing) {
|
|
190
|
+
const hits = [];
|
|
191
|
+
for (let i = 0; i < n; i++) {
|
|
192
|
+
const j = (i + 1) % n, a = U[i], b = U[j];
|
|
193
|
+
if ((a <= u) === (b <= u)) continue;
|
|
194
|
+
const t = (u - a) / (b - a);
|
|
195
|
+
hits.push({ v: V[i] + (V[j] - V[i]) * t, y: pts[i][1] + (pts[j][1] - pts[i][1]) * t });
|
|
196
|
+
}
|
|
197
|
+
hits.sort((p, q) => p.v - q.v);
|
|
198
|
+
for (let k = 0; k + 1 < hits.length; k += 2) {
|
|
199
|
+
const a = hits[k], b = hits[k + 1];
|
|
200
|
+
if (b.v - a.v < 1e-9) continue;
|
|
201
|
+
// x = (u + v) / 2, z = (u - v) / 2
|
|
202
|
+
out.push([[(u + a.v) / 2, a.y, (u - a.v) / 2], [(u + b.v) / 2, b.y, (u - b.v) / 2]]);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Topology of the triangle meshes the viewer receives (GLB): vertices welded by exact position, connected pieces
|
|
2
|
+
// (what a click or a box selects inside one object: a rock of a scatter), and the edges the render tool marks in
|
|
3
|
+
// wireframe "boundary" (help topic "render"): open (used by one triangle), non-manifold (three or more) and winding
|
|
4
|
+
// flips (two triangles running the edge the same way). A polygon's triangulation never changes these: its inner
|
|
5
|
+
// diagonals are shared by exactly two of its triangles, wound alike.
|
|
6
|
+
// Plain functions on typed arrays, tested in Node (test/viewer-logic.ts).
|
|
7
|
+
|
|
8
|
+
/** The colours the render tool draws them in (src/render/raster.ts, wireframe "boundary"). */
|
|
9
|
+
export const EDGE_COLORS = { open: [1, 0.3, 0.62], nonManifold: [1, 0.92, 0.2], flipped: [0.72, 0.45, 1] };
|
|
10
|
+
|
|
11
|
+
const pow2 = (n) => { let s = 16; while (s < n) s <<= 1; return s; };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* For each vertex, the first vertex at exactly the same position (bit for bit): GLB vertices split at seams of
|
|
15
|
+
* normals or uvs weld back into the points they came from.
|
|
16
|
+
*/
|
|
17
|
+
export function weld(positions) {
|
|
18
|
+
const n = (positions.length / 3) | 0;
|
|
19
|
+
const bits = new Uint32Array(positions.buffer, positions.byteOffset, n * 3);
|
|
20
|
+
const size = pow2(n * 2), mask = size - 1;
|
|
21
|
+
const table = new Int32Array(size).fill(-1);
|
|
22
|
+
const out = new Uint32Array(n);
|
|
23
|
+
for (let i = 0; i < n; i++) {
|
|
24
|
+
const a = bits[i * 3], b = bits[i * 3 + 1], c = bits[i * 3 + 2];
|
|
25
|
+
let h = (Math.imul(a, 0x9e3779b1) ^ Math.imul(b, 0x85ebca77) ^ Math.imul(c, 0xc2b2ae3d)) >>> 0;
|
|
26
|
+
h = (h ^ (h >>> 15)) & mask;
|
|
27
|
+
for (;;) {
|
|
28
|
+
const j = table[h];
|
|
29
|
+
if (j < 0) { table[h] = i; out[i] = i; break; }
|
|
30
|
+
if (bits[j * 3] === a && bits[j * 3 + 1] === b && bits[j * 3 + 2] === c) { out[i] = j; break; }
|
|
31
|
+
h = (h + 1) & mask;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Union-find over welded vertex ids. */
|
|
38
|
+
function makeSets(n) {
|
|
39
|
+
const parent = new Int32Array(n);
|
|
40
|
+
for (let i = 0; i < n; i++) parent[i] = i;
|
|
41
|
+
const find = (x) => { while (parent[x] !== x) { parent[x] = parent[parent[x]]; x = parent[x]; } return x; };
|
|
42
|
+
const union = (a, b) => { a = find(a); b = find(b); if (a !== b) { if (a < b) parent[b] = a; else parent[a] = b; } };
|
|
43
|
+
return { find, union };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Connected pieces of a mesh with `count` vertices drawn as `per`-vertex elements (3: triangles, 2: segments) by
|
|
48
|
+
* `index` (null: 0, 1, 2, … in order). Pieces are numbered by their first element. Returns {count, elem, vert}:
|
|
49
|
+
* the number of pieces, the piece of each element and of each vertex (-1 for vertices no element uses).
|
|
50
|
+
*/
|
|
51
|
+
export function pieces(index, count, welded, per = 3) {
|
|
52
|
+
const nElem = Math.floor((index ? index.length : count) / per);
|
|
53
|
+
const at = index ? (i) => index[i] : (i) => i;
|
|
54
|
+
const sets = makeSets(count);
|
|
55
|
+
for (let e = 0; e < nElem; e++) {
|
|
56
|
+
const a = welded[at(e * per)];
|
|
57
|
+
for (let k = 1; k < per; k++) sets.union(a, welded[at(e * per + k)]);
|
|
58
|
+
}
|
|
59
|
+
const id = new Int32Array(count).fill(-1);
|
|
60
|
+
const elem = new Uint32Array(nElem), vert = new Int32Array(count).fill(-1);
|
|
61
|
+
let n = 0;
|
|
62
|
+
for (let e = 0; e < nElem; e++) {
|
|
63
|
+
const r = sets.find(welded[at(e * per)]);
|
|
64
|
+
if (id[r] < 0) id[r] = n++;
|
|
65
|
+
elem[e] = id[r];
|
|
66
|
+
for (let k = 0; k < per; k++) vert[at(e * per + k)] = id[r];
|
|
67
|
+
}
|
|
68
|
+
return { count: n, elem, vert };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Bounds of each piece: Float64Array of [minx, miny, minz, maxx, maxy, maxz] per piece. */
|
|
72
|
+
export function pieceBounds(positions, vertPiece, count) {
|
|
73
|
+
const b = new Float64Array(count * 6);
|
|
74
|
+
for (let p = 0; p < count; p++) { b.fill(Infinity, p * 6, p * 6 + 3); b.fill(-Infinity, p * 6 + 3, p * 6 + 6); }
|
|
75
|
+
for (let i = 0; i < vertPiece.length; i++) {
|
|
76
|
+
const p = vertPiece[i];
|
|
77
|
+
if (p < 0) continue;
|
|
78
|
+
for (let a = 0; a < 3; a++) {
|
|
79
|
+
const x = positions[i * 3 + a];
|
|
80
|
+
if (x < b[p * 6 + a]) b[p * 6 + a] = x;
|
|
81
|
+
if (x > b[p * 6 + 3 + a]) b[p * 6 + 3 + a] = x;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return b;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** An open-addressing map from an edge (two welded ids, smaller first) to a slot number. */
|
|
88
|
+
function edgeTable(capacity) {
|
|
89
|
+
const size = pow2(capacity * 2), mask = size - 1;
|
|
90
|
+
const ka = new Int32Array(size).fill(-1), kb = new Int32Array(size);
|
|
91
|
+
let used = 0;
|
|
92
|
+
return {
|
|
93
|
+
get used() { return used; },
|
|
94
|
+
/** the slot of edge (a, b), made when new */
|
|
95
|
+
slot(a, b) {
|
|
96
|
+
let h = ((Math.imul(a, 0x9e3779b1) ^ Math.imul(b, 0x85ebca77)) >>> 0) & mask;
|
|
97
|
+
for (;;) {
|
|
98
|
+
if (ka[h] < 0) { ka[h] = a; kb[h] = b; used++; return h; }
|
|
99
|
+
if (ka[h] === a && kb[h] === b) return h;
|
|
100
|
+
h = (h + 1) & mask;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
size,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The edges of a triangle mesh the render tool marks: {open, nonManifold, flipped}, each a Uint32Array of vertex
|
|
109
|
+
* index pairs (one pair per edge, original vertex indices for drawing).
|
|
110
|
+
*/
|
|
111
|
+
export function edgeClasses(index, count, welded) {
|
|
112
|
+
const nTri = Math.floor((index ? index.length : count) / 3);
|
|
113
|
+
const at = index ? (i) => index[i] : (i) => i;
|
|
114
|
+
const t = edgeTable(nTri * 3);
|
|
115
|
+
// per slot: triangles running the edge from the smaller id (fwd) and from the larger (bwd), counted up to 255
|
|
116
|
+
const fwd = new Uint8Array(t.size), bwd = new Uint8Array(t.size);
|
|
117
|
+
const each = (f) => {
|
|
118
|
+
for (let f3 = 0; f3 < nTri * 3; f3 += 3) {
|
|
119
|
+
for (let k = 0; k < 3; k++) {
|
|
120
|
+
const i = at(f3 + k), j = at(f3 + ((k + 1) % 3)), a = welded[i], b = welded[j];
|
|
121
|
+
if (a !== b) f(a < b ? t.slot(a, b) : t.slot(b, a), a < b, i, j);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
each((s, up) => { if (up) { if (fwd[s] < 255) fwd[s]++; } else if (bwd[s] < 255) bwd[s]++; });
|
|
126
|
+
// a second pass names each marked edge once, by the first triangle edge that runs it
|
|
127
|
+
const open = [], nonManifold = [], flipped = [], done = new Uint8Array(t.size);
|
|
128
|
+
each((s, _up, i, j) => {
|
|
129
|
+
if (done[s]) return;
|
|
130
|
+
done[s] = 1;
|
|
131
|
+
const n = fwd[s] + bwd[s];
|
|
132
|
+
if (n === 1) open.push(i, j);
|
|
133
|
+
else if (n > 2) nonManifold.push(i, j);
|
|
134
|
+
else if (fwd[s] === 2 || bwd[s] === 2) flipped.push(i, j);
|
|
135
|
+
});
|
|
136
|
+
return { open: Uint32Array.from(open), nonManifold: Uint32Array.from(nonManifold), flipped: Uint32Array.from(flipped) };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The elements (triangles) of the given pieces, as an index array into the same vertices. */
|
|
140
|
+
export function subsetIndex(index, count, elemPiece, keep, per = 3) {
|
|
141
|
+
const nElem = elemPiece.length;
|
|
142
|
+
const at = index ? (i) => index[i] : (i) => i;
|
|
143
|
+
let n = 0;
|
|
144
|
+
for (let e = 0; e < nElem; e++) if (keep.has(elemPiece[e])) n++;
|
|
145
|
+
const out = new Uint32Array(n * per);
|
|
146
|
+
let o = 0;
|
|
147
|
+
for (let e = 0; e < nElem; e++) {
|
|
148
|
+
if (!keep.has(elemPiece[e])) continue;
|
|
149
|
+
for (let k = 0; k < per; k++) out[o++] = at(e * per + k);
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The distinct edges of triangles `index` (welded), as vertex index pairs: a wireframe without doubled lines. */
|
|
155
|
+
export function edgePairs(index, welded) {
|
|
156
|
+
const nTri = Math.floor(index.length / 3);
|
|
157
|
+
const t = edgeTable(nTri * 3);
|
|
158
|
+
const seen = new Uint8Array(t.size);
|
|
159
|
+
const out = [];
|
|
160
|
+
for (let f = 0; f < nTri; f++) {
|
|
161
|
+
for (let k = 0; k < 3; k++) {
|
|
162
|
+
const i = index[f * 3 + k], j = index[f * 3 + ((k + 1) % 3)];
|
|
163
|
+
const a = welded[i], b = welded[j];
|
|
164
|
+
if (a === b) continue;
|
|
165
|
+
const s = a < b ? t.slot(a, b) : t.slot(b, a);
|
|
166
|
+
if (seen[s]) continue;
|
|
167
|
+
seen[s] = 1;
|
|
168
|
+
out.push(i, j);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return Uint32Array.from(out);
|
|
172
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// The left panel (docs/design/viewer.md section 2): three tabs. Scene is the outliner tree: the output (the node being
|
|
2
|
+
// shown), the graph's nodes (click one to show its result; the square is its display flag) and the guides. Outputs
|
|
3
|
+
// is the published results (outputs.js). Inputs is the files in inputs/ (reference layers) with Add input.
|
|
4
|
+
// Rows carry a visibility eye, a display mode and the name; selecting a row selects in the viewport and back.
|
|
5
|
+
// Rows are kept and updated in place, so an open menu survives a refresh.
|
|
6
|
+
import { opOf } from './selection.js';
|
|
7
|
+
import { DISPLAY_MODES, LAYER_MODES } from './scene.js';
|
|
8
|
+
import { EDITOR_NAMES } from './markers.js';
|
|
9
|
+
import { fmtBytes } from './units.js';
|
|
10
|
+
import { layerId, isInputImage, inputImageURL } from './layers.js';
|
|
11
|
+
import { guideId } from './guides.js';
|
|
12
|
+
|
|
13
|
+
const EYE = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3"><path d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8z"/><circle class="pupil" cx="8" cy="8" r="2"/><path class="slash" d="M3 13L13 3"/></svg>';
|
|
14
|
+
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text !== undefined) e.textContent = text; return e; };
|
|
15
|
+
|
|
16
|
+
export function createOutliner(ctx, panes) {
|
|
17
|
+
// the tabs: one pane shown, remembered per browser; arrow keys move between tabs
|
|
18
|
+
const tabs = [...document.querySelectorAll('#outliner [data-tab]')], paneEls = [...document.querySelectorAll('#outliner [data-pane]')];
|
|
19
|
+
let tab = ctx.store.get('outliner.tab', 'outputs');
|
|
20
|
+
const showTab = (name, focus = false) => {
|
|
21
|
+
if (!tabs.some((t) => t.dataset.tab === name)) name = 'outputs';
|
|
22
|
+
tab = name; ctx.store.set('outliner.tab', name);
|
|
23
|
+
for (const t of tabs) { const on = t.dataset.tab === name; t.classList.toggle('on', on); t.setAttribute('aria-selected', String(on)); t.tabIndex = on ? 0 : -1; if (on && focus) t.focus(); }
|
|
24
|
+
for (const p of paneEls) p.hidden = p.dataset.pane !== name;
|
|
25
|
+
};
|
|
26
|
+
for (const t of tabs) {
|
|
27
|
+
t.onclick = () => showTab(t.dataset.tab);
|
|
28
|
+
t.onkeydown = (e) => {
|
|
29
|
+
if (!['ArrowLeft', 'ArrowRight'].includes(e.key)) return;
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
const i = tabs.indexOf(t), next = tabs[(i + (e.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length];
|
|
32
|
+
showTab(next.dataset.tab, true);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
showTab(tab);
|
|
36
|
+
const tabCount = (name, n) => { const c = document.querySelector(`#tab-${name} .count`); if (c) c.textContent = n ? String(n) : ''; };
|
|
37
|
+
const picker = document.getElementById('input-file');
|
|
38
|
+
document.getElementById('add-input').onclick = () => picker.click();
|
|
39
|
+
picker.onchange = () => { ctx.layers.upload([...picker.files], []); picker.value = ''; };
|
|
40
|
+
const sizes = [32, 56, 88], sizeButton = document.getElementById('thumb-size');
|
|
41
|
+
let size = ctx.store.get('outliner.thumbnailSize', 56);
|
|
42
|
+
if (!sizes.includes(size)) size = 56;
|
|
43
|
+
const applySize = () => { document.getElementById('outliner').style.setProperty('--thumb-size', size + 'px'); sizeButton.textContent = size + ' px'; };
|
|
44
|
+
sizeButton.onclick = () => { size = sizes[(sizes.indexOf(size) + 1) % sizes.length]; ctx.store.set('outliner.thumbnailSize', size); applySize(); };
|
|
45
|
+
applySize();
|
|
46
|
+
const closed = new Set(ctx.store.get('outliner.closed', []));
|
|
47
|
+
const sections = new Map();
|
|
48
|
+
/** A collapsible section in a pane (the scene tree by default); a headless one is just rows (the Inputs tab). */
|
|
49
|
+
const section = (key, title, pane = panes.scene, headless = false) => {
|
|
50
|
+
let s = sections.get(key);
|
|
51
|
+
if (s) return s;
|
|
52
|
+
const box = el('div', 'sec' + (closed.has(key) && !headless ? ' closed' : '')), head = el('div', 'sh'), rows = el('div', 'rows'), count = el('span', 'count');
|
|
53
|
+
head.append(el('span', '', title), count);
|
|
54
|
+
head.onclick = () => { box.classList.toggle('closed'); if (box.classList.contains('closed')) closed.add(key); else closed.delete(key); ctx.store.set('outliner.closed', [...closed]); };
|
|
55
|
+
head.hidden = headless;
|
|
56
|
+
box.append(head, rows);
|
|
57
|
+
pane.append(box);
|
|
58
|
+
s = { box, rows, count, keyed: new Map(), tail: [] };
|
|
59
|
+
sections.set(key, s);
|
|
60
|
+
return s;
|
|
61
|
+
};
|
|
62
|
+
/** Keep one row per key in order; `make()` builds a row {el, update(data)}. */
|
|
63
|
+
const sync = (s, items, make) => {
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
let prev = null;
|
|
66
|
+
for (const it of items) {
|
|
67
|
+
seen.add(it.key);
|
|
68
|
+
let r = s.keyed.get(it.key);
|
|
69
|
+
if (!r) { r = make(it); s.keyed.set(it.key, r); }
|
|
70
|
+
r.update(it);
|
|
71
|
+
const want = prev ? prev.nextSibling : s.rows.firstChild;
|
|
72
|
+
if (r.el !== want) s.rows.insertBefore(r.el, want);
|
|
73
|
+
prev = r.el;
|
|
74
|
+
}
|
|
75
|
+
for (const [k, r] of s.keyed) if (!seen.has(k)) { r.el.remove(); s.keyed.delete(k); }
|
|
76
|
+
for (const t of s.tail) t.remove();
|
|
77
|
+
s.tail = [];
|
|
78
|
+
};
|
|
79
|
+
const note = (s, text, cls = 'note') => { const n = el('div', cls, text); s.rows.append(n); s.tail.push(n); return n; };
|
|
80
|
+
const selectRow = (row, id) => {
|
|
81
|
+
row.addEventListener('pointerdown', (e) => {
|
|
82
|
+
if (e.button !== 0 || e.target.closest('button, select, input')) return;
|
|
83
|
+
ctx.selection.apply([id], opOf(e));
|
|
84
|
+
});
|
|
85
|
+
row.addEventListener('pointerenter', () => ctx.setHover(id));
|
|
86
|
+
row.addEventListener('pointerleave', () => { if (ctx.hover === id) ctx.setHover(null); });
|
|
87
|
+
};
|
|
88
|
+
const eye = (onToggle) => {
|
|
89
|
+
const b = el('button', 'eye');
|
|
90
|
+
b.innerHTML = EYE;
|
|
91
|
+
b.onclick = (e) => { e.stopPropagation(); onToggle(); b.blur(); };
|
|
92
|
+
return b;
|
|
93
|
+
};
|
|
94
|
+
const displaySelect = (modes, onChange) => {
|
|
95
|
+
const s = el('select', 'disp');
|
|
96
|
+
for (const [v, t] of modes) s.append(new Option(t, v));
|
|
97
|
+
s.onchange = () => { onChange(s.value); s.blur(); };
|
|
98
|
+
s.title = 'display mode';
|
|
99
|
+
return s;
|
|
100
|
+
};
|
|
101
|
+
const mark = (row, id) => {
|
|
102
|
+
row.classList.toggle('sel', ctx.selection.has(id));
|
|
103
|
+
row.classList.toggle('part', !ctx.selection.has(id) && ctx.selection.touches(id));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function render() {
|
|
107
|
+
// output: the node being shown
|
|
108
|
+
{
|
|
109
|
+
const s = section('output', 'Scene');
|
|
110
|
+
const g = ctx.graph.current();
|
|
111
|
+
s.count.textContent = '';
|
|
112
|
+
sync(s, g ? [{ key: 'out' }] : [], () => {
|
|
113
|
+
const row = el('div', 'row'), ey = eye(() => ctx.output.setVisible(!ctx.output.visible)), nm = el('span', 'nm'), mt = el('span', 'mt');
|
|
114
|
+
const ds = displaySelect(DISPLAY_MODES, (m) => ctx.output.setDisplay(m));
|
|
115
|
+
row.append(ey, ds, nm, mt);
|
|
116
|
+
selectRow(row, 'out');
|
|
117
|
+
return {
|
|
118
|
+
el: row,
|
|
119
|
+
update() {
|
|
120
|
+
ey.classList.toggle('off', !ctx.output.visible);
|
|
121
|
+
ey.title = ctx.output.visible ? 'hide (H)' : 'show';
|
|
122
|
+
if (document.activeElement !== ds) ds.value = ctx.output.display;
|
|
123
|
+
const node = ctx.graph.shownNode();
|
|
124
|
+
nm.textContent = node ?? '(none)';
|
|
125
|
+
row.title = ctx.graph.node ? `showing node ${node} (click "${ctx.graph.current()?.output ?? 'output'}" in Nodes to follow the output again)` : `the graph's output, node ${node}`;
|
|
126
|
+
mt.textContent = ctx.output.loading ? 'cooking…' : ctx.graph.node ? 'node' : 'output';
|
|
127
|
+
mark(row, 'out');
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// the graph's nodes: the square is the display flag
|
|
133
|
+
{
|
|
134
|
+
const s = section('nodes', 'Nodes');
|
|
135
|
+
const g = ctx.graph.current();
|
|
136
|
+
const nodes = g?.nodes ?? [];
|
|
137
|
+
s.count.textContent = nodes.length || '';
|
|
138
|
+
sync(s, nodes.map((n) => ({ key: n.name, n })), ({ n: first }) => {
|
|
139
|
+
const row = el('div', 'row'), flag = el('span', 'flag'), nm = el('span', 'nm'), mt = el('span', 'mt');
|
|
140
|
+
row.append(flag, nm, mt);
|
|
141
|
+
let name = first.name;
|
|
142
|
+
row.addEventListener('pointerdown', (e) => { if (e.button === 0) ctx.graph.show(name); });
|
|
143
|
+
return {
|
|
144
|
+
el: row,
|
|
145
|
+
update({ n }) {
|
|
146
|
+
name = n.name;
|
|
147
|
+
const shown = ctx.graph.shownNode() === n.name;
|
|
148
|
+
flag.classList.toggle('on', shown);
|
|
149
|
+
nm.textContent = n.name + (n.name === g.output ? ' ◂ output' : '');
|
|
150
|
+
mt.textContent = n.type + (n.ms != null ? ` · ${n.ms.toFixed(0)} ms` : '');
|
|
151
|
+
row.classList.toggle('err', !!n.error);
|
|
152
|
+
row.title = n.error ?? `${n.type}${n.in?.length ? ' ← ' + n.in.filter(Boolean).join(', ') : ''} — click to show its result`;
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// inputs: reference layers, in the Inputs tab
|
|
158
|
+
{
|
|
159
|
+
const s = section('inputs', 'Inputs', panes.inputs, true);
|
|
160
|
+
const L = ctx.layers;
|
|
161
|
+
tabCount('inputs', L.list.length);
|
|
162
|
+
const where = document.getElementById('inputs-where');
|
|
163
|
+
where.textContent = L.where ? `inputs/ ${L.where}` : 'inputs/'; where.title = L.dir ?? '';
|
|
164
|
+
sync(s, L.list.map((f) => ({ key: f.path, f })), ({ f: first }) => {
|
|
165
|
+
const path = first.path, id = layerId(path);
|
|
166
|
+
const wrap = el('div', ''), row = el('div', 'row input-card'), ey = eye(() => L.show(path, !L.shown.has(path))), nm = el('span', 'nm', path), mt = el('span', 'mt'), er = el('div', 'rowerr');
|
|
167
|
+
const ds = displaySelect(LAYER_MODES, (m) => L.setDisplay(path, m));
|
|
168
|
+
const thumb = el('img', 'input-thumb'), body = el('div', 'input-body'), controls = el('div', 'input-controls'), icon = el('span', 'file-icon', first.ext?.toUpperCase() || 'FILE');
|
|
169
|
+
thumb.alt = ''; thumb.loading = 'lazy'; thumb.onerror = () => { thumb.hidden = true; icon.hidden = false; };
|
|
170
|
+
controls.append(ey, ds, mt); body.append(nm, controls); row.append(thumb, icon, body);
|
|
171
|
+
wrap.append(row, er);
|
|
172
|
+
selectRow(row, id);
|
|
173
|
+
row.onclick = (e) => { if (!e.target.closest('button,select,input') && isInputImage(path)) ctx.outputs.openInput(path); };
|
|
174
|
+
row.addEventListener('pointerenter', () => setTimeout(() => L.fetchInfo(path), 150));
|
|
175
|
+
return {
|
|
176
|
+
el: wrap,
|
|
177
|
+
update({ f }) {
|
|
178
|
+
const canPreview = isInputImage(path) || ['mesh', 'geometry', 'points'].includes(f.kind) || /\.(obj|stl|ply|glb|gltf|blend|geo|bgeo|json|csv)$/i.test(path);
|
|
179
|
+
const src = canPreview ? (isInputImage(path) ? inputImageURL(f) : '/api/input_thumb?' + new URLSearchParams({ path, rev: `${f.mtime}:${f.size}` })) : '';
|
|
180
|
+
if (thumb.dataset.source !== src) { thumb.dataset.source = src; thumb.hidden = !src; icon.hidden = !!src; if (src) thumb.src = src; }
|
|
181
|
+
const on = L.shown.has(path), e = ctx.objects.get(id);
|
|
182
|
+
ey.classList.toggle('off', !on);
|
|
183
|
+
ey.title = on ? 'hide (unloads the layer)' : 'show as a reference layer';
|
|
184
|
+
if (document.activeElement !== ds) ds.value = L.display.get(path) ?? 'view';
|
|
185
|
+
mt.textContent = e?.loading ? 'loading…' : fmtBytes(f.size);
|
|
186
|
+
row.title = `inputs/${path} · ${L.fileText(f)}`;
|
|
187
|
+
const err = L.errors.get(path);
|
|
188
|
+
er.textContent = err?.msg ?? '';
|
|
189
|
+
er.hidden = !err;
|
|
190
|
+
mark(row, id);
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
if (!L.list.length) note(s, 'No inputs yet: Add input, or drop meshes, curves, points, PNG, JPEG or WebP files anywhere on this page. The agent hears about new files and reads them as inputs/<name>.');
|
|
195
|
+
else note(s, 'a file node reads these as inputs/<name>; the agent hears about new ones');
|
|
196
|
+
}
|
|
197
|
+
tabCount('outputs', ctx.outputs?.count);
|
|
198
|
+
// guides
|
|
199
|
+
{
|
|
200
|
+
const s = section('guides', 'Guides');
|
|
201
|
+
const G = ctx.guides;
|
|
202
|
+
s.count.textContent = G.list.length || '';
|
|
203
|
+
sync(s, G.list.map((m) => ({ key: m.id, m })), ({ m: first }) => {
|
|
204
|
+
const gid = first.id, id = guideId(gid);
|
|
205
|
+
const row = el('div', 'row'), ey = eye(() => G.setHidden([gid], !G.hidden.has(gid))), kind = el('span', 'kind'), nm = el('span', 'nm');
|
|
206
|
+
row.append(ey, kind, nm);
|
|
207
|
+
selectRow(row, id);
|
|
208
|
+
return {
|
|
209
|
+
el: row,
|
|
210
|
+
update({ m }) {
|
|
211
|
+
const hidden = G.hidden.has(gid);
|
|
212
|
+
ey.classList.toggle('off', hidden);
|
|
213
|
+
ey.title = hidden ? 'show' : 'hide (H)';
|
|
214
|
+
kind.textContent = EDITOR_NAMES[m.kind];
|
|
215
|
+
nm.textContent = m.name;
|
|
216
|
+
row.title = `${EDITOR_NAMES[m.kind]} "${m.name}" — role "${m.kind}" in inputs/markers.json`;
|
|
217
|
+
mark(row, id);
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
if (!G.list.length) note(s, 'none yet — Shift+1 null, Shift+2 curve, Shift+3 area, Shift+4 volume; agents read them as inputs/markers.json');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return { render };
|
|
225
|
+
}
|