@floless/app 0.127.5 → 0.127.6

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.
@@ -2,7 +2,7 @@
2
2
  name: floless-app-steel-takeoff
3
3
  description: Read a structural steel drawing into an editable steel.takeoff/v1 contract in floless.app — the "Steel Takeoff" reader. Triggers on a pending floless `rebake` request for the `steel-model` app (queued from its "Re-read & re-bake ▸" button), or asks like "read this framing plan into a takeoff", "turn this structural drawing into a takeoff", "bake my drawing into steel-model", "extract members from this PDF". Teaches the host AI to READ a steel drawing (PDF/image) with its own vision at COMPOSE time, build a steel.takeoff/v1 contract (members + profiles + elevations + weights from AISC lookup), write it to the contract store, and hand control to the editor — no model in the run path, no API key.
4
4
  metadata:
5
- version: 0.17.0
5
+ version: 0.18.0
6
6
  ---
7
7
 
8
8
  # Steel Takeoff — read a drawing into a steel.takeoff/v1 contract
@@ -275,6 +275,14 @@ sheets (Foundation, each Floor, Roof). **Show the user the list and get an expli
275
275
  "I found these framing plans: Foundation, 2nd Floor, Roof — filter all of these?" — before the pass. (The full
276
276
  elevation/detail classification is the broader workflow; here we only need the plan set.)
277
277
 
278
+ **Narrow headless revision exception.** When floless.app's server-owned headless preamble explicitly
279
+ says this is a phase-one-only `revision-read`, exposes only the immutable leased PDF sources plus the
280
+ request-scoped contract/prepass calls, and requires the exact Steel Filter Save question, do not
281
+ create an earlier plan-confirmation checkpoint. Match framing pages only to the plan sheet names
282
+ already present in that project's current contract; if the match is absent or ambiguous, stop with
283
+ `needs-you` instead of inventing a plan name. This exception never applies to an initial read, an
284
+ interactive session, or phase two, and it is not permission to read members before the Filter Save.
285
+
278
286
  ⚠️ **This ONE plan-scope confirm covers both the filter pass AND the member read — they run on the
279
287
  same sheet set. Getting the OK does NOT mean "go read members"; the very next thing you do is the
280
288
  filter pass below, then hand off the Filter node. Do not let the confirm gate double as permission to
@@ -200,6 +200,53 @@ export function visibleGridLevels(levels = [], hiddenZ = []) {
200
200
  return (Array.isArray(levels) ? levels : []).filter((level) => !hidden.has(gridLevelKey(level && level.mm)));
201
201
  }
202
202
 
203
+ /**
204
+ * Identity of the authored grid currently rendered in 3D. Regular grid ids (`gv:i` / `gh:i`) are
205
+ * positional, so transient selection/visibility state may only survive while this signature is exact.
206
+ */
207
+ export function gridTransientScopeSignature(scopeKey, draw) {
208
+ return JSON.stringify([
209
+ String(scopeKey == null ? '' : scopeKey),
210
+ draw && draw.g ? draw.g : null,
211
+ draw && Number.isFinite(draw.k) ? draw.k : null,
212
+ !!(draw && draw.flipY),
213
+ ]);
214
+ }
215
+
216
+ /**
217
+ * Reconcile session-only 3D grid state against one completed structural-grid rebuild.
218
+ * A changed authored scope clears positional ids instead of silently applying them to another line.
219
+ */
220
+ export function reconcileGridTransientState(state = {}, validIds = [], scopeChanged = false) {
221
+ const valid = new Set(Array.isArray(validIds) ? validIds : []);
222
+ const priorSelected = Array.isArray(state.selected) ? state.selected : [];
223
+ const priorHidden = Array.isArray(state.hidden) ? state.hidden : [];
224
+ const priorIsolated = Array.isArray(state.isolated) ? state.isolated : null;
225
+ const meshIsolationCount = Number.isFinite(state.meshIsolationCount) ? Math.max(0, state.meshIsolationCount) : 0;
226
+ const keep = (ids) => ids.filter((id) => valid.has(id));
227
+ const selected = scopeChanged ? [] : keep(priorSelected);
228
+ const hidden = scopeChanged ? [] : keep(priorHidden);
229
+ let isolated = priorIsolated === null ? null : (scopeChanged ? [] : keep(priorIsolated));
230
+ const clearMeshIsolation = isolated !== null && isolated.length === 0 && meshIsolationCount === 0;
231
+ if (clearMeshIsolation) isolated = null;
232
+ const same = (a, b) => a === b || (Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((v, i) => v === b[i]));
233
+ return {
234
+ selected, hidden, isolated, clearMeshIsolation,
235
+ selectionChanged: !same(priorSelected, selected),
236
+ changed: !same(priorSelected, selected) || !same(priorHidden, hidden) || !same(priorIsolated, isolated) || clearMeshIsolation,
237
+ };
238
+ }
239
+
240
+ /** Class-neutral status copy for selections that include logical grid lines. */
241
+ export function objectSelectionStatus(meshCount = 0, gridCount = 0) {
242
+ const meshes = Math.max(0, Number.isFinite(meshCount) ? meshCount : 0);
243
+ const grids = Math.max(0, Number.isFinite(gridCount) ? gridCount : 0);
244
+ const total = meshes + grids;
245
+ if (total > 1) return `${total} objects selected`;
246
+ if (grids === 1) return '1 grid line selected';
247
+ return '';
248
+ }
249
+
203
250
  /**
204
251
  * Re-key source-indexed labels to the sorted/deduplicated level order while retaining every
205
252
  * non-empty label whose source elevation was dropped. Extras remain appended until the user
@@ -22,13 +22,14 @@ import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
22
22
  import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf } from './steel-3d-core.js';
23
23
  // `gridGeometry`, `gridCandidates3d` and `mmPerPx` moved behind the host's model read half (unit 5, P7d):
24
24
  // each takes a `ptPerFt`, which is a v1 PLAN default and meaningless on a world-mm model grid.
25
- import { visibleGridLevels } from './grid-core.js';
25
+ import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
26
26
 
27
27
  let renderer, scene, perspCam, orthoCam, camera, controls, root, api, canvasEl, ro, rafId, grid, raycaster, downXY, lastPick = '(none)';
28
28
  let lightAmb, lightKey, lightFill; // dimmed in Realistic, where the environment lights the scene
29
29
  let shadowGround = null, shadowsEnabled = false; // the `shadowed` mode's ground catcher + its compiled state
30
30
  let pending = null, dragging = null, marker = null, readout = null; // pending = member gesture; readout = drag dimension overlay
31
31
  let boxSel = null, rubber = null; // LEFT-drag-on-empty rubber-band multi-select
32
+ let selectionTrace = null; // last ordinary pointer-selection route (read-only E2E diagnostic)
32
33
  let hoverId = null, hoverGlowIds = [], hoverChip = null, hoverRAF = 0, lastHoverXY = null; // hover readout + cursor; hoverGlowIds = every mesh currently wearing the sky glow (the WHOLE connection when hovering one of its parts)
33
34
  let epGroup = null; // yellow/magenta endpoint markers (start/end direction dots)
34
35
  let epGeom = null, epMatStart = null, epMatEnd = null; // shared across all endpoint dots (no per-rebuild churn)
@@ -73,6 +74,8 @@ let soloGroups = new Set(); // profile keys isolated via the leg
73
74
  let isolatedIds = null; // Tekla "isolate selected": Set of ids shown exclusively, or null for off
74
75
  let connHidden = new Set(); // explicit per-PART hide (legend connection rows) — lets a shared part-kind (weld/nut) hide per-connection by id, not per group
75
76
  let selectionHidden = new Set(); // session-only per-mesh hide from the toolbar's Hide selected action; raw renderer ids never enter the tagged saved-view contract
77
+ let isolatedGridIds = null; // isolate-selected's logical grid-line half; null = no isolation, an empty Set intentionally hides every grid
78
+ let gridSelectionHidden = new Set(); // session-only logical grid lines hidden by Hide selected (never mutates the authored grid)
76
79
  let cube = null; // ViewCube { renderer, scene, cam, mesh, faces }
77
80
  let triad = null; // world-axis triad { renderer, scene, cam, group } — passive X/Y/Z readout
78
81
  const DRAG_TOL_PX = 4; // movement past this = a drag (not a click)
@@ -885,14 +888,17 @@ function buildFromScene(sc) {
885
888
  dimParts = (sc.elements || []).filter((el) => el && (el.kind === 'plate' || el.kind === 'cut'));
886
889
  renderClipGizmo(); // re-anchor the selected clip's gizmo to the (possibly new) sceneBox after a rebuild
887
890
  buildGrid(box);
891
+ // Reconcile mesh visibility BEFORE the structural grid: mixed member+grid isolation needs the
892
+ // grid reconciler to see the surviving mesh count, otherwise deleting the last isolated member
893
+ // while the grid changes can leave an empty grid isolation active indefinitely.
894
+ const hadVisibilityFilter = hasVisibilityFilter();
895
+ if (isolatedIds) { isolatedIds = new Set([...isolatedIds].filter((id) => meshById.has(id))); if (!isolatedIds.size && isolatedGridIds === null) isolatedIds = null; } // drop removed mesh ids; preserve the intentional empty mesh half of a surviving grid isolation, otherwise exit mesh-only isolation
896
+ if (connHidden.size) connHidden = new Set([...connHidden].filter((id) => meshById.has(id))); // drop per-part hides whose mesh an edit removed
897
+ if (selectionHidden.size) selectionHidden = new Set([...selectionHidden].filter((id) => meshById.has(id))); // drop transient hides whose mesh an edit removed
888
898
  buildStructGrid();
889
899
  buildRefLines();
890
900
  syncMemberLabels(); // refresh the member-label pool from the (possibly edited) member set
891
901
  syncPropLabels(); // re-anchor the property labels too (member geometry may have moved)
892
- const hadVisibilityFilter = hasVisibilityFilter();
893
- if (isolatedIds) { isolatedIds = new Set([...isolatedIds].filter((id) => meshById.has(id))); if (!isolatedIds.size) isolatedIds = null; } // drop ids an edit removed; if none survive, exit isolation
894
- if (connHidden.size) connHidden = new Set([...connHidden].filter((id) => meshById.has(id))); // drop per-part hides whose mesh an edit removed
895
- if (selectionHidden.size) selectionHidden = new Set([...selectionHidden].filter((id) => meshById.has(id))); // drop transient hides whose mesh an edit removed
896
902
  if (hadVisibilityFilter !== hasVisibilityFilter()) notifyVisibilityChange(); // keep the host's recovery control honest when an edit removes the last hidden/isolated mesh
897
903
  applyGroupVisibility(); applyDisplayMode();
898
904
  built = true;
@@ -2042,6 +2048,7 @@ let structGridGroup = null, gridLabelGroup = null;
2042
2048
  let gridLevelsMm = []; // world Zs the grid is DRAWN at (one per visible level) — set by buildStructGrid so grid snapping can never drift from what the user sees
2043
2049
  const structGridLines = new Map();
2044
2050
  let selectedGridIds = new Set();
2051
+ let structGridSignature = null;
2045
2052
  const gridTexCache = new Map(); // 'b:LABEL' bubble / 't:LABEL' tag -> CanvasTexture (kept until dispose)
2046
2053
 
2047
2054
  // Snap targets for the 3D tools. Members come from the WHOLE model — every sheet, not just the active
@@ -2114,23 +2121,24 @@ function clearStructGrid() {
2114
2121
  structGridGroup = gridLabelGroup = null;structGridLines.clear();gridLevelsMm = [];
2115
2122
  }
2116
2123
  function buildStructGrid() {
2117
- clearStructGrid();
2118
2124
  dimCandidates3d = null; tfCandidates = null; clipCandidates = null; clipLevels = null; invalidateModelCache(); // the grid just changed → EVERY cached snap set built from the OLD one is stale (dim, Move/Copy + Add, clip-box draw). rebuild() already nulls these, but refresh3DGrid() (grid panel edits, and the plan switch setPlan now fires) reaches us without it, which would pair one sheet's grid X/Y with another's elevations.
2119
- if (!api || !scene) return;
2120
2125
  // THE GRID NEEDS ITS OWN v2 PATH, and this is the one place it shows (§8.3). v1's grid is stored in the
2121
2126
  // active sheet's DISPLAY space — px, with Y growing DOWN the page — so the two conversions below are a
2122
2127
  // scale AND a reflection. v2's grid is already world mm with Y up. Handing a world-mm grid to the v1
2123
2128
  // conversion would not throw; it would draw the whole grid mirrored about Y, plausibly, at 1/12 scale.
2124
2129
  // So the read half answers with the drawable geometry AND the two facts needed to place it.
2125
2130
  let d = null;
2126
- try { d = MODEL().gridDraw(); }
2127
- catch (e) { console.warn('[steel-3d] grid skipped (bad grid data)', e); return; }
2128
- if (!d) return; // no grid, or the grid is switched off
2131
+ try { if(api&&scene)d = MODEL().gridDraw(); }
2132
+ catch (e) { console.warn('[steel-3d] grid skipped (bad grid data)', e); }
2133
+ const nextSignature=gridTransientScopeSignature(api&&api.gridScopeKey?api.gridScopeKey():'',d),scopeChanged=structGridSignature!==null&&nextSignature!==structGridSignature;
2134
+ structGridSignature=nextSignature;clearStructGrid();
2135
+ const finish=()=>{reconcileGridVisibilityState(scopeChanged);applyGridVisibility();};
2136
+ if (!api || !scene || !d) {finish();return;} // no grid, switched off, or bad grid data
2129
2137
  const { g, geo, k, flipY } = d;
2130
- if (!geo.v.length && !geo.h.length && !(geo.lines && geo.lines.length)) return;
2138
+ if (!geo.v.length && !geo.h.length && !(geo.lines && geo.lines.length)) {finish();return;}
2131
2139
  const mmX = (u) => u * k, mmY = (u) => (flipY ? -u : u) * k; // stored space → scene
2132
2140
  const levels = geo.zs.length ? visibleGridLevels(geo.zs, g.hidden_z) : [{ mm: 0, label: '0' }];
2133
- if (!levels.length) return; // every authored Z datum is hidden
2141
+ if (!levels.length) {finish();return;} // every authored Z datum is hidden
2134
2142
  gridLevelsMm = levels.map((lv) => lv.mm); // the planes grid snapping evaluates on — same list, same order as what gets drawn below
2135
2143
  structGridGroup = new THREE.Group();
2136
2144
  // Drawn at the level's TRUE Z. It used to sit 25 mm under it ("no z-fight/burial"), but the snap
@@ -2160,6 +2168,7 @@ function buildStructGrid() {
2160
2168
  (geo.lines || []).forEach((l,i)=>{const id='gl:'+(l.id!=null?l.id:i);sprite(gridBubbleTexture(l.label), mmX(l.a[0]), mmY(l.a[1]), z0, dia, dia,l.label,id); sprite(gridBubbleTexture(l.label), mmX(l.b[0]), mmY(l.b[1]), z0, dia, dia,l.label,id);});
2161
2169
  if (geo.zs.length) for (const lv of levels) sprite(gridTagTexture(lv.label), mmX(geo.x0), mmY(geo.y1), lv.mm, dia * 4.8, dia * 0.75,lv.label); // 6.4:1 sprite matches the tag texture, so long elevation labels stay undistorted
2162
2170
  overlayScene.add(gridLabelGroup);
2171
+ finish();
2163
2172
  }
2164
2173
 
2165
2174
  // The ortho frustum half-height in world units (set by a fit to the box, or by a projection toggle
@@ -2453,7 +2462,13 @@ function visibleMemberIds() {
2453
2462
  for (const [id, m] of meshById) if (m.visible && !m.userData.derived) out.push(id);
2454
2463
  return out;
2455
2464
  }
2456
- function notifyVisibilityChange() { if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null); }
2465
+ function visibleObjectIds() {
2466
+ const out = [];
2467
+ for (const [id, m] of meshById) if (m.visible) out.push(id);
2468
+ return out;
2469
+ }
2470
+ function visibleGridIds() { return [...structGridLines].filter(([, line]) => line.visible).map(([id]) => id); }
2471
+ function notifyVisibilityChange() { if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null || isolatedGridIds !== null); }
2457
2472
  function toggleGroup(k) { if (groupHidden.has(k)) groupHidden.delete(k); else groupHidden.add(k); soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
2458
2473
  // Hide/show a SET of groups in one pass (a legend type-category master toggle) — deterministic (not a flip),
2459
2474
  // so "hide all" / "show all" for the category is exact. Clears solo, like toggleGroup.
@@ -2464,7 +2479,7 @@ function setIdsHidden(ids, hidden) { for (const id of (ids || [])) { if (hidden)
2464
2479
  // Isolate an explicit SET of profile groups (the editor's legend builds it from Ctrl/Shift dbl-clicks, Explorer-style).
2465
2480
  function setSoloGroups(keys) { soloGroups = new Set((keys || []).filter((k) => k != null)); if (soloGroups.size) groupHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
2466
2481
  function soloToggle(k) { setSoloGroups(soloGroups.size === 1 && soloGroups.has(k) ? [] : [k]); } // plain dbl-click: isolate just this group (or clear if it's already the only one)
2467
- function showAllGroups() { groupHidden.clear(); soloGroups.clear(); isolatedIds = null; connHidden.clear(); selectionHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
2482
+ function showAllGroups() { groupHidden.clear(); soloGroups.clear(); isolatedIds = null; isolatedGridIds = null; connHidden.clear(); selectionHidden.clear(); gridSelectionHidden.clear(); applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
2468
2483
  function groupState() { return { hidden: [...groupHidden], solo: [...soloGroups] }; }
2469
2484
  // One serialisable snapshot of the objects-list pane's PERSISTENT visibility state — group hide/solo +
2470
2485
  // isolate-selected + per-part legend hides. This is what a saved view (Views Organizer) captures; it
@@ -2481,18 +2496,19 @@ function applyObjectsPaneState(s) {
2481
2496
  isolatedIds = (Array.isArray(s.isolated) && s.isolated.length) ? new Set(s.isolated) : null;
2482
2497
  connHidden = new Set(Array.isArray(s.connHidden) ? s.connHidden : []);
2483
2498
  selectionHidden.clear(); // Hide selected is session-only; applying a saved view restores its authored persistent visibility without leaking the current session filter
2484
- applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims();
2499
+ gridSelectionHidden.clear(); isolatedGridIds = isolatedIds === null ? null : new Set(); // saved member-only isolation still means "only these objects"; raw logical-grid ids remain session-only
2500
+ applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims();
2485
2501
  notifyVisibilityChange();
2486
2502
  }
2487
2503
  // Tekla "isolate selected": show ONLY the currently-selected parts (a snapshot taken now — distinct from
2488
2504
  // soloToggle, which isolates a whole PROFILE group from the legend). clearIsolation / showAllGroups restore all.
2489
- function isolateSelected() { if (!selIds.size) return false; isolatedIds = new Set(selIds); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return true; }
2505
+ function isolateSelected() { if (!selIds.size && !selectedGridIds.size) return false; isolatedIds = new Set(selIds); isolatedGridIds = new Set(selectedGridIds); applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return true; }
2490
2506
  // Hide the current selection by explicit mesh id. This remains session-only because v2 saved views require tagged
2491
2507
  // SceneRefs while the renderer owns raw ids; broadening that contract is a separate migration, not toolbar state.
2492
- function hideSelected() { const ids = [...selIds].filter((id) => meshById.has(id)); if (!ids.length) return 0; for (const id of ids) selectionHidden.add(id); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return ids.length; }
2493
- function clearIsolation() { if (isolatedIds === null) return; isolatedIds = null; applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
2494
- function isIsolated() { return isolatedIds !== null; }
2495
- function hasVisibilityFilter() { return isolatedIds !== null || groupHidden.size > 0 || soloGroups.size > 0 || connHidden.size > 0 || selectionHidden.size > 0; }
2508
+ function hideSelected() { const ids = [...selIds].filter((id) => meshById.has(id)), gridIds = [...selectedGridIds].filter((id) => structGridLines.has(id)); if (!ids.length && !gridIds.length) return 0; for (const id of ids) selectionHidden.add(id); for (const id of gridIds) gridSelectionHidden.add(id); applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return ids.length + gridIds.length; }
2509
+ function clearIsolation() { if (isolatedIds === null && isolatedGridIds === null) return; isolatedIds = null; isolatedGridIds = null; applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
2510
+ function isIsolated() { return isolatedIds !== null || isolatedGridIds !== null; }
2511
+ function hasVisibilityFilter() { return isolatedIds !== null || isolatedGridIds !== null || groupHidden.size > 0 || soloGroups.size > 0 || connHidden.size > 0 || selectionHidden.size > 0 || gridSelectionHidden.size > 0; }
2496
2512
  function getGroups() { return sceneGroups.map((g) => ({ ...g })); }
2497
2513
 
2498
2514
  // ---- clip planes / clip boxes (Tekla-style sectioning) ----
@@ -3006,7 +3022,7 @@ function onKey(e) {
3006
3022
  if (insertMode && e.key === 'Escape') { e.preventDefault(); setInsertMode(false); if (api && api.toast) api.toast('Insert cancelled'); return; } // Esc disarms the detail-placement pick
3007
3023
  if (basePickCol && e.key === 'Escape') { e.preventDefault(); setBasePickMode(null); if (api && api.toast) api.toast('Trim cancelled'); return; } // Esc disarms the Mode B column-base pick
3008
3024
  if (clipMode && e.key === 'Escape') { e.preventDefault(); if (clipMode === 'box' && clipBoxDraft) { if (clipBoxDraft.b) clipBoxDraft.b = null; else clipBoxDraft = null; setClipPreview(null); if (marker) marker.visible = false; updateStatusChip(); } else setClipMode(null); return; } // Esc steps back: height→footprint→cancel, else disarms the pick
3009
- if (isolatedIds && e.key === 'Escape' && !dimMode3d) { e.preventDefault(); clearIsolation(); return; } // Esc exits isolate-selected (the dim tool's own Esc wins while it's armed)
3025
+ if (isIsolated() && e.key === 'Escape' && !dimMode3d) { e.preventDefault(); clearIsolation(); return; } // Esc exits isolate-selected (the dim tool's own Esc wins while it's armed)
3010
3026
  // Esc ascends the REFERENCE drill: one object → the whole reference. ONE RUNG ONLY — unlike the
3011
3027
  // connection ladder below, which is part → whole → nothing. A reference is borrowed geometry you keep
3012
3028
  // selected while you build against it, so Esc stops at the reference rather than clearing it; the
@@ -3811,7 +3827,22 @@ function pickGridAt(cx,cy){
3811
3827
  return best;
3812
3828
  }
3813
3829
 
3814
- function setGridSelection(ids){selectedGridIds=ids instanceof Set?new Set(ids):new Set(ids||[]);for(const [id,line] of structGridLines){line.material.color.setHex(selectedGridIds.has(id)?0x3b82f6:0x64748b);line.material.opacity=selectedGridIds.has(id)?1:0.85;}}
3830
+ function applyGridVisibility(){
3831
+ let anyLine=false;
3832
+ for(const [id,line] of structGridLines){const on=(isolatedGridIds===null||isolatedGridIds.has(id))&&!gridSelectionHidden.has(id);line.visible=on;if(on)anyLine=true;}
3833
+ if(gridLabelGroup)for(const label of gridLabelGroup.children){const id=label.userData&&label.userData.gridId;label.visible=id?((isolatedGridIds===null||isolatedGridIds.has(id))&&!gridSelectionHidden.has(id)):anyLine;}
3834
+ }
3835
+ function reconcileGridVisibilityState(scopeChanged=false){
3836
+ const next=reconcileGridTransientState({
3837
+ selected:[...selectedGridIds],hidden:[...gridSelectionHidden],isolated:isolatedGridIds===null?null:[...isolatedGridIds],
3838
+ meshIsolationCount:isolatedIds===null?0:isolatedIds.size,
3839
+ },[...structGridLines.keys()],scopeChanged);
3840
+ selectedGridIds=new Set(next.selected);gridSelectionHidden=new Set(next.hidden);isolatedGridIds=next.isolated===null?null:new Set(next.isolated);
3841
+ if(next.clearMeshIsolation){isolatedIds=null;applyGroupVisibility();rebuildEndpoints();refreshOverlayDims();refreshDims();}
3842
+ if(next.selectionChanged&&api&&api.onGridSelectionReset)api.onGridSelectionReset();
3843
+ if(next.changed){updateStatusChip();notifyVisibilityChange();}
3844
+ }
3845
+ function setGridSelection(ids){selectedGridIds=ids instanceof Set?new Set(ids):new Set(ids||[]);for(const [id,line] of structGridLines){line.material.color.setHex(selectedGridIds.has(id)?0x3b82f6:0x64748b);line.material.opacity=selectedGridIds.has(id)?1:0.85;}updateStatusChip();}
3815
3846
  // Raycast ALL visible meshes — members AND derived connection parts — at a client point → ids
3816
3847
  // front-to-back (nearest first), deduped. Backs click-to-cycle so a small plate/bolt/weld stacked on a
3817
3848
  // beam at a joint is reachable without a modifier (D). pickAt stays members-only — the down-gesture
@@ -3831,6 +3862,7 @@ const CYCLE_TOL_PX = 8;
3831
3862
  function resetCycle() { cycleAnchor = null; cycleIds = []; cycleIdx = 0; }
3832
3863
  function clickSelect(cx, cy, ctrl) {
3833
3864
  let hits = []; try { hits = pickAllAt(cx, cy); } catch { hits = []; }
3865
+ selectionTrace={phase:'up-pick',x:cx,y:cy,ownHits:hits.slice(0,4)};
3834
3866
  if (hits.length) selectReference(null); // anything of OURS under the cursor drops a reference selection
3835
3867
  if (!hits.length) {
3836
3868
  // Nothing of ours here — only NOW may a reference answer. Consulted second, never first, so a
@@ -3841,7 +3873,12 @@ function clickSelect(cx, cy, ctrl) {
3841
3873
  // stacked inside a connection, and it is free here: the modifier's other meaning (additive select)
3842
3874
  // belongs to the branch above, which this arm is only ever reached instead of.
3843
3875
  let ref = null; try { ref = pickReferenceAt(cx, cy); } catch { ref = null; }
3876
+ selectionTrace={...selectionTrace,reference:ref,referenceAllowed:!api||!api.canSelectReference||api.canSelectReference()};
3844
3877
  if (ref) {
3878
+ // A filtered class is inert: hitting it must not be reinterpreted as empty canvas, because that
3879
+ // would clear the selection the user already has. Selection filtering and visibility remain
3880
+ // independent, just as they are for native members.
3881
+ if (api && api.canSelectReference && !api.canSelectReference()) return;
3845
3882
  resetCycle();
3846
3883
  // The drill FALLS BACK to selecting the whole reference when the object cannot be addressed
3847
3884
  // (`objectIndex` -1 from a mesh built before this existed). Refusing outright would make Ctrl+click
@@ -4441,6 +4478,7 @@ const tfLock = new Set(); // subset of {'u','v','n'} the move is LINE-loc
4441
4478
  let tfCandidates = null;
4442
4479
  let tfGhost = null, tfRubber = null, tfRubberA = null, tfGhostMat = null;
4443
4480
  const cmActive = () => (api && api.cmState ? api.cmState() : null);
4481
+ const cmTargetPresent = (st) => !!(selIds.size || (st && st.tool === 'move' && st.referenceId && xrefSelected === st.referenceId && !xrefSubSelected));
4444
4482
  const cmHasBase = () => !!tfDraft;
4445
4483
  const cmLastClient = () => tfLastClient;
4446
4484
  // X/Y/Z each TOGGLE their axis in the lock set (press again to release, press another to ADD → the move
@@ -4567,7 +4605,11 @@ function tfGhostBuild(offs) {
4567
4605
  tfDisposeGhost(); // dispose the previous rebuild's own geometries (the >600 boxes) before dropping it
4568
4606
  tfGhost = new THREE.Group();
4569
4607
  if (!tfGhostMat) { tfGhostMat = new THREE.MeshBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: 0.3, depthWrite: false }); }
4570
- const sel = [...selIds].map((id) => meshById.get(id)).filter((m) => m && m.visible);
4608
+ const st = cmActive(), sel = [...selIds].map((id) => meshById.get(id)).filter((m) => m && m.visible);
4609
+ if (!sel.length && st && st.referenceId === xrefSelected && !xrefSubSelected) {
4610
+ const entry = xrefById.get(st.referenceId);
4611
+ if (entry && entry.group.visible) entry.group.traverse((m) => { if (m.isMesh && m.visible) sel.push(m); });
4612
+ }
4571
4613
  if (sel.length * offs.length <= 600) {
4572
4614
  for (const off of offs) for (const m of sel) {
4573
4615
  const c = new THREE.Mesh(m.geometry, tfGhostMat); // shares the source geometry — nothing to dispose
@@ -4607,7 +4649,7 @@ function tfPreview(e) {
4607
4649
  }
4608
4650
  function tfClick(e) {
4609
4651
  const st = cmActive(); if (!st) return false;
4610
- if (!selIds.size) { // selection drained while armed (undo/delete) — end the tool and let the click SELECT instead
4652
+ if (!cmTargetPresent(st)) { // selection drained while armed (undo/delete) — end the tool and let the click SELECT instead
4611
4653
  if (api && api.toast) api.toast('Selection is empty — ' + (st.tool === 'move' ? 'Move' : 'Copy') + ' ended');
4612
4654
  if (api && api.disarmTransform) api.disarmTransform();
4613
4655
  return false;
@@ -4959,6 +5001,10 @@ function onDown(e) {
4959
5001
  }
4960
5002
  let gridHit=null,allMeshHits=[];try{gridHit=pickGridAt(e.clientX,e.clientY);}catch(err){console.error('steel-3d: grid hit-test failed',err);}try{allMeshHits=meshHitsAt(e.clientX,e.clientY);}catch(err){console.error('steel-3d: mesh hit-test failed',err);}const gridAllowed=!api||!api.canSelectGrid||api.canSelectGrid(),gridOccluders=OPAQUE_MODES.has(displayMode)?allMeshHits.filter(occludesGrid):[],meshDepth=gridOccluders.length?gridOccluders[0].point.clone().project(camera).z:Infinity,gridInFront=gridHit&&gridDepthWins(gridHit.depth,meshDepth);if(gridHit&&!gridAllowed&&gridInFront){e.stopPropagation();controls.enabled=false;pending={filteredGrid:true};return;} // Deliberately consume the LEFT select gesture like 2D when the visible grid is frontmost: a filtered grid stays inert and preserves selection. RIGHT-drag orbit is a separate handler.
4961
5003
  const gridWins=gridAllowed&&gridHit&&gridInFront;if(gridWins){e.stopPropagation();controls.enabled=false;pending={gridId:gridHit.id,add:e.ctrlKey||e.metaKey||e.shiftKey};return;} // Compare projected depth in Solid; Wire/X-ray fills do not write depth and therefore cannot phantom-occlude a visible grid.
5004
+ // Consume a filtered reference on DOWN, before it can become an empty-space box/click gesture. The
5005
+ // up-side picker repeats this guard defensively, but a real pointer lifecycle may otherwise clear the
5006
+ // current native selection before that late raycast gets a vote.
5007
+ if(!id&&api&&api.canSelectReference&&!api.canSelectReference()){let filteredRef=null;try{filteredRef=pickReferenceAt(e.clientX,e.clientY);}catch{}selectionTrace={phase:'down-filter',x:e.clientX,y:e.clientY,own:id,reference:filteredRef,referenceAllowed:false};if(filteredRef){e.stopPropagation();controls.enabled=false;pending={filteredReference:true};return;}}
4962
5008
  if (!id) { pending = null; boxSel = { x: e.clientX, y: e.clientY }; return; } // empty space → box-select on drag
4963
5009
  e.stopPropagation(); controls.enabled = false; // grabbed a member → suppress orbit (enabled=false is the reliable guard)
4964
5010
  try {
@@ -5209,7 +5255,7 @@ function onMove(e) {
5209
5255
  if (pending && pending.clipDrag) { onMoveClip(e); return; } // dragging a clip handle (plane offset / box face)
5210
5256
  if (pending && pending.frameDrag) { onMoveFrame(e); return; } // dragging the local-frame origin / rotation ring
5211
5257
  if (!pending || pending.geo) return;
5212
- if (pending.gridId||pending.filteredGrid) { const d=Math.hypot(e.clientX-downXY[0],e.clientY-downXY[1]);if(d<=DRAG_TOL_PX)return;pending=null;controls.enabled=true;boxSel={x:downXY[0],y:downXY[1]};onBoxMove(e);return; } // any grid press becomes a normal marquee once it moves, even when grid selection is filtered off; only a true click stays grid-specific/inert
5258
+ if (pending.gridId||pending.filteredGrid||pending.filteredReference) { const d=Math.hypot(e.clientX-downXY[0],e.clientY-downXY[1]);if(d<=DRAG_TOL_PX)return;pending=null;controls.enabled=true;boxSel={x:downXY[0],y:downXY[1]};onBoxMove(e);return; } // a filtered-reference/grid click stays inert, but once it moves the same press becomes a normal marquee so an overlay cannot blanket-disable box selection
5213
5259
  if (pending.epDrag) { onMoveEndpoint(e); return; }
5214
5260
  if (!pending.grab || !pending.origMm) return;
5215
5261
  if (!dragging && Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) <= DRAG_TOL_PX) return;
@@ -5317,7 +5363,7 @@ const gridPlaneSpecs=planes=>(planes||[]).map(p=>({normal:[p.normal.x,p.normal.y
5317
5363
  function visibleGridSegment(a,b){return clipSegmentToPlanes(a,b,gridPlaneSpecs(renderer&&renderer.clippingPlanes));}
5318
5364
  function gridCameraFrustum(){camera.updateMatrixWorld();return new THREE.Frustum().setFromProjectionMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix,camera.matrixWorldInverse));}
5319
5365
  function cameraVisibleGridSegment(p,frustum){return clipSegmentToPlanes(p[0],p[1],gridPlaneSpecs(frustum&&frustum.planes));}
5320
- function gridsInRect(x0,y0,x1,y1,windowMode){const rect=canvasEl.getBoundingClientRect(),r=[Math.min(x0,x1),Math.min(y0,y1),Math.max(x0,x1),Math.max(y0,y1)],out=[],frustum=gridCameraFrustum();const screen=p=>{const v=new THREE.Vector3(...p).project(camera);return Number.isFinite(v.x)&&Number.isFinite(v.y)?[rect.left+(v.x*.5+.5)*rect.width,rect.top+(-v.y*.5+.5)*rect.height]:null;};for(const [id,line] of structGridLines){const pts=line.userData.segments||[];let hit=false;for(let i=0;i+1<pts.length;i+=2){const sectionVisible=visibleGridSegment(pts[i],pts[i+1]),vis=sectionVisible&&cameraVisibleGridSegment(sectionVisible,frustum);if(!vis)continue;const a=screen(vis[0]),b=screen(vis[1]);if(!a||!b)continue;if(segmentHitsRect2d(a,b,r,windowMode)){hit=true;break;}}if(hit)out.push(id);}return out;} // Keep raw hits even when grid selection is filtered off; the host batch filter uses them to make filtered-only marquees inert instead of clearing the current selection.
5366
+ function gridsInRect(x0,y0,x1,y1,windowMode){const rect=canvasEl.getBoundingClientRect(),r=[Math.min(x0,x1),Math.min(y0,y1),Math.max(x0,x1),Math.max(y0,y1)],out=[],frustum=gridCameraFrustum();const screen=p=>{const v=new THREE.Vector3(...p).project(camera);return Number.isFinite(v.x)&&Number.isFinite(v.y)?[rect.left+(v.x*.5+.5)*rect.width,rect.top+(-v.y*.5+.5)*rect.height]:null;};for(const [id,line] of structGridLines){if(!line.visible)continue;const pts=line.userData.segments||[];let hit=false;for(let i=0;i+1<pts.length;i+=2){const sectionVisible=visibleGridSegment(pts[i],pts[i+1]),vis=sectionVisible&&cameraVisibleGridSegment(sectionVisible,frustum);if(!vis)continue;const a=screen(vis[0]),b=screen(vis[1]);if(!a||!b)continue;if(segmentHitsRect2d(a,b,r,windowMode)){hit=true;break;}}if(hit)out.push(id);}return out;} // Keep visible raw hits even when grid selection is filtered off; the host batch filter uses them to make filtered-only marquees inert instead of clearing the current selection. Visibility-hidden grids never become phantom box hits.
5321
5367
  // Connection Components whose screen footprint (projected bbox) meets a marquee rect — so area-select picks
5322
5368
  // up connections, not just members. window: the whole footprint enclosed · crossing: it overlaps the rect.
5323
5369
  function connsInRect(x0, y0, x1, y1, windowMode) {
@@ -5392,7 +5438,7 @@ function onUp(e) {
5392
5438
  controls.enabled = true;
5393
5439
  const moved = downXY ? Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) : Infinity; downXY = null;
5394
5440
  if (!p) return;
5395
- if(p.filteredGrid)return;
5441
+ if(p.filteredGrid||p.filteredReference)return;
5396
5442
  if(p.gridId){if(moved>DRAG_TOL_PX)return;if(!p.add)resetConnState();if(api&&api.onSelectBatch)api.onSelectBatch({memberIds:[],gridIds:[p.gridId]},p.add);else if(api&&api.onSelectGrid)api.onSelectGrid(p.gridId,p.add);return;}
5397
5443
  if (p.clipDrag) return; // a clip handle drag is applied live during onMoveClip; nothing to commit on up (controls re-enabled above)
5398
5444
  if (p.frameDrag) { if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; tfCandidates = null; dimCandidates3d = null; return; } // local-frame origin/rotation is applied live during onMoveFrame; session-only, nothing to commit — clear the snap marker/readout AND re-null the snap caches (they were rebuilt sans the UCS origin during the drag) so the next Move/Dimension snaps TO the moved origin again (code-review)
@@ -5596,7 +5642,7 @@ function updateStatusChip() {
5596
5642
  if (!hoverChip || !canvasEl) return;
5597
5643
  const rect = canvasEl.getBoundingClientRect();
5598
5644
  let txt = '';
5599
- const showId = hoverId || (selIds.size === 1 ? [...selIds][0] : null);
5645
+ const selectionStatus=objectSelectionStatus(selIds.size,selectedGridIds.size),showId=hoverId||(!selectionStatus&&selIds.size===1?[...selIds][0]:null);
5600
5646
  // The badge follows the cursor and so clips away at the window edge — from there this chip is the
5601
5647
  // only thing still telling the user what releasing will do.
5602
5648
  if (teklaDrag && teklaDrag.active) {
@@ -5624,9 +5670,9 @@ function updateStatusChip() {
5624
5670
  else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
5625
5671
  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';
5626
5672
  else if (showId) { const m = memberById(showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
5627
- else if (selIds.size > 1) txt = `${selIds.size} members selected`;
5628
- else if (isolatedIds) txt = `Isolated: ${isolatedIds.size} · Show all to restore`;
5629
- else if (selectionHidden.size) txt = `${selectionHidden.size} objects hidden · Show all to restore`;
5673
+ else if (selectionStatus) txt = selectionStatus;
5674
+ else if (isIsolated()) txt = `Isolated: ${(isolatedIds ? isolatedIds.size : 0) + (isolatedGridIds ? isolatedGridIds.size : 0)} · Show all to restore`;
5675
+ else if (selectionHidden.size || gridSelectionHidden.size) txt = `${selectionHidden.size + gridSelectionHidden.size} objects hidden · Show all to restore`;
5630
5676
  // A read-only host (the vector 3D viewer) supplies its own idle hint — the default speaks editing
5631
5677
  // verbs (move/stretch/elevate) a viewer's no-op api would silently ignore. Otherwise the default
5632
5678
  // tells the truth about the drag-move/copy toggle (ON = drag-move + Ctrl-drag-copy; OFF = click-select).
@@ -5752,7 +5798,8 @@ function debug() {
5752
5798
  // the pixels valid. Exists so a MATERIAL change can be checked by looking at it, not only by
5753
5799
  // asserting on state — the whole point of Realistic is how it looks.
5754
5800
  snapshot: (quality = 0.82) => { renderer.render(scene, camera); return canvasEl.toDataURL('image/jpeg', quality); },
5755
- hidden: [...groupHidden], solo: [...soloGroups], isolated: isolatedIds ? [...isolatedIds] : null, selectionHidden: [...selectionHidden], visible: [...meshById.values()].filter((m) => m.visible).length,
5801
+ hidden: [...groupHidden], solo: [...soloGroups], isolated: isolatedIds ? [...isolatedIds] : null, selectionHidden: [...selectionHidden], gridIsolated: isolatedGridIds === null ? null : [...isolatedGridIds], gridSelectionHidden: [...gridSelectionHidden], visible: [...meshById.values()].filter((m) => m.visible).length,
5802
+ selected: [...selIds], selectedGrids: [...selectedGridIds], derivedIds: [...meshById].filter(([,m])=>m.userData&&m.userData.derived).map(([id])=>id),
5756
5803
  endpoints: epGroup ? epGroup.children.length : 0,
5757
5804
  endpointColors: epGroup ? epGroup.children.map((c) => '#' + c.material.color.getHexString()) : [],
5758
5805
  hoverId, hoverGlowIds: [...hoverGlowIds], hoverEp, dragEp, refLine: refLineOn, // hoverGlowIds = the group the hover glow is computed over (whole connection at root, one part once drilled) — hoverId alone can't show that grouping. Selection still beats hover, so a selected id in this set glows brand blue, not sky
@@ -5766,6 +5813,7 @@ function debug() {
5766
5813
  clips: getClips(), clipPlaneCount: renderer && renderer.clippingPlanes ? renderer.clippingPlanes.length : 0, clipMode, workArea: workAreaState(), selectedClips: [...selectedClipIds],
5767
5814
  workPlane: workPlaneInfo(), tfHasBase: !!tfDraft, tfGhosts: tfGhost ? tfGhost.children.length : 0, drHasStart: !!drDraft,
5768
5815
  wp: { origin: [...effectiveWP().origin], normal: [...effectiveWP().normal] }, // resolved working plane (◇ Plane, local UCS, or default level) — lets an E2E pick an off-plane vertex + assert the workplane-only snap constraint
5816
+ selectionTrace, selectedIds:[...selIds],
5769
5817
  };
5770
5818
  }
5771
5819
  // test helper: the current material colour + emissive of a member (verifies deselect restores colour)
@@ -5834,6 +5882,9 @@ function referenceObjectsScreen(refId, opts) {
5834
5882
  }
5835
5883
  return out;
5836
5884
  }
5885
+ // Read-only E2E diagnostic for the exact ordinary-selection raycasts at one client pixel. This keeps
5886
+ // browser verification on the real picker without exposing or mutating selection state.
5887
+ function selectionHitAtScreen(x,y){let own=null,ref=null;try{own=pickAt(x,y);}catch{}try{ref=pickReferenceAt(x,y);}catch{}return {own,reference:ref,referenceAllowed:!api||!api.canSelectReference||api.canSelectReference(),pending:pending?{filteredReference:!!pending.filteredReference,filteredGrid:!!pending.filteredGrid}:null,box:!!boxSel};}
5837
5888
  // test helper: projected, clip-trimmed structural-grid segments. E2E uses these coordinates to drive a
5838
5889
  // real line click / marquee without guessing where an oblique 3D line landed after camera fitting.
5839
5890
  function gridSegmentsScreen() {
@@ -5869,6 +5920,7 @@ window.Steel3DView = {
5869
5920
  refMeasureLabelText: () => (refMeasureLabel && refMeasureLabel.style.display !== 'none' ? refMeasureLabel.textContent : null),
5870
5921
  refMeasureLineOn: () => !!(refMeasureLine && refMeasureLine.visible),
5871
5922
  refMeasurePointAtScreen: (x, y) => refMeasurePointAt({ clientX: x, clientY: y }), // test probe: what WOULD snap at a cursor — read-only, no pick
5923
+ selectionHitAtScreen,
5872
5924
  refCandidateCount: (id) => referenceCandidates(id).length, // test probe: how many points the restricted set offers
5873
5925
  // TEST PROBE FOR THE RESTRICTION ITSELF, and it exists because nothing else can see it: swap
5874
5926
  // referenceCandidates(refId) for allCandidates(null) and every other assertion in this feature still
@@ -5886,12 +5938,12 @@ window.Steel3DView = {
5886
5938
  epScreen: (id) => { const m = memberById(id); if (!m || !canvasEl) return null; const g = geoOf(m); 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
5887
5939
  refreshGrid: buildStructGrid, // grid edited in the panel → re-render without a full rebuild
5888
5940
  armGridLinePick3d, gridLinePick3dState: () => (gridLinePick3d ? { armed: true, hasFirst: !!gridLinePick3d.a, a: gridLinePick3d.a || null } : { armed: false, hasFirst: false, a: null }), // grid panel "Add single line" in 3D (+ test probe)
5889
- gridInfo: () => ({ lines: structGridLines.size, labels: gridLabelGroup ? gridLabelGroup.children.length : 0,labelTexts:gridLabelGroup?[...new Set(gridLabelGroup.children.map(s=>s.userData.label).filter(Boolean))]:[],selected:[...selectedGridIds],ids:[...structGridLines.keys()] }), // test helper
5941
+ gridInfo: () => ({ lines: structGridLines.size, labels: gridLabelGroup ? gridLabelGroup.children.length : 0,labelTexts:gridLabelGroup?[...new Set(gridLabelGroup.children.map(s=>s.userData.label).filter(Boolean))]:[],selected:[...selectedGridIds],ids:[...structGridLines.keys()],visible:visibleGridIds(),hidden:[...gridSelectionHidden],isolated:isolatedGridIds===null?null:[...isolatedGridIds] }), // test helper
5890
5942
  wpProbe: () => { // test helper: the "Show plane" reference surface — asserts no grid, bbox-sized surface, light-blue colour. `extent` is the projected u/v footprint the surface was actually sized to (work-area/tilted-plane aware), null for the fallback square. Surface w == extent.uSpan + 2*extent.margin.
5891
5943
  if (!wpGroup) return { group: false, extent: wpExtent };
5892
5944
  return { group: true, extent: wpExtent, children: wpGroup.children.map((c) => ({ type: c.type, color: c.material && '#' + c.material.color.getHexString(), opacity: c.material && c.material.opacity, w: c.geometry && c.geometry.parameters ? c.geometry.parameters.width : null, h: c.geometry && c.geometry.parameters ? c.geometry.parameters.height : null })) };
5893
5945
  },
5894
- toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], selectionHiddenIds: () => [...selectionHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups, visibleMemberIds,
5946
+ toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], selectionHiddenIds: () => [...selectionHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups, visibleMemberIds, visibleObjectIds, visibleGridIds,
5895
5947
  setClipMode, clipMode: clipModeOn, addClipBox, toggleClip, removeClip, clearClips, getClips, renameClip, selectClip, setSelectedClips, selectedClips, deleteSelectedClips, clipState, setClipState,
5896
5948
  isolateSelected, hideSelected, clearIsolation, isIsolated, hasVisibilityFilter,
5897
5949
  cameraState, setCameraState, sectionViewState, sceneBounds, objectsPaneState, applyObjectsPaneState, // saved-view snapshot surface (Views Organizer + F11 generated cuts)