@floless/app 0.94.0 → 0.95.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.94.0" : void 0,
53109
+ define: true ? "0.95.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.94.0" : void 0 });
53119
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.95.0" : void 0 });
53120
53120
  }
53121
53121
 
53122
53122
  // workflow-update.ts
@@ -54144,7 +54144,8 @@ function typeMatches(value, t) {
54144
54144
  case "string":
54145
54145
  return typeof value === "string";
54146
54146
  case "number":
54147
- return typeof value === "number";
54147
+ return typeof value === "number" && Number.isFinite(value);
54148
+ // reject ±Infinity (a 1e400 literal JSON-parses to Infinity, then JSON.stringify → null — silent corruption)
54148
54149
  case "integer":
54149
54150
  return typeof value === "number" && Number.isInteger(value);
54150
54151
  case "boolean":
@@ -54158,6 +54159,7 @@ function typeMatches(value, t) {
54158
54159
  function kindOf(v) {
54159
54160
  if (v === null) return "null";
54160
54161
  if (Array.isArray(v)) return "array";
54162
+ if (typeof v === "number" && !Number.isFinite(v)) return "non-finite number";
54161
54163
  return typeof v;
54162
54164
  }
54163
54165
  function deepEqual(a, b) {
@@ -363,7 +363,8 @@
363
363
  "id": { "type": "string" },
364
364
  "a": { "$ref": "#/$defs/point3", "description": "First snapped anchor, world-scene mm." },
365
365
  "b": { "$ref": "#/$defs/point3", "description": "Second snapped anchor, world-scene mm." },
366
- "axis": { "enum": ["free", "x", "y", "z"], "description": "free = 3D distance ‖b-a‖; x|y|z = the component along that world axis. The dim line is drawn axis-aligned for x|y|z." }
366
+ "axis": { "enum": ["free", "x", "y", "z"], "description": "free = 3D distance ‖b-a‖; x|y = the component along the local-frame X/Y (see axisDir) when a frame was active at placement, else the global world X/Y; z = the world-Z (elevation) component. The dim line is drawn along that direction for x|y|z." },
367
+ "axisDir": { "type": "array", "items": { "type": "number" }, "minItems": 3, "maxItems": 3, "description": "Optional world direction an x|y measurement runs along, captured from the active local frame (frame3d) at placement; normalized on read. Absent/legacy, or a degenerate (zero/overflow) vector, or presence on z|free → the measurement falls back to the normal `axis` behavior (the world X/Y/Z component, or the full 3D distance for free). Editor-only like the whole dims3d array: stripped before bake, never in the lock / IFC / BOM." }
367
368
  }
368
369
  },
369
370
  "frame": {
@@ -316,17 +316,58 @@ export function offsetsFor(v, st, vA) {
316
316
  return st.tool === 'copy' ? lin(v, st.count) : [v];
317
317
  }
318
318
 
319
+ // UCS Stage 5 — one shared unit-direction rule for a frame-aware dim's world axisDir.
320
+ // Below EPS a vector is degenerate (no direction); above UNIT_TOL from 1 it's non-unit and gets re-normalized.
321
+ export const AXDIR_EPS = 1e-9, AXDIR_UNIT_TOL = 1e-6;
322
+ /**
323
+ * Normalize a candidate world direction, or return null when it carries no usable direction.
324
+ * null unless v is [finite, finite, finite] with a FINITE magnitude > AXDIR_EPS. Math.hypot can
325
+ * overflow to Infinity for huge finite components (e.g. 1.1e308) — the Number.isFinite(m) guard
326
+ * rejects that so we never divide by Infinity into [0,0,0]/NaN. Shared by dim3dGeom (render) and
327
+ * sanitizeDims3d (editor load) so both apply the exact same rule.
328
+ */
329
+ export function unitOrNull(v) {
330
+ if (!Array.isArray(v) || v.length !== 3 || !v.every(Number.isFinite)) return null;
331
+ const m = Math.hypot(v[0], v[1], v[2]);
332
+ if (!Number.isFinite(m) || m <= AXDIR_EPS) return null;
333
+ return [v[0] / m, v[1] / m, v[2] / m];
334
+ }
335
+
336
+ /**
337
+ * Canonicalize each 3D dim's optional `axisDir` so the editor never persists junk (which would
338
+ * wedge the schema-validated save). Pure: drops axisDir that is wrong-shape / degenerate / attached
339
+ * to a non-x|y axis, normalizes a non-unit vector, and keeps an already-unit vector verbatim (so a
340
+ * canonical write never ULP-churns across reloads). Run at every point a dims3d array is assigned.
341
+ */
342
+ export function sanitizeDims3d(arr) {
343
+ if (!Array.isArray(arr)) return [];
344
+ return arr.map((d) => {
345
+ if (!d || d.axisDir === undefined) return d;
346
+ if (d.axis !== 'x' && d.axis !== 'y') { const { axisDir, ...rest } = d; return rest; } // z/free never carry axisDir
347
+ const u = unitOrNull(d.axisDir);
348
+ if (!u) { const { axisDir, ...rest } = d; return rest; } // wrong-shape / degenerate / overflow → drop
349
+ const m = Math.hypot(d.axisDir[0], d.axisDir[1], d.axisDir[2]);
350
+ return Math.abs(m - 1) > AXDIR_UNIT_TOL ? { ...d, axisDir: u } : d; // non-unit → normalize; already-unit → keep
351
+ });
352
+ }
353
+
319
354
  /**
320
355
  * 3D dimension geometry (pure). a,b are scene mm [x,y,z]. axis ∈ free|x|y|z.
321
- * free → the straight segment a→b (valueMm = full 3D distance); x|y|z →
322
- * axis-aligned from a, advancing only that one world component to b
323
- * (valueMm = that component's length). Returns the drawn endpoints, the
324
- * midpoint (where the label sits), and the measured length in mm.
356
+ * free → the straight segment a→b (valueMm = full 3D distance); z → the world-Z (elevation)
357
+ * component; x|y → the component along `axisDir` (a world unit direction from the active local
358
+ * frame, normalized on read) when supplied & usable, else the world X/Y axis (legacy / global).
359
+ * valueMm = that component's length. Returns the drawn endpoints, the midpoint (where the label
360
+ * sits), and the measured length in mm.
325
361
  */
326
- export function dim3dGeom(a, b, axis) {
362
+ export function dim3dGeom(a, b, axis, axisDir) {
327
363
  const p1 = [a[0], a[1], a[2]];
364
+ const u = (axis === 'x' || axis === 'y') ? unitOrNull(axisDir) : null; // z/free never project onto axisDir
328
365
  let p2;
329
- if (axis === 'x') p2 = [b[0], a[1], a[2]];
366
+ if (u) {
367
+ const t = (b[0] - a[0]) * u[0] + (b[1] - a[1]) * u[1] + (b[2] - a[2]) * u[2]; // signed projection of a→b onto û
368
+ p2 = [a[0] + t * u[0], a[1] + t * u[1], a[2] + t * u[2]];
369
+ }
370
+ else if (axis === 'x') p2 = [b[0], a[1], a[2]];
330
371
  else if (axis === 'y') p2 = [a[0], b[1], a[2]];
331
372
  else if (axis === 'z') p2 = [a[0], a[1], b[2]];
332
373
  else p2 = [b[0], b[1], b[2]]; // free (default for any unrecognised axis)
@@ -61,6 +61,8 @@ const meshById = new Map(); // member id -> THREE.Mesh
61
61
  const groupColor = new Map(); // group key -> THREE.Color
62
62
  const baseMat = new Map(); // group key -> MeshStandardMaterial (shared per profile)
63
63
  const SELECT_EMISSIVE = 0x3b82f6; // --brand: selected members glow blue
64
+ const HOVER_EMISSIVE = 0x38bdf8; // sky: a cooler, lighter hue than the selection blue — paired with a softer glow (HOVER_INTENSITY) so hover reads distinct from selection
65
+ const HOVER_INTENSITY = 0.3; // hover glow strength (softer than the 0.6 selection glow)
64
66
  const EP_START = 0xfacc15; // start endpoint (end 1) — yellow
65
67
  const EP_END = 0xf472b6; // end endpoint (end 2) — magenta
66
68
 
@@ -213,6 +215,7 @@ function init(canvas, theApi) {
213
215
  window.addEventListener('pointermove', onMove); // window so a drag keeps tracking off-canvas
214
216
  window.addEventListener('pointerup', onUp);
215
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
216
219
  canvas.addEventListener('dblclick', onDblClick); // "zoom to detail": dbl-click a part zooms to it (empty = no-op)
217
220
  window.addEventListener('keydown', onKey); // Tekla keyboard nav: arrows pan, Ctrl/Shift+arrows rotate
218
221
  ro = new ResizeObserver(resize); ro.observe(canvas.parentElement || canvas);
@@ -523,12 +526,14 @@ function clearRoot() {
523
526
  for (const [id, m] of meshById) {
524
527
  m.geometry.dispose();
525
528
  if (m.userData._selMat) m.userData._selMat.dispose(); // per-mesh selection clone (else it leaks per rebuild)
529
+ if (m.userData._hovMat) m.userData._hovMat.dispose(); // per-mesh hover clone — same leak-per-rebuild story as _selMat
526
530
  // A placed detail (Slice 4) owns a per-mesh MeshBasicMaterial + its image texture (NOT a shared baseMat);
527
531
  // dispose both or every rebuild — which happens on each edit — leaks the old material + GPU texture.
528
532
  if (String(id).startsWith('det:') && m.material) { if (m.material.map) m.material.map.dispose(); m.material.dispose(); }
529
533
  root.remove(m);
530
534
  }
531
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
532
537
  }
533
538
 
534
539
  // Subtract each cope (a `cut` part) from a member's solid via CSG — a real coped beam end. Cut boxes are
@@ -1632,7 +1637,28 @@ function reflectDimBar() {
1632
1637
  const sh = document.getElementById('m3dDimShow'); if (sh) sh.style.display = dimMode3d ? 'inline-block' : 'none';
1633
1638
  reflectDimAxisBar();
1634
1639
  }
1635
- function reflectDimAxisBar() { document.querySelectorAll('#m3dDimAxis button').forEach((x) => x.classList.toggle('on', x.dataset.d3axis === dimAxis3d)); }
1640
+ // UCS Stage 5: the X/Y/Z labels must NEVER lie about what a dim measures. Three honest states:
1641
+ // · global (no frame, no plane) → X / Y / Z (as before)
1642
+ // · a local frame (unshadowed) → X′ / Y′ (local) + Elev (Z stays world elevation — a tilted frame is a hybrid)
1643
+ // · a ◇ Plane set (shadows the frame) → World X / World Y / Elev + a tip: dims IGNORE the plane (they go global)
1644
+ function reflectDimAxisBar() {
1645
+ const framed = !!frame3d && !workPlane, planed = !!workPlane;
1646
+ const LBL = {
1647
+ x: planed ? 'World X' : framed ? 'X′' : 'X',
1648
+ y: planed ? 'World Y' : framed ? 'Y′' : 'Y',
1649
+ z: (framed || planed) ? 'Elev' : 'Z',
1650
+ };
1651
+ const TIP = {
1652
+ x: planed ? 'Dims measure WORLD X, not the ◇ Plane (X)' : framed ? 'Measure along the local frame X′ (X)' : 'Lock measurement to X (X)',
1653
+ y: planed ? 'Dims measure WORLD Y, not the ◇ Plane (Y)' : framed ? 'Measure along the local frame Y′ (Y)' : 'Lock measurement to Y (Y)',
1654
+ z: (framed || planed) ? 'World Z — stays vertical even with a tilted frame (Z); Alt = quick vertical' : 'Lock to Z / vertical (Z); Alt = quick vertical',
1655
+ };
1656
+ document.querySelectorAll('#m3dDimAxis button').forEach((x) => {
1657
+ const a = x.dataset.d3axis;
1658
+ x.classList.toggle('on', a === dimAxis3d);
1659
+ if (a && LBL[a]) { x.textContent = LBL[a]; x.dataset.tip = TIP[a]; } // free button untouched (no LBL entry)
1660
+ });
1661
+ }
1636
1662
  // "Zoom to detail": double-click a part → zoom to a tight region around the click point so a connection
1637
1663
  // fills the view (members AND their derived connection parts are valid targets), keeping the current view
1638
1664
  // direction. Empty space → no-op (use the Fit button / Home for fit-all, so a stray double-click can't
@@ -1681,7 +1707,8 @@ function setSelection(ids) {
1681
1707
  applyDisplayMode(); // selection swapped the materials → re-apply wire/xray
1682
1708
  selIds = new Set(set);
1683
1709
  reconcileConnState(set); // any selection path (2D click, box-select, keyboard) must not leave a stale connection envelope/drill
1684
- rebuildEndpoints(); // endpoint dots follow the selection (+ any hover)
1710
+ rebuildEndpoints(); // endpoint dots follow the selection
1711
+ if (hoverId != null && !set.has(hoverId)) setHoverGlow(hoverId, true); // a still-hovered, now-unselected member keeps its glow (the material swap above cleared it)
1685
1712
  updateStatusChip();
1686
1713
  }
1687
1714
  let selIds = new Set();
@@ -1689,15 +1716,40 @@ function selectedMaterial(mesh) {
1689
1716
  if (!mesh.userData._selMat) mesh.userData._selMat = materialFor(mesh.userData.group).clone();
1690
1717
  return mesh.userData._selMat;
1691
1718
  }
1719
+ // ---- sky hover glow (replaces the on-hover endpoint dots) ----
1720
+ // A per-mesh clone so glowing one member doesn't tint its whole profile group (same trick as
1721
+ // selection). Selection always wins: a selected member keeps its blue glow and is left untouched.
1722
+ function hoverMaterial(mesh) {
1723
+ if (!mesh.userData._hovMat) mesh.userData._hovMat = materialFor(mesh.userData.group).clone();
1724
+ return mesh.userData._hovMat;
1725
+ }
1726
+ function setHoverGlow(id, on) {
1727
+ if (id == null) return;
1728
+ const mesh = meshById.get(id);
1729
+ if (!mesh || String(id).startsWith('det:')) return; // placed details use a texture, no emissive to glow
1730
+ if (selIds.has(id)) return; // selected beats hovered — don't disturb its blue glow
1731
+ mesh.material = on ? hoverMaterial(mesh) : materialFor(mesh.userData.group);
1732
+ mesh.material.emissive = new THREE.Color(on ? HOVER_EMISSIVE : 0x000000);
1733
+ mesh.material.emissiveIntensity = on ? HOVER_INTENSITY : 0;
1734
+ 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).
1735
+ }
1736
+ // Move the hover glow from the previous member to `id` (null = clear). One entry point so every
1737
+ // hoverId transition stays consistent.
1738
+ function setHover(id) {
1739
+ if (id === hoverId) return;
1740
+ setHoverGlow(hoverId, false);
1741
+ hoverId = id;
1742
+ setHoverGlow(hoverId, true);
1743
+ }
1692
1744
 
1693
1745
  // ---- yellow (start) / magenta (end) endpoint markers — also the drag handles ----
1694
- // Shown for every selected member, plus the hovered member. The dot at the member's `from` end
1746
+ // Shown for every SELECTED member (hover shows a sky glow instead — setHoverGlow). The dot at the member's `from` end
1695
1747
  // (start / end 1) is yellow; the `to` end (end 2 / column top) is magenta. Sizes held ~constant on
1696
1748
  // screen in the render loop (sizeEndpoints).
1697
1749
  function rebuildEndpoints() {
1698
1750
  if (!epGroup) return;
1699
1751
  for (const c of [...epGroup.children]) epGroup.remove(c); // shared geom/material → nothing to dispose
1700
- const show = new Set(selIds); if (hoverId) show.add(hoverId);
1752
+ const show = new Set(selIds); // dots follow the SELECTION only — hover now shows a glow instead (setHoverGlow)
1701
1753
  for (const id of show) {
1702
1754
  const mesh = meshById.get(id); if (mesh && !mesh.visible) continue; // a legend-hidden member shows no dots
1703
1755
  const m = memberById(id); if (!m) continue;
@@ -1771,7 +1823,7 @@ function refreshDims() {
1771
1823
  if (dims3dVisibleFlag) {
1772
1824
  for (const d of dims) {
1773
1825
  if (dimHiddenByIsolation(d)) continue; // isolated away → no line (the label is hidden in syncDimLabels)
1774
- const g = dim3dGeom(d.a, d.b, d.axis);
1826
+ const g = dim3dGeom(d.a, d.b, d.axis, d.axisDir); // placed dims render from their STORED axisDir (frame-independent), not the live frame
1775
1827
  const col = sel.has(d.id) ? 0xf59e0b : 0x67e8f9; // amber (#f59e0b) when selected, else muted cyan-300 — a quieter tint of the 0x22d3ee preview/2D-dim cyan (intentional, not a stray value)
1776
1828
  const pts = [new THREE.Vector3(...g.p1), new THREE.Vector3(...g.p2), ...dimTicks(g.p1, g.p2)]; // the dim line + a 45° tick at each end
1777
1829
  const line = new THREE.LineSegments(new THREE.BufferGeometry().setFromPoints(pts), new THREE.LineBasicMaterial({ color: col }));
@@ -1794,7 +1846,7 @@ function syncDimLabels(dims) {
1794
1846
  const el = dimLabelPool[i], d = dims[i];
1795
1847
  if (!d || !dims3dVisibleFlag || dimHiddenByIsolation(d)) { el.style.display = 'none'; el._dimId = null; el._mid = null; continue; } // isolated-away dims hide their label too
1796
1848
  el._dimId = d.id;
1797
- const g = dim3dGeom(d.a, d.b, d.axis);
1849
+ const g = dim3dGeom(d.a, d.b, d.axis, d.axisDir);
1798
1850
  el.textContent = api.fmtLen ? api.fmtLen(g.valueMm) : (g.valueMm / 304.8).toFixed(2) + ' ft';
1799
1851
  const seld = selSet.has(d.id);
1800
1852
  el.style.borderColor = seld ? '#f59e0b' : 'var(--line,#1e293b)';
@@ -2350,7 +2402,7 @@ function frameInfo() {
2350
2402
  }
2351
2403
  return { mode: 'global' };
2352
2404
  }
2353
- function fireFrameChange() { invalidatePointEntry('drift'); if (!(pending && pending.frameDrag)) { tfCandidates = null; dimCandidates3d = null; } renderWorkPlane(); } // re-draws the gizmo + reference plane + fires the Axes chip; invalidates the typed HUD (drift) + the snap caches so the UCS-origin snap follows the frame — but NOT during a live origin drag (the drag's own snap cache, which excludes the origin, stays efficient)
2405
+ function fireFrameChange() { invalidatePointEntry('drift'); if (!(pending && pending.frameDrag)) { tfCandidates = null; dimCandidates3d = null; } renderWorkPlane(); reflectDimAxisBar(); } // re-draws the gizmo + reference plane + fires the Axes chip; relabels the dim-axis bar (X′/Y′/Elev follows the frame); invalidates the typed HUD (drift) + the snap caches so the UCS-origin snap follows the frame — but NOT during a live origin drag (the drag's own snap cache, which excludes the origin, stays efficient)
2354
2406
  // Set a HORIZONTAL frame at origin (numeric entry + gizmo materialize). origin defaults its Z to the active level.
2355
2407
  function setFrame3d(originMm, angleDeg) {
2356
2408
  const z = (originMm && originMm.length > 2) ? originMm[2] : frameZ();
@@ -2596,7 +2648,7 @@ function renderWorkPlane() {
2596
2648
  }
2597
2649
  function reflectWpBar() { const b = document.getElementById('m3dWp'); if (b) { b.classList.toggle('on', !!wpMode || !!workPlane);
2598
2650
  const kind = workPlane && workPlane.kind ? { face: 'Face', p3: '3pt', xy: 'XY', xz: 'XZ', yz: 'YZ' }[workPlane.kind] || '' : '';
2599
- b.textContent = wpMode ? '◇ Plane ✕' : (kind ? '◇ Plane: ' + kind + ' ▾' : '◇ Plane ▾'); } } // the label reads the active plane without opening the menu (ux review)
2651
+ 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)
2600
2652
  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)
2601
2653
  function setWorkPlanePrincipal(kind, offsetMm) {
2602
2654
  const off = offsetMm || 0;
@@ -2980,6 +3032,13 @@ function gridPlaneZ() {
2980
3032
  // The axis to measure on: Alt held during the 2nd pick forces a pure-vertical (Z) measurement,
2981
3033
  // overriding the sticky axis (else a sticky X/Y would collapse the Alt-locked point to zero length).
2982
3034
  function dimEffectiveAxis(alt) { return alt && dimDraft3d ? 'z' : dimAxis3d; }
3035
+ // UCS Stage 5: the world direction a frame-aware x|y dim measures along — the LOCAL frame's X/Y, captured at
3036
+ // placement so the dim survives frame changes/reset/reload. null when: no local frame; a ◇ Plane shadows the frame
3037
+ // (dims go global under a plane — never a SHADOWED frame3d, matching the chip/gizmo); or axis is z/free (world).
3038
+ function dimAxisDir(axis) {
3039
+ if (!frame3d || workPlane) return null;
3040
+ return axis === 'x' ? [...frame3d.xAxis] : axis === 'y' ? [...frame3d.yAxis] : null;
3041
+ }
2983
3042
 
2984
3043
  function onDown(e) {
2985
3044
  if (readout) { readout.style.display = 'none'; if (readout._coord) readout._coord.style.display = 'none'; } // UCS Stage 2: hide the whole readout chip so a drag never shows a lingering coordinate (or an empty coord-only shell); the drag/next hover re-shows it
@@ -3014,10 +3073,11 @@ function onDown(e) {
3014
3073
  const r = dimPointAt(e, dimDraft3d && dimDraft3d.a); if (!r) return;
3015
3074
  if (!dimDraft3d) { dimDraft3d = { a: r.p }; dimCandidates3d = null; }
3016
3075
  else {
3017
- const a = dimDraft3d.a, b = r.p, axis = dimEffectiveAxis(e.altKey);
3018
- const g = dim3dGeom(a, b, axis);
3076
+ const a = dimDraft3d.a, b = r.p, axis = dimEffectiveAxis(e.altKey), axisDir = dimAxisDir(axis);
3077
+ const g = dim3dGeom(a, b, axis, axisDir);
3019
3078
  dimDraft3d = null; dimPreviewLine.visible = false; marker.visible = false; readout.style.display = 'none'; dimCandidates3d = null;
3020
- if (g.valueMm > 1 && api && api.onAddDim3d) api.onAddDim3d({ id: api.newDim3dId(), a, b, axis });
3079
+ if (g.valueMm > 1 && api && api.onAddDim3d) api.onAddDim3d({ id: api.newDim3dId(), a, b, axis, ...(axisDir ? { axisDir } : {}) });
3080
+ else if (g.valueMm <= 1 && axis !== 'free') { dimDraft3d = { a }; if (api && api.toast) api.toast('No length along the locked axis — move the second point or switch axis'); } // any AXIS-LOCKED projection (world X/Y/Z/Elev or local X′/Y′) collapsed to ~0 despite a real 2nd pick — e.g. two points at the same level with Z / Alt-vertical → keep the first anchor + explain, don't silently drop the pick. A coincident 'free' double-click stays a silent no-op.
3021
3081
  }
3022
3082
  return;
3023
3083
  }
@@ -3391,7 +3451,8 @@ function onHoverMove(e) {
3391
3451
  if (snapped) showMarker(r.p, r.type); else marker.visible = false; // reticle only on a real snap (free point rides the preview line) — parity with 2D snapClear
3392
3452
  canvasEl.style.cursor = snapped ? 'none' : 'crosshair'; // at a snap the reticle IS the cursor (Tekla) — hide the native crosshair so it doesn't double up on the marker
3393
3453
  if (dimDraft3d && r) {
3394
- const g = dim3dGeom(dimDraft3d.a, r.p, dimEffectiveAxis(dimLastAlt));
3454
+ const ax = dimEffectiveAxis(dimLastAlt);
3455
+ const g = dim3dGeom(dimDraft3d.a, r.p, ax, dimAxisDir(ax)); // live preview matches what the commit will store
3395
3456
  dimPreviewLine.geometry.setFromPoints([new THREE.Vector3(...g.p1), new THREE.Vector3(...g.p2)]); dimPreviewLine.visible = true;
3396
3457
  readout._dist.textContent = api.fmtLen ? api.fmtLen(g.valueMm) : (g.valueMm / 304.8).toFixed(2) + ' ft';
3397
3458
  readout._type.textContent = r.type ? ' · ' + r.type : (dimLastAlt ? ' ↕' : '');
@@ -3419,9 +3480,9 @@ function onHoverMove(e) {
3419
3480
  }
3420
3481
  if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(lastHoverXY[0], lastHoverXY[1]); } catch { ch = null; } if (ch) { canvasEl.style.cursor = 'move'; return; } } // over a clip handle → move cursor
3421
3482
  let ep = null; try { ep = pickEndpoint(lastHoverXY[0], lastHoverXY[1]); } catch { ep = null; }
3422
- if (ep) { // over an end node → ring + move cursor; keep its member's dots shown
3483
+ if (ep) { // over an end node (a selected member's drag handle) → ring + move cursor
3423
3484
  hoverEp = ep; canvasEl.style.cursor = 'move';
3424
- if (hoverId !== ep.id) { hoverId = ep.id; rebuildEndpoints(); }
3485
+ setHover(ep.id); // glow is a no-op here (ep.id is selected → selection wins), but this clears any prior member's glow
3425
3486
  updateStatusChip(); return;
3426
3487
  }
3427
3488
  hoverEp = null;
@@ -3429,7 +3490,7 @@ function onHoverMove(e) {
3429
3490
  const topMesh = top ? meshById.get(top) : null, isPart = !!(topMesh && topMesh.userData.derived);
3430
3491
  const canDrag = api && api.dragMoveEnabled && api.dragMoveEnabled();
3431
3492
  canvasEl.style.cursor = geoMode() ? 'crosshair' : (top ? ((isPart || !canDrag) ? 'pointer' : 'grab') : 'default'); // derived part → pointer (select-only); member → grab only when drag-move is ON, else pointer (a click just selects — the cursor tells the truth, like 2D)
3432
- if (top !== hoverId) { hoverId = top; rebuildEndpoints(); updateStatusChip(); }
3493
+ if (top !== hoverId) { setHover(top); updateStatusChip(); }
3433
3494
  });
3434
3495
  }
3435
3496
  function updateStatusChip() {
@@ -3606,6 +3667,8 @@ window.Steel3DView = {
3606
3667
  overlayDimsInfo: () => computeOverlayDims().map((s) => ({ label: s.label, cat: s.cat })), // the dims currently emitted (toggle + visibility applied) — for tests
3607
3668
  overlayLabelTexts: () => overlayLabelPool.filter((el) => el.style.display !== 'none' && el.style.visibility !== 'hidden').map((el) => el.textContent),
3608
3669
  dims3dCount: () => (api && api.getDims3d ? (api.getDims3d() || []).length : 0),
3670
+ dims3dRecords: () => (api && api.getDims3d ? (api.getDims3d() || []).map((d) => ({ id: d.id, axis: d.axis, axisDir: d.axisDir || null, valueMm: dim3dGeom(d.a, d.b, d.axis, d.axisDir).valueMm })) : []), // test probe: lightweight per-dim {axis, axisDir, rendered length} for E2E assertions (frame-aware capture + read==write)
3671
+ dimAxisBarLabels: () => Array.from(document.querySelectorAll('#m3dDimAxis button')).map((b) => b.textContent), // test probe: the visible axis-control labels (3-state disclosure)
3609
3672
  selDims3dCount: () => (api && api.selDim3d ? (api.selDim3d() || []).length : 0), // test helper: how many 3D dims are selected
3610
3673
  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 }; },
3611
3674
  debug, probe, screenOf, centerOf, worldOf, snapCandidatesScreen, clipHandlesScreen,
@@ -20,6 +20,7 @@
20
20
  .seg-group{display:inline-flex;border:1px solid #475569;border-radius:6px;overflow:hidden}
21
21
  .seg-group button{border:0;border-radius:0;border-right:1px solid #475569}
22
22
  .seg-group button:last-child{border-right:0}
23
+ #m3dDimAxis button{min-width:5.2em;white-space:nowrap;text-align:center} /* UCS Stage 5: min-width holds the longest label ("World X") so relabeling X→X′→World X across frame states keeps every segment — and the group's total width — constant (no header-cluster jitter) */
23
24
  main{flex:1;display:flex;min-height:0}
24
25
  #stagewrap{flex:1;position:relative;min-width:0;display:flex}
25
26
  #stage{flex:1;overflow:auto;background:#0b1220;display:flex;align-items:safe center;justify-content:safe center}
@@ -729,7 +730,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
729
730
  <button id=dimB data-tip="Dimension tool (D) — click two snapped points, then a third to place. Default Free (aligned); hold Shift to lock to an axis, X/Y force horizontal/vertical, F free. Right-click the canvas to restrict snapping to one type.">⊢ Dimension</button>
730
731
  <!-- 3D Dimension cluster — relocated here from the 3D toolbar so Dimension has ONE home; shown only in 3D (applyViewState). Same ids so steel-3d-view.js reflectDimBar() still drives it. -->
731
732
  <span id=dim3dWrap style="display:none;align-items:center;gap:8px">
732
- <button id=m3dDim data-tip="Measure in 3D — click two snapped points (D); axis Free / X / Y / Z, Alt = vertical; right-click = restrict snap">⊢ Dimension</button>
733
+ <button id=m3dDim data-tip="Measure in 3D — click two snapped points (D); the axis buttons follow the active coordinate frame (X′/Y′/Elev local, World X/Y under a ◇ Plane); Alt = vertical; right-click = restrict snap">⊢ Dimension</button>
733
734
  <div class=seg-group id=m3dDimAxis style="display:none"><button data-d3axis=free class=on data-tip="Free 3D measurement (F)">Free</button><button data-d3axis=x data-tip="Lock measurement to X (X)">X</button><button data-d3axis=y data-tip="Lock measurement to Y (Y)">Y</button><button data-d3axis=z data-tip="Lock to Z / vertical (Z); Alt = quick vertical">Z</button></div>
734
735
  <button id=m3dDimShow data-tip="Show or hide placed 3D dimensions" style="display:none">Hide dims</button>
735
736
  </span>
@@ -1044,6 +1045,7 @@ const APP_ID = new URLSearchParams(location.search).get('app') || '';
1044
1045
  const PROJECT = new URLSearchParams(location.search).get('project') || '';
1045
1046
  const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
1046
1047
  let C, PAL, WT;
1048
+ let SteelCore = null; // steel-3d-core.js module namespace — boot() awaits its dynamic import before main() so the classic script can call its pure helpers (sanitizeDims3d) at load
1047
1049
  let TARGET_CONF = null; // the app's target_confidence input default (%), or null when undeclared — drives the chip's "· target N%" goal
1048
1050
  let view3d = false, view3dReady = false; // 2D|3D toggle state; view3dReady once Steel3DView.init has run
1049
1051
  // Fallback palette (colorFor indexes this array by profile order) when a contract ships no `palette`
@@ -1063,6 +1065,7 @@ function showEmpty(icon, headline, bodyText, appIdText) {
1063
1065
  }
1064
1066
  async function boot() {
1065
1067
  if (!APP_ID) { showEmpty('⊞', 'No workflow selected', 'Open a workflow in the FloLess canvas, then open the contract editor from that workflow’s node.'); return; }
1068
+ SteelCore = await import('./steel-3d-core.js'); // await BEFORE main()/restoreSaved() so the mandatory dims3d sanitizer is loaded (no deferred-module race — a passive window shim could be undefined here)
1066
1069
  const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS);
1067
1070
  if (!res.ok) {
1068
1071
  if (res.status === 404) {
@@ -1517,7 +1520,7 @@ function restoreSaved(){try{const raw=localStorage.getItem(LSKEY);if(!raw)return
1517
1520
  if(Array.isArray(d.member_types))C.member_types=sanitizeMemberTypes(d.member_types);
1518
1521
  if(d.target_confidence!=null)C.target_confidence=d.target_confidence;
1519
1522
  C.plans.forEach(p=>{const s=by[p.sheet];if(s){if(Array.isArray(s.members))p.members=s.members;if(s.default_tos!=null)p.default_tos=s.default_tos;if(Array.isArray(s.details))p.details=s.details;if(Array.isArray(s.dims))p.dims=s.dims;if('frame' in s)p.frame=s.frame||null;if('grid' in s)p.grid=s.grid||null;p.autofilled=true;}});
1520
- if(Array.isArray(d.dims3d))C.dims3d=d.dims3d; // restore model-global 3D dims from the local draft
1523
+ if(Array.isArray(d.dims3d))C.dims3d=SteelCore?SteelCore.sanitizeDims3d(d.dims3d):d.dims3d; // restore model-global 3D dims from the local draft — re-sanitise axisDir (a stale draft could carry junk that would wedge the next save)
1521
1524
  if(Array.isArray(d.detail_placements))C.detail_placements=d.detail_placements; // restore placed details
1522
1525
  if(d.dim_overlays&&typeof d.dim_overlays==='object'&&!Array.isArray(d.dim_overlays)){const o=d.dim_overlays;C.dim_overlays={bolt_pitch:o.bolt_pitch!==false,edge_clearance:o.edge_clearance!==false,cope_size:o.cope_size!==false,base_plate:o.base_plate!==false,anchor_depth:o.anchor_depth!==false};} // restore the legend DIMENSIONS toggles — sanitised to the known boolean keys (a corrupt/partial draft can't desync the legend from what's drawn; on unless explicitly false)
1523
1526
  if('dim_style' in d){C.dim_style=d.dim_style;sanitizeDimStyle();} // restore the model-global dimension-style defaults — sanitised to the three known keys
@@ -3166,6 +3169,7 @@ function sanitizePropLabels(x){const o=(x&&typeof x==='object'&&!Array.isArray(x
3166
3169
  ids:Array.isArray(o.ids)?o.ids.filter(v=>typeof v==='string'):[]};}
3167
3170
  C.prop_labels=sanitizePropLabels(C.prop_labels); // normalise the contract's incoming value now (PROP_KEYS is initialised above; runs before main's bootstrap render + restoreSaved override)
3168
3171
  C.views=sanitizeViews(C.views); // normalise the incoming saved views now — inside main() where sanitizeViews is in scope (boot() only guaranteed an array); runs before the bootstrap render + restoreSaved override, same pattern as prop_labels above
3172
+ if(SteelCore)C.dims3d=SteelCore.sanitizeDims3d(C.dims3d); // UCS Stage 5: canonicalise each 3D dim's axisDir (drop junk / normalise non-unit) so a bad value can't wedge the schema-validated save — the SERVER contract copy; restoreSaved re-sanitises the localStorage draft below
3169
3173
  // the "Label: value" lines a member contributes for the currently-checked props (registry order; skips N/A + empty)
3170
3174
  function propLabelLinesFor(m){const pl=C.prop_labels;if(!pl||!pl.props.length)return [];ensureMeta(m);
3171
3175
  const out=[];for(const def of PROP_DEFS){if(!pl.props.includes(def.key))continue;const raw=def.get(m);if(raw===undefined)continue;const t=def.fmt(raw);if(t==='')continue;out.push(def.label+': '+t);}return out;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.94.0",
3
+ "version": "0.95.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": {