@floless/app 0.92.0 → 0.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53106,7 +53106,7 @@ function appVersion() {
53106
53106
  return resolveVersion({
53107
53107
  isSea: isSea2(),
53108
53108
  sqVersionXml: readSqVersionXml(),
53109
- define: true ? "0.92.0" : void 0,
53109
+ define: true ? "0.93.0" : void 0,
53110
53110
  pkgVersion: readPkgVersion()
53111
53111
  });
53112
53112
  }
@@ -53116,7 +53116,7 @@ function resolveChannel(s) {
53116
53116
  return "dev";
53117
53117
  }
53118
53118
  function appChannel() {
53119
- return resolveChannel({ isSea: isSea2(), define: true ? "0.92.0" : void 0 });
53119
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.93.0" : void 0 });
53120
53120
  }
53121
53121
 
53122
53122
  // workflow-update.ts
@@ -181,6 +181,23 @@ export function projectToPlane(p, origin, normal) {
181
181
  return [p[0] - d * n[0], p[1] - d * n[1], p[2] - d * n[2]];
182
182
  }
183
183
 
184
+ /**
185
+ * Signed world distance t from axisP to the point on the axis line closest to the cursor ray
186
+ * (rayO + s·rayD) — the standard closest-approach of two lines. axisN is normalized internally,
187
+ * so t is a distance along the UNIT axis n̂ and the locked point is `axisP + t·n̂` (NOT axisP +
188
+ * t·axisN for a non-unit axisN). Returns null when the ray is ~parallel to the axis (Top-view
189
+ * degeneracy: |r̂·n̂| > ~0.999), where the closest-approach is singular and the caller must fall
190
+ * back to a screen-space map. rayD/axisN need not be unit — both are normalized here.
191
+ */
192
+ export function rayAxisT(rayO, rayD, axisP, axisN) {
193
+ const r = _norm(rayD), n = _norm(axisN);
194
+ if (!r || !n) return null;
195
+ const b = _dot(r, n), denom = 1 - b * b; // 1 − cos²θ; → 0 as the ray aligns with the axis
196
+ if (denom < 2e-3) return null; // |r̂·n̂| > ~0.999 → singular; caller maps screen-Y → t
197
+ const w = [rayO[0] - axisP[0], rayO[1] - axisP[1], rayO[2] - axisP[2]];
198
+ return (_dot(n, w) - b * _dot(r, w)) / denom; // t = (e − b·d)/denom, unit basis so a=c=1
199
+ }
200
+
184
201
  /** Plane from 3 picked points (Tekla flow): origin=a, xAxis toward b, normal = x̂ × (c−a). null when degenerate. */
185
202
  export function planeFrom3Points(a, b, c) {
186
203
  const xAxis = _norm([b[0] - a[0], b[1] - a[1], b[2] - a[2]]);
@@ -17,7 +17,7 @@
17
17
  import * as THREE from 'three';
18
18
  import { OrbitControls } from 'three/addons/OrbitControls.js';
19
19
  import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
20
- import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor } from './steel-3d-core.js';
20
+ import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, rayAxisT } from './steel-3d-core.js';
21
21
  import { gridGeometry, gridCandidates3d, mmPerPx } from './grid-core.js';
22
22
 
23
23
  let renderer, scene, perspCam, orthoCam, camera, controls, root, api, canvasEl, ro, rafId, grid, raycaster, downXY, lastPick = '(none)';
@@ -1573,7 +1573,7 @@ function onKey(e) {
1573
1573
  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
1574
1574
  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)
1575
1575
  if (e.key === 'Escape' && !dimMode3d && !cmActive() && ascendConn()) { e.preventDefault(); return; } // Esc ascends the connection drill: part → whole → nothing
1576
- if ((e.key === ' ' && e.shiftKey) || ((e.key === 'z' || e.key === 'Z') && e.altKey)) { e.preventDefault(); frameSelection(); return; } // zoom-selected (Tekla Shift+Space / viewer Alt+Z)
1576
+ 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)
1577
1577
  const k = e.key.toLowerCase();
1578
1578
  // Don't touch the dim tool while a member gesture (drag / box-select) owns the shared marker/readout —
1579
1579
  // toggling would clear them mid-gesture. The gesture finishes on pointerup; the key is a no-op until then.
@@ -2263,6 +2263,7 @@ let framePickPts = null; // null = not picking; [] / [origin] / [origin,x
2263
2263
  let framePreview = null; // THREE.Group: the live X/Y rubber-band + Z-flip arrow during a pick
2264
2264
  const cloneFrame = (f) => ({ origin: [...f.origin], xAxis: [...f.xAxis], yAxis: [...f.yAxis], normal: [...f.normal] });
2265
2265
  const _dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
2266
+ const _unit3 = (a) => { const L = Math.hypot(a[0], a[1], a[2]) || 1; return [a[0] / L, a[1] / L, a[2] / L]; };
2266
2267
  function frameZ() { return frame3d ? frame3d.origin[2] : (api ? api.defaultTosMm() : 0); }
2267
2268
  function effectiveWP() {
2268
2269
  if (workPlane) return workPlane; // explicit ◇ Plane wins (unchanged)
@@ -2593,6 +2594,15 @@ function rayToWP(cx, cy, wp) {
2593
2594
  const hit = new THREE.Vector3();
2594
2595
  return raycaster.ray.intersectPlane(plane, hit) ? [hit.x, hit.y, hit.z] : null;
2595
2596
  }
2597
+ // The cursor's world-space pick ray {o, d} (d unit), mirroring rayToWP's NDC → raycaster setup.
2598
+ function cameraRay(cx, cy) {
2599
+ camera.updateMatrixWorld();
2600
+ const rect = canvasEl.getBoundingClientRect(); if (!rect.width || !rect.height) return null;
2601
+ const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
2602
+ raycaster.setFromCamera(ndc, camera);
2603
+ const o = raycaster.ray.origin, d = raycaster.ray.direction;
2604
+ return { o: [o.x, o.y, o.z], d: [d.x, d.y, d.z] };
2605
+ }
2596
2606
 
2597
2607
  // ---- 3D Move/Copy (spec §3+§6): the EDITOR owns the tool state (cmState via api); this side owns
2598
2608
  // picking/preview in scene mm against the working plane, and hands commit offsets back. ----
@@ -2600,13 +2610,13 @@ let tfDraft = null; // {base:[mm], vA:[mm]|null}
2600
2610
  let tfLastShift = false; // shiftKey mirror for the rAF-synthetic hover event
2601
2611
  let tfLast = null; // last constrained preview point (HUD distance direction)
2602
2612
  let tfLastClient = null; // last pointer client [x,y] (HUD placement)
2603
- let tfAxis = 'free'; // 'free' | 'u' | 'v' — X/Y force along the plane basis
2613
+ let tfAxis = 'free'; // 'free' | 'u' | 'v' | 'n' — X/Y force in-plane, 'n' = normal-axis lock (UCS Stage 4)
2604
2614
  let tfCandidates = null;
2605
2615
  let tfGhost = null, tfRubber = null, tfRubberA = null, tfGhostMat = null;
2606
2616
  const cmActive = () => (api && api.cmState ? api.cmState() : null);
2607
2617
  const cmHasBase = () => !!tfDraft;
2608
2618
  const cmLastClient = () => tfLastClient;
2609
- function setCmAxis(a) { tfAxis = a === 'x' ? 'u' : a === 'y' ? 'v' : 'free'; }
2619
+ function setCmAxis(a) { tfAxis = a === 'x' ? 'u' : a === 'y' ? 'v' : a === 'z' ? 'n' : 'free'; }
2610
2620
  function cmClear3d() { tfDraft = null; tfCandidates = null; tfAxis = 'free'; tfPreviewClear(); if (canvasEl) canvasEl.style.cursor = 'default'; } // callable BEFORE init() (editor boot) — every touched handle is guarded
2611
2621
  function cmEscape() { if (!tfDraft) return false; if (tfDraft.vA) { tfDraft.vA = null; tfPreviewClear(); return true; } tfDraft = null; tfPreviewClear(); return true; }
2612
2622
  function tfDisposeGhost() { if (!tfGhost) return; if (scene) scene.remove(tfGhost); for (const c of tfGhost.children) { if (c.userData._ownGeom && c.geometry) c.geometry.dispose(); } tfGhost = null; } // clones share the source geometry/material; only the >600 fallback BoxGeometry is per-ghost → dispose those (flagged _ownGeom) so the preview can't leak
@@ -2633,6 +2643,47 @@ function tfConstrain(p, e) {
2633
2643
  if (ax === 'v') return [b[0] + c.dv * v[0], b[1] + c.dv * v[1], b[2] + c.dv * v[2]];
2634
2644
  return p;
2635
2645
  }
2646
+ // Move/Copy normal-axis lock (UCS Stage 4): with a base picked, hold Alt (transient) or press Z (sticky)
2647
+ // to constrain the move to the working frame's normal. Project the cursor ray onto base + t·normal and
2648
+ // commit that. Top-view degeneracy (view ray ~∥ normal → rayAxisT returns null): fall back to a TRUE
2649
+ // screen-Y → distance map from the base's screen position. A ~vertical normal then snaps to framing
2650
+ // levels (same feel as the plain-drag Alt-elevation move).
2651
+ function cmNormalLock(e) {
2652
+ const base = tfDraft.base, n = _unit3(effectiveWP().normal);
2653
+ const ray = cameraRay(e.clientX, e.clientY);
2654
+ let t = ray ? rayAxisT(ray.o, ray.d, base, n) : null;
2655
+ if (t == null) { // singular → screen-Y drives the distance
2656
+ const bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
2657
+ const dy = bs.y - (e.clientY - rect.top); // cursor above the base → +normal (fixed sign)
2658
+ t = dy * pxToWorldAt(1, base);
2659
+ // ponytail: uses the horizontal px→world scale as the vertical proxy (a straight-down view has no true
2660
+ // vertical scale). Fine for the rare look-down-the-normal case; the level snap fixes the landing.
2661
+ }
2662
+ if (!Number.isFinite(t)) t = 0; // never commit a NaN offset — a non-finite scale/ray pins the destination to the base (no move)
2663
+ let p = [base[0] + n[0] * t, base[1] + n[1] * t, base[2] + n[2] * t];
2664
+ let snap = false, type = null;
2665
+ if (Math.abs(n[2]) > 0.999) { // ~vertical normal → snap the elevation to a framing level
2666
+ // World-space snap (NOT screen-space): in Top view every level projects to the same screen point, so a
2667
+ // screen snap can't tell them apart and would pin to one level regardless of the cursor. Snap p.z to the
2668
+ // nearest level within a screen-proportional world tolerance, then re-solve t so the point stays exactly
2669
+ // on base + t·normal (the normal may tilt a hair even at |n.z| > 0.999).
2670
+ const tol = pxToWorldAt(SNAP_TOL_PX, base);
2671
+ let best = null, bestD = tol;
2672
+ for (const z of elevationLevels(members(), api.ptPerFt(), api.defaultTosMm(), null)) { const d = Math.abs(p[2] - z); if (d <= bestD) { bestD = d; best = z; } }
2673
+ if (best != null) { t = (best - base[2]) / n[2]; p = [base[0] + n[0] * t, base[1] + n[1] * t, best]; snap = true; type = 'level'; }
2674
+ }
2675
+ return { p, snap, type };
2676
+ }
2677
+ // Resolve the Move/Copy destination with axis precedence: Alt (normal) > Shift (in-plane) > sticky tfAxis.
2678
+ // Returns { p, snap, type }; snap means p landed ON a candidate (show the reticle). null = no valid pick
2679
+ // (cursor off the plane, edge-on) for the in-plane path — the normal-lock path never needs the plane.
2680
+ function cmDestPoint(e) {
2681
+ const alt = !!(e && e.altKey), shift = !!(e && e.shiftKey);
2682
+ if (tfDraft && (alt || (tfAxis === 'n' && !shift))) return cmNormalLock(e);
2683
+ const r = wpPointAt(e); if (!r) return null;
2684
+ const p = tfConstrain(r.p, e);
2685
+ return { p, snap: r.snap && tfAxis === 'free' && !shift, type: r.type }; // in-plane force moves p off the raw snap → no reticle
2686
+ }
2636
2687
  // the offset list is the pure core `offsetsFor` (unit-tested for linear/grid) — counts INCLUDE the original, grid skips (0,0)
2637
2688
  function tfOffsetsFor(v, st) { return offsetsFor(v, st, tfDraft ? tfDraft.vA : null); }
2638
2689
  function tfGhostBuild(offs) {
@@ -2657,10 +2708,10 @@ function tfGhostBuild(offs) {
2657
2708
  }
2658
2709
  function tfPreview(e) {
2659
2710
  const st = cmActive(); if (!st || !tfDraft) return;
2660
- const r = wpPointAt(e); if (!r) { if (readout) readout.style.display = 'none'; return; } // cursor off the plane (edge-on) → clear the chip, don't freeze the last readout
2661
- const p = tfConstrain(r.p, e);
2711
+ const q = cmDestPoint(e); if (!q) { if (readout) readout.style.display = 'none'; return; } // cursor off the plane (edge-on) → clear the chip, don't freeze the last readout
2712
+ const p = q.p;
2662
2713
  tfLast = p; tfLastClient = [e.clientX, e.clientY];
2663
- if (r.snap && tfAxis === 'free' && !e.shiftKey) showMarker(p, r.type); else marker.visible = false;
2714
+ if (q.snap) showMarker(p, q.type); else marker.visible = false;
2664
2715
  const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
2665
2716
  tfGhostBuild(tfOffsetsFor(v, st));
2666
2717
  if (!tfRubber) { tfRubber = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]), new THREE.LineBasicMaterial({ color: 0x22d3ee })); tfRubber.material.depthTest = false; tfRubber.renderOrder = 997; scene.add(tfRubber); }
@@ -2673,7 +2724,7 @@ function tfPreview(e) {
2673
2724
  }
2674
2725
  const L = Math.hypot(v[0], v[1], v[2]);
2675
2726
  readout._dist.textContent = api.fmtLen ? api.fmtLen(L) : (L / FT_MM).toFixed(2) + ' ft';
2676
- readout._type.textContent = r.snap ? ' · ' + (r.type || 'snap') : (st.tool === 'copy' && !st.array && st.count > 1 ? ' ×' + st.count : '');
2727
+ readout._type.textContent = q.snap ? ' · ' + (q.type || 'snap') : (st.tool === 'copy' && !st.array && st.count > 1 ? ' ×' + st.count : '');
2677
2728
  readout.style.left = (e.clientX + 14) + 'px'; readout.style.top = (e.clientY + 14) + 'px'; readout.style.display = 'block';
2678
2729
  roCoords(p); // local coords of the destination point
2679
2730
  }
@@ -2684,8 +2735,8 @@ function tfClick(e) {
2684
2735
  if (api && api.disarmTransform) api.disarmTransform();
2685
2736
  return false;
2686
2737
  }
2687
- const r = wpPointAt(e); if (!r) return true;
2688
- const p = tfConstrain(r.p, e);
2738
+ const q = cmDestPoint(e); if (!q) return true;
2739
+ const p = q.p;
2689
2740
  tfLastClient = [e.clientX, e.clientY];
2690
2741
  if (!tfDraft) { notePointerPick(); tfDraft = { base: p, vA: null }; tfCandidates = null; tfLast = p; return true; } // base pick bumps the gen so a stale typed token can't survive
2691
2742
  const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
@@ -2794,7 +2845,8 @@ function drPreview(e) {
2794
2845
  function pxToWorldAt(px, pos) {
2795
2846
  const h = (canvasEl && canvasEl.clientHeight) || 1;
2796
2847
  if (camera === orthoCam) return px * ((orthoCam.top - orthoCam.bottom) / (orthoCam.zoom || 1)) / h;
2797
- const dist = pos ? camera.position.distanceTo(pos) : camera.position.distanceTo(controls.target);
2848
+ const p3 = Array.isArray(pos) ? new THREE.Vector3(pos[0], pos[1], pos[2]) : pos; // accept an [x,y,z] array too — distanceTo reads .x/.y/.z, so a raw array would yield NaN (perspective only)
2849
+ const dist = p3 ? camera.position.distanceTo(p3) : camera.position.distanceTo(controls.target);
2798
2850
  return px * (2 * Math.tan(THREE.MathUtils.degToRad(perspCam.fov) / 2) * dist) / h;
2799
2851
  }
2800
2852
  const RETICLE_PX = 44; // on-screen size of the snap reticle (the full sprite); the ring/glyph fill the middle ~55%
@@ -3328,7 +3380,7 @@ function updateStatusChip() {
3328
3380
  if (wpMode === 'face') txt = 'Click a member face — the working plane lands on it · Esc to cancel';
3329
3381
  else if (wpMode === '3pt') txt = ['Click the plane origin (snapped) · Esc to cancel', 'Click the local-X direction point · Esc to cancel', 'Click a point on the plane’s Y side · Esc to cancel'][(wpDraft || []).length] || '';
3330
3382
  else if (addActive()) txt = drDraft ? 'Click the member end · Shift straight · Esc drops the start' : 'Draw a member on the working plane — click the start point · Esc exits';
3331
- else if (cmActive()) { const st = cmActive(), lock = tfAxis === 'u' ? ' · X locked' : tfAxis === 'v' ? ' · Y locked' : '';
3383
+ else if (cmActive()) { const st = cmActive(), lock = tfAxis === 'u' ? ' · X locked' : tfAxis === 'v' ? ' · Y locked' : tfAxis === 'n' ? ' · Z locked' : '';
3332
3384
  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')
3333
3385
  : (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; }
3334
3386
  else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
@@ -4101,8 +4101,8 @@ addEventListener('keydown',e=>{
4101
4101
  if(dimMode&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const dk=e.key.toLowerCase();
4102
4102
  if(dk==='x'||dk==='y'||dk==='f'){e.preventDefault();dimSetAxis(dk==='f'?'free':dk);dimDraft&&svg.querySelector('#dimPrevG')&&dimRefreshPrev();return;}
4103
4103
  if(dk==='c'){e.preventDefault();toggleDimChain();return;}} // C — toggle chained (continuous) dimensioning
4104
- if(cmTool&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ak=e.key.toLowerCase(); // Move/Copy armed: X/Y/F force the axis (plane axes in 3D), typing opens the exact-value HUD
4105
- if(ak==='x'||ak==='y'||ak==='f'){e.preventDefault();
4104
+ if(cmTool&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ak=e.key.toLowerCase(); // Move/Copy armed: X/Y/F force the axis, Z (3D only) locks the frame normal, typing opens the exact-value HUD
4105
+ if(ak==='x'||ak==='y'||ak==='f'||(ak==='z'&&view3d)){e.preventDefault(); // Z is 3D-only (the normal-axis lock); 2D has no Z, and Alt+Z stays Zoom-Selected (never reaches here — this block requires !altKey)
4106
4106
  if(view3d&&window.Steel3DView&&window.Steel3DView.setCmAxis)window.Steel3DView.setCmAxis(ak);
4107
4107
  else{cmAxis=ak==='f'?'free':ak;cmRefreshPrev();}return;}
4108
4108
  const hasBase=cmDraft||(view3d&&window.Steel3DView&&window.Steel3DView.cmHasBase&&window.Steel3DView.cmHasBase());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.92.0",
3
+ "version": "0.93.0",
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": {