@floless/app 0.104.1 → 0.104.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.104.1" : void 0,
53586
+ define: true ? "0.104.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.104.1" : void 0 });
53596
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.104.2" : void 0 });
53597
53597
  }
53598
53598
 
53599
53599
  // workflow-update.ts
@@ -68,6 +68,10 @@ const EP_END = 0xf472b6; // end endpoint (end 2) — magenta
68
68
 
69
69
  // ---- 3D dimension tool ----
70
70
  let dimMode3d = false; // tool armed
71
+ // The grid panel's "Add single line" pick, armed while the 3D view is showing. Same two-click gesture as the
72
+ // dimension tool (and as the 2D pick it mirrors): null = disarmed, {a:null} = waiting for the first point,
73
+ // {a:[x,y,z]} = waiting for the second. The editor owns the arming — it drives BOTH views off one flag.
74
+ let gridLinePick3d = null;
71
75
  let snapOnly3d = null; // Tekla-style snap override for the dim tool: a snapCandidates type ('vertex'|'intersection'|'midpoint'|'centerline'|'vertical-axis'), 'none' = free, null = all (set from the right-click menu in steel-editor.html)
72
76
  // map a 3D candidate type → the 2D running-snap key (⋯ menu → Snapping). Types with no key (level, vertical-axis) are 3D-only aids, always allowed.
73
77
  const SNAP3D_PREF = { vertex: 'end', intersection: 'int', midpoint: 'mid', centerline: 'line', 'grid-line': 'line', 'grid-int': 'int' };
@@ -678,6 +682,7 @@ function setRefLine(on) { refLineOn = !!on; buildRefLines(); }
678
682
  // placement click raycasts a member face (anchor) or the ground plane and hands the point + basis +
679
683
  // anchor id back to the editor, which creates + selects the detail and records the create request.
680
684
  function setInsertMode(on, pending) {
685
+ if (on) dropGridLinePick3d();
681
686
  insertMode = !!on;
682
687
  insertPending = insertMode ? (pending || insertPending) : null;
683
688
  if (insertMode) { if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); setClipMode(null); disarmFrame3d(); }
@@ -691,6 +696,7 @@ function insertModeOn() { return insertMode; }
691
696
  // snaps the base to a real framing level. A one-shot left-click hands the picked base elevation to the editor
692
697
  // via api.onBasePick. Mirrors setInsertMode.
693
698
  function setBasePickMode(colId) {
699
+ if (colId) dropGridLinePick3d();
694
700
  basePickCol = colId || null;
695
701
  basePickLevels = null;
696
702
  if (basePickCol) {
@@ -1244,6 +1250,7 @@ function rebuildClipPlanes(c) { // recompute a clip's .planes from its ed
1244
1250
  c.planes = c.kind === 'box' ? boxToPlanes(c.box) : [new THREE.Plane().setFromNormalAndCoplanarPoint(c.n, c.point)];
1245
1251
  }
1246
1252
  function setClipMode(m) { // arm/disarm a clip pick: 'plane' (click a face) | 'box' (draw 2 corners) | null
1253
+ if (m) dropGridLinePick3d();
1247
1254
  if (m && dimMode3d) toggleDimTool();
1248
1255
  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)
1249
1256
  clipMode = (m === 'plane' || m === 'box') ? m : null;
@@ -1702,6 +1709,10 @@ function onKey(e) {
1702
1709
  if (wasEp) rebuildEndpoints(); // restore the dragged endpoint dot to its original spot
1703
1710
  return;
1704
1711
  }
1712
+ // No Escape branch for gridLinePick3d on purpose: the EDITOR owns Esc for this tool. Its window keydown is bound at
1713
+ // parse time, ours inside init(), so the editor's always runs first and cancels the pick while leaving grid mode open.
1714
+ // Cancelling here first would make its handler fall through to setGridMode(false) and close the panel too — one Esc
1715
+ // doing two things.
1705
1716
  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
1706
1717
  if (insertMode && e.key === 'Escape') { e.preventDefault(); setInsertMode(false); if (api && api.toast) api.toast('Insert cancelled'); return; } // Esc disarms the detail-placement pick
1707
1718
  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
@@ -1728,12 +1739,34 @@ function onKey(e) {
1728
1739
  }
1729
1740
  // ---- 3D dimension tool controls (driven from the toolbar + the keyboard) ----
1730
1741
  function toggleDimTool() {
1742
+ if (!dimMode3d) dropGridLinePick3d(); // arming the dim tool takes the left-click — cancel an armed grid-line pick through the editor first
1731
1743
  dimMode3d = !dimMode3d;
1732
1744
  if (!dimMode3d) { dimDraft3d = null; dimCandidates3d = null; dimPreviewLine.visible = false; marker.visible = false; readout.style.display = 'none'; canvasEl.style.cursor = 'default'; setSnapOnly3d(null); } // disarming ends the operation → the snap override reverts to all snaps
1733
1745
  else { if (clipMode) setClipMode(null); if (wpMode) armWorkPlanePick(wpMode); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); drClear3d(); disarmFrame3d(); controls.enabled = true; canvasEl.style.cursor = 'crosshair'; } // arming the dim tool disarms the clip pick, a set-plane pick, Move/Copy, Add-member AND the local frame (all share the left-click + Esc)
1734
1746
  reflectDimBar();
1735
1747
  return dimMode3d;
1736
1748
  }
1749
+ // Arm/disarm the grid panel's "Add single line" pick for the 3D view. The early-out keeps re-arming a no-op:
1750
+ // every path that arms this pick starts from a fresh {a:null}, so a redundant arm can never wipe a half-finished one.
1751
+ function armGridLinePick3d(on) {
1752
+ on = !!on;
1753
+ if (on === !!gridLinePick3d) return on;
1754
+ // Disarm the conflicting tools BEFORE raising our own flag — each call below takes the DISARM direction, where their
1755
+ // own dropGridLinePick3d() guard is skipped, so this cannot cancel the very pick being armed.
1756
+ // basePickCol and insertMode matter as much as the rest: onDown routes both AHEAD of this pick, so leaving either
1757
+ // armed would make every click place a detail / do the base pick while the hint still reads "Pick the first point"
1758
+ // — the exact dead-control failure this change exists to fix.
1759
+ if (on) { if (dimMode3d) toggleDimTool(); if (clipMode) setClipMode(null); setInsertMode(false); setBasePickMode(null); if (wpMode) armWorkPlanePick(wpMode); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); drClear3d(); disarmFrame3d(); }
1760
+ gridLinePick3d = on ? { a: null } : null;
1761
+ if (!gridLinePick3d) { if (dimPreviewLine) dimPreviewLine.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; if (canvasEl) canvasEl.style.cursor = 'default'; }
1762
+ else { if (controls) controls.enabled = true; if (canvasEl) canvasEl.style.cursor = 'crosshair'; }
1763
+ updateStatusChip();
1764
+ return on;
1765
+ }
1766
+ // The reverse of the exclusivity above: another 3D tool taking the left-click must cancel an armed grid-line pick
1767
+ // THROUGH the editor, so the panel hint and the button's armed state can't be left claiming a pick that no longer owns
1768
+ // the canvas. Falls back to a local disarm if the host wired no callback, so the pick can never survive the handover.
1769
+ function dropGridLinePick3d() { if (!gridLinePick3d) return; if (api && api.onGridLinePickCancel) api.onGridLinePickCancel(); else armGridLinePick3d(false); }
1737
1770
  // snap override setter — notifies the host page so its header chip stays in sync with every clear path
1738
1771
  function setSnapOnly3d(k) { snapOnly3d = k || null; if (api && api.onSnapOnlyChanged) api.onSnapOnlyChanged(); }
1739
1772
  // X/Y/Z each TOGGLE the measure axis in the lock set (press again to release; combine 2–3 → the dim measures along
@@ -2589,6 +2622,7 @@ function setFrameOrigin(originMm) {
2589
2622
  function clearFrame3d() { const had = !!frame3d || frameMode; cancelFramePick(); frame3d = null; frameMode = false; if (had) fireFrameChange(); }
2590
2623
  function armFrame3d(on) { // arm/disarm the tool; arming disarms conflicting tools
2591
2624
  frameMode = on == null ? !frameMode : !!on;
2625
+ if (frameMode) dropGridLinePick3d();
2592
2626
  if (frameMode) {
2593
2627
  if (dimMode3d) toggleDimTool(); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); if (wpMode) { wpMode = null; wpDraft = null; reflectWpBar(); } setClipMode(null); setInsertMode(false); // arming the frame disarms EVERY other left-click 3D tool (incl. clip + insert)
2594
2628
  framePickPts = frame3d ? null : []; // no frame yet → start the 3-click pick; an existing frame → straight to drag-refine (re-pick from the panel)
@@ -2821,7 +2855,7 @@ function renderWorkPlane() {
2821
2855
  function reflectWpBar() { const b = document.getElementById('m3dWp'); if (b) { b.classList.toggle('on', !!wpMode || !!workPlane);
2822
2856
  const kind = workPlane && workPlane.kind ? { face: 'Face', p3: '3pt', xy: 'XY', xz: 'XZ', yz: 'YZ' }[workPlane.kind] || '' : '';
2823
2857
  b.textContent = wpMode ? '◇ Plane ✕' : (kind ? '◇ Plane: ' + kind + ' ▾' : '◇ Plane ▾'); } reflectDimAxisBar(); } // the label reads the active plane without opening the menu (ux review); relabel the dim-axis bar (a set/cleared plane flips X/Y between World and local)
2824
- function armWorkPlanePick(mode) { if (wpMode === mode) { wpMode = null; wpDraft = null; } else { wpMode = mode; wpDraft = null; if (dimMode3d) toggleDimTool(); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); disarmFrame3d(); } marker.visible = false; canvasEl.style.cursor = wpMode ? 'crosshair' : 'default'; reflectWpBar(); } // a set-plane pick shares the left-click — disarm Move/Copy + Add + the local frame (their onDown routes run first)
2858
+ function armWorkPlanePick(mode) { if (wpMode === mode) { wpMode = null; wpDraft = null; } else { wpMode = mode; wpDraft = null; dropGridLinePick3d(); if (dimMode3d) toggleDimTool(); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); disarmFrame3d(); } marker.visible = false; canvasEl.style.cursor = wpMode ? 'crosshair' : 'default'; reflectWpBar(); } // a set-plane pick shares the left-click — disarm Move/Copy + Add + the local frame (their onDown routes run first)
2825
2859
  function setWorkPlanePrincipal(kind, offsetMm) {
2826
2860
  const off = offsetMm || 0;
2827
2861
  const def = { xy: { normal: [0, 0, 1], xAxis: [1, 0, 0] }, xz: { normal: [0, 1, 0], xAxis: [1, 0, 0] }, yz: { normal: [1, 0, 0], xAxis: [0, 1, 0] } }[kind];
@@ -3238,6 +3272,26 @@ function dimPointAt(e, anchor) {
3238
3272
  const win = rGrid && (!rMem || rGrid.d <= rMem.d) ? rGrid : rMem;
3239
3273
  return { p: win ? win.r.snapped : hit, type: win ? win.r.candidate.type : null };
3240
3274
  }
3275
+ // The point under the cursor for the grid-line pick. Reuses the dimension tool's snapped pick (member + grid
3276
+ // candidates, running-snaps applied) with NO anchor, so Alt never forces the dim tool's vertical branch — a grid
3277
+ // line is a plan entity and only its X/Y survive the commit.
3278
+ function gridLinePickPoint3d(e) { return dimPointAt({ clientX: e.clientX, clientY: e.clientY, altKey: false }, null); }
3279
+ // Rubber-band + readout while placing a grid line: plan length and bearing, matching what the 2D pick shows.
3280
+ function gridLineHoverPreview3d() {
3281
+ if (!lastHoverXY || !canvasEl || !dimPreviewLine) return;
3282
+ const r = gridLinePickPoint3d({ clientX: lastHoverXY[0], clientY: lastHoverXY[1] });
3283
+ const snapped = !!(r && r.type);
3284
+ if (snapped) showMarker(r.p, r.type); else marker.visible = false; // reticle only on a real snap — same rule as the dim tool
3285
+ canvasEl.style.cursor = snapped ? 'none' : 'crosshair';
3286
+ if (gridLinePick3d.a && r) {
3287
+ dimPreviewLine.geometry.setFromPoints([new THREE.Vector3(...gridLinePick3d.a), new THREE.Vector3(...r.p)]);
3288
+ dimPreviewLine.visible = true;
3289
+ const dx = r.p[0] - gridLinePick3d.a[0], dy = r.p[1] - gridLinePick3d.a[1], len = Math.hypot(dx, dy); // PLAN length (X/Y only) — the Z the pick landed on is discarded on commit
3290
+ readout._dist.textContent = api.fmtLen ? api.fmtLen(len) : (len / 304.8).toFixed(2) + ' ft';
3291
+ readout._type.textContent = ' · angle ' + Math.round(Math.atan2(-dy, dx) * 180 / Math.PI) + '°' + (r.type ? ' · ' + r.type : ''); // NEGATE dy: scene Y runs opposite plan-display Y (buildStructGrid: mmY = -px*k), so a raw atan2 would report the bearing mirrored against the 2D tool for the very same line. The k>0 scale cancels out of the ratio.
3292
+ readout.style.left = (lastHoverXY[0] + 14) + 'px'; readout.style.top = (lastHoverXY[1] + 14) + 'px'; readout.style.display = 'block';
3293
+ } else { dimPreviewLine.visible = false; if (r) roShowCoordOnly(r.p, lastHoverXY[0], lastHoverXY[1]); else readout.style.display = 'none'; }
3294
+ }
3241
3295
  // The axis to measure on: Alt held during the 2nd pick forces a pure-vertical (Z) measurement,
3242
3296
  // overriding the sticky axis (else a sticky X/Y would collapse the Alt-locked point to zero length).
3243
3297
  // The ONE axis a dimension measures along, resolving the lock set: Alt (held on the 2nd pick) forces vertical Z;
@@ -3284,11 +3338,20 @@ function onDown(e) {
3284
3338
  if (clipMode === 'box') { e.stopPropagation(); onClipBoxClick(e); return; } // armed: 2-corner clip-box draw on the floor plane
3285
3339
  if (framePicking()) { e.stopPropagation(); controls.enabled = true; framePickClick(e); return; } // 3-click UCS set: this click collects the origin / X point / Y point
3286
3340
  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)
3287
- if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !selectedClipIds.size) { // passive gizmo, no tool armed → clicking its origin/ring re-selects the local frame for editing (NOT reached by box-select or select-all, which only touch members)
3341
+ if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !gridLinePick3d && !selectedClipIds.size) { // passive gizmo, no tool armed → clicking its origin/ring re-selects the local frame for editing (NOT reached by box-select or select-all, which only touch members). gridLinePick3d belongs in this list like every other armed tool: the handle captures within ~16 px, so without it the frame ORIGIN — a snap target the grid pick advertises — could never be used as a grid endpoint; the click would re-arm the frame and cancel the pick instead.
3288
3342
  let fh = null; try { fh = pickFrameHandle(e.clientX, e.clientY, true); } catch { fh = null; }
3289
3343
  if (fh) { e.stopPropagation(); controls.enabled = false; armFrame3d(true); startFrameDrag(fh, e); return; } // re-arm the tool + grab the clicked handle so a click-drag manipulates immediately
3290
3344
  }
3291
- if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(e.clientX, e.clientY); } catch { ch = null; } if (ch) { e.stopPropagation(); controls.enabled = false; downXY = [e.clientX, e.clientY]; startClipDrag(ch, e); return; } } // grab a clip handle (plane dot / box face) → drag it
3345
+ if (selectedClipIds.size && !gridLinePick3d) { let ch = null; try { ch = pickClipHandle(e.clientX, e.clientY); } catch { ch = null; } if (ch) { e.stopPropagation(); controls.enabled = false; downXY = [e.clientX, e.clientY]; startClipDrag(ch, e); return; } } // grab a clip handle (plane dot / box face) → drag it. Not while the grid pick is armed: a handle drag would start under an armed two-click tool, leaving the button + hint claiming a pick and the shared preview line stranded (onUp clears the marker/readout but not dimPreviewLine).
3346
+ if (gridLinePick3d) { // grid panel "Add single line": pick A, then B → the editor commits it (mirrors the 2D pick)
3347
+ e.stopPropagation(); controls.enabled = true;
3348
+ const r = gridLinePickPoint3d(e); if (!r) return;
3349
+ if (!gridLinePick3d.a) { gridLinePick3d.a = r.p; updateStatusChip(); if (api && api.onGridLinePickStep) api.onGridLinePickStep(); return; } // step BOTH readouts to "second point" — the canvas chip and the panel hint
3350
+ const a = gridLinePick3d.a;
3351
+ if (dimPreviewLine) dimPreviewLine.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none';
3352
+ if (api && api.onAddGridLine3d) api.onAddGridLine3d(a, r.p); // the editor converts world mm → plan display px, commits + disarms; a rejected (too-short) line leaves the pick armed so the 2nd point can be retried, exactly as in 2D
3353
+ return;
3354
+ }
3292
3355
  if (dimMode3d) { // 2-click dimension placement (not a drag): pick A, then B → place
3293
3356
  e.stopPropagation(); controls.enabled = true;
3294
3357
  const r = dimPointAt(e, dimDraft3d && dimDraft3d.a); if (!r) return;
@@ -3660,6 +3723,7 @@ function onHoverMove(e) {
3660
3723
  hoverRAF = requestAnimationFrame(() => {
3661
3724
  hoverRAF = 0;
3662
3725
  if (!lastHoverXY || pending || dragging || boxSel) return;
3726
+ if (gridLinePick3d) { gridLineHoverPreview3d(); return; } // armed grid-line pick owns the hover (rubber-band + snap reticle)
3663
3727
  if (basePickCol) { // Mode B armed: reticle on the column axis + a live elevation readout
3664
3728
  const p = basePickPoint(lastHoverXY[0], lastHoverXY[1]);
3665
3729
  if (p) {
@@ -3733,6 +3797,7 @@ function updateStatusChip() {
3733
3797
  else if (cmActive()) { const st = cmActive(), lock = lockChipTxt();
3734
3798
  txt = (!tfDraft ? ((st.tool === 'move' ? 'Move' : (st.array ? 'Copy array' : 'Copy')) + ' — click the base point on the working plane · type after the pick for an exact value')
3735
3799
  : (st.array && !tfDraft.vA ? 'Click the direction-A point — or type its spacing' : st.array ? 'Click the direction-B point — the grid previews live' : 'Click the destination — X/Y lock to the plane axes · Esc cancels')) + lock; }
3800
+ else if (gridLinePick3d) txt = gridLinePick3d.a ? 'Click the second point of the grid line · Esc to cancel' : 'Click the first point of the grid line · Esc to cancel'; // must sit above the showId/default branches, else an armed two-click tool shows the hovered member or the drag-move hint the user can't act on
3736
3801
  else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
3737
3802
  else if (clipMode === 'box') txt = !clipBoxDraft ? 'Click the first floor corner of the clip box · Esc to cancel' : !clipBoxDraft.b ? 'Click the opposite floor corner · Esc to cancel' : 'Move up/down to set the height, then click · Esc to step back';
3738
3803
  else if (showId) { const m = memberById(showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
@@ -3887,6 +3952,7 @@ window.Steel3DView = {
3887
3952
  selLenLabelTexts: () => selLenLabelPool.filter((el) => el.style.display !== 'none' && el.style.visibility !== 'hidden').map((el) => el.textContent), // visible on-select length chips — for tests
3888
3953
  epScreen: (id) => { const m = memberById(id); if (!m || !canvasEl) return null; const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm()); const rect = canvasEl.getBoundingClientRect(); const proj = (p) => { const v = new THREE.Vector3(p[0], p[1], p[2]).project(camera); return { x: rect.left + (v.x * 0.5 + 0.5) * rect.width, y: rect.top + (-v.y * 0.5 + 0.5) * rect.height }; }; return { a: proj(g.line[0]), b: proj(g.line[1]) }; }, // project a member's endpoints to viewport px — test probe for endpoint-drag tests
3889
3954
  refreshGrid: buildStructGrid, // grid edited in the panel → re-render without a full rebuild
3955
+ 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)
3890
3956
  gridInfo: () => ({ lines: structGridLines.size, labels: gridLabelGroup ? gridLabelGroup.children.length : 0,labelTexts:gridLabelGroup?[...new Set(gridLabelGroup.children.map(s=>s.userData.label).filter(Boolean))]:[],selected:[...selectedGridIds],ids:[...structGridLines.keys()] }), // test helper
3891
3957
  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.
3892
3958
  if (!wpGroup) return { group: false, extent: wpExtent };
@@ -2127,11 +2127,25 @@ function sanitizePlanGrid(pl){if(!pl||pl.grid==null)return;const g=pl.grid;
2127
2127
  function gridLineId(){return 'gl'+Date.now().toString(36)+Math.floor(Math.random()*1000).toString(36);}
2128
2128
  function gridNextLineLabel(){const n=(P&&P.grid&&Array.isArray(P.grid.lines))?P.grid.lines.length+1:1;return 'L'+n;}
2129
2129
  function gridEnsureForLine(a){const gc=GC();if(P.grid)return;P.grid={on:true,origin:a.slice(),x:'',y:'',z:"0'-0\"",labels_x:'',labels_y:'',labels_z:[],ext:gc?5*gc.FT_MM:1524,lines:[]};}
2130
- function gridAddFreeLine(a,b,label){const gc=GC();if(Math.hypot(b[0]-a[0],b[1]-a[1])<6/zoom){toast('Line is too short to create a grid line');return false;}
2130
+ // The 3D pick's minimum line length, in display px — a fixed floor, since 3D has no 2D `zoom` to scale by. 6 px is
2131
+ // what the 2D tool enforces at 1:1; in real terms that is 6*mmPerPx (~2" at a typical 1/4"=1' sheet scale).
2132
+ const GRID_LINE_MIN_DISP=6;
2133
+ // minDisp = the shortest acceptable line, in DISPLAY px. 2D defaults to 6/zoom so the floor is a constant ~6 px on
2134
+ // screen whatever the pan/zoom. A 3D caller must pass its own: `zoom` is the 2D viewport's live scale and is
2135
+ // meaningless while the user is in 3D, so inheriting it would make an identical 3D pick commit or get rejected
2136
+ // depending on a hidden viewport (fitted at zoom≈0.2 it would silently refuse lines under ~2.5 ft).
2137
+ function gridAddFreeLine(a,b,label,minDisp){const gc=GC();if(Math.hypot(b[0]-a[0],b[1]-a[1])<(minDisp>0?minDisp:6/zoom)){toast('Line is too short to create a grid line');return false;}
2131
2138
  gridEnsureForLine(a);if(!Array.isArray(P.grid.lines))P.grid.lines=[];
2132
2139
  P.grid.lines.push({id:gridLineId(),label:label||gridNextLineLabel(),a:a.slice(),b:b.slice()});return true;}
2133
- function gridSetPickClass(){document.body.classList.toggle('gridpick',!!gridPick||!!gridLinePick);}
2140
+ function gridSetPickClass(){document.body.classList.toggle('gridpick',!!gridPick||!!gridLinePick);
2141
+ // ONE choke point for the 3D side: every path that arms or tears down the pick (start, cancel, setGridMode,
2142
+ // Move/Copy arm, plan switch, view switch) already calls this, so the 3D pick can never outlive the 2D flag.
2143
+ // Panel repaints do NOT come through here — they don't need to; the 3D view owns the live draft once armed.
2144
+ if(window.Steel3DView&&window.Steel3DView.armGridLinePick3d)window.Steel3DView.armGridLinePick3d(!!gridLinePick&&view3d);}
2134
2145
  function gridStartLinePick(){gridPick=false;gridLinePick={a:null};gridSetPickClass();panel();}
2146
+ // Has the first point been placed? In 3D the live draft lives in the 3D view (its point is scene mm, deliberately
2147
+ // NOT stored in gridLinePick.a, which the 2D handler reads as display px). One helper so the panel hint is honest in both views.
2148
+ const gridPickHasFirst=()=>view3d?!!(window.Steel3DView&&window.Steel3DView.gridLinePick3dState&&window.Steel3DView.gridLinePick3dState().hasFirst):!!(gridLinePick&&gridLinePick.a);
2135
2149
  function gridCancelLinePick(){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridLinePick=null;gridSetPickClass();snapClear();gridReadoutHide();panel();}
2136
2150
  function planColumnCount(){let n=0;for(const m of ((P&&P.members)||[]))if(m.role==='column')n++;return n;}
2137
2151
  // The active plan's steel-filter elements (per-sheet linework the reader captured) — the source the
@@ -2222,7 +2236,7 @@ function renderGridPanel(p){
2222
2236
  p.innerHTML=`<span class=badge>Grid lines</span>
2223
2237
  <div class=hint style="margin-top:8px">No grid yet. Grid lines are a plan reference — they don't constrain members.</div>
2224
2238
  <div class=gbtns><button id=gridLineB class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button><button id=gridReadB ${hasEls?'':'disabled'} data-tip="${hasEls?'Detect the printed grid lines and bubbles in this sheet’s linework. Undoable.':'Needs this sheet’s filter linework — re-read the drawing with the steel filter step to capture it.'}">From drawing</button><button id=gridAutoB ${nCols<2?'disabled':''} data-tip="${nCols<2?'Needs at least two columns in the model to infer spacing.':'Infer spacings and origin from the column layout. Undoable.'}">Auto from columns</button><button id=gridBlankB data-tip="Start from a 4×4 grid of 30' bays and edit the spacings. Undoable.">Start blank</button></div>
2225
- ${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridLinePick.a?'Pick the second point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.':'Pick the first point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.')+'</div>':''}
2239
+ ${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridPickHasFirst()?'Pick the second point for the grid line':'Pick the first point for the grid line')+(view3d?' — snaps to the model and the grid.':' — snaps to linework (<b>Alt</b> off).')+' <b>Esc</b> cancels.</div>':''}
2226
2240
  <div class=hint style="margin-top:10px">Spacing uses <b>n*d</b> to repeat (e.g. <b>3*25'</b> = three 25' bays). Tokens: <b>25'-6"</b>, <b>6"</b>, <b>7.5m</b>, bare mm.</div>`;
2227
2241
  document.getElementById('gridLineB').onclick=gridStartLinePick;
2228
2242
  const rb=document.getElementById('gridReadB');if(rb)rb.onclick=()=>gridReadFromDrawing(null);
@@ -2261,7 +2275,7 @@ function renderGridPanel(p){
2261
2275
  <div class=sect style="margin-top:10px">Single lines <span style="color:var(--mut);font-weight:400;text-transform:none">· any angle</span></div>
2262
2276
  <div class=gfb>${(g.lines&&g.lines.length)?(g.lines.length+' individual line'+(g.lines.length===1?'':'s')+' · drag endpoints to adjust'):'No individual lines yet.'}</div>
2263
2277
  <div class=gbtns><button id=gridLineB class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button>${(g.lines&&g.lines.length)?'<button id=gridClearLinesB class=ghostw data-tip="Remove every individual grid line. The X/Y grid and levels stay. Undoable.">Clear single lines</button>':''}</div>
2264
- ${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridLinePick.a?'Pick the second point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.':'Pick the first point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.')+'</div>':''}
2278
+ ${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridPickHasFirst()?'Pick the second point for the grid line':'Pick the first point for the grid line')+(view3d?' — snaps to the model and the grid.':' — snaps to linework (<b>Alt</b> off).')+' <b>Esc</b> cancels.</div>':''}
2265
2279
  <div class=sect style="margin-top:10px">Extension</div>
2266
2280
  <input id=gExt class=gin style="width:110px" value="${esc(gc.fmtLen(isFinite(g.ext)?g.ext:1524))}" autocomplete=off spellcheck=false>
2267
2281
  <div class=hint style="margin-top:3px">How far every line runs past the outermost, in plan. Drag a bubble <b>along</b> its line to override just that one.</div>
@@ -4587,6 +4601,7 @@ function setMode(){document.body.classList.toggle('add',mode==='add');document.g
4587
4601
  picking=false;pickKind='profile';pickEnd=null; // a pick armed in one mode must never bleed into the other (an inspector ⌖ pick would otherwise show the Add panel's button pre-armed)
4588
4602
  if(mode!=='add'){drawDraft=null;drawPrevClear();cmHudClose();if(view3d&&window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}} // leaving Add-member drops the in-progress start + preview, closes any open typed-entry HUD, and clears the 3D draw start (else a stale Add token could revalidate on re-arm — Codex)
4589
4603
  document.getElementById('mAdd').onclick=()=>{if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();if(qdPick){qdPick=null;setQdPickCls();}
4604
+ if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();} // arming Add leaves the grid panel — same mutual exclusion Move/Copy already enforces. In 3D addActive() consumes the click AHEAD of the grid pick, so without this the Add gesture would run while the grid button + hint still claimed an armed pick (the A shortcut routes through this same handler)
4590
4605
  if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();} // the 3D dim tool + the local frame share the left-click — disarm both when entering add mode
4591
4606
  selDimIds.clear();dimStyleMode=false;mode=(mode==='add'?'sel':'add');if(mode==='add')selIds.clear();else if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();snapOnlyClear2d();setMode();render();setLastCmd('Add member',()=>{if(mode!=='add'){if(dimMode){dimMode=false;setDimMode();}mode='add';selIds.clear();setMode();render();}});}; // entering add/sel disarms the Dimension + set-axes tools + the Dimension style pane + drops any dim selection + reverts a snap override; leaving add clears the 3D draw draft
4592
4607
  document.getElementById('dimB').onclick=()=>{if(csaxisMode){csaxisMode=false;setCsMode();}if(qdPick){qdPick=null;setQdPickCls();}dimMode=!dimMode;setDimMode();render();setLastCmd('Dimension',()=>{if(!dimMode){dimMode=true;setDimMode();render();}});};
@@ -4678,7 +4693,7 @@ addEventListener('keydown',e=>{
4678
4693
  if(ck==='b'){e.preventDefault();window.Steel3DView.setClipMode('box');setLastCmd('Clip box',()=>window.Steel3DView.setClipMode('box'));return;}}
4679
4694
  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)
4680
4695
  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)
4681
- if(e.key==='Escape'&&gridLinePick){gridCancelLinePick();return;} // Esc disarms add-single-line (grid mode stays)
4696
+ if(e.key==='Escape'&&gridLinePick){e.stopImmediatePropagation();gridCancelLinePick();return;} // Esc disarms add-single-line (grid mode stays). stopImmediatePropagation because the 3D view binds its OWN window keydown: this Esc is fully consumed here, and without it the same press would ALSO run the 3D handler — which, seeing the pick already cancelled, falls through and clears an active isolation. One Esc, one action.
4682
4697
  if(e.key==='Escape'&&gridPick){gridPick=false;gridSetPickClass();snapClear();panel();return;} // Esc disarms pick-origin (grid mode stays)
4683
4698
  if(e.key==='Escape'&&gridMode&&!inForm){setGridMode(false);render();return;} // Esc exits the grid panel (a focused field handles its own Esc = revert)
4684
4699
  if(e.key==='Escape'&&dimStyleMode&&!inForm){setDimStyleMode(false);render();return;} // …likewise the Dimension style pane
@@ -4951,6 +4966,14 @@ const view3dApi={
4951
4966
  getDimOverlays:()=>C.dim_overlays||{}, // the legend DIMENSIONS toggles {bolt_pitch,edge_clearance,cope_size} — the 3D view derives + filters overlays from this
4952
4967
  // dims3d is model-global: mutate + persist directly. NOT via edit() — a plan-scoped undo snapshot would corrupt dims3d across plans (undo on plan A could wipe dims added on plan B), and edit()'s sync3D would needlessly re-extrude every member mesh for a pure annotation. boot() guarantees C.dims3d is an array.
4953
4968
  onAddDim3d:(dim)=>{C.dims3d.push(dim);scheduleSave();refreshDims3d();},
4969
+ // "Add single line" committed from the 3D view. The picked points are scene mm; grid lines are stored in the
4970
+ // plan's display space, so invert exactly what buildStructGrid does to draw them (mmX=px*k, mmY=-px*k → Y flips).
4971
+ // Z is dropped on purpose: a grid line is a plan entity, drawn in 3D at every grid level.
4972
+ onAddGridLine3d:(a,b)=>{const gc=GC();if(!gc||!P){panel();return;} // no grid module / no active plan → repaint so the hint can't outlive a pick that cannot commit
4973
+ const k=gc.mmPerPx(P.pt_per_ft>0?P.pt_per_ft:1),toDisp=p=>[p[0]/k,-p[1]/k],pv=snapshot();
4974
+ if(gridAddFreeLine(toDisp(a),toDisp(b),null,GRID_LINE_MIN_DISP)){pushUndo(pv);gridCancelLinePick();render();refresh3DGrid();}else panel();}, // rejected (too short) → keep the pick armed and let the user retry the 2nd point, same as 2D
4975
+ onGridLinePickStep:()=>panel(), // first point placed in 3D → repaint the panel hint ("Pick the second point")
4976
+ onGridLinePickCancel:()=>gridCancelLinePick(), // Esc in the 3D view cancels the pick (grid mode stays)
4954
4977
  onSnapOnlyChanged:()=>updSnapStat(), // keep the header snap-override chip honest for every 3D-side clear (tool disarm etc.)
4955
4978
  onDeleteDim3d:(id)=>{C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
4956
4979
  onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.104.1",
3
+ "version": "0.104.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": {