@floless/app 0.84.0 → 0.86.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.
@@ -9,9 +9,11 @@
9
9
  *
10
10
  * Contract shape (PER-PLAN, plan.grid — origin/spacings live in that sheet's display space, like
11
11
  * member wp / frame / dims, so it rides the per-plan undo stack safely):
12
- * { on, origin:[x,y] px, x:"0 3*25'", y:"0 4*20'", z:"0", labels_x:"", labels_y:"", ext: mm }
12
+ * { on, origin:[x,y] px, x:"0 3*25'", y:"0 4*20'", z:"0", labels_x:"", labels_y:"", ext: mm,
13
+ * lines:[{ id, label, a:[x,y], b:[x,y] }] }
13
14
  * X entries position lines ALONG +X (the lines run vertically on the plan), labelled 1,2,3… ;
14
15
  * Y entries march UP the sheet (display -Y == scene +Y), lines horizontal, labelled A,B,C… .
16
+ * `lines` holds individual free-angle grid/reference lines, used for skewed grids or partial one-offs.
15
17
  */
16
18
 
17
19
  export const IN_MM = 25.4;
@@ -118,10 +120,25 @@ export function sane(g) {
118
120
  return !!(g && Array.isArray(g.origin) && g.origin.length >= 2 && isFinite(g.origin[0]) && isFinite(g.origin[1]));
119
121
  }
120
122
 
123
+ const pt2 = (p) => Array.isArray(p) && p.length >= 2 && isFinite(p[0]) && isFinite(p[1]) ? [+p[0], +p[1]] : null;
124
+
125
+ /** Sanitized standalone/free-angle grid lines. Invalid or zero-length lines are ignored. */
126
+ export function gridLines(g) {
127
+ const out = [];
128
+ if (!g || !Array.isArray(g.lines)) return out;
129
+ for (let i = 0; i < g.lines.length; i++) {
130
+ const l = g.lines[i] || {}, a = pt2(l.a), b = pt2(l.b);
131
+ if (!a || !b || Math.hypot(b[0] - a[0], b[1] - a[1]) < 1e-6) continue;
132
+ out.push({ id: String(l.id || ('line-' + (i + 1))), label: String(l.label || (i + 1)), a, b });
133
+ }
134
+ return out;
135
+ }
136
+
121
137
  /**
122
138
  * The grid resolved to display-space plan geometry.
123
139
  * v = vertical lines (spaced along +X, labels 1,2,3…): { x, label }
124
140
  * h = horizontal lines (spaced UP the sheet = -Y, labels A,B,C…): { y, label }
141
+ * lines = standalone free-angle lines: { id, label, a, b }
125
142
  * zs = levels: { mm, label } (sorted, deduped). ext/extents are display px.
126
143
  * errX/errY/errZ carry per-axis parse errors; lines of a failed axis are [].
127
144
  */
@@ -148,12 +165,19 @@ export function gridGeometry(g, ptPerFt) {
148
165
  const zs = errZ ? [] : zmm.map((mm) => ({ mm, label: fmtLen(mm) }));
149
166
  const ext = px((g && isFinite(g.ext)) ? g.ext : 5 * FT_MM);
150
167
  const xs = v.map((l) => l.x), ys = h.map((l) => l.y);
168
+ const lines = gridLines(g);
169
+ const lx0 = lines.length ? Math.min(...lines.flatMap((l) => [l.a[0], l.b[0]])) : ox;
170
+ const lx1 = lines.length ? Math.max(...lines.flatMap((l) => [l.a[0], l.b[0]])) : ox;
171
+ const ly0 = lines.length ? Math.min(...lines.flatMap((l) => [l.a[1], l.b[1]])) : oy;
172
+ const ly1 = lines.length ? Math.max(...lines.flatMap((l) => [l.a[1], l.b[1]])) : oy;
151
173
  const geo = {
152
- v, h, zs,
174
+ v, h, lines, zs,
153
175
  errX: X.err, errY: Y.err, errZ,
154
176
  ext,
155
- x0: (xs.length ? Math.min(...xs) : ox) - ext, x1: (xs.length ? Math.max(...xs) : ox) + ext,
156
- y0: (ys.length ? Math.min(...ys) : oy) - ext, y1: (ys.length ? Math.max(...ys) : oy) + ext,
177
+ x0: Math.min((xs.length ? Math.min(...xs) : ox), lx0) - ext,
178
+ x1: Math.max((xs.length ? Math.max(...xs) : ox), lx1) + ext,
179
+ y0: Math.min((ys.length ? Math.min(...ys) : oy), ly0) - ext,
180
+ y1: Math.max((ys.length ? Math.max(...ys) : oy), ly1) + ext,
157
181
  };
158
182
  // per-line extent overrides (g.ends_x / g.ends_y: { "<index>": [lo|null, hi|null] } display px along
159
183
  // the line — a real sheet has partial lines like a 5.1 covering one wing). null / absent = the auto
@@ -204,8 +228,17 @@ export function gridSnapGeom(geo) {
204
228
  const segs = [], pts = [];
205
229
  for (const l of geo.v) segs.push([[l.x, l.lo], [l.x, l.hi]]);
206
230
  for (const l of geo.h) segs.push([[l.lo, l.y], [l.hi, l.y]]);
207
- for (const a of geo.v) for (const b of geo.h) {
208
- if (b.y >= a.lo && b.y <= a.hi && a.x >= b.lo && a.x <= b.hi) pts.push([a.x, b.y]);
231
+ for (const l of geo.lines || []) { segs.push([l.a, l.b]); pts.push(l.a, l.b); }
232
+ const addPt = (p) => { if (!pts.some((q) => Math.hypot(q[0] - p[0], q[1] - p[1]) < 1e-6)) pts.push(p); };
233
+ const cross = (a, b, c, d) => {
234
+ const rx = b[0] - a[0], ry = b[1] - a[1], sx = d[0] - c[0], sy = d[1] - c[1], den = rx * sy - ry * sx;
235
+ if (Math.abs(den) < 1e-9) return null;
236
+ const qx = c[0] - a[0], qy = c[1] - a[1], t = (qx * sy - qy * sx) / den, u = (qx * ry - qy * rx) / den;
237
+ return (t < 0 || t > 1 || u < 0 || u > 1) ? null : [a[0] + rx * t, a[1] + ry * t];
238
+ };
239
+ for (let i = 0; i < segs.length; i++) for (let j = i + 1; j < segs.length; j++) {
240
+ const p = cross(segs[i][0], segs[i][1], segs[j][0], segs[j][1]);
241
+ if (p) addPt(p);
209
242
  }
210
243
  return { segs, pts };
211
244
  }
@@ -222,6 +255,7 @@ export function gridCandidates3d(g, ptPerFt) {
222
255
  const out = [];
223
256
  for (const l of geo.v) out.push({ type: 'grid-line', a: [l.x * k, -l.hi * k, 0], b: [l.x * k, -l.lo * k, 0], fromId: 'grid-' + l.label });
224
257
  for (const l of geo.h) out.push({ type: 'grid-line', a: [l.lo * k, -l.y * k, 0], b: [l.hi * k, -l.y * k, 0], fromId: 'grid-' + l.label });
258
+ for (const l of geo.lines || []) out.push({ type: 'grid-line', a: [l.a[0] * k, -l.a[1] * k, 0], b: [l.b[0] * k, -l.b[1] * k, 0], fromId: 'grid-line-' + l.id });
225
259
  for (const a of geo.v) for (const b of geo.h) {
226
260
  if (b.y >= a.lo && b.y <= a.hi && a.x >= b.lo && a.x <= b.hi) out.push({ type: 'grid-int', p: [a.x * k, -b.y * k, 0], fromId: 'grid-' + a.label + '/' + b.label });
227
261
  }
@@ -73,14 +73,23 @@
73
73
  in slices 2/3. Hidden (never disabled) outside an open project. -->
74
74
  <div class="ws-spine" id="ws-spine" hidden>
75
75
  <label id="ws-proj-label">project</label>
76
- <button id="ws-proj-trigger" class="wf-trigger" type="button" aria-haspopup="menu" aria-expanded="false"
77
- data-tip="This project — open another, rename, duplicate, archive">
78
- <span id="ws-proj-name">—</span>
79
- <svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
80
- </button>
76
+ <!-- Mirrors #wf-combo/#wf-popover exactly (same classes) so the project picker is
77
+ the SAME control as the workflow picker, not a bespoke reskin — see
78
+ docs/superpowers/specs/2026-07-06-workspaces-slices-6.1-6.5-post-testing-fixes.md. -->
79
+ <div class="wf-combo" id="ws-proj-combo">
80
+ <button id="ws-proj-trigger" class="wf-trigger" type="button" aria-haspopup="listbox" aria-expanded="false" aria-controls="ws-proj-popover" aria-labelledby="ws-proj-label ws-proj-name"
81
+ data-tip="This project — open another, rename, duplicate, archive">
82
+ <span id="ws-proj-name" class="wf-trigger-label">—</span>
83
+ <svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
84
+ </button>
85
+ <div id="ws-proj-popover" class="wf-popover" role="listbox" aria-label="Select project" hidden>
86
+ <div class="wf-search-wrap"><input id="ws-proj-search" class="wf-search" type="text" placeholder="Search projects…" autocomplete="off" aria-label="Search projects" aria-controls="ws-proj-list"></div>
87
+ <div class="wf-list" id="ws-proj-list"></div>
88
+ </div>
89
+ </div>
81
90
  <span class="ctl-sep" aria-hidden="true"></span>
82
91
  <button id="ws-approve" type="button" class="primary"
83
- data-tip="Locks in this version of the model — your edits already auto-save; this is the sign-off.">✓ Approve</button>
92
+ data-tip="Locks in this version — your edits already auto-save; this is the sign-off.">✓ Approve</button>
84
93
  </div>
85
94
  <!-- Per-workflow onboarding beacon. Pulses "✨ Start here" while this workflow is
86
95
  new to the user (no first Run completed, not dismissed); calms to a quiet
@@ -165,6 +174,7 @@
165
174
  <span class="ws-status" id="ws-status"></span>
166
175
  </div>
167
176
  <div class="tabs ws-step-tabs" id="ws-step-tabs" role="tablist" aria-label="Project steps">
177
+ <button type="button" data-step="knowledge" role="tab" aria-selected="false">Knowledge</button>
168
178
  <button type="button" data-step="drawings" role="tab" aria-selected="false">Drawings</button>
169
179
  <button type="button" data-step="model" class="active" role="tab" aria-selected="true">Model</button>
170
180
  <button type="button" data-step="exports" role="tab" aria-selected="false">Exports</button>
@@ -173,9 +183,9 @@
173
183
  <!-- Drawings step: a shell toolbar band + revision-read status card ABOVE the filter iframe
174
184
  (chrome around it, never inside — the filter owns its own layout). Shown only on Drawings. -->
175
185
  <div class="ws-drawings-bar" id="ws-drawings-bar" hidden>
176
- <span class="ws-drawings-bar-label">Drawing set</span>
186
+ <span class="ws-drawings-bar-label">Source</span>
177
187
  <span class="ws-drawings-bar-sep"></span>
178
- <button type="button" id="ws-attach-revision" class="btn-mini" data-tip="Attach a revised drawing set — your terminal AI reads it into a new version">⤒ Attach revised drawings…</button>
188
+ <button type="button" id="ws-attach-revision" class="btn-mini" data-tip="Attach a revised drawing set (PDF or image) — your terminal AI reads it into a new version">⤒ Attach revised drawings…</button>
179
189
  <input type="file" id="ws-revision-file" accept=".pdf,image/*" multiple hidden>
180
190
  </div>
181
191
  <div class="ws-revision-card" id="ws-revision-card" hidden></div>
@@ -183,6 +193,16 @@
183
193
  Same-origin like #contract-editor-frame (they call /api/contract directly). -->
184
194
  <iframe id="ws-frame-model" class="ws-frame" title="Project model editor" hidden></iframe>
185
195
  <iframe id="ws-frame-drawings" class="ws-frame" title="Project drawings & filter" hidden></iframe>
196
+ <!-- Source-step placeholder: a workspace app with NO filter iframe (vectorize) shows this
197
+ where steel shows its filter. The ws-drawings-bar (attach/replace to re-trace) sits
198
+ above; this pane explains the Source step. Toggled by setStep() in workspaces.js. -->
199
+ <div class="ws-source-placeholder" id="ws-source-placeholder" hidden>
200
+ <div class="ws-source-inner">
201
+ <span class="ws-source-ico" aria-hidden="true">▨</span>
202
+ <div class="ws-source-title">This project's source drawing</div>
203
+ <div class="ws-source-sub">The lines on the Traced tab were read from the drawing you imported. Drop a revised drawing in the bar above to re-trace it as a new version.</div>
204
+ </div>
205
+ </div>
186
206
  <!-- Exports = a SHELL-rendered pane (not an iframe): export cards over the project's own
187
207
  contract. workspaces.js fills it on step-switch (renderExports). -->
188
208
  <div class="ws-exports" id="ws-exports" hidden></div>
@@ -190,6 +210,13 @@
190
210
  workspaces.js fills it on step-switch (renderHistory). Rollback is per-row (a header
191
211
  ↺ Rollback verb was cut in design review — no selection context; per-row is unambiguous). -->
192
212
  <div class="ws-history" id="ws-history" hidden></div>
213
+ <!-- Knowledge = a SHELL-rendered pane (not an iframe): the project's Knowledge Base.
214
+ workspaces.js fills it on step-switch (renderKnowledge). Stage B ships the References
215
+ column (drop / useAsKb / remove / Organize); the graph + note columns are Stage C/D.
216
+ The UI never parses a source or edits the wiki — Organize queues a Request the
217
+ terminal AI drains (AI at the edges). -->
218
+ <div class="ws-knowledge" id="ws-knowledge" hidden></div>
219
+ <input type="file" id="ws-knowledge-file" accept=".pdf,.png,.jpg,.jpeg,.txt,.csv,.md,image/*" multiple hidden>
193
220
  </div>
194
221
  <div class="hint" id="canvas-hint">Click any node to inspect. Star ★ a node to save it as a reusable Template. Drag the background to pan — or press Home to fit.</div>
195
222
  <div class="fav-bar" id="fav-bar">
@@ -261,9 +288,11 @@
261
288
  <span class="sep">·</span>
262
289
  <span class="stat"><span class="stat-key">agents</span><span class="stat-val" id="agents-count">—</span></span>
263
290
  <span class="sep">·</span>
264
- <span class="stat"><span class="stat-key">workflows</span><span class="stat-val" id="apps-count">—</span></span>
265
- <span class="sep">·</span>
266
- <span class="stat"><span class="stat-key">templates</span><span class="stat-val" id="fav-count">0</span></span>
291
+ <span id="wf-templates-stats">
292
+ <span class="stat"><span class="stat-key">workflows</span><span class="stat-val" id="apps-count">—</span></span>
293
+ <span class="sep">·</span>
294
+ <span class="stat"><span class="stat-key">templates</span><span class="stat-val" id="fav-count">0</span></span>
295
+ </span>
267
296
  <span class="sep">·</span>
268
297
  <span class="stat stat-requests" id="req-stat" data-tip="Changes queued for your terminal AI — click to view & manage"><span class="stat-key">requests</span><span class="stat-val" id="req-count">0</span></span>
269
298
  </div>
@@ -590,6 +619,25 @@
590
619
  </div>
591
620
  </div>
592
621
 
622
+ <div class="modal-backdrop" id="request-help-modal">
623
+ <div class="modal request-help" role="dialog" aria-modal="true" aria-labelledby="request-help-title" aria-describedby="request-help-sub request-help-steps" tabindex="-1">
624
+ <div class="guide-eyebrow">Requests</div>
625
+ <div class="modal-title" id="request-help-title">Request queued</div>
626
+ <div class="modal-sub" id="request-help-sub" aria-live="polite">Your drawing was added to Requests, and the terminal instructions were copied to your clipboard.</div>
627
+ <div class="request-help-steps" id="request-help-steps">
628
+ <div class="request-help-step"><span>1</span><p>Open the terminal agent.</p></div>
629
+ <div class="request-help-step"><span>2</span><p>Paste the copied instructions.</p></div>
630
+ <div class="request-help-step"><span>3</span><p>Return here to track progress in Requests.</p></div>
631
+ </div>
632
+ <div class="request-help-note" id="request-help-note">The web UI queues the request; your terminal agent applies it and reports progress back here.</div>
633
+ <div class="modal-actions">
634
+ <button id="request-help-copy" hidden>Copy instruction</button>
635
+ <button id="request-help-keep">Keep working</button>
636
+ <button id="request-help-open" class="primary">Open Requests</button>
637
+ </div>
638
+ </div>
639
+ </div>
640
+
593
641
  <!-- Per-workflow onboarding "Start here" guide. Surfaces the workflow's plain-English
594
642
  description + a live "Set inputs → Compile → Run" checklist (ticks from real state),
595
643
  and relays a "walk me through it" ask to the terminal AI. A styled modal — never a
@@ -828,6 +876,7 @@
828
876
  nothing project-specific (spec §2). Populated per-open in workspaces.js. -->
829
877
  <div class="menu ws-proj-menu" id="ws-proj-menu" role="menu" hidden></div>
830
878
 
879
+ <script src="analytics.js"></script>
831
880
  <script src="app.js"></script>
832
881
  <script src="renderers.js"></script>
833
882
  <script src="aware.js"></script>
@@ -106,7 +106,7 @@ function init(canvas, theApi) {
106
106
  perspCam.up.set(0, 0, 1); // Z-up to match the scene
107
107
  orthoCam = new THREE.OrthographicCamera(-1, 1, 1, -1, 1, 50_000_000);
108
108
  orthoCam.up.set(0, 0, 1);
109
- camera = perspCam;
109
+ camera = orthoCam; // default to ORTHO (CAD/Tekla-style parallel projection); the first fitCamera on 3D-entry sizes it (orthoBaseH+reframeOrtho). A saved View or the Persp toggle still switches to perspective.
110
110
  controls = new OrbitControls(camera, canvas);
111
111
  controls.enableDamping = false; // CAD feel: rotate/pan stop dead on release — NO post-release inertia/drift
112
112
  controls.zoomSpeed = 1.3; // a little snappier so the wheel reaches a connection detail in fewer ticks
@@ -277,9 +277,16 @@ const _ZA = new THREE.Vector3(0, 0, 1), _YA = new THREE.Vector3(0, 1, 0);
277
277
  // NOTE vs AWARE viewer-3d: AWARE converts the Z-up scene into Three's Y-up world before orienting, so
278
278
  // its roll targets world-Y. We render the scene NATIVELY Z-up (camera.up=Z), so the roll must target
279
279
  // world-Z (_ZA) — else the web rolls flat (horizontal) instead of standing vertical.
280
- function orientMember(mesh, dir) {
280
+ function orientMember(mesh, dir, el) {
281
281
  const m = dir.clone().normalize();
282
- if (mesh.geometry.type === 'BoxGeometry') { mesh.quaternion.setFromUnitVectors(_YA, m); return; } // length on local Y
282
+ // el.rot (section roll about the reference line) applies to ANY member — columns AND beams. A member
283
+ // rendered as an explicit BOX (traced section, no profile) rolls about its length axis (local Y here).
284
+ const rollRad = (el && typeof el.rot === 'number' && el.rot) ? el.rot * Math.PI / 180 : 0;
285
+ if (mesh.geometry.type === 'BoxGeometry') {
286
+ mesh.quaternion.setFromUnitVectors(_YA, m); // length on local Y
287
+ if (rollRad) mesh.quaternion.premultiply(new THREE.Quaternion().setFromAxisAngle(m, rollRad));
288
+ return;
289
+ }
283
290
  const q = new THREE.Quaternion().setFromUnitVectors(_ZA, m); // member axis = extrude (local Z)
284
291
  const proj = _ZA.clone().sub(m.clone().multiplyScalar(_ZA.dot(m))); // world-UP (Z) perpendicular to member
285
292
  if (proj.lengthSq() > 1e-6) {
@@ -287,6 +294,15 @@ function orientMember(mesh, dir) {
287
294
  const ly = _YA.clone().applyQuaternion(q); // where the section depth (local Y) points
288
295
  const ang = Math.atan2(ly.clone().cross(proj).dot(m), ly.dot(proj));
289
296
  q.premultiply(new THREE.Quaternion().setFromAxisAngle(m, ang)); // roll so the web stands vertical (depth → world-Z)
297
+ // then apply the authored roll about the member axis — for a beam this spins the section around its
298
+ // reference line (0 = web vertical, as before). Columns take the degenerate branch below instead.
299
+ if (rollRad) q.premultiply(new THREE.Quaternion().setFromAxisAngle(m, rollRad));
300
+ } else if (el && typeof el.rot === 'number') {
301
+ // A vertical member (column): the world-up roll above is degenerate, so face the section by the
302
+ // authored plan rotation instead of an arbitrary default. Matches the 2D editor's section angle.
303
+ // `el.rot` is ALREADY Y-flip-corrected (negated) in contract-to-scene, so a skewed column now reads
304
+ // the same way as its 2D footprint — apply it directly here (do NOT re-negate).
305
+ q.premultiply(new THREE.Quaternion().setFromAxisAngle(m, el.rot * Math.PI / 180));
290
306
  }
291
307
  mesh.quaternion.copy(q);
292
308
  }
@@ -296,7 +312,7 @@ function placeMember(mesh, a, b, el) {
296
312
  const dir = new THREE.Vector3().subVectors(B, A); const len = dir.length() || 1; dir.normalize();
297
313
  const w = Math.max((el.section && el.section.w) || 50, 1), d = Math.max((el.section && el.section.d) || 50, 1);
298
314
  mesh.geometry = memberGeom(el, w, d, len);
299
- orientMember(mesh, dir);
315
+ orientMember(mesh, dir, el);
300
316
  mesh.position.copy(A).addScaledVector(dir, len / 2);
301
317
  }
302
318
 
@@ -903,7 +919,7 @@ function buildStructGrid() {
903
919
  let g = null, geo = null;
904
920
  try { g = api.getGrid(); if (!g || g.on === false) return; geo = gridGeometry(g, api.ptPerFt()); }
905
921
  catch (e) { console.warn('[steel-3d] grid skipped (bad grid data)', e); return; }
906
- if (!geo.v.length && !geo.h.length) return;
922
+ if (!geo.v.length && !geo.h.length && !(geo.lines && geo.lines.length)) return;
907
923
  const k = mmPerPx(api.ptPerFt());
908
924
  const mmX = (px) => px * k, mmY = (px) => -px * k; // display → scene (Y flips)
909
925
  const levels = geo.zs.length ? geo.zs : [{ mm: 0, label: '0' }];
@@ -912,6 +928,7 @@ function buildStructGrid() {
912
928
  const z = lv.mm - 25; // sit just under the steel at the level (no z-fight/burial)
913
929
  for (const l of geo.v) pts.push(V(mmX(l.x), mmY(l.lo), z), V(mmX(l.x), mmY(l.hi), z));
914
930
  for (const l of geo.h) pts.push(V(mmX(l.lo), mmY(l.y), z), V(mmX(l.hi), mmY(l.y), z));
931
+ for (const l of geo.lines || []) pts.push(V(mmX(l.a[0]), mmY(l.a[1]), z), V(mmX(l.b[0]), mmY(l.b[1]), z));
915
932
  }
916
933
  structGridGroup = new THREE.Group();
917
934
  const seg = new THREE.LineSegments(
@@ -926,12 +943,17 @@ function buildStructGrid() {
926
943
  const dia = Math.min(Math.max(span * 0.035, 400), 3000); // bubble ⌀ scales with the grid, clamped sane
927
944
  const z0 = levels[0].mm;
928
945
  const sprite = (tex, x, y, z, w, h) => {
929
- const s = new THREE.Sprite(new THREE.SpriteMaterial({ map: tex, depthTest: false, transparent: true }));
946
+ // depthTest ON so steel in FRONT occludes the bubble/level tag (B7). The overlay pass runs with the
947
+ // depth buffer from pass 1 (members) intact — autoClear is off — so this occludes against the steel
948
+ // WITHOUT moving the labels out of overlayScene: they stay unclipped, so a section plane still can't
949
+ // cut them (the clip-regression guard above holds).
950
+ const s = new THREE.Sprite(new THREE.SpriteMaterial({ map: tex, depthTest: true, depthWrite: false, transparent: true }));
930
951
  s.position.set(x, y, z); s.scale.set(w, h, 1); s.renderOrder = 994;
931
952
  gridLabelGroup.add(s);
932
953
  };
933
954
  for (const l of geo.v) { sprite(gridBubbleTexture(l.label), mmX(l.x), mmY(l.lo), z0, dia, dia); sprite(gridBubbleTexture(l.label), mmX(l.x), mmY(l.hi), z0, dia, dia); }
934
955
  for (const l of geo.h) { sprite(gridBubbleTexture(l.label), mmX(l.lo), mmY(l.y), z0, dia, dia); sprite(gridBubbleTexture(l.label), mmX(l.hi), mmY(l.y), z0, dia, dia); }
956
+ for (const l of geo.lines || []) { sprite(gridBubbleTexture(l.label), mmX(l.a[0]), mmY(l.a[1]), z0, dia, dia); sprite(gridBubbleTexture(l.label), mmX(l.b[0]), mmY(l.b[1]), z0, dia, dia); }
935
957
  if (geo.zs.length > 1) for (const lv of geo.zs) sprite(gridTagTexture(lv.label), mmX(geo.x0), mmY(geo.y1), lv.mm, dia * 2.4, dia * 0.75); // level tags up the near corner
936
958
  overlayScene.add(gridLabelGroup);
937
959
  }
@@ -1034,17 +1056,50 @@ function setProjection(mode) {
1034
1056
  }
1035
1057
  function projection() { return camera === orthoCam ? 'ortho' : 'persp'; }
1036
1058
  function setDisplayMode(m) { displayMode = m; applyDisplayMode(); }
1037
- // solid → opaque; wire → wireframe; xray → translucent, no depth write. Applied to whatever material
1038
- // each mesh currently carries (shared profile material OR its selection clone).
1059
+ // Wireframe mode uses per-mesh THREE.EdgesGeometry outlines instead of mat.wireframe: the latter draws
1060
+ // every triangulation edge, so each beam face shows a spurious diagonal "internal line" (F2). An
1061
+ // EdgesGeometry with a threshold angle keeps only edges where adjacent faces diverge past the threshold —
1062
+ // dropping the coplanar diagonals, keeping the true member outline. Built lazily on first Wire entry and
1063
+ // cached per mesh; the outline is a CHILD of the mesh (inherits its transform, hidden with it) and is never
1064
+ // picked (member raycasts are non-recursive over meshById). The outline is drawn in the MEMBER's colour
1065
+ // (matches the Solid legend, incl. the selection highlight) — line materials are shared per colour so ~24
1066
+ // profiles cost ~24 materials, not one per member.
1067
+ const WIRE_EDGE_FALLBACK = 0x94a3b8; // slate — only if a mesh somehow has no colour
1068
+ const wireEdgeMats = new Map(); // colour hex -> shared LineBasicMaterial
1069
+ const wireEdges = new Map(); // meshId -> LineSegments (edge overlay child)
1070
+ function wireEdgeColorOf(mesh) { const c = mesh.material && mesh.material.color; return c ? c.getHex() : WIRE_EDGE_FALLBACK; }
1071
+ function wireEdgeMatFor(hex) { let m = wireEdgeMats.get(hex); if (!m) { m = new THREE.LineBasicMaterial({ color: hex }); wireEdgeMats.set(hex, m); } return m; }
1072
+ function wireEdgesFor(id, mesh) {
1073
+ let ls = wireEdges.get(id);
1074
+ if (ls && ls.parent !== mesh) { if (ls.parent) ls.parent.remove(ls); ls.geometry.dispose(); ls = null; } // mesh rebuilt under the same id → drop the stale outline
1075
+ const mat = wireEdgeMatFor(wireEdgeColorOf(mesh));
1076
+ if (!ls) { ls = new THREE.LineSegments(new THREE.EdgesGeometry(mesh.geometry, 20), mat); mesh.add(ls); wireEdges.set(id, ls); } // 20° threshold: keep corners, drop the flat-face triangulation diagonals
1077
+ else ls.material = mat; // re-colour if the member's colour changed (selection highlight / recolour) — applyDisplayMode re-runs on selection
1078
+ return ls;
1079
+ }
1080
+ function clearWireEdges() {
1081
+ for (const ls of wireEdges.values()) { if (ls.parent) ls.parent.remove(ls); if (ls.geometry) ls.geometry.dispose(); }
1082
+ wireEdges.clear();
1083
+ for (const m of wireEdgeMats.values()) m.dispose();
1084
+ wireEdgeMats.clear();
1085
+ }
1086
+ // solid → opaque; wire → EdgesGeometry outline (fill hidden); xray → translucent, no depth write. Applied to
1087
+ // whatever material each mesh currently carries (shared profile material OR its selection clone).
1039
1088
  function applyDisplayMode() {
1089
+ const wire = displayMode === 'wire', live = new Set();
1040
1090
  for (const [id, mesh] of meshById) {
1041
1091
  const mat = mesh.material; if (!mat) continue;
1042
1092
  if (String(id).startsWith('det:')) continue; // placed details (Slice 4) own their transparency + opacity — display mode must not override them
1043
- if (displayMode === 'wire') { mat.wireframe = true; mat.transparent = false; mat.opacity = 1; mat.depthWrite = true; }
1044
- else if (displayMode === 'xray') { mat.wireframe = false; mat.transparent = true; mat.opacity = 0.25; mat.depthWrite = false; }
1045
- else { mat.wireframe = false; mat.transparent = false; mat.opacity = 1; mat.depthWrite = true; }
1093
+ live.add(id);
1094
+ if (wire) { mat.wireframe = false; mat.transparent = false; mat.opacity = 1; mat.depthWrite = true; mat.visible = false; wireEdgesFor(id, mesh).visible = true; } // hide the solid fill; the outline carries the shape
1095
+ else {
1096
+ mat.visible = true; const ls = wireEdges.get(id); if (ls) ls.visible = false;
1097
+ if (displayMode === 'xray') { mat.wireframe = false; mat.transparent = true; mat.opacity = 0.25; mat.depthWrite = false; }
1098
+ else { mat.wireframe = false; mat.transparent = false; mat.opacity = 1; mat.depthWrite = true; }
1099
+ }
1046
1100
  mat.needsUpdate = true;
1047
1101
  }
1102
+ for (const [id, ls] of wireEdges) if (!live.has(id) || ls.parent !== meshById.get(id)) { if (ls.parent) ls.parent.remove(ls); if (ls.geometry) ls.geometry.dispose(); wireEdges.delete(id); } // prune outlines whose mesh is gone OR was rebuilt under the same id (wireEdgesFor rebuilds on next Wire entry)
1048
1103
  }
1049
1104
  // A work area in "show whole parts" mode acts as a spatial filter: a part whose world AABB touches the box shows
1050
1105
  // in FULL (never sliced), a part entirely outside hides. Only evaluated when that mode is active (setFromObject
@@ -1615,7 +1670,7 @@ function rebuildEndpoints() {
1615
1670
  const show = new Set(selIds); if (hoverId) show.add(hoverId);
1616
1671
  for (const id of show) {
1617
1672
  const mesh = meshById.get(id); if (mesh && !mesh.visible) continue; // a legend-hidden member shows no dots
1618
- const m = members().find((x) => x.id === id); if (!m) continue;
1673
+ const m = memberById(id); if (!m) continue;
1619
1674
  const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm());
1620
1675
  addEndpoint(g.line[0], epMatStart, id, 0); addEndpoint(g.line[1], epMatEnd, id, 1);
1621
1676
  }
@@ -2163,6 +2218,16 @@ function rayToVerticalPlane(cx, cy, thru) {
2163
2218
  return raycaster.ray.intersectPlane(plane, hit) ? [hit.x, hit.y, hit.z] : null;
2164
2219
  }
2165
2220
  const members = () => (api && api.getMembers && api.getMembers()) || [];
2221
+ // Resolve a member by id MODEL-WIDE (every sheet), not just the active plane: the 3D shows all sheets,
2222
+ // so a pick / drag / hover / endpoint-handle can target a member on any plane. Falls back to the active
2223
+ // list if the host doesn't expose allMembers.
2224
+ // ponytail: geometry + drag/endpoint commits here still use the ACTIVE plane's ppf/dtos (api.ptPerFt/
2225
+ // defaultTosMm) — the whole 3D interaction layer (snap, grid, geometry) is built on one active scale.
2226
+ // That is EXACT when the set has a uniform ppf, which real reads guarantee (same assumption membersInRect
2227
+ // documents). Editing an off-active-sheet member whose sheet has a DIFFERENT ppf would mis-scale the
2228
+ // commit. Upgrade path if sheets ever differ: expose api.ptPerFtFor(id)/defaultTosMmFor(id) and thread the
2229
+ // per-member scale through the drag-start capture + memberGeometry/planPointToWp commit sites.
2230
+ const memberById = (id) => { const all = (api && api.allMembers && api.allMembers()) || members(); return all.find((x) => x.id === id); };
2166
2231
  const geoMode = () => (api && api.geoMode && api.geoMode()) || null;
2167
2232
 
2168
2233
  // ---- working plane (spec §6): session view-state grounding ALL 3D picks. null = the active plan's
@@ -2453,7 +2518,7 @@ function dimPointAt(e, anchor) {
2453
2518
  }
2454
2519
  let id = null; try { id = pickAt(e.clientX, e.clientY); } catch { id = null; }
2455
2520
  let planeZ = sceneBox.isEmpty() ? 0 : sceneBox.min.z;
2456
- if (id) { const m = members().find((x) => x.id === id); if (m) { const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm()); planeZ = (g.line[0][2] + g.line[1][2]) / 2; } }
2521
+ if (id) { const m = memberById(id); if (m) { const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm()); planeZ = (g.line[0][2] + g.line[1][2]) / 2; } }
2457
2522
  const hit = rayToPlane(e.clientX, e.clientY, planeZ); if (!hit) return null;
2458
2523
  if (!dimCandidates3d) dimCandidates3d = allCandidates(null); // member + grid candidates (allCandidates folds in the grid)
2459
2524
  const cands = dimCandidates3d.filter((c) => candAllowed3d(c.type)); // right-click override (one type / free) + the persistent running-snaps from the ⋯ menu
@@ -2526,7 +2591,7 @@ function onDown(e) {
2526
2591
  if (!id) { pending = null; boxSel = { x: e.clientX, y: e.clientY }; return; } // empty space → box-select on drag
2527
2592
  e.stopPropagation(); controls.enabled = false; // grabbed a member → suppress orbit (enabled=false is the reliable guard)
2528
2593
  try {
2529
- const m = members().find((x) => x.id === id);
2594
+ const m = memberById(id);
2530
2595
  const ppf = api.ptPerFt(), dtos = api.defaultTosMm();
2531
2596
  const geo = m ? memberGeometry(m, ppf, dtos) : null;
2532
2597
  const mesh = meshById.get(id);
@@ -2562,7 +2627,7 @@ function onMoveVertical(e) {
2562
2627
  // Grab a single end node: drag it on the member's work-plane (its TOS), snapping to other members.
2563
2628
  function startEndpointGrab(ep, e) {
2564
2629
  try {
2565
- const m = members().find((x) => x.id === ep.id); if (!m) { controls.enabled = true; return; }
2630
+ const m = memberById(ep.id); if (!m) { controls.enabled = true; return; }
2566
2631
  const ppf = api.ptPerFt(), dtos = api.defaultTosMm();
2567
2632
  const g = memberGeometry(m, ppf, dtos);
2568
2633
  pending = {
@@ -2661,18 +2726,49 @@ function _inRect(p, r) { return p[0] >= r[0] && p[0] <= r[2] && p[1] >= r[1] &&
2661
2726
  function _ccw(a, b, c) { return (c[1] - a[1]) * (b[0] - a[0]) - (b[1] - a[1]) * (c[0] - a[0]); }
2662
2727
  function _segSeg(a, b, c, d) { return (_ccw(a, c, d) > 0) !== (_ccw(b, c, d) > 0) && (_ccw(a, b, c) > 0) !== (_ccw(a, b, d) > 0); }
2663
2728
  function _rectHit(p0, p1, r) { if (_inRect(p0, r) || _inRect(p1, r)) return true; const c = [[r[0], r[1]], [r[2], r[1]], [r[2], r[3]], [r[0], r[3]]]; for (let i = 0; i < 4; i++) if (_segSeg(p0, p1, c[i], c[(i + 1) % 4])) return true; return false; }
2729
+ const _boxEdges = [[0, 1], [0, 2], [0, 4], [3, 1], [3, 2], [3, 7], [5, 1], [5, 4], [5, 7], [6, 2], [6, 4], [6, 7]];
2730
+ function _rectOverlap(a, r) { return a && a[0] <= r[2] && a[2] >= r[0] && a[1] <= r[3] && a[3] >= r[1]; }
2731
+ function memberFootprintHit(mesh, r, windowMode, rect) {
2732
+ if (!mesh || !mesh.geometry) return false;
2733
+ if (!mesh.geometry.boundingBox) mesh.geometry.computeBoundingBox();
2734
+ const b = mesh.geometry.boundingBox;
2735
+ if (!b || b.isEmpty()) return false;
2736
+ mesh.updateMatrixWorld(true);
2737
+ const pts = [];
2738
+ let sx0 = Infinity, sy0 = Infinity, sx1 = -Infinity, sy1 = -Infinity, behind = false;
2739
+ for (let i = 0; i < 8; i++) {
2740
+ const p = new THREE.Vector3(i & 1 ? b.max.x : b.min.x, i & 2 ? b.max.y : b.min.y, i & 4 ? b.max.z : b.min.z).applyMatrix4(mesh.matrixWorld);
2741
+ const v = p.project(camera);
2742
+ if (v.z > 1) { behind = true; break; }
2743
+ const s = [rect.left + (v.x * 0.5 + 0.5) * rect.width, rect.top + (-v.y * 0.5 + 0.5) * rect.height];
2744
+ pts.push(s); sx0 = Math.min(sx0, s[0]); sy0 = Math.min(sy0, s[1]); sx1 = Math.max(sx1, s[0]); sy1 = Math.max(sy1, s[1]);
2745
+ }
2746
+ if (behind || !pts.length) return false;
2747
+ if (windowMode) return pts.every((p) => _inRect(p, r));
2748
+ if (!_rectOverlap([sx0, sy0, sx1, sy1], r)) return false;
2749
+ if (pts.some((p) => _inRect(p, r))) return true;
2750
+ const rc = [[r[0], r[1]], [r[2], r[1]], [r[2], r[3]], [r[0], r[3]]];
2751
+ for (const [a, b] of _boxEdges) for (let i = 0; i < 4; i++) if (_segSeg(pts[a], pts[b], rc[i], rc[(i + 1) % 4])) return true;
2752
+ return true; // overlapping projected solid AABBs still count for crossing; avoids missing thick/vertical members.
2753
+ }
2664
2754
  // every VISIBLE member whose projected centreline meets the drag rect — window: both ends inside · crossing: touches
2665
2755
  function membersInRect(x0, y0, x1, y1, windowMode) {
2666
2756
  const rect = canvasEl.getBoundingClientRect();
2667
2757
  const r = [Math.min(x0, x1), Math.min(y0, y1), Math.max(x0, x1), Math.max(y0, y1)];
2668
2758
  const ppf = api.ptPerFt(), dtos = api.defaultTosMm();
2669
- const memById = new Map(members().map((m) => [m.id, m]));
2759
+ // ALL sheets' members, not just the active one — the 3D shows every plan, so a box must be able to grab a
2760
+ // member on any floor (the meshes are server-positioned, so the primary footprint hit is correct across
2761
+ // sheets; the client-recomputed a/b fallback uses the active ppf and may be off for a far sheet, but the
2762
+ // footprint test catches those). Without this, an area-select only picks the active sheet — "selection
2763
+ // depth doesn't match what I see."
2764
+ const memById = new Map(((api && api.allMembers && api.allMembers()) || members()).map((m) => [m.id, m]));
2670
2765
  const toScreen = (p) => { const w = new THREE.Vector3(p[0], p[1], p[2]).project(camera); return { s: [rect.left + (w.x * 0.5 + 0.5) * rect.width, rect.top + (-w.y * 0.5 + 0.5) * rect.height], behind: w.z > 1 }; };
2671
2766
  const out = [];
2672
2767
  for (const [id, m] of meshById) {
2673
2768
  if (!m.visible || m.userData.derived) continue; // derived connection parts aren't member-selectable (mirrors pickAt; dbl-click-zoom deliberately includes them)
2674
2769
  const mem = memById.get(id); if (!mem) continue;
2675
2770
  let a, b; try { const g = memberGeometry(mem, ppf, dtos); a = toScreen(g.line[0]); b = toScreen(g.line[1]); } catch { continue; }
2771
+ if (memberFootprintHit(m, r, windowMode, rect)) { out.push(id); continue; } // select what the user boxed: the rendered solid, including high-level members and columns
2676
2772
  if (a.behind || b.behind) { // an endpoint is behind the camera → the projected segment is unreliable; fall back to the member-centre test (old behaviour, no regression for members straddling the camera plane)
2677
2773
  const w = m.getWorldPosition(new THREE.Vector3()).project(camera); if (w.z > 1) continue;
2678
2774
  if (_inRect([rect.left + (w.x * 0.5 + 0.5) * rect.width, rect.top + (-w.y * 0.5 + 0.5) * rect.height], r)) out.push(id);
@@ -2737,7 +2833,7 @@ function onUp(e) {
2737
2833
  if (moved > DRAG_TOL_PX) return;
2738
2834
  if (p.geo === 'el') { if (p.targetId && !selIds.has(p.targetId) && api && api.onTrimExtend) api.onTrimExtend(p.targetId); return; } // target line ≠ a selected member; trims ALL selected
2739
2835
  if (p.geo === 'split') { // cut the selected member at the clicked point on its centreline
2740
- const m = members().find((x) => x.id === p.selId); if (!m) return;
2836
+ const m = memberById(p.selId); if (!m) return;
2741
2837
  const ppf = api.ptPerFt();
2742
2838
  const g = memberGeometry(m, ppf, api.defaultTosMm());
2743
2839
  const planeZ = (g.line[0][2] + g.line[1][2]) / 2;
@@ -2856,7 +2952,7 @@ function updateStatusChip() {
2856
2952
  : (st.array && !tfDraft.vA ? 'Click the direction-A point — or type its spacing' : st.array ? 'Click the direction-B point — the grid previews live' : 'Click the destination — X/Y lock to the plane axes · Esc cancels')) + lock; }
2857
2953
  else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
2858
2954
  else if (clipMode === 'box') txt = !clipBoxDraft ? 'Click the first floor corner of the clip box · Esc to cancel' : !clipBoxDraft.b ? 'Click the opposite floor corner · Esc to cancel' : 'Move up/down to set the height, then click · Esc to step back';
2859
- else if (showId) { const m = members().find((x) => x.id === showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
2955
+ else if (showId) { const m = memberById(showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
2860
2956
  else if (selIds.size > 1) txt = `${selIds.size} members selected`;
2861
2957
  else if (isolatedIds) txt = `Isolated: ${isolatedIds.size} · Show all to restore`;
2862
2958
  // A read-only host (the vector 3D viewer) supplies its own idle hint — the default speaks editing
@@ -2918,6 +3014,7 @@ function dispose() {
2918
3014
  epGeom = epMatStart = epMatEnd = epRing = epPreview = epMovedLine = refGroup = null;
2919
3015
  dims3dGroup = dimPreviewLine = overlayDimsGroup = null;
2920
3016
  clearStructGrid();
3017
+ clearWireEdges();
2921
3018
  for (const tex of gridTexCache.values()) tex.dispose();
2922
3019
  gridTexCache.clear();
2923
3020
  clearRoot();
@@ -2960,7 +3057,7 @@ function probe(id) {
2960
3057
  }
2961
3058
  // test helper: client (px) coords of a member's endpoint (end 0|1) — lets an E2E drive a precise drag
2962
3059
  function screenOf(id, end) {
2963
- const m = members().find((x) => x.id === id); if (!m) return null;
3060
+ const m = memberById(id); if (!m) return null;
2964
3061
  const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm());
2965
3062
  const s = toScreen(g.line[end]); const rect = canvasEl.getBoundingClientRect();
2966
3063
  return { x: rect.left + s.x, y: rect.top + s.y };
@@ -2992,7 +3089,7 @@ window.Steel3DView = {
2992
3089
  setSelLenLabels, // on-select member-length labels: editor pushes [{id,text}] (⋯ Display "Show member length")
2993
3090
  propLabelTexts: () => propLabelPool.filter((el) => el.style.display !== 'none' && el.style.visibility !== 'hidden').map((el) => el.textContent), // visible property-label chips — for tests
2994
3091
  selLenLabelTexts: () => selLenLabelPool.filter((el) => el.style.display !== 'none' && el.style.visibility !== 'hidden').map((el) => el.textContent), // visible on-select length chips — for tests
2995
- epScreen: (id) => { const m = members().find((x) => x.id === id); if (!m || !canvasEl) return null; const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm()); const rect = canvasEl.getBoundingClientRect(); const proj = (p) => { const v = new THREE.Vector3(p[0], p[1], p[2]).project(camera); return { x: rect.left + (v.x * 0.5 + 0.5) * rect.width, y: rect.top + (-v.y * 0.5 + 0.5) * rect.height }; }; return { a: proj(g.line[0]), b: proj(g.line[1]) }; }, // project a member's endpoints to viewport px — test probe for endpoint-drag tests
3092
+ epScreen: (id) => { const m = memberById(id); if (!m || !canvasEl) return null; const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm()); const rect = canvasEl.getBoundingClientRect(); const proj = (p) => { const v = new THREE.Vector3(p[0], p[1], p[2]).project(camera); return { x: rect.left + (v.x * 0.5 + 0.5) * rect.width, y: rect.top + (-v.y * 0.5 + 0.5) * rect.height }; }; return { a: proj(g.line[0]), b: proj(g.line[1]) }; }, // project a member's endpoints to viewport px — test probe for endpoint-drag tests
2996
3093
  refreshGrid: buildStructGrid, // grid edited in the panel → re-render without a full rebuild
2997
3094
  gridInfo: () => ({ lines: structGridGroup ? 1 : 0, labels: gridLabelGroup ? gridLabelGroup.children.length : 0 }), // test helper
2998
3095
  toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups,