@floless/app 0.103.0 → 0.103.2

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.
@@ -53583,7 +53583,7 @@ function appVersion() {
53583
53583
  return resolveVersion({
53584
53584
  isSea: isSea2(),
53585
53585
  sqVersionXml: readSqVersionXml(),
53586
- define: true ? "0.103.0" : void 0,
53586
+ define: true ? "0.103.2" : void 0,
53587
53587
  pkgVersion: readPkgVersion()
53588
53588
  });
53589
53589
  }
@@ -53593,7 +53593,7 @@ function resolveChannel(s) {
53593
53593
  return "dev";
53594
53594
  }
53595
53595
  function appChannel() {
53596
- return resolveChannel({ isSea: isSea2(), define: true ? "0.103.0" : void 0 });
53596
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.103.2" : void 0 });
53597
53597
  }
53598
53598
 
53599
53599
  // workflow-update.ts
@@ -215,7 +215,7 @@ function init(canvas, theApi) {
215
215
  window.addEventListener('pointermove', onMove); // window so a drag keeps tracking off-canvas
216
216
  window.addEventListener('pointerup', onUp);
217
217
  canvas.addEventListener('pointermove', onHoverMove); // canvas-only: cursor + hover readout when idle
218
- canvas.addEventListener('pointerleave', () => { hoverEp = null; if (hoverRAF) { cancelAnimationFrame(hoverRAF); hoverRAF = 0; } setHover(null); updateStatusChip(); }); // leaving the canvas clears the hover glow + chip; cancel any queued hover frame so it can't re-glow the last member after the cursor left
218
+ canvas.addEventListener('pointerleave', () => { hoverEp = null; if (hoverRAF) { cancelAnimationFrame(hoverRAF); hoverRAF = 0; } setHover(null); setClipPlanePreview(null); if (clipMode && marker) marker.visible = false; updateStatusChip(); }); // leaving the canvas clears the hover glow + chip + clip-plane ghost + a clip snap reticle; cancel any queued hover frame so it can't re-glow the last member after the cursor left
219
219
  canvas.addEventListener('dblclick', onDblClick); // "zoom to detail": dbl-click a part zooms to it (empty = no-op)
220
220
  window.addEventListener('keydown', onKey); // Tekla keyboard nav: arrows pan, Ctrl/Shift+arrows rotate
221
221
  ro = new ResizeObserver(resize); ro.observe(canvas.parentElement || canvas);
@@ -601,6 +601,7 @@ function applyCopes(mesh, cuts) {
601
601
 
602
602
  function buildFromScene(sc) {
603
603
  clearRoot();
604
+ clipCandidates = null; clipLevels = null; // the model changed (edit/undo/redo) — drop the clip-draw snap cache so a draw in progress re-snaps against the CURRENT members/grid/levels, never stale ones
604
605
  resetConnState(); // a fresh scene rebuilds selection from scratch — drop any stale connection envelope/context
605
606
  for (const mat of baseMat.values()) mat.dispose(); // shared per-profile materials from the prior build
606
607
  groupColor.clear(); baseMat.clear();
@@ -1068,6 +1069,8 @@ let rebuildSeq = 0;
1068
1069
  async function rebuild(fit = false) {
1069
1070
  if (!api) return;
1070
1071
  invalidatePointEntry('rebuild'); // synchronous, BEFORE the first await — the scene is changing; drop any open typed entry + stale base (never on stale async completion)
1072
+ clipCandidates = null; clipLevels = null; // …and the clip-draw snap cache, 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
1073
+ 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)
1071
1074
  if (fit) fitPending = true; // entering 3D re-fits; an edit-triggered rebuild keeps the camera put
1072
1075
  const seq = ++rebuildSeq;
1073
1076
  const sc = await api.fetchScene(); // editor POSTs the current contract to /scene
@@ -1215,6 +1218,8 @@ let clipGizmo = null; // THREE.Group: the selected clip's outlin
1215
1218
  let clipPreview = null; // THREE.Box3Helper while drawing a clip box
1216
1219
  const EMPTY_CLIPS = Object.freeze([]);
1217
1220
  const CLIP_PLANE_COLOR = 0x3b82f6, CLIP_BOX_COLOR = 0x93c5fd; // brand blue (plane) / lighter blue (box) — match the legend swatches
1221
+ const CLIP_PREVIEW_COLOR = 0xbfdbfe; // pale blue — the armed-plane hover ghost, bright enough to read against any member colour
1222
+ const CLIP_PLANE_PATCH_R = FT_MM; // plane-patch half-size = 1 ft → a 2'×2' marker; the hover ghost + the placed gizmo outline share this size/place (the ghost just adds a translucent fill in the pale preview colour) so the preview lands where a click will
1218
1223
  function applyClips() {
1219
1224
  if (!renderer) return;
1220
1225
  const active = clips.filter((c) => c.enabled).flatMap((c) => c.planes);
@@ -1236,30 +1241,57 @@ function setClipMode(m) { // arm/disarm a clip pick: 'plane' (clic
1236
1241
  if (m && dimMode3d) toggleDimTool();
1237
1242
  if (m) { if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); disarmFrame3d(); } // clip shares the left-click — disarm Move/Copy + Add + the local frame so their picks don't steal it (onDown routes them first)
1238
1243
  clipMode = (m === 'plane' || m === 'box') ? m : null;
1239
- clipBoxDraft = null; setClipPreview(null);
1244
+ clipBoxDraft = null; clipCandidates = null; clipLevels = null; setClipPreview(null); setClipPlanePreview(null); if (marker) marker.visible = false; // drop the per-draw snap cache + any live snap marker when arming/disarming
1240
1245
  if (canvasEl) canvasEl.style.cursor = clipMode ? 'crosshair' : 'default';
1241
1246
  updateStatusChip();
1242
1247
  if (api && api.onClipModeChange) api.onClipModeChange(clipMode);
1243
1248
  return clipMode;
1244
1249
  }
1245
1250
  function clipModeOn() { return clipMode; }
1246
- // A clip plane from a clicked surface (screen px): keep the camera-far side. Selects the new clip. Stays armed.
1247
- function addClipPlaneAtScreen(cx, cy) {
1251
+ // The plane a face-pick would produce at (cx,cy): { n (keep-side normal, pointing away from the camera), point } or
1252
+ // null on a miss. Shared by the actual pick and the hover preview so the ghost always matches what a click places.
1253
+ function clipPlaneAtScreen(cx, cy) {
1248
1254
  camera.updateMatrixWorld(); root.updateMatrixWorld(true);
1249
1255
  const rect = canvasEl.getBoundingClientRect(); if (!rect.width || !rect.height) return null;
1250
1256
  const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
1251
1257
  raycaster.setFromCamera(ndc, camera);
1252
1258
  const hit = raycaster.intersectObjects([...meshById.values()].filter((m) => m.visible), false)[0];
1253
- if (!hit || !hit.face) return null; // missed a face → no plane (the user can click again)
1259
+ if (!hit || !hit.face) return null; // missed a face → no plane
1254
1260
  const n = hit.face.normal.clone().transformDirection(hit.object.matrixWorld).normalize(); // face normal → world
1255
1261
  if (n.dot(camera.position.clone().sub(hit.point)) > 0) n.negate(); // point AWAY from the camera → keep the FAR side, cut away what's between you and the clicked surface (reveal the section)
1262
+ return { n, point: hit.point.clone() };
1263
+ }
1264
+ // A clip plane from a clicked surface (screen px). Selects the new clip. Returns the id on a hit (the caller then
1265
+ // disarms — one plane per command) or null on a miss (stays armed to retry).
1266
+ function addClipPlaneAtScreen(cx, cy) {
1267
+ const pp = clipPlaneAtScreen(cx, cy); if (!pp) return null;
1256
1268
  if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
1257
1269
  const id = 'clip' + (++clipSeq);
1258
- const c = { id, kind: 'plane', enabled: true, n: n.clone(), point: hit.point.clone(), planes: [], label: 'Plane ' + clipSeq };
1270
+ const c = { id, kind: 'plane', enabled: true, n: pp.n.clone(), point: pp.point.clone(), planes: [], label: 'Plane ' + clipSeq };
1259
1271
  rebuildClipPlanes(c); clips.push(c);
1260
1272
  applyClips(); selectClip(id); if (api && api.onClipsChange) api.onClipsChange();
1261
1273
  return id;
1262
1274
  }
1275
+ // The in-plane square (4 corners) for a plane patch of half-size r around hp — shared by the gizmo outline + the
1276
+ // hover preview so both read as the same 2'×2' marker.
1277
+ function planePatchCorners(hp, n, r) {
1278
+ const u = (Math.abs(n.z) < 0.9 ? new THREE.Vector3(0, 0, 1) : new THREE.Vector3(1, 0, 0)).cross(n).normalize(), v = n.clone().cross(u).normalize();
1279
+ return [hp.clone().addScaledVector(u, r).addScaledVector(v, r), hp.clone().addScaledVector(u, -r).addScaledVector(v, r), hp.clone().addScaledVector(u, -r).addScaledVector(v, -r), hp.clone().addScaledVector(u, r).addScaledVector(v, -r)];
1280
+ }
1281
+ let clipPlanePreview = null; // translucent ghost patch under the cursor while the plane pick is armed
1282
+ // Show/clear the hover ghost: a translucent 2'×2' patch + outline at hp oriented to n (null hp clears it).
1283
+ function setClipPlanePreview(hp, n) {
1284
+ if (clipPlanePreview) { if (overlayScene) overlayScene.remove(clipPlanePreview); clipPlanePreview.traverse((o) => { if (o.geometry) o.geometry.dispose(); const mm = Array.isArray(o.material) ? o.material : (o.material ? [o.material] : []); mm.forEach((m) => m.dispose()); }); clipPlanePreview = null; }
1285
+ if (!hp || !overlayScene) return;
1286
+ const r = CLIP_PLANE_PATCH_R;
1287
+ clipPlanePreview = new THREE.Group();
1288
+ const fill = new THREE.Mesh(new THREE.PlaneGeometry(2 * r, 2 * r), new THREE.MeshBasicMaterial({ color: CLIP_PREVIEW_COLOR, transparent: true, opacity: 0.3, side: THREE.DoubleSide }));
1289
+ fill.material.depthTest = false; fill.renderOrder = 995; fill.position.copy(hp); fill.quaternion.setFromUnitVectors(_ZA, n); clipPlanePreview.add(fill);
1290
+ const outline = new THREE.LineLoop(new THREE.BufferGeometry().setFromPoints(planePatchCorners(hp, n, r)), new THREE.LineBasicMaterial({ color: CLIP_PREVIEW_COLOR })); outline.material.depthTest = false; outline.renderOrder = 996; clipPlanePreview.add(outline);
1291
+ overlayScene.add(clipPlanePreview);
1292
+ }
1293
+ // Hover while the plane pick is armed: preview the patch the cursor is over, or clear it on a miss.
1294
+ function clipPlanePreviewAt(cx, cy) { const pp = clipPlaneAtScreen(cx, cy); setClipPlanePreview(pp ? pp.point : null, pp ? pp.n : null); }
1263
1295
  function addClipBoxFromBox(box) { // commit a clip box from an explicit Box3 (the 2-corner draw) — selects it
1264
1296
  if (!box || box.isEmpty()) return null;
1265
1297
  if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
@@ -1354,12 +1386,9 @@ function renderClipGizmo() {
1354
1386
  addHandle(p, nf, { face: f, clipId: c.id }, CLIP_BOX_COLOR);
1355
1387
  }
1356
1388
  } else {
1357
- const ctr = sceneBox.getCenter(new THREE.Vector3());
1358
- const d = c.n.dot(ctr) + c.planes[0].constant, hp = ctr.clone().addScaledVector(c.n, -d); // model centre projected onto the plane
1359
- const r = (sceneBox.getSize(new THREE.Vector3()).length() * 0.28) || 800; // a moderate plane "patch" around the handle — shows the plane without spanning the whole view
1360
- const u = (Math.abs(c.n.z) < 0.9 ? new THREE.Vector3(0, 0, 1) : new THREE.Vector3(1, 0, 0)).cross(c.n).normalize(), v = c.n.clone().cross(u).normalize();
1361
- const sq = [hp.clone().addScaledVector(u, r).addScaledVector(v, r), hp.clone().addScaledVector(u, -r).addScaledVector(v, r), hp.clone().addScaledVector(u, -r).addScaledVector(v, -r), hp.clone().addScaledVector(u, r).addScaledVector(v, -r)];
1362
- const outline = new THREE.LineLoop(new THREE.BufferGeometry().setFromPoints(sq), new THREE.LineBasicMaterial({ color: CLIP_PLANE_COLOR })); outline.material.depthTest = false; outline.renderOrder = 996; clipGizmo.add(outline);
1389
+ const hp = c.point.clone(); // the patch sits at the click point (c.point moves along the normal as you drag, so it stays put laterally)
1390
+ const r = CLIP_PLANE_PATCH_R; // small fixed 2'×2' patch — a marker at the cut, not a view-spanning sheet
1391
+ const outline = new THREE.LineLoop(new THREE.BufferGeometry().setFromPoints(planePatchCorners(hp, c.n, r)), new THREE.LineBasicMaterial({ color: CLIP_PLANE_COLOR })); outline.material.depthTest = false; outline.renderOrder = 996; clipGizmo.add(outline);
1363
1392
  addHandle(hp, c.n, { plane: true, clipId: c.id }, CLIP_PLANE_COLOR); // disc-in-plane + normal arrow (same manipulator as the box faces)
1364
1393
  }
1365
1394
  }
@@ -1450,36 +1479,61 @@ const clipBoxFloorZ = () => (sceneBox.isEmpty() ? 0 : sceneBox.min.z);
1450
1479
  function clipBoxFrom(a, b, zlo, ztop) {
1451
1480
  return new THREE.Box3(new THREE.Vector3(Math.min(a[0], b[0]), Math.min(a[1], b[1]), Math.min(zlo, ztop)), new THREE.Vector3(Math.max(a[0], b[0]), Math.max(a[1], b[1]), Math.max(zlo, ztop)));
1452
1481
  }
1453
- // the cursor's height above the floor — the closest point on the vertical line through the footprint centre to
1454
- // the cursor ray (works in any non-top view; a top view can't define a height so it stays ~flat there).
1482
+ // The clip-box draw's snap targets, built ONCE per draw (allCandidates does O(n²) beam-intersection work — the
1483
+ // dim/Move tools cache it too, tfCandidates/dimCandidates3d). Members can't change mid-draw, so setClipMode drops
1484
+ // the cache on every arm/disarm. A malformed member/grid degrades to no snap (raw floor), never a broken tool.
1485
+ let clipCandidates = null, clipLevels = null;
1486
+ function clipBoxSnapCands() { if (!clipCandidates) { try { clipCandidates = allCandidates(null); } catch { clipCandidates = []; } } return clipCandidates; }
1487
+ function clipBoxLevels() { if (!clipLevels) { try { clipLevels = elevationLevels(members(), api.ptPerFt(), api.defaultTosMm(), null); } catch { clipLevels = []; } } return clipLevels; }
1488
+ // A footprint corner from the cursor: the floor point under it, PULLED to a member/grid/UCS snap when one is
1489
+ // screen-near — same candidates + running-snaps filter as the Dimension / Move tools. Returns { xy:[x,y], snap,
1490
+ // world } or null (ray parallel to the floor). We keep only the snap's X/Y (the corner rides the floor plane).
1491
+ function clipBoxFloorPoint(cx, cy) {
1492
+ const zlo = clipBoxFloorZ(), g = rayToPlane(cx, cy, zlo); if (!g) return null;
1493
+ const cands = clipBoxSnapCands().filter((c) => candAllowed3d(c.type));
1494
+ const r = snapPoint([g[0], g[1], zlo], cands, toScreen, SNAP_TOL_PX);
1495
+ return r.candidate ? { xy: [r.snapped[0], r.snapped[1]], snap: r.candidate.type, world: r.snapped } : { xy: [g[0], g[1]], snap: null, world: [g[0], g[1], zlo] };
1496
+ }
1497
+ // the box-top height from the cursor — the closest point on the vertical line through the footprint centre to the
1498
+ // cursor ray (works in any non-top view; a top view can't define a height so it stays ~flat there), SNAPPED to
1499
+ // member endpoint elevations (T.O.S / base levels — the Alt-vertical member-drag feel). Returns { z, snap:[x,y,z]|null }.
1455
1500
  function clipBoxHeightAt(cx, cy) {
1456
- const zlo = clipBoxFloorZ(), a = clipBoxDraft.a, b = clipBoxDraft.b;
1457
- const P = new THREE.Vector3((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, zlo);
1458
- return zlo + Math.max(lineClosestT(P, new THREE.Vector3(0, 0, 1), rayAt(cx, cy)), 1);
1501
+ const zlo = clipBoxFloorZ(), a = clipBoxDraft.a, b = clipBoxDraft.b, mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2;
1502
+ const zRaw = zlo + Math.max(lineClosestT(new THREE.Vector3(mx, my, zlo), new THREE.Vector3(0, 0, 1), rayAt(cx, cy)), 1);
1503
+ const s0 = toScreen([mx, my, zlo]), s1 = toScreen([mx, my, zlo + FT_MM]);
1504
+ if (Math.hypot(s1.x - s0.x, s1.y - s0.y) < 4) return { z: zRaw, snap: null }; // vertical axis edge-on (top view): every level projects to one screen point → snapping would silently pick the lowest, so keep the pulled height
1505
+ const levels = clipBoxLevels().map((z) => ({ type: 'level', p: [mx, my, z] }));
1506
+ const r = snapPoint([mx, my, zRaw], levels, toScreen, SNAP_TOL_PX);
1507
+ return r.candidate ? { z: r.snapped[2], snap: [mx, my, r.snapped[2]] } : { z: zRaw, snap: null };
1459
1508
  }
1460
1509
  function onClipBoxClick(e) {
1461
1510
  const zlo = clipBoxFloorZ();
1511
+ const clearBoxHint = () => { setClipPreview(null); if (marker) marker.visible = false; };
1462
1512
  if (!clipBoxDraft) { // corner 1
1463
- const g = rayToPlane(e.clientX, e.clientY, zlo); if (!g) return;
1464
- clipBoxDraft = { a: [g[0], g[1]], b: null }; updateStatusChip(); return;
1513
+ const fp = clipBoxFloorPoint(e.clientX, e.clientY); if (!fp) { clearBoxHint(); return; } // ray edge-on to the floor → nothing to place; don't strand a stale preview/reticle
1514
+ clipBoxDraft = { a: fp.xy, b: null }; updateStatusChip(); return;
1465
1515
  }
1466
1516
  if (!clipBoxDraft.b) { // corner 2 → footprint set; enter height mode
1467
- const g = rayToPlane(e.clientX, e.clientY, zlo); if (!g) return;
1468
- if (Math.abs(g[0] - clipBoxDraft.a[0]) < 1 && Math.abs(g[1] - clipBoxDraft.a[1]) < 1) return; // ignore a same-point 2nd click
1469
- clipBoxDraft.b = [g[0], g[1]]; updateStatusChip(); return;
1517
+ const fp = clipBoxFloorPoint(e.clientX, e.clientY); if (!fp) { clearBoxHint(); return; }
1518
+ if (Math.abs(fp.xy[0] - clipBoxDraft.a[0]) < 1 && Math.abs(fp.xy[1] - clipBoxDraft.a[1]) < 1) return; // ignore a same-point 2nd click
1519
+ clipBoxDraft.b = fp.xy; updateStatusChip(); return;
1470
1520
  }
1471
- const box = clipBoxFrom(clipBoxDraft.a, clipBoxDraft.b, zlo, clipBoxHeightAt(e.clientX, e.clientY)); // 3rd click → commit the height
1472
- clipBoxDraft = null; setClipPreview(null); setClipMode(null);
1521
+ const box = clipBoxFrom(clipBoxDraft.a, clipBoxDraft.b, zlo, clipBoxHeightAt(e.clientX, e.clientY).z); // 3rd click → commit the height
1522
+ clipBoxDraft = null; setClipPreview(null); if (marker) marker.visible = false; setClipMode(null);
1473
1523
  if (box.min.x < box.max.x && box.min.y < box.max.y && box.min.z < box.max.z) addClipBoxFromBox(box);
1474
1524
  }
1475
- function clipBoxPreviewAt(cx, cy) { // live preview: a flat footprint rectangle while picking corners, then the pulled height
1476
- if (clipMode !== 'box' || !clipBoxDraft) return;
1525
+ function clipBoxPreviewAt(cx, cy) { // live preview: snap marker + a flat footprint rectangle while picking corners, then the pulled height
1526
+ if (clipMode !== 'box') return;
1477
1527
  const zlo = clipBoxFloorZ();
1478
- if (!clipBoxDraft.b) {
1479
- const g = rayToPlane(cx, cy, zlo); if (!g) { setClipPreview(null); return; }
1480
- setClipPreview(clipBoxFrom(clipBoxDraft.a, [g[0], g[1]], zlo, zlo)); // flat rectangle on the floor
1481
- } else {
1482
- setClipPreview(clipBoxFrom(clipBoxDraft.a, clipBoxDraft.b, zlo, clipBoxHeightAt(cx, cy)));
1528
+ if (!clipBoxDraft || !clipBoxDraft.b) { // corner 1 / corner 2: snap the floor point, mark it
1529
+ const fp = clipBoxFloorPoint(cx, cy);
1530
+ if (fp && fp.snap) showMarker(fp.world, fp.snap); else if (marker) marker.visible = false;
1531
+ if (!clipBoxDraft || !fp) { setClipPreview(null); return; } // corner 1 (no rectangle yet) or a ray-miss (edge-on floor) → clear the preview
1532
+ setClipPreview(clipBoxFrom(clipBoxDraft.a, fp.xy, zlo, zlo)); // flat rectangle on the floor
1533
+ } else { // height phase: mark a snapped level, pull the box up
1534
+ const h = clipBoxHeightAt(cx, cy);
1535
+ if (h.snap) showMarker(h.snap, 'level'); else if (marker) marker.visible = false;
1536
+ setClipPreview(clipBoxFrom(clipBoxDraft.a, clipBoxDraft.b, zlo, h.z));
1483
1537
  }
1484
1538
  }
1485
1539
 
@@ -1645,7 +1699,7 @@ function onKey(e) {
1645
1699
  if (wpMode && e.key === 'Escape') { e.preventDefault(); if (wpMode === '3pt' && wpDraft && wpDraft.length) { wpDraft.pop(); updateStatusChip(); } else { wpMode = null; wpDraft = null; marker.visible = false; canvasEl.style.cursor = 'default'; reflectWpBar(); updateStatusChip(); } return; } // Esc steps a 3pt pick back, else disarms the set-plane mode
1646
1700
  if (insertMode && e.key === 'Escape') { e.preventDefault(); setInsertMode(false); if (api && api.toast) api.toast('Insert cancelled'); return; } // Esc disarms the detail-placement pick
1647
1701
  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
1648
- if (clipMode && e.key === 'Escape') { e.preventDefault(); if (clipMode === 'box' && clipBoxDraft) { if (clipBoxDraft.b) clipBoxDraft.b = null; else clipBoxDraft = null; setClipPreview(null); updateStatusChip(); } else setClipMode(null); return; } // Esc steps back: height→footprint→cancel, else disarms the pick
1702
+ 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
1649
1703
  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)
1650
1704
  if (e.key === 'Escape' && !dimMode3d && !cmActive() && ascendConn()) { e.preventDefault(); return; } // Esc ascends the connection drill: part → whole → nothing
1651
1705
  if ((e.key === ' ' && e.shiftKey) || ((e.key === 'z' || e.key === 'Z') && e.altKey && !tfDraft)) { e.preventDefault(); frameSelection(); return; } // zoom-selected (Tekla Shift+Space / viewer Alt+Z) — Alt+Z is suppressed while a Move/Copy base is active: there Alt is the normal-lock modifier, so a reflexive Alt+Z must not jerk the camera mid-move (UCS Stage 4)
@@ -3200,7 +3254,7 @@ function onDown(e) {
3200
3254
  if (cmActive()) { if (tfClick(e)) { e.stopPropagation(); controls.enabled = true; return; } } // Move/Copy armed (editor state) → picks land on the working plane; an empty-selection click falls through to select
3201
3255
  if (basePickCol) { e.stopPropagation(); const r = basePickPoint(e.clientX, e.clientY); if (r) { if (api && api.onBasePick) api.onBasePick(r); setBasePickMode(null); } return; } // Mode B: commit + disarm only on a valid on-column pick; an off-column click is ignored (stays armed) — Esc cancels
3202
3256
  if (insertMode) { e.stopPropagation(); const r = insertPick(e.clientX, e.clientY); const sticky = insertPending && insertPending.sticky; if (r && api && api.onInsertPlace) api.onInsertPlace(r, insertPending); if (!sticky) setInsertMode(false); return; } // armed: place at the pick. One-shot for a detail / IFC import; a sticky pending (a favourite) STAYS armed for repeat placement — Esc/onInsertPlace's own cancel disarms.
3203
- if (clipMode === 'plane') { e.stopPropagation(); addClipPlaneAtScreen(e.clientX, e.clientY); return; } // armed: left-click a face → place a clip plane (stays armed)
3257
+ if (clipMode === 'plane') { e.stopPropagation(); if (addClipPlaneAtScreen(e.clientX, e.clientY)) setClipMode(null); return; } // armed: left-click a face → place ONE clip plane, then the command is done (a miss keeps it armed to try again)
3204
3258
  if (clipMode === 'box') { e.stopPropagation(); onClipBoxClick(e); return; } // armed: 2-corner clip-box draw on the floor plane
3205
3259
  if (framePicking()) { e.stopPropagation(); controls.enabled = true; framePickClick(e); return; } // 3-click UCS set: this click collects the origin / X point / Y point
3206
3260
  if (frameMode) { let fh = null; try { fh = pickFrameHandle(e.clientX, e.clientY); } catch { fh = null; } if (fh) { e.stopPropagation(); controls.enabled = false; startFrameDrag(fh, e); return; } } // grab the local-frame origin/ring (armed) → drag it; an empty click falls through (orbit)
@@ -3608,7 +3662,7 @@ function onHoverMove(e) {
3608
3662
  if (r && r.snap) showMarker(r.p, r.type); else marker.visible = false;
3609
3663
  if (r) roShowCoordOnly(r.p, lastHoverXY[0], lastHoverXY[1]); else if (readout) readout.style.display = 'none'; } // local coords of the base point before it's picked
3610
3664
  updateStatusChip(); return; }
3611
- if (clipMode) { canvasEl.style.cursor = 'crosshair'; if (clipMode === 'box') clipBoxPreviewAt(lastHoverXY[0], lastHoverXY[1]); return; } // armed clip pick: crosshair (+ live box preview while drawing)
3665
+ if (clipMode) { canvasEl.style.cursor = 'crosshair'; if (clipMode === 'box') clipBoxPreviewAt(lastHoverXY[0], lastHoverXY[1]); else clipPlanePreviewAt(lastHoverXY[0], lastHoverXY[1]); return; } // armed clip pick: crosshair (+ live box draw preview / plane hover ghost)
3612
3666
  if (dimMode3d) { dimHoverPreview(dimLastAlt); return; } // dim tool: snap marker + live preview line + readout (extracted so setDimAxis can refresh it synchronously)
3613
3667
  if (framePicking()) { // 3-click UCS set in progress: live rubber-band X/Y + Z-flip arrow, snap marker at the cursor
3614
3668
  canvasEl.style.cursor = 'crosshair';
@@ -3725,7 +3779,7 @@ function dispose() {
3725
3779
  clearRoot();
3726
3780
  if (workAreaHelper) { if (overlayScene) overlayScene.remove(workAreaHelper); workAreaHelper.geometry.dispose(); workAreaHelper.material.dispose(); workAreaHelper = null; }
3727
3781
  if (wpGroup) { if (scene) scene.remove(wpGroup); wpGroup.traverse((o) => { if (o.geometry) o.geometry.dispose(); if (o.material) o.material.dispose(); }); wpGroup = null; } // the reference plane can exist by default now → dispose it too (code-review)
3728
- clearConnEnvelope(); clearClipGizmo(); setClipPreview(null); disposeFramePreview(); disposeFrameGizmo(); overlayScene = null; // dispose the frame gizmo/preview THREE resources before dropping the scene (Codex)
3782
+ clearConnEnvelope(); clearClipGizmo(); setClipPreview(null); setClipPlanePreview(null); disposeFramePreview(); disposeFrameGizmo(); overlayScene = null; // dispose the clip/frame gizmo/preview THREE resources before dropping the scene (Codex)
3729
3783
  clips = []; workArea = null; clipMode = null; selectedClipIds.clear(); clipBoxDraft = null; // clips live on the renderer; drop them with the renderer
3730
3784
  if (renderer) renderer.dispose();
3731
3785
  renderer = scene = camera = perspCam = orthoCam = controls = root = api = canvasEl = ro = null; built = false;
@@ -3837,5 +3891,7 @@ window.Steel3DView = {
3837
3891
  selDims3dCount: () => (api && api.selDim3d ? (api.selDim3d() || []).length : 0), // test helper: how many 3D dims are selected
3838
3892
  dim3dLabelOf: (i) => { const el = dimLabelPool[i]; if (!el || el.style.display === 'none') return null; const r = el.getBoundingClientRect(); return { x: r.left + r.width / 2, y: r.top + r.height / 2, text: el.textContent }; },
3839
3893
  debug, probe, screenOf, centerOf, worldOf, snapCandidatesScreen, gridSegmentsScreen, gridBubblesScreen, clipHandlesScreen,
3894
+ clipPlanePreviewShown: () => !!clipPlanePreview, // test helper: is the armed-plane hover ghost currently showing?
3895
+ clipBoxFloorAt: (x, y) => clipBoxFloorPoint(x, y), // test helper: the snapped footprint point at a cursor ({ xy, snap, world } or null)
3840
3896
  pointClipped: (p) => isPointClipped(p), // test helper: is a world point on the cut-away side of any active clip?
3841
3897
  };
@@ -918,8 +918,8 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
918
918
  <div class=m3dwrap>
919
919
  <button id=m3dClip data-tip="Clip planes and boxes — section to see inside a connection">Clip ▾</button>
920
920
  <div id=m3dClipMenu class=m3dmenu role=menu>
921
- <button data-clip=plane data-tip="Click a model face to cut the view there">Add clip plane</button>
922
- <button data-clip=box data-tip="Section a box around the selection (or whole model)">Add clip box</button>
921
+ <button data-clip=plane data-tip="Click a model face to cut the view there (Shift+X)">Add clip plane</button>
922
+ <button data-clip=box data-tip="Section a box around the selection (or whole model) (Shift+B)">Add clip box</button>
923
923
  <hr>
924
924
  <button data-clip=clear class=mdanger data-tip="Remove every clip">Clear all clips</button>
925
925
  </div>
@@ -4673,6 +4673,9 @@ addEventListener('keydown',e=>{
4673
4673
  return;}
4674
4674
  if(e.key==='Escape'&&!view3d&&snapOnly){snapOnlyClear2d();return;} // own Esc rung: 1st Esc drops the snap override, the next cancels the tool/draft (mirrors the set-axes two-step)
4675
4675
  if(e.key==='Home'){e.preventDefault();if(view3d&&window.Steel3DView)window.Steel3DView.frameAll();else fitToWindow();return;}
4676
+ if(view3d&&window.Steel3DView&&!inForm&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!cmTool&&mode!=='add'&&!(window.Steel3DView.dimToolOn&&window.Steel3DView.dimToolOn())){const ck=e.key.toLowerCase(); // Shift+X arms a clip plane, Shift+B a clip box (3D-only sectioning; mirrors the Clip ▾ menu). Both are skipped while Move/Copy, Add, or 3D-Dim is armed: Shift+X then falls through to that tool's X-axis lock (instead of nuking the pick), and Shift+B is held off for the same reason so it can't discard an in-progress operation either.
4677
+ if(ck==='x'){e.preventDefault();window.Steel3DView.setClipMode('plane');setLastCmd('Clip plane',()=>window.Steel3DView.setClipMode('plane'));return;}
4678
+ if(ck==='b'){e.preventDefault();window.Steel3DView.setClipMode('box');setLastCmd('Clip box',()=>window.Steel3DView.setClipMode('box'));return;}}
4676
4679
  if(!view3d&&!inForm&&(((e.key==='z'||e.key==='Z')&&e.altKey)||(e.key===' '&&e.shiftKey))){e.preventDefault();zoomToSelection();return;} // 2D zoom-to-selected (Tekla Shift+Space / Alt+Z); 3D handles its own (steel-3d-view onKey)
4677
4680
  if((e.key===' '||e.key==='Enter')&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){if(!anyToolActive()&&lastCmd){e.preventDefault();repeatLast();}return;} // idle Space/Enter → repeat the last command (AutoCAD/Tekla)
4678
4681
  if(e.key==='Escape'&&gridLinePick){gridCancelLinePick();return;} // Esc disarms add-single-line (grid mode stays)
@@ -6397,7 +6400,7 @@ function updConnBtn(){const b=document.getElementById('connBtn');if(b)b.textCont
6397
6400
  // --- Auto-detail base plates: one click adds a base-plate joint (engine defaults) to every column
6398
6401
  // that lacks one; once all columns are detailed, clicking again clears the AUTO ones (user-placed/
6399
6402
  // AI-tuned base plates are kept). The engine renders the plate + anchor kit + weld in 3D. ---
6400
- function colMemberIds(){const ids=[];for(const m of (P.members||[]))if(m&&m.role==='column'&&m.id)ids.push(m.id);return ids;} // ACTIVE plan's columns — auto-detail + its undo are per-plan (a joint belongs to its column's sheet). Base-plate columns sit on one foundation sheet, so in practice this still reads as "every column".
6403
+ function colMemberIds(){const ids=[];for(const m of allMembers())if(m&&m.role==='column'&&m.id)ids.push(m.id);return ids;} // EVERY sheet's columns — selection, joints (C.joints) and undo are all model-wide, so the selection-scoped auto-detail must see columns on any sheet (else selecting a column on a non-active sheet in 3D wrongly disables Base plates).
6401
6404
  function bpTargetIds(){const all=colMemberIds();return selIds.size?all.filter(id=>selIds.has(id)):all;} // selected columns scope the auto-detail; empty selection = every column (issue: create for selection, still supports all)
6402
6405
  function bpJointId(mid){const ids=new Set((C.joints||[]).map(j=>j&&j.id));let id='bp-'+mid,k=2;while(ids.has(id))id='bp-'+mid+'-'+(k++);return id;} // unique vs ANY existing joint id (no collision with a user-placed joint)
6403
6406
  function updBpBtn(){const b=document.getElementById('bpBtn');if(!b)return;
@@ -6429,8 +6432,8 @@ function toggleBasePlates(){
6429
6432
  // --- Auto-detail shear plates: one click adds a shear-plate joint to every ELIGIBLE beam end that lacks
6430
6433
  // one; once all eligible ends are detailed, clicking again clears the AUTO ones (user/AI-tuned kept). An
6431
6434
  // end is eligible when its connection note/row reads shear/simple, or it frames into a support and isn't
6432
- // marked moment. main = the beam, at = end0|end1, secondaries = [support] (geometry inferred). Per-plan,
6433
- // undoable (rides snapshot()/apply() exactly like base plates). The engine renders the fin plate + bolt
6435
+ // marked moment. main = the beam, at = end0|end1, secondaries = [support] (geometry inferred). Model-wide
6436
+ // (like base plates — targets scan allMembers()), undoable (rides snapshot()/apply()). The engine renders the fin plate + bolt
6434
6437
  // group + weld (+ optional stiffener) in 3D. ---
6435
6438
  function spConnText(end){const r=end&&end.conn?connRowById(end.conn):null;return ((r&&r.type)||'')+' '+((end&&end.note)||'');}
6436
6439
  function spIsMoment(t){return /moment|fixed|\bmf\b|fully\s*weld/i.test(t||'');}
@@ -6438,17 +6441,18 @@ function spIsShear(t){return /shear|fin|tab|clip|simple|pin|web/i.test(t||'');}
6438
6441
  function spDist(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1]);}
6439
6442
  function spDistToSeg(p,a,b){const vx=b[0]-a[0],vy=b[1]-a[1],L2=vx*vx+vy*vy;if(L2<1e-9)return spDist(p,a);
6440
6443
  let t=((p[0]-a[0])*vx+(p[1]-a[1])*vy)/L2;t=Math.max(0,Math.min(1,t));return spDist(p,[a[0]+t*vx,a[1]+t*vy]);}
6441
- function spSupportTol(){const k=(P.pt_per_ft&&P.pt_per_ft>0)?P.pt_per_ft:12;return Math.max(6,0.75*k);} // ~9in at the plan's scale, min 6 display-pts: "the beam end meets this member"
6444
+ function spSupportTol(pl){const p=pl||P,k=(p.pt_per_ft&&p.pt_per_ft>0)?p.pt_per_ft:12;return Math.max(6,0.75*k);} // ~9in at the given plan's scale, min 6 display-pts: "the beam end meets this member". pt_per_ft is PER-SHEET, so the tolerance must use the beam's OWN plane (below), not the active one.
6442
6445
  function spInferSupport(beam,endIdx){if(!beam||!Array.isArray(beam.wp)||beam.wp.length<2)return null;const pt=beam.wp[endIdx];if(!pt)return null;
6443
- let best=null,bd=Infinity;for(const m of (P.members||[])){if(!m||m.id===beam.id||isBrace(m)||!Array.isArray(m.wp)||!m.wp.length)continue; // a brace never SUPPORTS a shear plate (mirrors server inferSupport)
6446
+ const pl=planeOfMember(beam)||P; // measure distances AND scale the tolerance in the beam's OWN sheet (wp are per-sheet 2D coords at that sheet's pt_per_ft — cross-sheet proximity is meaningless)
6447
+ let best=null,bd=Infinity;for(const m of (pl.members||[])){if(!m||m.id===beam.id||isBrace(m)||!Array.isArray(m.wp)||!m.wp.length)continue; // a brace never SUPPORTS a shear plate (mirrors server inferSupport)
6444
6448
  const d=(m.role==='column')?spDist(pt,m.wp[0]):(m.wp.length>=2?spDistToSeg(pt,m.wp[0],m.wp[1]):spDist(pt,m.wp[0]));if(d<bd){bd=d;best=m;}}
6445
- return (best&&bd<=spSupportTol())?best:null;}
6449
+ return (best&&bd<=spSupportTol(pl))?best:null;}
6446
6450
  function spEndEligible(beam,endIdx){if(!beam||beam.role==='column'||isBrace(beam)||!beam.ends)return false; // a brace never CARRIES a shear plate (mirrors server expandJoints)
6447
6451
  if(beam.mf===true||/^MF/i.test(beam.profile||''))return false; // a moment-frame girder (resolved via Frames → m.mf, or an unresolved MF mark) takes a MOMENT connection, not a shear tab
6448
6452
  const end=beam.ends[endIdx];if(!end)return false;
6449
6453
  const t=spConnText(end);if(spIsMoment(t))return false;if(spIsShear(t))return true;return !!spInferSupport(beam,endIdx);} // explicit moment → no; explicit shear → yes; else propose only where the end frames into a support
6450
- function spEligibleEnds(){const out=[];for(const m of (P.members||[])){if(!m||m.role==='column'||isBrace(m))continue;for(const e of [0,1])if(spEndEligible(m,e))out.push({beam:m,endIdx:e});}return out;}
6451
- function spBeamIds(){const s=new Set();for(const m of (P.members||[]))if(m&&m.role!=='column'&&!isBrace(m)&&m.id)s.add(m.id);return s;} // ACTIVE plan's beams (never braces) — auto-detail + its undo are per-plan
6454
+ function spEligibleEnds(){const out=[];for(const m of allMembers()){if(!m||m.role==='column'||isBrace(m))continue;for(const e of [0,1])if(spEndEligible(m,e))out.push({beam:m,endIdx:e});}return out;} // EVERY sheet's beams — eligibility per end still resolves the support within the beam's own sheet (spInferSupport)
6455
+ function spBeamIds(){const s=new Set();for(const m of allMembers())if(m&&m.role!=='column'&&!isBrace(m)&&m.id)s.add(m.id);return s;} // EVERY sheet's beams (never braces) — selection/joints/undo are model-wide, so a model-wide selection scopes correctly
6452
6456
  function spJointOf(beamId,endIdx){return (C.joints||[]).find(j=>j&&j.kind==='shear-plate'&&j.main===beamId&&j.at==='end'+endIdx);}
6453
6457
  function spTargetEnds(){const e=spEligibleEnds();return selIds.size?e.filter(({beam})=>selIds.has(beam.id)):e;} // eligible ends of the SELECTED beams; empty selection = every eligible end (issue: create for selection, still supports all)
6454
6458
  function spJointId(beamId,endIdx){const ids=new Set((C.joints||[]).map(j=>j&&j.id));let id='sp-'+beamId+'-e'+endIdx,k=2;while(ids.has(id))id='sp-'+beamId+'-e'+endIdx+'-'+(k++);return id;} // unique vs ANY existing joint id
@@ -6890,6 +6894,7 @@ const _restored=restoreSaved(); // bring back this brows
6890
6894
  // non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
6891
6895
  // AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
6892
6896
  for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
6897
+ for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))ensureMeta(_m); // normalize role/ends/col on EVERY sheet, not just the active one setPlan() does — model-wide detailing (Base/Shear plates) reads off-sheet members, so a beam with no authored `ends` must be normalized here or it reads as ineligible until its sheet is opened. Same order as the active plan (normBrace → ensureMeta).
6893
6898
  for(const _p of (C.plans||[]))sanitizeDims(_p); // F9: validate magnetic dim refs on EVERY sheet (not just the active one setPlan sanitizes) — an unvisited plan could otherwise keep a stale/cross-plan ref (Codex R1 #17). Runs after normBrace so isBrace is reliable.
6894
6899
  // Migrate every plan before the first whole-contract validation/save/3D build. Visiting sheets one-by-one must
6895
6900
  // not be required to turn legacy scalar/overlong labels_z into the canonical bounded array.
@@ -7362,7 +7367,8 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
7362
7367
  C.joints=sj;}
7363
7368
 
7364
7369
  // Detailing scoping + selected-connection delete (issue: create/remove for the selection, not the whole model)
7365
- {const sj=C.joints,ss=selIds,sPb=partsById;
7370
+ {const sj=C.joints,ss=selIds,sPb=partsById,sPl=C.plans,sA=C.active;
7371
+ C.plans=[P];C.active=0; // isolate: the target helpers are model-wide (allMembers over C.plans), so pin the world to this one test plan or a real multi-sheet contract's off-sheet columns/beams would leak into the counts
7366
7372
  // base plates: selection scopes the target columns; empty selection = every column
7367
7373
  P.members=[{id:'C1',role:'column',wp:[[0,0]]},{id:'C2',role:'column',wp:[[100,0]]}];
7368
7374
  selIds=new Set();ok(bpTargetIds().length===2,'bpTargetIds → every column when nothing is selected');
@@ -7378,7 +7384,7 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
7378
7384
  selIds=new Set(['jA:plate','jA:bolt0']);
7379
7385
  ok(selIsConnOnly()&&selJointIds().size===1&&selJointIds().has('jA'),'selJointIds/selIsConnOnly → the one joint of the selected parts');
7380
7386
  selIds=new Set(['jA:plate','C1']);ok(!selIsConnOnly(),'selIsConnOnly false when a member is mixed in');
7381
- C.joints=sj;selIds=ss;partsById=sPb;}
7387
+ C.joints=sj;selIds=ss;partsById=sPb;C.plans=sPl;C.active=sA;}
7382
7388
 
7383
7389
  // the editor's confidence mirror: brace ends are not scored as beam connections
7384
7390
  {const spl=C.plans,sa=C.active;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.103.0",
3
+ "version": "0.103.2",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {