@floless/app 0.103.1 → 0.103.3

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.1" : void 0,
53586
+ define: true ? "0.103.3" : 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.1" : void 0 });
53596
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.103.3" : void 0 });
53597
53597
  }
53598
53598
 
53599
53599
  // workflow-update.ts
@@ -58553,6 +58553,12 @@ function expandBasePlate(joint, col) {
58553
58553
  const SEAT = 0.5;
58554
58554
  const rodBelow = Math.max(embedment > 0 ? grout + embedment : projBelow, rodProj + nutH + apThick + SEAT);
58555
58555
  const plateTop = bz + EMBED, plateBottom = plateTop - thickness;
58556
+ const axisSign = col.to[2] < col.from[2] ? -1 : 1;
58557
+ const rollRad = (col.rot || 0) * Math.PI * axisSign / 180;
58558
+ const cosR = Math.cos(rollRad), sinR = Math.sin(rollRad);
58559
+ const nz = (x) => x === 0 ? 0 : x;
58560
+ const uD = [nz(cosR), nz(sinR), 0], vD = [nz(-sinR), nz(cosR), 0];
58561
+ const rotXY = (u, v) => [bx + (u * cosR - v * sinR), by + (u * sinR + v * cosR)];
58556
58562
  const us = spread(cols, Math.max(0, width / 2 - edge));
58557
58563
  const vs = spread(rows2, Math.max(0, depth / 2 - edge));
58558
58564
  const holes = [];
@@ -58563,11 +58569,11 @@ function expandBasePlate(joint, col) {
58563
58569
  let k = 0;
58564
58570
  for (const v of vs) {
58565
58571
  for (const u of us) {
58566
- const ax = bx + u, ay = by + v, jid = joint.id;
58572
+ const [ax, ay] = rotXY(u, v), jid = joint.id;
58567
58573
  holes.push({ id: `${jid}:plate-hole${k}`, u, v, d: boltDia + clearance });
58568
58574
  kit.push(
58569
58575
  { id: `${jid}:rod${k}`, group: "anchor", kind: "rod", from: [ax, ay, rodBotZ], to: [ax, ay, rodTopZ], d: boltDia, material: anchorRodMaterial, fastener: { role: "anchor-bolt" }, meta: { label: `Anchor rod \u2300${boltDia}` } },
58570
- { id: `${jid}:wp${k}`, group: "washer-plate", kind: "plate", center: [ax, ay, wpBot + wpThick / 2], uDir: [1, 0, 0], vDir: [0, 1, 0], width: wpSide, depth: wpSide, thickness: wpThick, material: plateMaterial, holes: [{ id: `${jid}:wp${k}:hole`, u: 0, v: 0, d: boltDia + 2 }], meta: { label: `Washer plate ${Math.round(wpSide)}\xD7${Math.round(wpSide)}\xD7${Math.round(wpThick)}` } },
58576
+ { id: `${jid}:wp${k}`, group: "washer-plate", kind: "plate", center: [ax, ay, wpBot + wpThick / 2], uDir: uD, vDir: vD, width: wpSide, depth: wpSide, thickness: wpThick, material: plateMaterial, holes: [{ id: `${jid}:wp${k}:hole`, u: 0, v: 0, d: boltDia + 2 }], meta: { label: `Washer plate ${Math.round(wpSide)}\xD7${Math.round(wpSide)}\xD7${Math.round(wpThick)}` } },
58571
58577
  { id: `${jid}:wsh${k}`, group: "washer", kind: "washer", from: [ax, ay, wpTop], to: [ax, ay, washerTop], dOuter: washerOD, dInner: washerID, material: fastenerMaterial, fastener: { role: "washer" }, meta: { label: `Washer \u2300${Math.round(washerOD)}` } },
58572
58578
  { id: `${jid}:fn${k}`, group: "nut", kind: "nut", from: [ax, ay, washerTop], to: [ax, ay, fnTop], acrossFlats: nutAF, material: fastenerMaterial, fastener: { role: "nut" }, meta: { label: `Nut M${boltDia}` } }
58573
58579
  );
@@ -58575,7 +58581,7 @@ function expandBasePlate(joint, col) {
58575
58581
  const nutBotZ = rodBotZ + rodProj;
58576
58582
  if (bottomNut) kit.push({ id: `${jid}:fnb${k}`, group: "nut", kind: "nut", from: [ax, ay, nutBotZ], to: [ax, ay, nutBotZ + nutH], acrossFlats: nutAF, material: fastenerMaterial, fastener: { role: "nut" }, meta: { label: `Anchor nut M${boltDia}` } });
58577
58583
  const apBotZ = nutBotZ + (bottomNut ? nutH : 0);
58578
- if (anchorPlate) kit.push({ id: `${jid}:ap${k}`, group: "anchor-plate", kind: "plate", center: [ax, ay, apBotZ + apThick / 2], uDir: [1, 0, 0], vDir: [0, 1, 0], width: apSide, depth: apSide, thickness: apThick, material: plateMaterial, holes: [{ id: `${jid}:ap${k}:hole`, u: 0, v: 0, d: boltDia + 2 }], meta: { label: `Anchor plate ${Math.round(apSide)}\xD7${Math.round(apSide)}\xD7${Math.round(apThick)}` } });
58584
+ if (anchorPlate) kit.push({ id: `${jid}:ap${k}`, group: "anchor-plate", kind: "plate", center: [ax, ay, apBotZ + apThick / 2], uDir: uD, vDir: vD, width: apSide, depth: apSide, thickness: apThick, material: plateMaterial, holes: [{ id: `${jid}:ap${k}:hole`, u: 0, v: 0, d: boltDia + 2 }], meta: { label: `Anchor plate ${Math.round(apSide)}\xD7${Math.round(apSide)}\xD7${Math.round(apThick)}` } });
58579
58585
  k++;
58580
58586
  }
58581
58587
  }
@@ -58585,8 +58591,8 @@ function expandBasePlate(joint, col) {
58585
58591
  kind: "plate",
58586
58592
  center: [bx, by, plateBottom + thickness / 2],
58587
58593
  // plate top seats the column (= bz + EMBED); body hangs below
58588
- uDir: [1, 0, 0],
58589
- vDir: [0, 1, 0],
58594
+ uDir: uD,
58595
+ vDir: vD,
58590
58596
  width,
58591
58597
  depth,
58592
58598
  thickness,
@@ -58599,9 +58605,6 @@ function expandBasePlate(joint, col) {
58599
58605
  anchor: { rodTopZ, rodBotZ, plateBotZ: plateBottom, concreteTopZ, projMm: rodTopZ - plateBottom, groutMm: plateBottom - concreteTopZ, embedMm: concreteTopZ - rodBotZ, embedSet: embedment > 0 }
58600
58606
  }
58601
58607
  };
58602
- const axisSign = col.to[2] < col.from[2] ? -1 : 1;
58603
- const rollRad = (col.rot || 0) * Math.PI * axisSign / 180;
58604
- const cosR = Math.cos(rollRad), sinR = Math.sin(rollRad);
58605
58608
  const weld = {
58606
58609
  id: `${joint.id}:weld`,
58607
58610
  group: "weld",
@@ -23,7 +23,7 @@ import { gridGeometry, gridCandidates3d, mmPerPx, visibleGridLevels } from './gr
23
23
  let renderer, scene, perspCam, orthoCam, camera, controls, root, api, canvasEl, ro, rafId, grid, raycaster, downXY, lastPick = '(none)';
24
24
  let pending = null, dragging = null, marker = null, readout = null; // pending = member gesture; readout = drag dimension overlay
25
25
  let boxSel = null, rubber = null; // LEFT-drag-on-empty rubber-band multi-select
26
- let hoverId = null, hoverChip = null, hoverRAF = 0, lastHoverXY = null; // hover readout + cursor
26
+ let hoverId = null, hoverGlowIds = [], hoverChip = null, hoverRAF = 0, lastHoverXY = null; // hover readout + cursor; hoverGlowIds = every mesh currently wearing the sky glow (the WHOLE connection when hovering one of its parts)
27
27
  let epGroup = null; // yellow/magenta endpoint markers (start/end direction dots)
28
28
  let epGeom = null, epMatStart = null, epMatEnd = null; // shared across all endpoint dots (no per-rebuild churn)
29
29
  let epRing = null, epPreview = null, epMovedLine = null; // white ring on the active end node + member rubber (epPreview) + the "moved" leader (epMovedLine) while dragging an end
@@ -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);
@@ -533,7 +533,7 @@ function clearRoot() {
533
533
  root.remove(m);
534
534
  }
535
535
  meshById.clear();
536
- hoverId = null; hoverEp = null; // the meshes are gone — drop stale hover state so the next pointermove re-glows the fresh mesh
536
+ hoverId = null; hoverGlowIds = []; hoverEp = null; // the meshes are gone — drop stale hover state so the next pointermove re-glows the fresh mesh
537
537
  }
538
538
 
539
539
  // Subtract each cope (a `cut` part) from a member's solid via CSG — a real coped beam end. Cut boxes are
@@ -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)
@@ -1774,7 +1828,8 @@ function setSelection(ids) {
1774
1828
  selIds = new Set(set);
1775
1829
  reconcileConnState(set); // any selection path (2D click, box-select, keyboard) must not leave a stale connection envelope/drill
1776
1830
  rebuildEndpoints(); // endpoint dots follow the selection
1777
- if (hoverId != null && !set.has(hoverId)) setHoverGlow(hoverId, true); // a still-hovered, now-unselected member keeps its glow (the material swap above cleared it)
1831
+ let reglow = false; for (const g of hoverGlowIds) if (!set.has(g)) { setHoverGlow(g, true, false); reglow = true; } // still-hovered, now-unselected parts keep their glow (the material swap above cleared it)
1832
+ if (reglow) applyDisplayMode(); // one re-sync after re-lighting the whole set, not one per part
1778
1833
  updateStatusChip();
1779
1834
  }
1780
1835
  let selIds = new Set();
@@ -1789,7 +1844,7 @@ function hoverMaterial(mesh) {
1789
1844
  if (!mesh.userData._hovMat) mesh.userData._hovMat = materialFor(mesh.userData.group).clone();
1790
1845
  return mesh.userData._hovMat;
1791
1846
  }
1792
- function setHoverGlow(id, on) {
1847
+ function setHoverGlow(id, on, sync = true) {
1793
1848
  if (id == null) return;
1794
1849
  const mesh = meshById.get(id);
1795
1850
  if (!mesh || String(id).startsWith('det:')) return; // placed details use a texture, no emissive to glow
@@ -1797,15 +1852,28 @@ function setHoverGlow(id, on) {
1797
1852
  mesh.material = on ? hoverMaterial(mesh) : materialFor(mesh.userData.group);
1798
1853
  mesh.material.emissive = new THREE.Color(on ? HOVER_EMISSIVE : 0x000000);
1799
1854
  mesh.material.emissiveIntensity = on ? HOVER_INTENSITY : 0;
1800
- applyDisplayMode(); // ALWAYS re-sync after a material swap (mirrors setSelection): the swapped-in clone may have been cloned in another mode, and on clear the restored shared material can itself be stale — for a sole-profile member it stays detached while its mesh wears _hovMat, so applyDisplayMode never updated it. emissive is preserved (applyDisplayMode never touches it).
1801
- }
1802
- // Move the hover glow from the previous member to `id` (null = clear). One entry point so every
1803
- // hoverId transition stays consistent.
1855
+ if (sync) applyDisplayMode(); // ALWAYS re-sync after a material swap (mirrors setSelection): the swapped-in clone may have been cloned in another mode, and on clear the restored shared material can itself be stale — for a sole-profile member it stays detached while its mesh wears _hovMat, so applyDisplayMode never updated it. emissive is preserved (applyDisplayMode never touches it). sync=false lets a whole-connection glow batch ONE applyDisplayMode() after the loop instead of an O(meshes) sweep per part.
1856
+ }
1857
+ // The ids that glow together when `id` is hovered: the WHOLE connection's parts (so hovering any part
1858
+ // lights the entire base-plate / shear-plate as one unit — parity with whole-connection SELECTION), unless
1859
+ // we've DRILLED into that connection (ctxConn) — then only the part under the cursor glows. A bare member
1860
+ // glows alone. connOf/connChildIds are function declarations (hoisted), safe to call from here.
1861
+ function hoverGroupOf(id) {
1862
+ if (id == null) return [];
1863
+ const conn = connOf(id);
1864
+ if (conn && conn !== ctxConn) { const kids = connChildIds(conn); if (kids.length) return kids; }
1865
+ return [id];
1866
+ }
1867
+ // Move the hover glow from the previous member/connection to `id` (null = clear). One entry point so every
1868
+ // hoverId transition stays consistent. `hoverId` stays the single representative (status chip); `hoverGlowIds`
1869
+ // is the full set actually lit.
1804
1870
  function setHover(id) {
1805
1871
  if (id === hoverId) return;
1806
- setHoverGlow(hoverId, false);
1872
+ for (const g of hoverGlowIds) setHoverGlow(g, false, false);
1807
1873
  hoverId = id;
1808
- setHoverGlow(hoverId, true);
1874
+ hoverGlowIds = hoverGroupOf(id);
1875
+ for (const g of hoverGlowIds) setHoverGlow(g, true, false);
1876
+ applyDisplayMode(); // ONE material re-sync for the whole clear+relight — not an O(meshes) sweep per part (a connection can be ~26 parts)
1809
1877
  }
1810
1878
 
1811
1879
  // ---- yellow (start) / magenta (end) endpoint markers — also the drag handles ----
@@ -3200,7 +3268,7 @@ function onDown(e) {
3200
3268
  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
3269
  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
3270
  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)
3271
+ 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
3272
  if (clipMode === 'box') { e.stopPropagation(); onClipBoxClick(e); return; } // armed: 2-corner clip-box draw on the floor plane
3205
3273
  if (framePicking()) { e.stopPropagation(); controls.enabled = true; framePickClick(e); return; } // 3-click UCS set: this click collects the origin / X point / Y point
3206
3274
  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 +3676,7 @@ function onHoverMove(e) {
3608
3676
  if (r && r.snap) showMarker(r.p, r.type); else marker.visible = false;
3609
3677
  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
3678
  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)
3679
+ 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
3680
  if (dimMode3d) { dimHoverPreview(dimLastAlt); return; } // dim tool: snap marker + live preview line + readout (extracted so setDimAxis can refresh it synchronously)
3613
3681
  if (framePicking()) { // 3-click UCS set in progress: live rubber-band X/Y + Z-flip arrow, snap marker at the cursor
3614
3682
  canvasEl.style.cursor = 'crosshair';
@@ -3725,7 +3793,7 @@ function dispose() {
3725
3793
  clearRoot();
3726
3794
  if (workAreaHelper) { if (overlayScene) overlayScene.remove(workAreaHelper); workAreaHelper.geometry.dispose(); workAreaHelper.material.dispose(); workAreaHelper = null; }
3727
3795
  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)
3796
+ clearConnEnvelope(); clearClipGizmo(); setClipPreview(null); setClipPlanePreview(null); disposeFramePreview(); disposeFrameGizmo(); overlayScene = null; // dispose the clip/frame gizmo/preview THREE resources before dropping the scene (Codex)
3729
3797
  clips = []; workArea = null; clipMode = null; selectedClipIds.clear(); clipBoxDraft = null; // clips live on the renderer; drop them with the renderer
3730
3798
  if (renderer) renderer.dispose();
3731
3799
  renderer = scene = camera = perspCam = orthoCam = controls = root = api = canvasEl = ro = null; built = false;
@@ -3837,5 +3905,7 @@ window.Steel3DView = {
3837
3905
  selDims3dCount: () => (api && api.selDim3d ? (api.selDim3d() || []).length : 0), // test helper: how many 3D dims are selected
3838
3906
  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
3907
  debug, probe, screenOf, centerOf, worldOf, snapCandidatesScreen, gridSegmentsScreen, gridBubblesScreen, clipHandlesScreen,
3908
+ clipPlanePreviewShown: () => !!clipPlanePreview, // test helper: is the armed-plane hover ghost currently showing?
3909
+ clipBoxFloorAt: (x, y) => clipBoxFloorPoint(x, y), // test helper: the snapped footprint point at a cursor ({ xy, snap, world } or null)
3840
3910
  pointClipped: (p) => isPointClipped(p), // test helper: is a world point on the cut-away side of any active clip?
3841
3911
  };
@@ -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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.103.1",
3
+ "version": "0.103.3",
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": {