@floless/app 0.137.3 → 0.138.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.
Files changed (47) hide show
  1. package/dist/floless-server.cjs +47890 -27033
  2. package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
  3. package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
  4. package/dist/schemas/steel.model.v2.schema.json +218 -27
  5. package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
  6. package/dist/skills/floless-app-rfi/SKILL.md +410 -0
  7. package/dist/skills/floless-app-routines/SKILL.md +7 -2
  8. package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
  9. package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
  10. package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
  11. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
  12. package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
  13. package/dist/templates/floless-workspace-knowledge.flo +20 -4
  14. package/dist/templates/steel-model.flo +27 -15
  15. package/dist/web/app.css +559 -131
  16. package/dist/web/app.js +216 -54
  17. package/dist/web/aware.js +982 -128
  18. package/dist/web/checkpoint-standard.js +218 -0
  19. package/dist/web/commands-filter.js +23 -0
  20. package/dist/web/commands-shell.js +237 -5
  21. package/dist/web/commands-steel.js +172 -47
  22. package/dist/web/connection-review-client.js +2 -2
  23. package/dist/web/display-units.js +243 -0
  24. package/dist/web/grid-core.js +474 -58
  25. package/dist/web/grid-display.js +344 -0
  26. package/dist/web/index.html +106 -66
  27. package/dist/web/instructor-reporter.js +5 -0
  28. package/dist/web/instructor.js +175 -33
  29. package/dist/web/json-schema-subset.js +145 -25
  30. package/dist/web/steel-3d-core.js +237 -151
  31. package/dist/web/steel-3d-view.js +366 -113
  32. package/dist/web/steel-catalog-picker.js +98 -15
  33. package/dist/web/steel-detail-refs.js +1 -1
  34. package/dist/web/steel-editor.html +6479 -921
  35. package/dist/web/steel-filter.html +404 -57
  36. package/dist/web/steel-model-adapter.js +1 -1
  37. package/dist/web/steel-model-commands.js +72 -66
  38. package/dist/web/steel-model-v2-client-validation.js +10 -3
  39. package/dist/web/steel-model-v2-commands.js +269 -77
  40. package/dist/web/steel-model-v2-projection.js +18 -17
  41. package/dist/web/steel-plan-transform.js +52 -9
  42. package/dist/web/steel-plan-view-id.js +1 -7
  43. package/dist/web/steel-read-confidence.js +454 -5
  44. package/dist/web/steel-units.js +39 -0
  45. package/dist/web/steel-view-generation.js +21 -7
  46. package/dist/web/workspaces.js +2178 -497
  47. package/package.json +5 -1
@@ -7,9 +7,9 @@
7
7
  * (RIGHT-drag orbit, MIDDLE-drag pan, wheel zoom — LEFT is reserved for editing/select), same chrome
8
8
  * (Persp/Ortho, Solid/Wire/X-ray, Fit, a per-profile legend with hide/isolate, a ViewCube, a hover
9
9
  * readout) — PLUS editing: drag a member to move it (Alt = elevation), and Trim/Extend + Split. The
10
- * member's START end shows a YELLOW dot, the END a MAGENTA dot — in 3D these mark direction and show
11
- * the member is grabbable (the BODY is the grab handle; single-end changes go through Trim/Extend or
12
- * Split, since free endpoint-drag is depth-ambiguous). In 2D the same dots ARE the draggable handles.
10
+ * member's START end shows a YELLOW dot, the END a MAGENTA dot. A host can expose those dots as narrow
11
+ * world-mm endpoint handles without enabling broad member-body editing; legacy projected hosts keep their
12
+ * sheet-space handles. The body remains the move/copy grab handle only when that wider capability is on.
13
13
  *
14
14
  * Exposes `window.Steel3DView` so the editor's classic script can drive it. The scene is Z-up
15
15
  * (contractToScene emits meta.up='z'), so the camera/grid are set up Z-up.
@@ -20,9 +20,10 @@ import { RoomEnvironment } from 'three/addons/RoomEnvironment.js';
20
20
  import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-materials.js';
21
21
  import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
22
22
  import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
23
- 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, sectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, translateEndpoints, livePositionState, swingBasis, swingEndpoint, swingBarriers, clampSwingTheta, POSITION_SWING_MARGIN_RAD, POSITION_OFFSET_SNAP_MM, POSITION_ROT_SNAP_DEG, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
24
- // `gridGeometry`, `gridCandidates3d` and `mmPerPx` live behind the host's model read boundary because
25
- // their display-scale argument is meaningless on a world-mm model grid.
23
+ import { FT_TO_MM as FT_MM } from './steel-units.js';
24
+ import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, projectPointOnSegment2d, projectPointOnSegment3d, selectedFrontmostHit, worldEndpointCommit, SEG_DEGENERACY, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, translateEndpoints, livePositionState, swingBasis, swingEndpoint, swingBarriers, clampSwingTheta, POSITION_SWING_MARGIN_RAD, POSITION_OFFSET_SNAP_MM, POSITION_ROT_SNAP_DEG, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
25
+ // `gridGeometry`, `gridCandidates3d` and `sheetScaleMm` live behind the host's model read boundary
26
+ // because their display-scale argument is meaningless on a world-mm model grid.
26
27
  import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
27
28
 
28
29
  let renderer, scene, perspCam, orthoCam, camera, controls, root, api, canvasEl, ro, rafId, grid, raycaster, downXY, lastPick = '(none)';
@@ -56,6 +57,8 @@ let selLenLabelSpec = null; // [{id, text}] pushed from the editor when "
56
57
  const EP_PX = 4; // end-dot radius in screen px (screen-constant via pxToWorld)
57
58
  let sceneBox = new THREE.Box3(); // current model bounds (Fit / ViewCube)
58
59
  let displayMode = 'solid';
60
+ let ghostUnselectedEnabled = false; // live visibility treatment: current selection stays normal; other rendered objects fade
61
+ const GHOST_OPACITY_CAP = Object.freeze({ solid: 0.18, wire: 0.24, xray: 0.10, realistic: 0.18, shadowed: 0.18 });
59
62
  // Modes that draw solid fills, and so can hide a grid line behind a member. Wire and X-ray cannot:
60
63
  // their fills do not write depth, so a grid behind them is genuinely visible. Realistic and Shadowed
61
64
  // are as opaque as Solid — leaving them out made every member sitting on a grid line unclickable,
@@ -81,8 +84,9 @@ let gridSelectionHidden = new Set(); // session-only logical grid lines h
81
84
  let cube = null; // ViewCube { renderer, scene, cam, mesh, faces }
82
85
  let triad = null; // world-axis triad { renderer, scene, cam, group } — passive X/Y/Z readout
83
86
  const DRAG_TOL_PX = 4; // movement past this = a drag (not a click)
87
+ import { endpointDragPoint } from './steel-3d-core.js';
84
88
  const SNAP_TOL_PX = 10; // snap an endpoint to a target within this screen distance
85
- const FT_MM = 304.8; // mm per foot (the dimension readout shows feet, matching the editor)
89
+ // mm per foot (the dimension readout shows feet, matching the editor) — the shared constant (#951).
86
90
  let built = false, fitPending = false;
87
91
  const meshById = new Map(); // member id -> THREE.Mesh
88
92
  const groupColor = new Map(); // group key -> THREE.Color
@@ -365,10 +369,12 @@ function init(canvas, theApi) {
365
369
  // amber over a half-moved preview with orbit disabled, and nothing but another gesture could repair it.
366
370
  if (pending && pending.posGizmo) restorePositionGizmoMesh(pending.posGizmo);
367
371
  const hadPos = !!(pending && pending.posGizmo) || posInteraction === 'dragging';
372
+ const hadDirectMember = !!(pending && (pending.epDrag || pending.geo === 'split'));
368
373
  if (hadPos) { endPositionGesture(); hidePositionLeader(); if (readout) readout.style.display = 'none'; renderPositionGizmo(); }
369
374
  if (teklaDrag) endTeklaDrag();
370
- else if (!hadPos) return;
375
+ else if (!hadPos && !hadDirectMember) return;
371
376
  pending = dragging = null; downXY = null; if (controls) controls.enabled = true;
377
+ if (hadDirectMember) { dragEp = null; if (epPreview) epPreview.visible = false; if (epMovedLine) epMovedLine.visible = false; rebuildEndpoints(); }
372
378
  });
373
379
  window.addEventListener('keydown', onKey); // Tekla keyboard nav: arrows pan, Ctrl/Shift+arrows rotate
374
380
  window.addEventListener('keydown', onModifierChange); // the drag-out cursor hint tracks the keys, not just the mouse
@@ -686,6 +692,9 @@ function placeImage(mesh, el) {
686
692
  const tex = new THREE.TextureLoader().load(el.url || '', (t) => {
687
693
  const iw = t.image && t.image.width, ih = t.image && t.image.height;
688
694
  if (iw && ih) mesh.scale.set(1, ih / iw, 1); // geometry is square; scale local Y to the image aspect
695
+ // Aspect ratio changes the detail's real rendered footprint. Re-evaluate the live ghost focus once
696
+ // the image is ready, but only if this exact mesh still belongs to the rebuilt scene.
697
+ if (ghostUnselectedEnabled && mesh.userData.id && meshById.get(mesh.userData.id) === mesh) applyDisplayMode();
689
698
  });
690
699
  tex.colorSpace = THREE.SRGBColorSpace;
691
700
  mesh.material = new THREE.MeshBasicMaterial({ map: tex, transparent: true, opacity: el.opacity == null ? 1 : el.opacity, side: THREE.DoubleSide, depthWrite: false });
@@ -875,6 +884,7 @@ function clearRoot() {
875
884
  if (m.userData._selMat) m.userData._selMat.dispose(); // per-mesh selection clone (else it leaks per rebuild)
876
885
  if (m.userData._hovMat) m.userData._hovMat.dispose(); // per-mesh hover clone — same leak-per-rebuild story as _selMat
877
886
  if (m.userData._revMat) m.userData._revMat.dispose(); // per-mesh review (amber) clone — likewise, and a review lift survives many rebuilds
887
+ if (m.userData._ghostMat) m.userData._ghostMat.dispose(); // per-mesh faded clone; shared profile materials must never be attenuated in place
878
888
  // A placed detail (Slice 4) owns a per-mesh MeshBasicMaterial + its image texture (NOT a shared baseMat);
879
889
  // dispose both or every rebuild — which happens on each edit — leaks the old material + GPU texture.
880
890
  if (String(id).startsWith('det:') && m.material) { if (m.material.map) m.material.map.dispose(); m.material.dispose(); }
@@ -3412,11 +3422,10 @@ function sizeGridLabels() {
3412
3422
  }
3413
3423
  if (segs.length) lineSegs.set(id, segs);
3414
3424
  }
3415
- const distToSeg = (px, py, x1, y1, x2, y2) => {
3416
- const vx = x2 - x1, vy = y2 - y1, len2 = vx * vx + vy * vy;
3417
- const t = len2 > 0 ? Math.max(0, Math.min(1, ((px - x1) * vx + (py - y1) * vy) / len2)) : 0;
3418
- return Math.hypot(px - (x1 + t * vx), py - (y1 + t * vy));
3419
- };
3425
+ // Screen pixels, and this caller's historic rule is `len2 > 0` (#951 — the shared primitive lives in
3426
+ // steel-3d-core; the rule stays this caller's own).
3427
+ const distToSeg = (px, py, x1, y1, x2, y2) =>
3428
+ projectPointOnSegment2d([px, py], [x1, y1], [x2, y2], SEG_DEGENERACY.atMost(0)).distance;
3420
3429
  const survivors = [];
3421
3430
  for (const s of placed) {
3422
3431
  const p = _spA.copy(s.position).project(camera);
@@ -3542,8 +3551,19 @@ function repivotToCursor() {
3542
3551
  }
3543
3552
 
3544
3553
  let rebuildSeq = 0;
3554
+ function cancelDirectMemberGestureForRebuild() {
3555
+ if (!pending || (!pending.epDrag && pending.geo !== 'split')) return;
3556
+ pending = dragging = null; downXY = null; dragEp = null;
3557
+ if (controls) controls.enabled = true;
3558
+ if (marker) marker.visible = false;
3559
+ if (readout) readout.style.display = 'none';
3560
+ if (epPreview) epPreview.visible = false;
3561
+ if (epMovedLine) epMovedLine.visible = false;
3562
+ rebuildEndpoints(); // restore the canonical dot immediately; a failed async scene refresh must not strand the drag preview
3563
+ }
3545
3564
  async function rebuild(fit = false) {
3546
3565
  if (!api) return;
3566
+ cancelDirectMemberGestureForRebuild(); // synchronous: no frozen host snapshot may survive into the awaited replacement scene
3547
3567
  invalidatePointEntry('rebuild'); // synchronous, BEFORE the first await — the scene is changing; drop any open typed entry + stale base (never on stale async completion)
3548
3568
  clipCandidates = null; clipLevels = null; invalidateClipFloor(); invalidateModelCache(); // …and the clip-draw snap cache + measured floor, synchronously here too (not only in buildFromScene): every edit/undo/redo funnels through rebuild(), so a draw in progress can't snap against pre-edit candidates during the async fetchScene window
3549
3569
  if (marker && clipMode === 'box') marker.visible = false; // a model change under an armed box draw invalidates the reticle position — drop it (the next hover re-snaps)
@@ -3591,7 +3611,13 @@ function setProjection(mode) {
3591
3611
  controls.update();
3592
3612
  }
3593
3613
  function projection() { return camera === orthoCam ? 'ortho' : 'persp'; }
3594
- function setDisplayMode(m) { displayMode = m; applyDisplayMode(); }
3614
+ function setDisplayMode(m) {
3615
+ displayMode = m;
3616
+ // Display modes repaint shared family materials (Realistic in particular replaces their colour).
3617
+ // Reconcile the live selection first so returning to Solid gives every focused/context mesh its
3618
+ // proper resting material before Ghost derives a faded clone from it.
3619
+ setSelection(selIds);
3620
+ }
3595
3621
  // Realistic metal is nothing but reflections: against the editor's two-directional rig, with nothing
3596
3622
  // to reflect, metalness=1 renders BLACK. So Realistic generates an image-based light in the browser
3597
3623
  // (RoomEnvironment → PMREM, both from the vendored three — no CDN, still offline) and switches on
@@ -3674,7 +3700,13 @@ const wireEdges = new Map(); // meshId -> LineSegments (edge
3674
3700
  // up by the rebuild's own sweep — which re-colours through wireEdgesFor. hoverGlowIds (not hoverId) is the set
3675
3701
  // actually lit, so hovering one part of a connection outlines the whole connection — the grouping the glow uses.
3676
3702
  function wireEdgeColorOf(id, mesh) {
3677
- if (selIds.has(id)) return SELECT_EMISSIVE; // selected → brand-blue outline
3703
+ if (selIds.has(id)) {
3704
+ if (!ghostUnselectedEnabled) return SELECT_EMISSIVE;
3705
+ // Ghost focus keeps its semantic resting colour and still beats hover. A click commonly leaves
3706
+ // the pointer on the focused part, so letting hover win here would turn that outline sky-blue.
3707
+ if (mesh.userData && mesh.userData.connReview === 'needs-review') return REVIEW_EMISSIVE;
3708
+ const c = mesh.material && mesh.material.color; return c ? c.getHex() : WIRE_EDGE_FALLBACK;
3709
+ }
3678
3710
  if (hoverGlowIds.includes(id)) return HOVER_EMISSIVE; // hovered → sky outline (matches Solid/X-ray)
3679
3711
  /* Wire hides the solid fill entirely and the OUTLINE carries the shape, so emissive is ignored here —
3680
3712
  the amber lift has to be re-stated as a line colour or it silently vanishes in a display mode the
@@ -3682,7 +3714,7 @@ function wireEdgeColorOf(id, mesh) {
3682
3714
  if (mesh.userData && mesh.userData.connReview === 'needs-review') return REVIEW_EMISSIVE;
3683
3715
  const c = mesh.material && mesh.material.color; return c ? c.getHex() : WIRE_EDGE_FALLBACK;
3684
3716
  }
3685
- function wireEdgeMatFor(hex) { let m = wireEdgeMats.get(hex); if (!m) { m = new THREE.LineBasicMaterial({ color: hex }); wireEdgeMats.set(hex, m); } return m; }
3717
+ function wireEdgeMatFor(hex, opacity = 1) { const key = `${hex}:${opacity.toFixed(4)}`; let m = wireEdgeMats.get(key); if (!m) { m = new THREE.LineBasicMaterial({ color: hex, transparent: opacity < 1, opacity, depthWrite: opacity >= 1 }); wireEdgeMats.set(key, m); } return m; }
3686
3718
  function wireEdgesFor(id, mesh) {
3687
3719
  let ls = wireEdges.get(id);
3688
3720
  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
@@ -3697,6 +3729,97 @@ function clearWireEdges() {
3697
3729
  for (const m of wireEdgeMats.values()) m.dispose();
3698
3730
  wireEdgeMats.clear();
3699
3731
  }
3732
+
3733
+ // Clip a convex polygon against the renderer's active world-space planes. This makes "focused" mean
3734
+ // "contributes a rendered fragment", not merely "its object.visible flag is true" — important when a
3735
+ // selected part sits wholly beyond a section plane.
3736
+ function clipPolygonToScene(poly) {
3737
+ let out = poly;
3738
+ for (const plane of ((renderer && renderer.clippingPlanes) || EMPTY_CLIPS)) {
3739
+ if (!out.length) break;
3740
+ const input = out; out = [];
3741
+ for (let i = 0; i < input.length; i++) {
3742
+ const a = input[i], b = input[(i + 1) % input.length], da = plane.distanceToPoint(a), db = plane.distanceToPoint(b);
3743
+ const ain = da >= -1e-7, bin = db >= -1e-7;
3744
+ if (ain) out.push(a);
3745
+ if (ain !== bin) out.push(a.clone().lerp(b, da / (da - db)));
3746
+ }
3747
+ }
3748
+ return out;
3749
+ }
3750
+ function meshContributesPixels(mesh, wire = false) {
3751
+ if (!mesh || !mesh.visible || !mesh.geometry) return false;
3752
+ const planes = (renderer && renderer.clippingPlanes) || EMPTY_CLIPS;
3753
+ if (!planes.length) return true;
3754
+ mesh.updateWorldMatrix(true, false);
3755
+ const g = wire ? ((wireEdges.get(mesh.userData.id) || {}).geometry) : mesh.geometry;
3756
+ const pos = g && g.attributes && g.attributes.position; if (!pos) return true;
3757
+ const idx = g.index;
3758
+ if (wire) {
3759
+ for (let i = 0; i + 1 < pos.count; i += 2) {
3760
+ const a = new THREE.Vector3().fromBufferAttribute(pos, i).applyMatrix4(mesh.matrixWorld);
3761
+ const b = new THREE.Vector3().fromBufferAttribute(pos, i + 1).applyMatrix4(mesh.matrixWorld);
3762
+ let lo = 0, hi = 1, alive = true;
3763
+ for (const p of planes) { const da = p.distanceToPoint(a), db = p.distanceToPoint(b); if (da < 0 && db < 0) { alive = false; break; } if (da < 0 || db < 0) { const t = da / (da - db); if (da < 0) lo = Math.max(lo, t); else hi = Math.min(hi, t); if (lo > hi) { alive = false; break; } } }
3764
+ if (alive) return true;
3765
+ }
3766
+ return false;
3767
+ }
3768
+ const count = idx ? idx.count : pos.count;
3769
+ for (let i = 0; i + 2 < count; i += 3) {
3770
+ const at = (n) => new THREE.Vector3().fromBufferAttribute(pos, idx ? idx.getX(i + n) : i + n).applyMatrix4(mesh.matrixWorld);
3771
+ if (clipPolygonToScene([at(0), at(1), at(2)]).length >= 3) return true;
3772
+ }
3773
+ return false;
3774
+ }
3775
+ function ghostPassState(wire) {
3776
+ if (!ghostUnselectedEnabled) return { active: false, opacity: 1, meshFocus: new Set(), gridFocus: new Set() };
3777
+ const meshFocus = new Set([...selIds].filter((id) => {
3778
+ const m = meshById.get(id); if (!m) return false;
3779
+ const isDetail = String(id).startsWith('det:');
3780
+ // A valid placed detail may be authored at 0% opacity. It contributes no pixels and must not
3781
+ // activate a 0-opacity Ghost pass that makes the entire surrounding model disappear with it.
3782
+ if (isDetail && (m.userData._detailOpacity == null ? m.material.opacity : m.userData._detailOpacity) <= 0) return false;
3783
+ // Details remain textured triangles in Wire mode; only native steel is replaced by line edges.
3784
+ // Testing a detail as lines would conservatively count a fully clipped plane as visible focus.
3785
+ return meshContributesPixels(m, wire && !isDetail);
3786
+ }));
3787
+ const gridFocus = new Set([...selectedGridIds].filter((id) => { const line = structGridLines.get(id); if (!line || !line.visible) return false; const pts = line.userData.segments || []; for (let i = 0; i + 1 < pts.length; i += 2) if (visibleGridSegment(pts[i], pts[i + 1])) return true; return false; }));
3788
+ if (!meshFocus.size && !gridFocus.size) return { active: false, opacity: 1, meshFocus, gridFocus };
3789
+ let weakest = gridFocus.size ? 1 : Infinity;
3790
+ for (const id of meshFocus) { const m = meshById.get(id); const authored = String(id).startsWith('det:') ? (m.userData._detailOpacity == null ? 1 : m.userData._detailOpacity) : (m.material && m.material.opacity == null ? 1 : m.material.opacity); weakest = Math.min(weakest, authored); }
3791
+ return { active: true, opacity: Math.min(GHOST_OPACITY_CAP[displayMode] || 0.18, (Number.isFinite(weakest) ? weakest : 1) * 0.4), meshFocus, gridFocus };
3792
+ }
3793
+ function ghostMaterial(mesh, source, opacity) {
3794
+ const u = mesh.userData;
3795
+ if (!u._ghostMat || u._ghostSource !== source || u._ghostOpacity !== opacity || u._ghostMode !== displayMode) {
3796
+ if (u._ghostMat) u._ghostMat.dispose();
3797
+ const m = source.clone(), tile = TILE_MM[u.family];
3798
+ if (tile) applyTriplanar(m, tile, DIRECTIONAL.has(u.family) ? u.axis : null);
3799
+ m.transparent = true; m.opacity = opacity; m.depthWrite = false; m.needsUpdate = true;
3800
+ u._ghostMat = m; u._ghostSource = source; u._ghostOpacity = opacity; u._ghostMode = displayMode;
3801
+ }
3802
+ return u._ghostMat;
3803
+ }
3804
+ function applyGridGhost(pass) {
3805
+ for (const [id, line] of structGridLines) {
3806
+ // Outside Ghost, retain the grid's ordinary blue selection cue. During Ghost, only a selected
3807
+ // line that contributes pixels is focus; every other visible line is context.
3808
+ const focused = pass.active ? pass.gridFocus.has(id) : selectedGridIds.has(id), faded = pass.active && !focused;
3809
+ line.material.color.setHex(focused ? 0x3b82f6 : 0x64748b);
3810
+ line.material.transparent = faded || !focused;
3811
+ line.material.opacity = faded ? pass.opacity : (focused ? 1 : 0.85);
3812
+ line.material.depthWrite = !faded;
3813
+ }
3814
+ if (gridLabelGroup) for (const label of gridLabelGroup.children) {
3815
+ if (!label.material) continue;
3816
+ const id = label.userData && label.userData.gridId;
3817
+ // Elevation tags are shared by the logical grid and intentionally have no line id. Keep them with
3818
+ // grid focus when any selected line survives; with mesh-only focus they belong to Ghost context.
3819
+ const faded = pass.active && (id ? !pass.gridFocus.has(id) : !pass.gridFocus.size);
3820
+ label.material.transparent = true; label.material.opacity = faded ? pass.opacity : 1; label.material.depthWrite = false;
3821
+ }
3822
+ }
3700
3823
  // solid → opaque; wire → EdgesGeometry outline (fill hidden); xray → translucent, no depth write. Applied to
3701
3824
  // whatever material each mesh currently carries (shared profile material OR its selection clone).
3702
3825
  function applyDisplayMode() {
@@ -3706,8 +3829,11 @@ function applyDisplayMode() {
3706
3829
  const realistic = setEnvironment(displayMode === 'realistic' || displayMode === 'shadowed');
3707
3830
  syncShadows(realistic && displayMode === 'shadowed');
3708
3831
  for (const [id, mesh] of meshById) {
3832
+ // Restore only while the mesh still wears OUR faded clone. Selection, hover, or a review update
3833
+ // may have installed a newer semantic material since the last pass; that newer owner must win.
3834
+ if (mesh.userData._ghostSource && mesh.material === mesh.userData._ghostMat) mesh.material = mesh.userData._ghostSource;
3709
3835
  const mat = mesh.material; if (!mat) continue;
3710
- if (String(id).startsWith('det:')) continue; // placed details (Slice 4) own their transparency + opacity — display mode must not override them
3836
+ if (String(id).startsWith('det:')) { if (mesh.userData._detailOpacity == null) mesh.userData._detailOpacity = mat.opacity == null ? 1 : mat.opacity; mat.opacity = mesh.userData._detailOpacity; mat.transparent = true; mat.depthWrite = false; mat.color.setHex(selIds.has(id) && !ghostUnselectedEnabled ? 0x93c5fd : 0xffffff); mesh.castShadow = false; continue; }
3711
3837
  live.add(id);
3712
3838
  // Reset the surface on EVERY pass so a mode switch is symmetric — leaving Realistic must restore
3713
3839
  // the flat shading exactly, not strand the last family's metalness on a shared material.
@@ -3747,6 +3873,15 @@ function applyDisplayMode() {
3747
3873
  mesh.castShadow = shadowsEnabled && mat.opacity >= 0.95;
3748
3874
  mat.needsUpdate = true;
3749
3875
  }
3876
+ const ghost = ghostPassState(wire);
3877
+ if (ghost.active) for (const [id, mesh] of meshById) {
3878
+ if (!mesh.visible || ghost.meshFocus.has(id)) continue;
3879
+ if (String(id).startsWith('det:')) { mesh.material.opacity = Math.min(mesh.userData._detailOpacity == null ? 1 : mesh.userData._detailOpacity, ghost.opacity); mesh.material.depthWrite = false; }
3880
+ else if (wire) { const ls = wireEdges.get(id); if (ls) ls.material = wireEdgeMatFor(wireEdgeColorOf(id, mesh), ghost.opacity); }
3881
+ else { const source = mesh.material; mesh.material = ghostMaterial(mesh, source, Math.min(source.opacity == null ? 1 : source.opacity, ghost.opacity)); }
3882
+ mesh.castShadow = false;
3883
+ }
3884
+ applyGridGhost(ghost);
3750
3885
  syncClipMirror(); // shadows just turned on or off — the mirror follows
3751
3886
  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)
3752
3887
  }
@@ -3782,23 +3917,23 @@ function visibleObjectIds() {
3782
3917
  }
3783
3918
  function visibleGridIds() { return [...structGridLines].filter(([, line]) => line.visible).map(([id]) => id); }
3784
3919
  function notifyVisibilityChange() { if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null || isolatedGridIds !== null); }
3785
- function toggleGroup(k) { if (groupHidden.has(k)) groupHidden.delete(k); else groupHidden.add(k); soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3920
+ function toggleGroup(k) { if (groupHidden.has(k)) groupHidden.delete(k); else groupHidden.add(k); soloGroups.clear(); applyGroupVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3786
3921
  // Hide/show a SET of groups in one pass (a legend type-category master toggle) — deterministic (not a flip),
3787
3922
  // so "hide all" / "show all" for the category is exact. Clears solo, like toggleGroup.
3788
- function setGroupsHidden(keys, hidden) { const target = new Set(keys || []); for (const k of target) { if (hidden) groupHidden.add(k); else groupHidden.delete(k); } if (!hidden && selectionHidden.size) selectionHidden = new Set([...selectionHidden].filter((id) => { const m = meshById.get(id); return !m || !target.has(m.userData && m.userData.group); })); soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3923
+ function setGroupsHidden(keys, hidden) { const target = new Set(keys || []); for (const k of target) { if (hidden) groupHidden.add(k); else groupHidden.delete(k); } if (!hidden && selectionHidden.size) selectionHidden = new Set([...selectionHidden].filter((id) => { const m = meshById.get(id); return !m || !target.has(m.userData && m.userData.group); })); soloGroups.clear(); applyGroupVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3789
3924
  // Hide/show specific PART ids (a legend connection row / connection master). Per-id so a connection's own
3790
3925
  // nuts/welds toggle independently of the other connection's (the part-kind group is shared across joints).
3791
- function setIdsHidden(ids, hidden) { for (const id of (ids || [])) { if (hidden) connHidden.add(id); else { connHidden.delete(id); selectionHidden.delete(id); } } applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3926
+ function setIdsHidden(ids, hidden) { for (const id of (ids || [])) { if (hidden) connHidden.add(id); else { connHidden.delete(id); selectionHidden.delete(id); } } applyGroupVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3792
3927
  // Isolate an explicit SET of profile groups (the editor's legend builds it from Ctrl/Shift dbl-clicks, Explorer-style).
3793
- function setSoloGroups(keys) { soloGroups = new Set((keys || []).filter((k) => k != null)); if (soloGroups.size) groupHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3928
+ function setSoloGroups(keys) { soloGroups = new Set((keys || []).filter((k) => k != null)); if (soloGroups.size) groupHidden.clear(); applyGroupVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
3794
3929
  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)
3795
- function showAllGroups() { groupHidden.clear(); soloGroups.clear(); isolatedIds = null; isolatedGridIds = null; connHidden.clear(); selectionHidden.clear(); gridSelectionHidden.clear(); applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
3930
+ function showAllGroups() { groupHidden.clear(); soloGroups.clear(); isolatedIds = null; isolatedGridIds = null; connHidden.clear(); selectionHidden.clear(); gridSelectionHidden.clear(); ghostUnselectedEnabled = false; applyGroupVisibility(); applyGridVisibility(); setSelection(selIds); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
3796
3931
  function groupState() { return { hidden: [...groupHidden], solo: [...soloGroups] }; }
3797
3932
  // One serialisable snapshot of the objects-list pane's PERSISTENT visibility state — group hide/solo +
3798
3933
  // isolate-selected + per-part legend hides. This is what a saved view (Views Organizer) captures; it
3799
3934
  // deliberately excludes the transient legend search (`legendQuery`, editor-side, never persisted) and the
3800
3935
  // live selection. Versioned + read/applied wholesale so it stays robust as the pane's filtering grows.
3801
- function objectsPaneState() { return { v: 1, hidden: [...groupHidden], solo: [...soloGroups], isolated: isolatedIds ? [...isolatedIds] : null, connHidden: [...connHidden] }; }
3936
+ function objectsPaneState() { return { v: 1, hidden: [...groupHidden], solo: [...soloGroups], isolated: isolatedIds ? [...isolatedIds] : null, connHidden: [...connHidden], ghostUnselected: ghostUnselectedEnabled }; }
3802
3937
  // Restore an objectsPaneState() blob — sanitised to arrays (a partial/stale draft can't desync the scene
3803
3938
  // from the legend, same discipline as the editor's dim_overlays restore), then re-apply visibility with the
3804
3939
  // exact refresh tail showAllGroups uses.
@@ -3808,20 +3943,23 @@ function applyObjectsPaneState(s) {
3808
3943
  soloGroups = new Set(Array.isArray(s.solo) ? s.solo : []);
3809
3944
  isolatedIds = (Array.isArray(s.isolated) && s.isolated.length) ? new Set(s.isolated) : null;
3810
3945
  connHidden = new Set(Array.isArray(s.connHidden) ? s.connHidden : []);
3946
+ ghostUnselectedEnabled = s.ghostUnselected === true;
3811
3947
  selectionHidden.clear(); // Hide selected is session-only; applying a saved view restores its authored persistent visibility without leaking the current session filter
3812
3948
  gridSelectionHidden.clear(); isolatedGridIds = isolatedIds === null ? null : new Set(); // saved member-only isolation still means "only these objects"; raw logical-grid ids remain session-only
3813
- applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims();
3949
+ applyGroupVisibility(); applyGridVisibility(); setSelection(selIds); rebuildEndpoints(); refreshOverlayDims(); refreshDims();
3814
3950
  notifyVisibilityChange();
3815
3951
  }
3816
3952
  // Tekla "isolate selected": show ONLY the currently-selected parts (a snapshot taken now — distinct from
3817
3953
  // soloToggle, which isolates a whole PROFILE group from the legend). clearIsolation / showAllGroups restore all.
3818
- 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; }
3954
+ function isolateSelected() { if (!selIds.size && !selectedGridIds.size) return false; isolatedIds = new Set(selIds); isolatedGridIds = new Set(selectedGridIds); applyGroupVisibility(); applyGridVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return true; }
3819
3955
  // Hide the current selection by explicit mesh id. This remains session-only because saved views require tagged
3820
3956
  // SceneRefs while the renderer owns raw ids; broadening that contract is separate from toolbar state.
3821
- 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; }
3822
- function clearIsolation() { if (isolatedIds === null && isolatedGridIds === null) return; isolatedIds = null; isolatedGridIds = null; applyGroupVisibility(); applyGridVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
3957
+ 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(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return ids.length + gridIds.length; }
3958
+ function clearIsolation() { if (isolatedIds === null && isolatedGridIds === null) return; isolatedIds = null; isolatedGridIds = null; applyGroupVisibility(); applyGridVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
3823
3959
  function isIsolated() { return isolatedIds !== null || isolatedGridIds !== null; }
3824
3960
  function hasVisibilityFilter() { return isolatedIds !== null || isolatedGridIds !== null || groupHidden.size > 0 || soloGroups.size > 0 || connHidden.size > 0 || selectionHidden.size > 0 || gridSelectionHidden.size > 0; }
3961
+ function hasVisibilityTreatment() { return hasVisibilityFilter() || ghostUnselectedEnabled; }
3962
+ function setGhostUnselected(on) { const next = !!on; if (ghostUnselectedEnabled === next) return next; ghostUnselectedEnabled = next; setSelection(selIds); updateStatusChip(); notifyVisibilityChange(); return next; }
3825
3963
  function getGroups() { return sceneGroups.map((g) => ({ ...g })); }
3826
3964
 
3827
3965
  // ---- clip planes / clip boxes (Tekla-style sectioning) ----
@@ -3848,6 +3986,7 @@ function applyClips() {
3848
3986
  if (workArea && workArea.enabled && !workArea.whole) active.push(...workArea.planes); // the work area sections the view too — unless it's in "show whole parts" mode (parts are hidden/shown whole via applyGroupVisibility, never sliced)
3849
3987
  renderer.clippingPlanes = active.length ? active : EMPTY_CLIPS;
3850
3988
  syncClipMirror(); // materials hold their own reference for the shadow pass — re-point it
3989
+ if (ghostUnselectedEnabled) applyDisplayMode(); // clipping can remove the last focused rendered fragment
3851
3990
  }
3852
3991
  // 6 inward planes (keep INSIDE) for an axis-aligned Box3 → a section/clip box.
3853
3992
  function boxToPlanes(b) {
@@ -4261,7 +4400,7 @@ function renderWorkArea() {
4261
4400
  workAreaHelper.material.depthTest = false; workAreaHelper.renderOrder = 995; // unclipped overlay pass keeps it visible through any clip
4262
4401
  overlayScene.add(workAreaHelper);
4263
4402
  }
4264
- function refreshWorkAreaVis() { applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); } // whole-parts mode hides/shows whole meshes → recompute visibility + dependent dims/endpoints (same trio the legend toggles use)
4403
+ function refreshWorkAreaVis() { applyGroupVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); } // whole-parts mode hides/shows whole meshes → recompute visibility + Ghost treatment + dependent dims/endpoints
4265
4404
  function setWorkAreaBox(box) {
4266
4405
  if (!box || box.isEmpty()) return false;
4267
4406
  if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
@@ -4816,13 +4955,13 @@ function setSelection(ids) {
4816
4955
  // A placed detail (Slice 4) uses a textured MeshBasicMaterial with no `.emissive` — the member
4817
4956
  // material swap below would drop its texture (and MeshBasicMaterial has no emissive to glow). Keep
4818
4957
  // its plane and tint the map (blue when selected, white = untinted otherwise) as the selection cue.
4819
- if (String(id).startsWith('det:')) { if (mesh.material && mesh.material.color) mesh.material.color.setHex(on ? 0x93c5fd : 0xffffff); continue; }
4958
+ if (String(id).startsWith('det:')) { if (mesh.material && mesh.material.color) mesh.material.color.setHex(on && !ghostUnselectedEnabled ? 0x93c5fd : 0xffffff); continue; }
4820
4959
  // Selected → a per-mesh clone that glows (so one selected member doesn't tint its whole profile
4821
4960
  // group). Deselected → back to the SHARED profile material (its real colour).
4822
4961
  // Deselecting returns to the RESTING material, which is amber when this part's connection is asking
4823
4962
  // for review — not unconditionally back to plain steel, which would erase the lift on the first click.
4824
- mesh.material = on ? selectedMaterial(mesh) : restingMaterial(mesh);
4825
- if (on) { mesh.material.emissive = new THREE.Color(SELECT_EMISSIVE); mesh.material.emissiveIntensity = 0.6; }
4963
+ mesh.material = on && !ghostUnselectedEnabled ? selectedMaterial(mesh) : restingMaterial(mesh);
4964
+ if (on && !ghostUnselectedEnabled) { mesh.material.emissive = new THREE.Color(SELECT_EMISSIVE); mesh.material.emissiveIntensity = 0.6; }
4826
4965
  else if (mesh.userData.connReview !== 'needs-review') { mesh.material.emissive = new THREE.Color(0x000000); mesh.material.emissiveIntensity = 0; }
4827
4966
  }
4828
4967
  selIds = new Set(set); // BEFORE applyDisplayMode: in Wire mode wireEdgeColorOf reads selIds to colour the outline, so it must already be current (mirrors the setHover ordering) — else a just-(de)selected outline keeps its old colour until the NEXT applyDisplayMode. The reglow re-sync below only fires when a still-hovered part was deselected, so it does not save the ordinary click-to-select case
@@ -4896,7 +5035,10 @@ function setConnReview(map) {
4896
5035
  if (mesh.userData.connReview === want) continue;
4897
5036
  mesh.userData.connReview = want;
4898
5037
  touched = true;
4899
- if (selIds.has(id) || hoverGlowIds.includes(id)) continue; // they own the material right now
5038
+ // Ordinary selection owns its blue material; Ghost selection deliberately does not. Reconcile a
5039
+ // selected Ghost focus immediately even while the pointer still hovers it, or a live review change
5040
+ // remains visually stale until deselection.
5041
+ if ((selIds.has(id) && !ghostUnselectedEnabled) || (!selIds.has(id) && hoverGlowIds.includes(id))) continue;
4900
5042
  mesh.material = restingMaterial(mesh);
4901
5043
  mesh.material.emissive = new THREE.Color(want === 'needs-review' ? REVIEW_EMISSIVE : 0x000000);
4902
5044
  mesh.material.emissiveIntensity = want === 'needs-review' ? REVIEW_INTENSITY : 0;
@@ -4960,7 +5102,7 @@ function rebuildEndpoints() {
4960
5102
  for (const id of show) {
4961
5103
  const mesh = meshById.get(id); if (mesh && !mesh.visible) continue; // a legend-hidden member shows no dots
4962
5104
  const m = memberById(id); if (!m) continue;
4963
- const g = geoOf(m);
5105
+ const g = geoOf(m); if (!g) continue;
4964
5106
  addEndpoint(g.line[0], epMatStart, id, 0); addEndpoint(g.line[1], epMatEnd, id, 1);
4965
5107
  }
4966
5108
  }
@@ -5354,9 +5496,27 @@ function initTriad() {
5354
5496
  }
5355
5497
  g.add(new THREE.Mesh(new THREE.SphereGeometry(0.1, 12, 8), new THREE.MeshBasicMaterial({ color: 0xe2e8f0 }))); // origin dot
5356
5498
  ts.add(g);
5357
- triad = { renderer: tr, scene: ts, cam: tc, group: g };
5499
+ // The glyph is three arms out of ONE corner, so its origin dot sits dead centre while its visible mass
5500
+ // hangs up-and-right of it — against a chip centred under the box, the triad read as shifted. Centre the
5501
+ // ARTWORK instead of the origin: measure the group's bounds once, here, before any rotation is applied.
5502
+ // Measured rather than typed, so a change to the arm length keeps it centred. The label SPRITES are
5503
+ // left out of that measurement: each is a 0.85-unit quad carrying a single letter with a lot of
5504
+ // transparent padding, so a bounds that counts the quad counts ink that is not there and drags the
5505
+ // centre toward the labels — which is what left the arms sitting up and right of the box. Bounding
5506
+ // the shafts, heads and origin dot centres what a reader actually sees as the glyph.
5507
+ const armsOnly = new THREE.Box3();
5508
+ g.traverse((o) => { if (o.isMesh) armsOnly.expandByObject(o); });
5509
+ const centre = armsOnly.isEmpty()
5510
+ ? new THREE.Box3().setFromObject(g).getCenter(new THREE.Vector3())
5511
+ : armsOnly.getCenter(new THREE.Vector3());
5512
+ triad = { renderer: tr, scene: ts, cam: tc, group: g, centre };
5513
+ }
5514
+ // The offset is re-rotated every frame rather than baked in: the group spins with the camera, so a fixed
5515
+ // translation would centre the glyph in one view and throw it off in every other.
5516
+ function syncTriad() {
5517
+ triad.group.quaternion.copy(camera.quaternion).invert();
5518
+ triad.group.position.copy(triad.centre).applyQuaternion(triad.group.quaternion).negate();
5358
5519
  }
5359
- function syncTriad() { triad.group.quaternion.copy(camera.quaternion).invert(); }
5360
5520
  // Mirror the scene from the main camera's direction (the FRONT face turns toward the viewer in a
5361
5521
  // front view, etc.) by orienting the cube by the inverse of the camera's world rotation.
5362
5522
  function syncCube() { cube.mesh.quaternion.copy(camera.quaternion).invert(); }
@@ -5368,7 +5528,11 @@ function meshHitsAt(cx,cy,primaryOnly=false) {
5368
5528
  const rect = canvasEl.getBoundingClientRect();
5369
5529
  const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
5370
5530
  raycaster.setFromCamera(ndc, camera);
5371
- return raycaster.intersectObjects([...meshById.values()].filter((m) => m.visible && (!primaryOnly || !m.userData.derived)), false).filter(h=>!isPointClipped([h.point.x,h.point.y,h.point.z]));
5531
+ const hits = raycaster.intersectObjects([...meshById.values()].filter((m) => m.visible && (!primaryOnly || !m.userData.derived)), false).filter(h=>!isPointClipped([h.point.x,h.point.y,h.point.z]));
5532
+ // Ghost context must remain selectable, but it must not phantom-occlude a focused opaque object at
5533
+ // the same cursor position. Preserve ray distance inside each tier so click-to-cycle stays stable.
5534
+ if (ghostUnselectedEnabled && selIds.size) hits.sort((a,b)=>(Number(selIds.has(b.object.userData.id))-Number(selIds.has(a.object.userData.id)))||(a.distance-b.distance));
5535
+ return hits;
5372
5536
  }
5373
5537
  function pickAt(cx, cy) {
5374
5538
  // Primary member id under the pointer, or null for empty space.
@@ -5387,7 +5551,7 @@ function pickGridAt(cx,cy){
5387
5551
  const frustum=gridCameraFrustum();
5388
5552
  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;};
5389
5553
  let best=null;
5390
- for(const [id,line] of structGridLines){if(!line.visible)continue;const pts=line.userData.segments||[];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;const hit=pointSegmentDistance2d([cx,cy],a,b),pixelDistance=hit.distance;if(pixelDistance>8)continue;const clip0=new THREE.Vector4(...vis[0],1).applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix),clip1=new THREE.Vector4(...vis[1],1).applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix),t=perspectiveSegmentParameter(hit.t,clip0.w,clip1.w),world=[vis[0][0]+(vis[1][0]-vis[0][0])*t,vis[0][1]+(vis[1][1]-vis[0][1])*t,vis[0][2]+(vis[1][2]-vis[0][2])*t],worldPoint=new THREE.Vector3(...world),distance=camera.position.distanceTo(worldPoint),depth=worldPoint.clone().project(camera).z;if(!best||pixelDistance<best.pixelDistance-0.01||(Math.abs(pixelDistance-best.pixelDistance)<=0.01&&distance<best.distance))best={id,bubble:false,distance,depth,pixelDistance};}}
5554
+ for(const [id,line] of structGridLines){if(!line.visible)continue;const pts=line.userData.segments||[];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;const hit=projectPointOnSegment2d([cx,cy],a,b,SEG_DEGENERACY.atMost(0)),pixelDistance=hit.distance;if(pixelDistance>8)continue;const clip0=new THREE.Vector4(...vis[0],1).applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix),clip1=new THREE.Vector4(...vis[1],1).applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix),t=perspectiveSegmentParameter(hit.t,clip0.w,clip1.w),world=[vis[0][0]+(vis[1][0]-vis[0][0])*t,vis[0][1]+(vis[1][1]-vis[0][1])*t,vis[0][2]+(vis[1][2]-vis[0][2])*t],worldPoint=new THREE.Vector3(...world),distance=camera.position.distanceTo(worldPoint),depth=worldPoint.clone().project(camera).z;if(!best||pixelDistance<best.pixelDistance-0.01||(Math.abs(pixelDistance-best.pixelDistance)<=0.01&&distance<best.distance))best={id,bubble:false,distance,depth,pixelDistance};}}
5391
5555
  return best;
5392
5556
  }
5393
5557
 
@@ -5410,7 +5574,8 @@ function reconcileGridVisibilityState(scopeChanged=false){
5410
5574
  if(next.selectionChanged&&api&&api.onGridSelectionReset)api.onGridSelectionReset();
5411
5575
  if(next.changed){updateStatusChip();notifyVisibilityChange();}
5412
5576
  }
5413
- 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();}
5577
+ function setGridSelection(ids){selectedGridIds=ids instanceof Set?new Set(ids):new Set(ids||[]);applyDisplayMode();updateStatusChip();}
5578
+ function setSelectionState(ids, gridIds){selectedGridIds=gridIds instanceof Set?new Set(gridIds):new Set(gridIds||[]);setSelection(ids);}
5414
5579
  // Raycast ALL visible meshes — members AND derived connection parts — at a client point → ids
5415
5580
  // front-to-back (nearest first), deduped. Backs click-to-cycle so a small plate/bolt/weld stacked on a
5416
5581
  // beam at a joint is reachable without a modifier (D). pickAt stays members-only — the down-gesture
@@ -5522,14 +5687,15 @@ function resetConnState() { selConn = null; setCtxConn(null); clearConnEnvelope(
5522
5687
  // Select the WHOLE connection at root (single-click a part, or a breadcrumb click). Clears any drill context.
5523
5688
  function selectWholeConn(conn) {
5524
5689
  const kids = conn ? connChildIds(conn) : [];
5525
- if (!conn || !kids.length) return clearConnSel();
5690
+ if (!conn || !kids.length) { clearConnSel(); return false; }
5526
5691
  // Host Select-filter: if this connection's kind is switched off, none of its parts are selectable —
5527
5692
  // stay INERT (leave the current selection + draw NO envelope) instead of a phantom envelope with an
5528
5693
  // empty selection. onSelectMany also filters, but the envelope + selConn are installed here first.
5529
- if (api && api.canSelectId && !kids.some(api.canSelectId)) return;
5694
+ if (api && api.canSelectId && !kids.some(api.canSelectId)) return false;
5530
5695
  selConn = conn; setCtxConn(null); // dropping the drill widens the hover GROUP back to the whole connection (masked while those parts stay selected — it pays off when the selection is later cleared and setSelection's re-glow pass re-lights the set)
5531
5696
  renderConnEnvelope(conn);
5532
5697
  if (api && api.onSelectMany) api.onSelectMany(kids);
5698
+ return true;
5533
5699
  }
5534
5700
  function selectWholeConnWithGrids(conn, gridIds) {
5535
5701
  const kids = conn ? connChildIds(conn) : [];
@@ -5622,8 +5788,8 @@ const members = () => (api && api.getMembers && api.getMembers()) || [];
5622
5788
  const memberById = (id) => { const all = (api && api.allMembers && api.allMembers()) || members(); return all.find((x) => x.id === id); };
5623
5789
  // Drag/endpoint grabs resolve the scale of the sheet that OWNS the grabbed member, from the same
5624
5790
  // per-plan list that builds the snap candidates (allCandidates → membersByPlan). Previously both used
5625
- // the ACTIVE plane's ppf/dtos, so editing an off-active-sheet member whose sheet has a different
5626
- // pt_per_ft inverted the commit through the wrong scale and wrote a mis-scaled wp — while the target it
5791
+ // the ACTIVE plane's mm/px and default TOS, so editing an off-active-sheet member whose sheet has a different
5792
+ // mm_per_px inverted the commit through the wrong scale and wrote a mis-scaled wp — while the target it
5627
5793
  // snapped to had been computed in the target sheet's own scale. One source ⇒ they cannot disagree.
5628
5794
  /*
5629
5795
  * ---- THE MODEL READ BOUNDARY --------------------------------------------------------------------
@@ -5936,7 +6102,7 @@ const POS_HANDLE_TIP = {
5936
6102
  slide: 'Slides the member along its own axis — both work points move together, length unchanged. Drag, or double-click to type an exact value — ¼" snap; hold Shift for no snap.',
5937
6103
  swingPlan: 'Swings the member in plan about its start point — the far end moves, the slope is kept. Drag, or double-click to type an exact angle — 5° snap; hold Shift for no snap.',
5938
6104
  swingElev: 'Tilts the member up or down about its start point — the far end moves, its plan direction is kept. Drag, or double-click to type an exact angle — 5° snap; hold Shift for no snap.',
5939
- anchor: 'Reference-line start — the profile offsets and both swings pivot here. The member-axis arrow slides it along with the far end; the dot itself is not a handle.',
6105
+ anchor: 'Reference-line start — the profile offsets and both swings pivot here. The member-axis arrow slides it along with the far end. Where this overlaps an editable endpoint, drag the endpoint to stretch the member; Alt at drag start changes only its elevation.',
5940
6106
  };
5941
6107
  const POS_SWING_MARGIN_RAD = POSITION_SWING_MARGIN_RAD; // shared with the typed path — see steel-3d-core; if the two drift, a number the drag allows gets refused when typed
5942
6108
  /* One CanvasTexture per glyph, built lazily and kept for the module's life. The gizmo is rebuilt once per
@@ -7063,8 +7229,11 @@ function cmHudApply(pv, abs) {
7063
7229
  const t = pointEntryTok, st = cmActive();
7064
7230
  if (!t || t.consumer !== 'movecopy' || t.gen !== pointEntryGen || !st || !tfDraft || addActive()) return { err: 'Pick the base point again' };
7065
7231
  let v;
7066
- if (pv.comp) {
7067
- const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.comp.map((c) => c * 25.4), provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
7232
+ if (pv.compMm) {
7233
+ // NO CONVERSION. The editor's parser answers millimetres now and the field says so; this used to
7234
+ // multiply by 25.4 in THIS file, one module away from the parse, where no grep of the editor could
7235
+ // ever have found it. The rename at the seam is what makes that impossible to reintroduce quietly.
7236
+ const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.compMm, provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
7068
7237
  if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
7069
7238
  v = r.vector;
7070
7239
  } else { // {dist} along the captured aim — REL / Move-Copy only
@@ -7072,8 +7241,8 @@ function cmHudApply(pv, abs) {
7072
7241
  if (!t.aimWorld) return { err: 'Move the mouse to aim, or type dx,dy' };
7073
7242
  const dir = [t.aimWorld[0] - t.anchorWorld[0], t.aimWorld[1] - t.anchorWorld[1], t.aimWorld[2] - t.anchorWorld[2]];
7074
7243
  const L = Math.hypot(dir[0], dir[1], dir[2]);
7075
- if (!(L > 1e-6) || !Number.isFinite(pv.dist)) return { err: 'Move the mouse to aim, or type dx,dy' };
7076
- const d = pv.dist * 25.4; v = [dir[0] / L * d, dir[1] / L * d, dir[2] / L * d];
7244
+ if (!(L > 1e-6) || !Number.isFinite(pv.distMm)) return { err: 'Move the mouse to aim, or type dx,dy' };
7245
+ const d = pv.distMm; v = [dir[0] / L * d, dir[1] / L * d, dir[2] / L * d];
7077
7246
  }
7078
7247
  if (!v.every(Number.isFinite)) return { err: 'Enter a valid value' };
7079
7248
  if (Math.hypot(v[0], v[1], v[2]) < 5) return { err: 'Zero distance — type a non-zero value' };
@@ -7091,8 +7260,8 @@ function cmHudApply(pv, abs) {
7091
7260
  function drHudApply(pv, abs) {
7092
7261
  const t = pointEntryTok;
7093
7262
  if (!t || t.consumer !== 'add' || t.gen !== pointEntryGen || !addActive()) return { err: 'Arm Add again' };
7094
- if (pv.dist != null) return { err: 'Type coordinates (X, Y) or a delta (dx, dy)' };
7095
- const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.comp.map((c) => c * 25.4), provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
7263
+ if (pv.distMm != null) return { err: 'Type coordinates (X, Y) or a delta (dx, dy)' };
7264
+ const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.compMm, provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
7096
7265
  if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
7097
7266
  const p = r.point;
7098
7267
  if (t.addPhase === 'start') { // set the start; the tool stays armed for the 2nd point
@@ -7385,9 +7554,15 @@ function onDown(e) {
7385
7554
  updateStatusChip(); return;
7386
7555
  }
7387
7556
  downXY = [e.clientX, e.clientY];
7557
+ // The selected member's end dot must remain draggable where the position anchor overlaps it.
7558
+ // Armed Trim/Extend and Split still own their clicks.
7559
+ let endpointHit = null;
7560
+ if (!geoMode() && (MODEL().endpointEditing === true || MODEL().memberEditing !== false)) {
7561
+ try { endpointHit = pickEndpoint(e.clientX, e.clientY); } catch { endpointHit = null; }
7562
+ }
7388
7563
  // Profile Position gizmo (slice 3a): a handle sits ON the selected member, so grab it before the
7389
7564
  // ordinary member pick/endpoint grab. Only a live handle (visible + single selection) can be hit.
7390
- if (positionGizmoVisible && posGizmoState) {
7565
+ if (positionGizmoVisible && posGizmoState && !endpointHit) {
7391
7566
  let pgh = null; try { pgh = pickPositionGizmoHandle(e.clientX, e.clientY); } catch (err) { console.error('steel-3d: position-gizmo hit-test failed', err); pgh = null; } // match the grid/mesh hit-test logging (no silent swallow)
7392
7567
  if (pgh) { e.stopPropagation(); controls.enabled = false; startPositionGizmoDrag(pgh, e); if (pending) return; }
7393
7568
  // The amber anchor is not draggable, but a press on it must not COST the user their selection either.
@@ -7401,12 +7576,27 @@ function onDown(e) {
7401
7576
  }
7402
7577
  let id = null; try { id = pickAt(e.clientX, e.clientY); } catch { id = null; }
7403
7578
  // Geometry-edit mode (Trim/Extend or Split armed in the inspector): a click does the edit, no drag.
7404
- if (geoMode() && (geoMode() === 'el' ? selIds.size >= 1 : selIds.size === 1)) { e.stopPropagation(); pending = { geo: geoMode(), selId: [...selIds][0], targetId: id }; return; } // Split: single; Extend/Trim: any selection
7405
- // An editable projected end node (the yellow/magenta dot) under the cursor → grab just that endpoint to
7406
- // stretch the member. Canonical members still render selection endpoint dots, but are not edited here:
7407
- // let those pixels fall through to the ordinary member-selection path below.
7408
- if (MODEL().memberEditing !== false) {
7409
- let ep = null; try { ep = pickEndpoint(e.clientX, e.clientY); } catch { ep = null; }
7579
+ const armedGeo = geoMode();
7580
+ if (armedGeo && (armedGeo === 'el' ? selIds.size >= 1 : selIds.size === 1)) {
7581
+ e.stopPropagation();
7582
+ const selId = [...selIds][0];
7583
+ let worldState = null;
7584
+ if (armedGeo === 'split' && api && api.splitGestureState) {
7585
+ try { worldState = api.splitGestureState(selId); }
7586
+ catch (err) { console.error('steel-3d: Split gesture snapshot failed', err); worldState = null; }
7587
+ if (!worldState || !worldState.available) {
7588
+ if (api && api.toast) api.toast(worldState && worldState.reason ? worldState.reason : 'That member cannot be split in 3D.');
7589
+ return;
7590
+ }
7591
+ }
7592
+ pending = { geo: armedGeo, selId, targetId: id, worldState };
7593
+ return;
7594
+ } // Split: single; Extend/Trim: any selection
7595
+ // An editable end node (the yellow/magenta dot) under the cursor → grab just that endpoint to stretch
7596
+ // the member. Canonical hosts opt into the narrow world-mm capability without reopening body dragging;
7597
+ // projected hosts inherit endpoint availability from their broader member-edit capability.
7598
+ if (MODEL().endpointEditing === true || MODEL().memberEditing !== false) {
7599
+ const ep = endpointHit;
7410
7600
  if (ep) { e.stopPropagation(); controls.enabled = false; startEndpointGrab(ep, e); return; }
7411
7601
  }
7412
7602
  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.
@@ -7454,15 +7644,15 @@ function onDown(e) {
7454
7644
  // or build display-space drag candidates. Keeping this boundary in the model adapter prevents selection from
7455
7645
  // failing before Member length (and every other selection-driven read) can see the chosen member.
7456
7646
  if (MODEL().memberEditing === false) { pending = { id, add }; return; }
7457
- const { ptPerFt: ppf, defaultTosMm: dtos } = scaleFor(m); // the GRABBED member's sheet, not the active one
7458
- const geo = m ? memberGeometry(m, ppf, dtos) : null;
7647
+ const { mmPerPx, defaultTosMm: dtos } = scaleFor(m); // the GRABBED member's sheet, not the active one
7648
+ const geo = m ? memberGeometry(m, mmPerPx, dtos) : null;
7459
7649
  const mesh = meshById.get(id);
7460
7650
  const planeZ = geo ? (geo.line[0][2] + geo.line[1][2]) / 2 : 0;
7461
7651
  // The drag-out arm above is claimed ahead of the copy/ortho state below, because
7462
7652
  // Ctrl+Shift+DRAG would otherwise mean copy-with-ortho-lock (the one gesture this feature costs).
7463
7653
  // A stationary Ctrl+Shift click still falls through to the toggle-select it has always been.
7464
7654
  pending = {
7465
- id, ctrl, add, ppf, planeZ,
7655
+ id, ctrl, add, mmPerPx, planeZ,
7466
7656
  copy: ctrl, copyIds: ctrl ? (selIds.has(id) ? [...selIds] : [id]) : null, // Ctrl+drag copies: the selection if this member is in it, else just it
7467
7657
  grab: geo ? rayToPlane(e.clientX, e.clientY, planeZ) : null,
7468
7658
  origMm: geo ? geo.line.map((p) => [p[0], p[1], p[2]]) : null,
@@ -7613,43 +7803,68 @@ function onMoveVertical(e) {
7613
7803
  readout.style.left = (e.clientX + 14) + 'px'; readout.style.top = (e.clientY + 14) + 'px'; readout.style.display = 'block';
7614
7804
  }
7615
7805
 
7616
- // Grab a single end node: drag it on the member's work-plane (its TOS), snapping to other members.
7806
+ // Grab one endpoint: free motion stays at its elevation; 3D snaps and Alt can change its Z.
7617
7807
  function startEndpointGrab(ep, e) {
7618
7808
  try {
7619
7809
  const m = memberById(ep.id); if (!m) { controls.enabled = true; return; }
7620
- const { ptPerFt: ppf, defaultTosMm: dtos } = scaleFor(m); // the GRABBED member's sheet, not the active one
7621
- const g = memberGeometry(m, ppf, dtos);
7810
+ if (api && api.endpointGestureState) {
7811
+ const state = api.endpointGestureState(ep.id);
7812
+ if (!state || !state.available) {
7813
+ controls.enabled = true; pending = null; dragEp = null;
7814
+ if (api.toast) api.toast(state && state.reason ? state.reason : 'That endpoint cannot be moved in 3D.');
7815
+ return;
7816
+ }
7817
+ const line = state.line;
7818
+ pending = {
7819
+ epDrag: true, world: true, state, id: ep.id, end: ep.end,
7820
+ planeZ: line[ep.end][2], fixed: line[1 - ep.end],
7821
+ candidates: allCandidates(ep.id).filter((c) => candAllowed3d(c.type)),
7822
+ orig: line[ep.end].slice(), newPt: line[ep.end].slice(),
7823
+ };
7824
+ dragEp = { id: ep.id, end: ep.end };
7825
+ return;
7826
+ }
7827
+ const { mmPerPx, defaultTosMm: dtos } = scaleFor(m); // the GRABBED member's sheet, not the active one
7828
+ const g = memberGeometry(m, mmPerPx, dtos);
7622
7829
  pending = {
7623
- epDrag: true, id: ep.id, end: ep.end, ppf,
7830
+ epDrag: true, id: ep.id, end: ep.end, mmPerPx,
7624
7831
  planeZ: g.line[ep.end][2], fixed: g.line[1 - ep.end],
7625
7832
  candidates: allCandidates(ep.id).filter((c) => candAllowed3d(c.type)), // member + grid snap targets, filtered by the running-snaps (⋯ menu → Snapping)
7626
7833
  orig: g.line[ep.end].slice(), // where this end started — the "moved" distance reference (the dragged end stays on planeZ, so orig[2] === planeZ)
7627
7834
  newPt: [g.line[ep.end][0], g.line[ep.end][1]],
7628
7835
  };
7629
7836
  dragEp = { id: ep.id, end: ep.end };
7630
- } catch (err) { controls.enabled = true; pending = null; dragEp = null; }
7837
+ } catch (err) { console.error('steel-3d: endpoint gesture failed', err); controls.enabled = true; pending = null; dragEp = null; }
7631
7838
  }
7632
7839
  function onMoveEndpoint(e) {
7633
7840
  if (!dragging && Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) <= DRAG_TOL_PX) return;
7841
+ if (!dragging) pending.vertical = pending.world === true && e.altKey;
7634
7842
  dragging = pending;
7635
- const hit = rayToPlane(e.clientX, e.clientY, pending.planeZ);
7636
- if (!hit) { epMovedLine.visible = false; epPreview.visible = false; marker.visible = false; readout.style.display = 'none'; return; } // ray parallel to the work-plane (edge-on) or canvas collapsed — park the overlay + readout, don't freeze them at a stale point
7637
- const r = snapPoint([hit[0], hit[1], pending.planeZ], pending.candidates, toScreen, SNAP_TOL_PX);
7638
- const np = r.candidate ? r.snapped : [hit[0], hit[1], pending.planeZ];
7639
- pending.newPt = [np[0], np[1]];
7843
+ const hit = pending.vertical ? null : rayToPlane(e.clientX, e.clientY, pending.planeZ);
7844
+ const verticalHit = (pending.vertical || !hit) ? rayToVerticalPlane(e.clientX, e.clientY, pending.orig) : null;
7845
+ const r = endpointDragPoint(pending.orig, hit, verticalHit, pending.vertical, pending.candidates,
7846
+ toScreen, SNAP_TOL_PX, pending.world === true && (!api || !api.snap3dFree || api.snap3dFree()));
7847
+ if (!r) {
7848
+ pending.newPt = null;
7849
+ const dot = epGroup.children.find((c) => c.userData.epId === pending.id && c.userData.epEnd === pending.end);
7850
+ if (dot) dot.position.set(...pending.orig);
7851
+ epMovedLine.visible = false; epPreview.visible = false; marker.visible = false; readout.style.display = 'none'; return;
7852
+ }
7853
+ const np = r.point;
7854
+ pending.newPt = np.slice();
7640
7855
  const dot = epGroup.children.find((c) => c.userData.epId === pending.id && c.userData.epEnd === pending.end);
7641
- if (dot) dot.position.set(np[0], np[1], pending.planeZ);
7856
+ if (dot) dot.position.set(...np);
7642
7857
  const f = pending.fixed, o = pending.orig;
7643
- epPreview.geometry.setFromPoints([new THREE.Vector3(f[0], f[1], f[2]), new THREE.Vector3(np[0], np[1], pending.planeZ)]);
7858
+ epPreview.geometry.setFromPoints([new THREE.Vector3(...f), new THREE.Vector3(...np)]);
7644
7859
  epPreview.visible = true;
7645
7860
  // "moved" leader: cyan dashed line from where the end started (o) to the new point — the 3D echo of the 2D Move rubber
7646
- epMovedLine.geometry.setFromPoints([new THREE.Vector3(o[0], o[1], o[2]), new THREE.Vector3(np[0], np[1], pending.planeZ)]);
7861
+ epMovedLine.geometry.setFromPoints([new THREE.Vector3(...o), new THREE.Vector3(...np)]);
7647
7862
  epMovedLine.computeLineDistances(); epMovedLine.visible = true;
7648
- if (r.candidate) showMarker(np, r.candidate.type); else marker.visible = false;
7649
- const len = Math.hypot(np[0] - f[0], np[1] - f[1], pending.planeZ - f[2]) / FT_MM; // true 3D member length (matches the inspector's Length)
7650
- const moved = Math.hypot(np[0] - o[0], np[1] - o[1]) / FT_MM; // in-plane distance the end has travelled ("same as Move")
7863
+ if (r.type) showMarker(np, r.type); else marker.visible = false;
7864
+ const len = Math.hypot(np[0] - f[0], np[1] - f[1], np[2] - f[2]) / FT_MM;
7865
+ const moved = Math.hypot(np[0] - o[0], np[1] - o[1], np[2] - o[2]) / FT_MM;
7651
7866
  readout._dist.textContent = len.toFixed(2) + ' ft'; // primary: the member's live length
7652
- readout._type.textContent = ' · moved ' + moved.toFixed(2) + ' ft' + (r.candidate ? ' · ' + r.candidate.type : ''); // secondary: how far the end moved (+ snap)
7867
+ readout._type.textContent = ' · moved ' + moved.toFixed(2) + ' ft' + (pending.vertical ? ' · elevation' : '') + (r.type ? ' · ' + r.type : '');
7653
7868
  readout.style.left = (e.clientX + 14) + 'px'; readout.style.top = (e.clientY + 14) + 'px'; readout.style.display = 'block';
7654
7869
  }
7655
7870
 
@@ -7903,23 +8118,43 @@ function onUp(e) {
7903
8118
  return;
7904
8119
  }
7905
8120
  if (p.epDrag) { // end-node drag → write just that endpoint's wp; a click (no drag) just selects the member
7906
- if (wasDragging && p.newPt && api && api.onMoveEndpoint) { if (api.onSelect) api.onSelect(p.id, false); api.onMoveEndpoint(p.id, p.end, planPointToWp(p.newPt, p.ppf)); }
7907
- else if (api && api.onSelect) api.onSelect(p.id, false);
8121
+ if (wasDragging && p.newPt && p.world && api && api.onMoveEndpointWorld) {
8122
+ if (api.onSelect) api.onSelect(p.id, false);
8123
+ const commit = worldEndpointCommit(p);
8124
+ if (!commit) { rebuildEndpoints(); return; } // moved away and returned: an ordinary no-op, not a canonical refusal
8125
+ let ok = false;
8126
+ try { ok = !!api.onMoveEndpointWorld(commit.id, commit.end, commit.point, commit.state); }
8127
+ catch (err) { console.error('steel-3d: endpoint commit failed', err); ok = false; }
8128
+ if (!ok) rebuildEndpoints();
8129
+ }
8130
+ else if (wasDragging && p.newPt && api && api.onMoveEndpoint) { if (api.onSelect) api.onSelect(p.id, false); api.onMoveEndpoint(p.id, p.end, planPointToWp(p.newPt, p.mmPerPx)); }
8131
+ else { if (api && api.onSelect) api.onSelect(p.id, false); rebuildEndpoints(); }
7908
8132
  return;
7909
8133
  }
7910
8134
  if (p.geo) { // Trim/Extend or Split — a click (no drag) performs the edit
7911
8135
  if (moved > DRAG_TOL_PX) return;
7912
8136
  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
7913
8137
  if (p.geo === 'split') { // cut the selected member at the clicked point on its centreline
8138
+ if (p.worldState && api && api.onSplitWorld) {
8139
+ let hit = null;
8140
+ try { hit = selectedFrontmostHit(meshHitsAt(e.clientX, e.clientY, true), p.selId); }
8141
+ catch (err) { console.error('steel-3d: Split mesh hit-test failed', err); return; }
8142
+ if (!hit) return; // only the visible frontmost solid may receive the cut
8143
+ const point = [hit.point.x, hit.point.y, hit.point.z];
8144
+ const projected = projectPointOnSegment3d(point, p.worldState.line[0], p.worldState.line[1], SEG_DEGENERACY.atMost(0));
8145
+ if (projected.t <= 0.03 || projected.t >= 0.97) return;
8146
+ api.onSplitWorld(p.selId, projected.t, p.worldState);
8147
+ return;
8148
+ }
7914
8149
  const m = memberById(p.selId); if (!m) return;
7915
- const { ptPerFt: ppf, defaultTosMm: dtos } = scaleFor(m); // the SPLIT member's sheet, not the active one
7916
- const g = memberGeometry(m, ppf, dtos);
8150
+ const { mmPerPx, defaultTosMm: dtos } = scaleFor(m); // the SPLIT member's sheet, not the active one
8151
+ const g = memberGeometry(m, mmPerPx, dtos);
7917
8152
  const planeZ = (g.line[0][2] + g.line[1][2]) / 2;
7918
8153
  const hit = rayToPlane(e.clientX, e.clientY, planeZ); if (!hit) return;
7919
8154
  if (p.targetId !== p.selId) return; // the cut click must land on the selected member's body
7920
- const { pt: cut, t } = closestOnSeg3([hit[0], hit[1]], g.line[0], g.line[1]); // nearest point ON the member (plan)
8155
+ const { pt: cut, t } = closestOnSegXY([hit[0], hit[1]], g.line[0], g.line[1]); // nearest point ON the member (plan)
7921
8156
  if (t <= 0.03 || t >= 0.97) return; // too near an end → no degenerate split
7922
- if (api && api.onSplit) api.onSplit(p.selId, planPointToWp(cut, ppf));
8157
+ if (api && api.onSplit) api.onSplit(p.selId, planPointToWp(cut, mmPerPx));
7923
8158
  return;
7924
8159
  }
7925
8160
  return;
@@ -7932,23 +8167,29 @@ function onUp(e) {
7932
8167
  if (p.delta && !(p.delta[0] === 0 && p.delta[1] === 0) && api && api.onCopyDrag3d) api.onCopyDrag3d(p.copyIds, p.delta[0], p.delta[1]);
7933
8168
  return;
7934
8169
  }
7935
- if (p.mode === 'vertical') { // elevation drag → write T.O.S (inches)
8170
+ if (p.mode === 'vertical') { // elevation drag → write T.O.S
7936
8171
  if (p.dz && Math.abs(p.dz) > 1e-6) {
7937
8172
  if (api && api.onSelect) api.onSelect(p.id, false);
7938
- if (api && api.onElevateMember) api.onElevateMember(p.id, p.dz / 25.4); // mm → inches
8173
+ // `p.dz` IS world millimetres and `onElevateMember` now takes millimetres, so there is nothing to
8174
+ // convert. It divided by 25.4 here for as long as the editor's elevations were inches; when they
8175
+ // became millimetres this line was the one that did not move, and a 304.8 mm drag committed 12 mm.
8176
+ // The unit tests could not see it because they call `onElevateMember` directly — the conversion
8177
+ // lives on the 3D-view side of the callback, so only a test that crosses the seam observes it.
8178
+ if (api && api.onElevateMember) api.onElevateMember(p.id, p.dz);
7939
8179
  }
7940
8180
  return;
7941
8181
  }
7942
8182
  if (!p.delta || (p.delta[0] === 0 && p.delta[1] === 0)) return; // dragged but no net move
7943
- const newWp = p.origMm.map((mm) => planPointToWp([mm[0] + p.delta[0], mm[1] + p.delta[1]], p.ppf));
8183
+ const newWp = p.origMm.map((mm) => planPointToWp([mm[0] + p.delta[0], mm[1] + p.delta[1]], p.mmPerPx));
7944
8184
  if (api && api.onSelect) api.onSelect(p.id, false); // keep the moved member selected
7945
8185
  if (api && api.onMoveMember) api.onMoveMember(p.id, newWp); // editor writes wp via edit()
7946
8186
  }
7947
- // nearest point on segment a-b to plan point p (XY only) → { pt:[x,y], t }
7948
- function closestOnSeg3(p, a, b) {
7949
- const abx = b[0] - a[0], aby = b[1] - a[1], l2 = abx * abx + aby * aby || 1;
7950
- let t = ((p[0] - a[0]) * abx + (p[1] - a[1]) * aby) / l2; t = Math.max(0, Math.min(1, t));
7951
- return { pt: [a[0] + abx * t, a[1] + aby * t], t };
8187
+ // Nearest point on segment a-b to plan point p — XY only, world mm, → { pt:[x,y], t }. The projection
8188
+ // is steel-3d-core's one implementation (#951); the tolerance stays this caller's historic rule, where
8189
+ // only a `len2 || 1` substitution stands in for a zero span. (The old name said 3; it was always planar.)
8190
+ function closestOnSegXY(p, a, b) {
8191
+ const { closest, t } = projectPointOnSegment2d(p, a, b, SEG_DEGENERACY.unitDenominator);
8192
+ return { pt: closest, t };
7952
8193
  }
7953
8194
 
7954
8195
  // ---- hover: cursor + readout chip (no drag in progress) ----
@@ -8034,7 +8275,11 @@ function onHoverMove(e) {
8034
8275
  if (p) {
8035
8276
  showMarker([p.x, p.y, p.z], p.snapped ? 'end' : 'dot');
8036
8277
  canvasEl.style.cursor = p.snapped ? 'none' : 'crosshair';
8037
- readout._dist.textContent = api.fmtLen ? api.fmtLen(p.z) : (p.z / 304.8).toFixed(2) + ' ft';
8278
+ // An ELEVATION, not a distance — this is the level the column base would seat at, and its
8279
+ // `_type` chip below literally says "level". One generic formatter would print a metric one as
8280
+ // 106000 where the convention on every real UK drawing is +106.000 metres, which is why the
8281
+ // editor injects two hooks rather than one.
8282
+ readout._dist.textContent = api.fmtElev ? api.fmtElev(p.z) : (api.fmtLen ? api.fmtLen(p.z) : (p.z / 304.8).toFixed(2) + ' ft');
8038
8283
  readout._type.textContent = p.snapped ? ' · ' + (p.label || 'level') : ' ↕';
8039
8284
  readout.style.left = (lastHoverXY[0] + 14) + 'px'; readout.style.top = (lastHoverXY[1] + 14) + 'px'; readout.style.display = 'block';
8040
8285
  roCoords([p.x, p.y, p.z]);
@@ -8070,8 +8315,23 @@ function onHoverMove(e) {
8070
8315
  canvasEl.style.cursor = fh ? 'grab' : 'crosshair';
8071
8316
  return;
8072
8317
  }
8318
+ if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !refMeasure3d && !selectedClipIds.size) { // hovering the PASSIVE gizmo (nothing armed) → pointer cursor hints "click to edit the local axes again"
8319
+ let fh = null; try { fh = pickFrameHandle(lastHoverXY[0], lastHoverXY[1], true); } catch { fh = null; }
8320
+ if (fh) { canvasEl.style.cursor = 'pointer'; return; }
8321
+ }
8322
+ if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(lastHoverXY[0], lastHoverXY[1]); } catch { ch = null; } if (ch) { canvasEl.style.cursor = 'move'; return; } } // over a clip handle → move cursor
8323
+ let ep = null;
8324
+ if (!geoMode() && (MODEL().endpointEditing === true || MODEL().memberEditing !== false)) {
8325
+ try { ep = pickEndpoint(lastHoverXY[0], lastHoverXY[1]); } catch { ep = null; }
8326
+ }
8327
+ if (ep) {
8328
+ if (posHovered) { setPositionHover(null); posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip(); }
8329
+ hoverEp = ep; canvasEl.style.cursor = 'move';
8330
+ setHover(ep.id); updateStatusChip(); return;
8331
+ }
8332
+ hoverEp = null;
8073
8333
  // Profile Position handle hover (toggle on, single selection, frame not armed): grab cursor + a themed
8074
- // tooltip. Mirrors onDown precedence (the handle sits ON the member and wins over the passive frame origin).
8334
+ // tooltip. Mirrors onDown precedence after explicit tools, passive frame / clip handles and endpoint dots.
8075
8335
  if (positionGizmoVisible && posGizmoState && !frameMode && posInteraction !== 'typing') {
8076
8336
  let ph = null; try { ph = pickPositionGizmoHandle(lastHoverXY[0], lastHoverXY[1]); } catch { ph = null; }
8077
8337
  // setPositionHover owns BOTH the amber repaint and the grab cursor — colour, cursor and tooltip are
@@ -8091,21 +8351,6 @@ function onHoverMove(e) {
8091
8351
  setPositionHover(null);
8092
8352
  if (posHovered) { posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip(); }
8093
8353
  } else if (posHovered) { setPositionHover(null); posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip(); } // gizmo disappeared while a tip was up
8094
- if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !refMeasure3d && !selectedClipIds.size) { // hovering the PASSIVE gizmo (nothing armed) → pointer cursor hints "click to edit the local axes again"
8095
- let fh = null; try { fh = pickFrameHandle(lastHoverXY[0], lastHoverXY[1], true); } catch { fh = null; }
8096
- if (fh) { canvasEl.style.cursor = 'pointer'; return; }
8097
- }
8098
- if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(lastHoverXY[0], lastHoverXY[1]); } catch { ch = null; } if (ch) { canvasEl.style.cursor = 'move'; return; } } // over a clip handle → move cursor
8099
- let ep = null;
8100
- if (MODEL().memberEditing !== false) {
8101
- try { ep = pickEndpoint(lastHoverXY[0], lastHoverXY[1]); } catch { ep = null; }
8102
- }
8103
- if (ep) { // over an end node (a selected member's drag handle) → ring + move cursor
8104
- hoverEp = ep; canvasEl.style.cursor = 'move';
8105
- setHover(ep.id); // glow is a no-op here (ep.id is selected → selection wins), but this clears any prior member's glow
8106
- updateStatusChip(); return;
8107
- }
8108
- hoverEp = null;
8109
8354
  let top = null; try { top = pickAllAt(lastHoverXY[0], lastHoverXY[1])[0] || null; } catch { top = null; }
8110
8355
  const topMesh = top ? meshById.get(top) : null, isPart = !!(topMesh && topMesh.userData.derived);
8111
8356
  const canDrag = api && api.dragMoveEnabled && api.dragMoveEnabled();
@@ -8252,6 +8497,12 @@ function updateStatusChip() {
8252
8497
  txt = (meta ? meta.label : cmd3d.armed) + pickedCountTxt(cmd3d.armed) + ' · ' + escRoute; } // reporter-unavailable fallback
8253
8498
  else if (toolGuidance.text) txt = toolGuidance.text;
8254
8499
  else if (showId) { const m = memberById(showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
8500
+ else if (ghostUnselectedEnabled) {
8501
+ const n = selIds.size + selectedGridIds.size, parts = [n ? `Ghost Unselected · ${n} selected` : 'Ghost Unselected on · select objects to focus'];
8502
+ if (isIsolated()) parts.push(`Isolated: ${(isolatedIds ? isolatedIds.size : 0) + (isolatedGridIds ? isolatedGridIds.size : 0)}`, 'Show all to restore');
8503
+ else if (selectionHidden.size || gridSelectionHidden.size) parts.push(`${selectionHidden.size + gridSelectionHidden.size} objects hidden`, 'Show all to restore');
8504
+ txt = parts.join(' · ');
8505
+ }
8255
8506
  else if (selectionStatus) txt = selectionStatus;
8256
8507
  else if (isIsolated()) txt = `Isolated: ${(isolatedIds ? isolatedIds.size : 0) + (isolatedGridIds ? isolatedGridIds.size : 0)} · Show all to restore`;
8257
8508
  else if (selectionHidden.size || gridSelectionHidden.size) txt = `${selectionHidden.size + gridSelectionHidden.size} objects hidden · Show all to restore`;
@@ -8455,7 +8706,7 @@ function debug() {
8455
8706
  // the pixels valid. Exists so a MATERIAL change can be checked by looking at it, not only by
8456
8707
  // asserting on state — the whole point of Realistic is how it looks.
8457
8708
  snapshot: (quality = 0.82) => { renderer.render(scene, camera); return canvasEl.toDataURL('image/jpeg', quality); },
8458
- 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,
8709
+ 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, ghostUnselected: ghostUnselectedEnabled,
8459
8710
  selected: [...selIds], selectedGrids: [...selectedGridIds], derivedIds: [...meshById].filter(([,m])=>m.userData&&m.userData.derived).map(([id])=>id),
8460
8711
  endpoints: epGroup ? epGroup.children.length : 0,
8461
8712
  endpointColors: epGroup ? epGroup.children.map((c) => '#' + c.material.color.getHexString()) : [],
@@ -8476,7 +8727,8 @@ function debug() {
8476
8727
  // test helper: the current material colour + emissive of a member (verifies deselect restores colour)
8477
8728
  function probe(id) {
8478
8729
  const m = meshById.get(id); if (!m) return null;
8479
- return { color: '#' + m.material.color.getHexString(), emissive: m.material.emissiveIntensity || 0, visible: m.visible, wireframe: !!m.material.wireframe };
8730
+ const ls = wireEdges.get(id);
8731
+ return { color: '#' + m.material.color.getHexString(), emissive: m.material.emissiveIntensity || 0, opacity: m.material.opacity, depthWrite: m.material.depthWrite, castShadow: m.castShadow, visible: m.visible, wireframe: !!m.material.wireframe, wireOpacity: ls && ls.visible ? ls.material.opacity : null, wireColor: ls && ls.visible ? '#' + ls.material.color.getHexString() : null };
8480
8732
  }
8481
8733
  // test helper: client (px) coords of a member's endpoint (end 0|1) — lets an E2E drive a precise drag
8482
8734
  function screenOf(id, end) {
@@ -8564,7 +8816,7 @@ function gridSegmentsScreen() {
8564
8816
  }
8565
8817
  function gridBubblesScreen(){if(!gridLabelGroup)return [];const rect=canvasEl.getBoundingClientRect();return gridLabelGroup.children.filter(s=>s.visible&&s.userData.gridId).map(s=>{const p=s.getWorldPosition(new THREE.Vector3()).project(camera);return {id:s.userData.gridId,x:rect.left+(p.x*.5+.5)*rect.width,y:rect.top+(-p.y*.5+.5)*rect.height};});}
8566
8818
  window.Steel3DView = {
8567
- init, show, hide, setInputActive, rebuild, setSelection, setGridSelection, isReady, dispose,
8819
+ init, show, hide, setInputActive, rebuild, setSelection, setGridSelection, setSelectionState, isReady, dispose,
8568
8820
  setProjection, projection, setDisplayMode, mode: () => displayMode, frameAll, frameSelection, applyView,
8569
8821
  setRefLine, refLine: () => refLineOn,
8570
8822
  setInsertMode, insertMode: insertModeOn, // arm/query the detail-placement pick (Slice 4)
@@ -8629,11 +8881,11 @@ window.Steel3DView = {
8629
8881
  propLabelTexts: () => propLabelPool.filter((el) => el.style.display !== 'none' && el.style.visibility !== 'hidden').map((el) => el.textContent), // visible property-label chips — for tests
8630
8882
  selLenLabelTexts: () => selLenLabelPool.filter((el) => el.style.display !== 'none' && el.style.visibility !== 'hidden').map((el) => el.textContent), // visible on-select length chips — for tests
8631
8883
  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
8632
- refreshGrid: buildStructGrid, // grid edited in the panel → re-render without a full rebuild
8884
+ refreshGrid: () => { buildStructGrid(); applyDisplayMode(); }, // grid edited in the panel → rebuild, then re-derive Ghost against the fresh line/label materials
8633
8885
  setGridLabelPx: (px) => { gridLabelPx = clampGridLabelPx(px); sizeGridLabels(); }, // ⋯ ▸ Display ▸ Grid label size — no rebuild needed, the labels are re-placed every frame anyway
8634
8886
  gridLabelPx: () => gridLabelPx,
8635
8887
  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)
8636
- 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
8888
+ gridInfo: () => ({ lines: structGridLines.size, labels: gridLabelGroup ? gridLabelGroup.children.length : 0,labelTexts:gridLabelGroup?[...new Set(gridLabelGroup.children.map(s=>s.userData.label).filter(Boolean))]:[],lineOpacities:[...structGridLines.values()].filter(l=>l.visible).map(l=>l.material.opacity),labelOpacities:gridLabelGroup?gridLabelGroup.children.filter(s=>s.visible).map(s=>s.material.opacity):[],selected:[...selectedGridIds],ids:[...structGridLines.keys()],visible:visibleGridIds(),hidden:[...gridSelectionHidden],isolated:isolatedGridIds===null?null:[...isolatedGridIds] }), // test helper
8637
8889
  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.
8638
8890
  if (!wpGroup) return { group: false, extent: wpExtent };
8639
8891
  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 })) };
@@ -8642,7 +8894,8 @@ window.Steel3DView = {
8642
8894
  setClipMode, clipMode: clipModeOn, toggleClip, removeClip, clearClips, getClips, renameClip, selectClip, setSelectedClips, selectedClips, deleteSelectedClips, clipState, setClipState,
8643
8895
  // Instructor seam: what this module has armed, and the one slot that paints what the shell produced.
8644
8896
  instructorCommand, renderGuidance,
8645
- isolateSelected, hideSelected, clearIsolation, isIsolated, hasVisibilityFilter,
8897
+ isolateSelected, hideSelected, clearIsolation, isIsolated, hasVisibilityFilter, hasVisibilityTreatment,
8898
+ setGhostUnselected, toggleGhostUnselected: () => setGhostUnselected(!ghostUnselectedEnabled), ghostUnselected: () => ghostUnselectedEnabled,
8646
8899
  cameraState, setCameraState, sectionViewState, sceneBounds, objectsPaneState, applyObjectsPaneState, // saved-view snapshot surface (Views Organizer + F11 generated cuts)
8647
8900
  workAreaSetAll, workAreaFromSelection, workAreaToggle, workAreaSetWhole, clearWorkArea, workAreaState,
8648
8901
  armWorkPlanePick, setWorkPlanePrincipal, clearWorkPlane, toggleWorkPlaneVisible, workPlaneInfo,