@floless/app 0.91.1 → 0.92.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.91.1" : void 0,
53109
+ define: true ? "0.92.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.91.1" : void 0 });
53119
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.92.0" : void 0 });
53120
53120
  }
53121
53121
 
53122
53122
  // workflow-update.ts
@@ -243,6 +243,61 @@ export function frameFromAngle(origin, angleRad) {
243
243
  return { origin: [origin[0], origin[1], origin[2]], xAxis: [c, s, 0], yAxis: [-s, c, 0], normal: [0, 0, 1] };
244
244
  }
245
245
 
246
+ /**
247
+ * Typed coordinate entry (UCS Stage 3) — the ONE pure seam Move/Copy + Add both route through. Given a
248
+ * parsed component triple + a `provided` mask (which slots the user actually typed), a mode, the anchor in
249
+ * WORLD, and the entry `frame`, return a finite world `{ point, vector }` (or `{ error }`). `vector` is the
250
+ * RELATIVE world offset (destination − anchor); array/linear repeat repeats THAT vector, so an absolute
251
+ * target is never re-applied N times. Every value is finite-checked here — the single guard against
252
+ * NaN/Infinity reaching the contract.
253
+ * ABS: local L = comps, each unprovided slot ← the anchor's local coord on that axis → point =
254
+ * localToWorld(L); vector = point − anchorWorld.
255
+ * REL: local Δ = comps, each unprovided slot ← 0 → vector = localVectorToWorld(Δ); point = anchor + vector.
256
+ */
257
+ export function resolvePointEntry({ mode, comps, provided, anchorWorld, frame }) {
258
+ if (!Array.isArray(comps) || !Array.isArray(anchorWorld) || !frame) return { error: 'bad-input' };
259
+ const pv = provided || [true, true, true];
260
+ if (!pv.some(Boolean)) return { error: 'empty' }; // a bare "," supplies no coordinate — reject
261
+ const c = [Number(comps[0]), Number(comps[1]), Number(comps[2])]; // NO `|| 0` — that would turn NaN into 0 and slip past the finite guard
262
+ for (let i = 0; i < 3; i++) { if (pv[i] && !Number.isFinite(c[i])) return { error: 'non-finite' }; if (!pv[i]) c[i] = 0; } // validate only the PROVIDED slots (unprovided are held/zeroed below); reject NaN/Infinity
263
+ if (!anchorWorld.every(Number.isFinite)) return { error: 'non-finite' };
264
+ const aLocal = worldToLocal(anchorWorld, frame);
265
+ let point, vector;
266
+ if (mode === 'abs') {
267
+ const L = [pv[0] ? c[0] : aLocal[0], pv[1] ? c[1] : aLocal[1], pv[2] ? c[2] : aLocal[2]];
268
+ point = localToWorld(L, frame);
269
+ vector = [point[0] - anchorWorld[0], point[1] - anchorWorld[1], point[2] - anchorWorld[2]];
270
+ } else {
271
+ const D = [pv[0] ? c[0] : 0, pv[1] ? c[1] : 0, pv[2] ? c[2] : 0];
272
+ vector = localVectorToWorld(D, frame);
273
+ point = [anchorWorld[0] + vector[0], anchorWorld[1] + vector[1], anchorWorld[2] + vector[2]];
274
+ }
275
+ if (!point.every(Number.isFinite) || !vector.every(Number.isFinite)) return { error: 'non-finite' };
276
+ return { point, vector };
277
+ }
278
+
279
+ /**
280
+ * The Move/Copy offset list for a commit vector `v` (scene mm) — extracted pure so the 3D view's
281
+ * `tfOffsetsFor` is a thin caller and the linear/grid multiplication is unit-tested directly. (The editor's
282
+ * 2D `linearOffsets`/`arrayOffsets` are the same shape but not yet wired through this — a future cleanup.)
283
+ * `st` = { array, tool:'move'|'copy', count, countA, countB }. Counts INCLUDE the original; the array grid
284
+ * skips (0,0) so an n×m grid adds n*m−1 copies. `vA` (direction A, or null) supplied for a staged array.
285
+ */
286
+ export function offsetsFor(v, st, vA) {
287
+ const z = (a) => a && a.length > 2 ? a[2] : 0; // 2D vectors omit Z → treat as 0
288
+ const lin = (vec, n) => { const o = []; for (let k = 1; k <= n; k++) o.push([vec[0] * k, vec[1] * k, z(vec) * k]); return o; };
289
+ if (st.array) {
290
+ if (!vA) return lin(v, Math.max(0, st.countA - 1));
291
+ const o = [];
292
+ for (let i = 0; i < st.countA; i++) for (let j = 0; j < st.countB; j++) {
293
+ if (!i && !j) continue;
294
+ o.push([vA[0] * i + v[0] * j, vA[1] * i + v[1] * j, z(vA) * i + z(v) * j]);
295
+ }
296
+ return o;
297
+ }
298
+ return st.tool === 'copy' ? lin(v, st.count) : [v];
299
+ }
300
+
246
301
  /**
247
302
  * 3D dimension geometry (pure). a,b are scene mm [x,y,z]. axis ∈ free|x|y|z.
248
303
  * free → the straight segment a→b (valueMm = full 3D distance); x|y|z →
@@ -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 } from './steel-3d-core.js';
20
+ import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor } 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)';
@@ -1037,6 +1037,7 @@ function repivotToCursor() {
1037
1037
  let rebuildSeq = 0;
1038
1038
  async function rebuild(fit = false) {
1039
1039
  if (!api) return;
1040
+ invalidatePointEntry('rebuild'); // synchronous, BEFORE the first await — the scene is changing; drop any open typed entry + stale base (never on stale async completion)
1040
1041
  if (fit) fitPending = true; // entering 3D re-fits; an edit-triggered rebuild keeps the camera put
1041
1042
  const seq = ++rebuildSeq;
1042
1043
  const sc = await api.fetchScene(); // editor POSTs the current contract to /scene
@@ -2268,6 +2269,52 @@ function effectiveWP() {
2268
2269
  if (frame3d) return { origin: [...frame3d.origin], normal: [...frame3d.normal], xAxis: [...frame3d.xAxis], kind: 'frame' };
2269
2270
  return { origin: [0, 0, api ? api.defaultTosMm() : 0], normal: [0, 0, 1], xAxis: [1, 0, 0] };
2270
2271
  }
2272
+ // ---- Typed coordinate entry (UCS Stage 3) — the ONE authoritative point-entry frame + a generation-stamped
2273
+ // lifecycle. `pointEntryFrame()` is what the tools actually follow: a ◇ Plane shadows the local frame, and
2274
+ // the GLOBAL fallback is a TRUE identity (origin [0,0,0], not effectiveWP's active-TOS origin) so global
2275
+ // ABS/readout are true global. `kind` drives the ′-prime (shown when kind !== 'global'). ----
2276
+ function pointEntryFrame() {
2277
+ if (workPlane) { const b = planeBasis(workPlane.normal, workPlane.xAxis); return { kind: 'plane', frame: { origin: [...workPlane.origin], xAxis: b.u || [1, 0, 0], yAxis: b.v || [0, 1, 0], normal: [...workPlane.normal] } }; }
2278
+ if (frame3d) return { kind: 'local', frame: frame3d }; // full basis already; token deep-clones it
2279
+ return { kind: 'global', frame: RO_IDENT }; // identity([0,0,0]) — reused, no per-call alloc
2280
+ }
2281
+ // A monotonic generation: any mutation that could change the entry frame, anchor, or scene bumps it, so a
2282
+ // token whose gen still matches at commit is proven un-drifted (frame/anchor snapshot stays valid).
2283
+ let pointEntryGen = 0;
2284
+ let pointEntryTok = null; // { consumer:'movecopy'|'add', gen, frame, kind, anchorWorld, aimWorld|null, addPhase } | null
2285
+ // Open: capture the frame/anchor/aim snapshot for one operation. Returns the initial HUD UI state, or null-ok.
2286
+ function pointEntryBegin(consumer) {
2287
+ const pef = pointEntryFrame();
2288
+ let anchorWorld, aimWorld = null, addPhase = null, locked = false, mode = 'rel';
2289
+ if (consumer === 'movecopy') {
2290
+ if (!cmActive() || !tfDraft || addActive()) return { ok: false };
2291
+ anchorWorld = [...tfDraft.base];
2292
+ aimWorld = tfLast ? [...tfLast] : null;
2293
+ } else { // add
2294
+ if (!addActive()) return { ok: false };
2295
+ if (drDraft) { anchorWorld = [...drDraft]; addPhase = 'second'; }
2296
+ else { anchorWorld = [...effectiveWP().origin]; addPhase = 'start'; locked = true; mode = 'abs'; } // 1st point has no anchor to offset from → ABS-only
2297
+ }
2298
+ pointEntryTok = { consumer, gen: pointEntryGen, frame: cloneFrame(pef.frame), kind: pef.kind, anchorWorld, aimWorld, addPhase };
2299
+ return { ok: true, mode, locked, kind: pef.kind, primed: pef.kind !== 'global' };
2300
+ }
2301
+ function pointEntryEnd() { pointEntryTok = null; } // editor closed the HUD (not a commit) → drop the token, no gen bump
2302
+ function pointEntryCommit() { pointEntryTok = null; pointEntryGen++; } // a successful commit: clear token + bump gen BEFORE the geometry callback (silent — no drift toast on the reentrant rebuild)
2303
+ // Any mutation that could change the entry frame/anchor/scene. hard = the scene/tool changed → also drop the
2304
+ // base/start so a stale anchor can't revalidate; soft (frame/workplane drift) keeps the world base.
2305
+ function invalidatePointEntry(reason) {
2306
+ const hadLive = !!pointEntryTok, hadStaged = !!(tfDraft && tfDraft.vA);
2307
+ pointEntryGen++; pointEntryTok = null;
2308
+ tfLast = null; tfLastClient = null; // drop the captured aim so a reopened {dist} demands a fresh hover under the new frame (Codex R5 #1)
2309
+ const hard = reason === 'rebuild' || reason === 'undo' || reason === 'view' || reason === 'hide';
2310
+ if (hard) { cmClear3d(); drClear3d(); }
2311
+ else if (tfDraft && tfDraft.vA) { tfDraft.vA = null; tfPreviewClear(); } // soft drift: drop staged direction A, keep the base (geometry didn't move)
2312
+ if (hadLive && api && api.closeCmHud) api.closeCmHud(); // close an open typed-entry HUD
2313
+ if (reason === 'drift' && (hadLive || hadStaged) && api && api.toast) api.toast('Frame changed — re-enter the value');
2314
+ }
2315
+ // A pointer base/start pick invalidates any open typed-entry token (silent — no toast): the anchor changed,
2316
+ // so a stale HUD from a prior phase/operation must not commit against the new draft.
2317
+ function notePointerPick() { if (pointEntryTok && api && api.closeCmHud) api.closeCmHud(); pointEntryTok = null; pointEntryGen++; }
2271
2318
  // What the tools ACTUALLY follow — a set ◇ Plane shadows the local frame, so the chip never claims Local
2272
2319
  // while a plane overrides it. Editor's Axes chip reads this in 3D. A horizontal frame reports its in-plane
2273
2320
  // angle; a tilted frame reports its tilt (normal off-vertical) — a single angle can't describe a 3D orientation.
@@ -2281,7 +2328,7 @@ function frameInfo() {
2281
2328
  }
2282
2329
  return { mode: 'global' };
2283
2330
  }
2284
- function fireFrameChange() { renderFrameGizmo(); if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); }
2331
+ function fireFrameChange() { invalidatePointEntry('drift'); renderFrameGizmo(); if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); } // a frame change re-bases typed entry → invalidate any open HUD (drift)
2285
2332
  // Set a HORIZONTAL frame at origin (numeric entry + gizmo materialize). origin defaults its Z to the active level.
2286
2333
  function setFrame3d(originMm, angleDeg) {
2287
2334
  const z = (originMm && originMm.length > 2) ? originMm[2] : frameZ();
@@ -2519,9 +2566,9 @@ function setWorkPlanePrincipal(kind, offsetMm) {
2519
2566
  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];
2520
2567
  if (!def) return;
2521
2568
  workPlane = { origin: def.normal.map((c) => c * off), normal: def.normal, xAxis: def.xAxis, kind };
2522
- wpMode = null; wpDraft = null; renderWorkPlane(); reflectWpBar();
2569
+ wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar();
2523
2570
  }
2524
- function clearWorkPlane() { workPlane = null; wpMode = null; wpDraft = null; renderWorkPlane(); reflectWpBar(); }
2571
+ function clearWorkPlane() { workPlane = null; wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar(); }
2525
2572
  function toggleWorkPlaneVisible(on) { wpVisible = on === undefined ? !wpVisible : !!on; renderWorkPlane(); }
2526
2573
  function workPlaneInfo() { return { set: !!workPlane, mode: wpMode, visible: wpVisible, plane: workPlane ? { origin: [...workPlane.origin], normal: [...workPlane.normal], xAxis: [...workPlane.xAxis] } : null }; }
2527
2574
  // face pick: the clip tool's raycast, minus the camera-side flip — the plane lands ON the face.
@@ -2586,15 +2633,8 @@ function tfConstrain(p, e) {
2586
2633
  if (ax === 'v') return [b[0] + c.dv * v[0], b[1] + c.dv * v[1], b[2] + c.dv * v[2]];
2587
2634
  return p;
2588
2635
  }
2589
- // mirror of the editor's offset builders (mm side): counts INCLUDE the original, grid skips (0,0)
2590
- function tfOffsetsFor(v, st) {
2591
- const lin = (vec, n) => { const o = []; for (let k = 1; k <= n; k++) o.push([vec[0] * k, vec[1] * k, vec[2] * k]); return o; };
2592
- if (st.array) {
2593
- if (!tfDraft.vA) return lin(v, Math.max(0, st.countA - 1));
2594
- const o = []; for (let i = 0; i < st.countA; i++) for (let j = 0; j < st.countB; j++) { if (!i && !j) continue; o.push([tfDraft.vA[0] * i + v[0] * j, tfDraft.vA[1] * i + v[1] * j, tfDraft.vA[2] * i + v[2] * j]); } return o;
2595
- }
2596
- return st.tool === 'copy' ? lin(v, st.count) : [v];
2597
- }
2636
+ // the offset list is the pure core `offsetsFor` (unit-tested for linear/grid) — counts INCLUDE the original, grid skips (0,0)
2637
+ function tfOffsetsFor(v, st) { return offsetsFor(v, st, tfDraft ? tfDraft.vA : null); }
2598
2638
  function tfGhostBuild(offs) {
2599
2639
  tfDisposeGhost(); // dispose the previous rebuild's own geometries (the >600 boxes) before dropping it
2600
2640
  tfGhost = new THREE.Group();
@@ -2647,7 +2687,7 @@ function tfClick(e) {
2647
2687
  const r = wpPointAt(e); if (!r) return true;
2648
2688
  const p = tfConstrain(r.p, e);
2649
2689
  tfLastClient = [e.clientX, e.clientY];
2650
- if (!tfDraft) { tfDraft = { base: p, vA: null }; tfCandidates = null; tfLast = p; return true; }
2690
+ 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
2651
2691
  const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
2652
2692
  if (Math.hypot(v[0], v[1], v[2]) < 5) return true; // ~zero pick (5 mm) — ignore, like the 2D 0.5 px guard
2653
2693
  if (st.array && !tfDraft.vA) { tfDraft.vA = v; return true; }
@@ -2657,23 +2697,54 @@ function tfClick(e) {
2657
2697
  tfDraft = null; tfPreviewClear();
2658
2698
  return true;
2659
2699
  }
2660
- // HUD hand-off: the editor parses (inches), we turn it into a plane-space vector and run the same flow.
2661
- function cmHudApply(pv) {
2662
- const st = cmActive(); if (!st || !tfDraft) return { err: 'Pick a base point first' };
2663
- const wp = effectiveWP(), { u, v: vv } = planeBasis(wp.normal, wp.xAxis);
2700
+ // HUD hand-off (Move/Copy): the editor parses (inches) + the pill mode (`abs`); we resolve through the pure
2701
+ // resolvePointEntry against the token's frame snapshot. The token gen must still match (no drift) or the HUD
2702
+ // is stale. ABS resolves an absolute local coord (offset = dest − base); REL a delta; both feed the same
2703
+ // `offsetsFor` so a Copy array repeats the RELATIVE vector, never re-stacks an absolute target.
2704
+ function cmHudApply(pv, abs) {
2705
+ const t = pointEntryTok, st = cmActive();
2706
+ if (!t || t.consumer !== 'movecopy' || t.gen !== pointEntryGen || !st || !tfDraft || addActive()) return { err: 'Pick the base point again' };
2664
2707
  let v;
2665
- if (pv.comp) { const IN = 25.4, du = pv.comp[0] * IN, dv = pv.comp[1] * IN, dn = (pv.comp[2] || 0) * IN;
2666
- v = [du * u[0] + dv * vv[0] + dn * wp.normal[0], du * u[1] + dv * vv[1] + dn * wp.normal[1], du * u[2] + dv * vv[2] + dn * wp.normal[2]]; }
2667
- else { if (!tfLast) return { err: 'Move the mouse to aim, or type dx,dy' };
2668
- const dir = [tfLast[0] - tfDraft.base[0], tfLast[1] - tfDraft.base[1], tfLast[2] - tfDraft.base[2]];
2669
- const L = Math.hypot(dir[0], dir[1], dir[2]); if (L < 1e-6) return { err: 'Move the mouse to aim, or type dx,dy' };
2670
- const d = pv.dist * 25.4; v = [dir[0] / L * d, dir[1] / L * d, dir[2] / L * d]; }
2708
+ if (pv.comp) {
2709
+ const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.comp.map((c) => c * 25.4), provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
2710
+ if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
2711
+ v = r.vector;
2712
+ } else { // {dist} along the captured aim — REL / Move-Copy only
2713
+ if (abs) return { err: 'Type X′,Y′ for an absolute point' }; // a bare length is meaningless as an absolute coordinate
2714
+ if (!t.aimWorld) return { err: 'Move the mouse to aim, or type dx,dy' };
2715
+ const dir = [t.aimWorld[0] - t.anchorWorld[0], t.aimWorld[1] - t.anchorWorld[1], t.aimWorld[2] - t.anchorWorld[2]];
2716
+ const L = Math.hypot(dir[0], dir[1], dir[2]);
2717
+ if (!(L > 1e-6) || !Number.isFinite(pv.dist)) return { err: 'Move the mouse to aim, or type dx,dy' };
2718
+ const d = pv.dist * 25.4; v = [dir[0] / L * d, dir[1] / L * d, dir[2] / L * d];
2719
+ }
2720
+ if (!v.every(Number.isFinite)) return { err: 'Enter a valid value' };
2671
2721
  if (Math.hypot(v[0], v[1], v[2]) < 5) return { err: 'Zero distance — type a non-zero value' };
2672
- if (st.array && !tfDraft.vA) { tfDraft.vA = v; tfPreviewClear(); return { ok: true, staged: true }; }
2722
+ if (st.array && !tfDraft.vA) { tfDraft.vA = v; tfPreviewClear(); return { ok: true, staged: true }; } // stage direction A — same operation, does NOT bump gen
2673
2723
  const offs = tfOffsetsFor(v, st);
2674
2724
  if (!offs.length) { tfDraft = null; tfPreviewClear(); return { err: st.array ? 'A 1 × 1 array places no copies — raise a count' : 'Nothing to place' }; }
2675
- api.onTransform3d(offs);
2725
+ if (!offs.every((o) => o.every(Number.isFinite))) { tfDraft = null; tfPreviewClear(); return { err: 'Value out of range' }; } // a big count × a big vector can overflow to Infinity — never send it to the contract
2726
+ pointEntryCommit(); // clear token + bump gen BEFORE the geometry callback so the reentrant rebuild can't false-toast
2676
2727
  tfDraft = null; tfPreviewClear();
2728
+ api.onTransform3d(offs);
2729
+ return { ok: true };
2730
+ }
2731
+ // HUD hand-off (Add-member): 1st point (no drDraft) = ABS-only → set the draw start; 2nd point = resolve
2732
+ // against the start and commit. A bare length ({dist}) is rejected — Add has no aim direction to run it along.
2733
+ function drHudApply(pv, abs) {
2734
+ const t = pointEntryTok;
2735
+ if (!t || t.consumer !== 'add' || t.gen !== pointEntryGen || !addActive()) return { err: 'Arm Add again' };
2736
+ if (pv.dist != null) return { err: 'Type coordinates (X, Y) or a delta (dx, dy)' };
2737
+ const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.comp.map((c) => c * 25.4), provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
2738
+ if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
2739
+ const p = r.point;
2740
+ if (t.addPhase === 'start') { // set the start; the tool stays armed for the 2nd point
2741
+ pointEntryCommit(); drDraft = p; tfCandidates = null;
2742
+ if (readout) readout.style.display = 'none';
2743
+ return { ok: true };
2744
+ }
2745
+ if (!drDraft || Math.hypot(p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]) < 0.5) return { err: 'Zero length — type a non-zero value' }; // sub-mm epsilon (typed; NOT the 50 mm pointer double-click guard)
2746
+ pointEntryCommit();
2747
+ commitDrawPoint(p);
2677
2748
  return { ok: true };
2678
2749
  }
2679
2750
 
@@ -2688,14 +2759,20 @@ function drShiftLock(p, e) { // Shift = ortho
2688
2759
  const wp = effectiveWP(), { u, v } = planeBasis(wp.normal, wp.xAxis), d = [p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]], c = vecToPlane(d, u, v, wp.normal);
2689
2760
  return Math.abs(c.du) >= Math.abs(c.dv) ? [drDraft[0] + c.du * u[0], drDraft[1] + c.du * u[1], drDraft[2] + c.du * u[2]] : [drDraft[0] + c.dv * v[0], drDraft[1] + c.dv * v[1], drDraft[2] + c.dv * v[2]];
2690
2761
  }
2762
+ // The shared "commit the 2nd draw point" transition — used by both the pointer (drClick) and typed entry
2763
+ // (drHudApply). Clears local draw state BEFORE the geometry callback so the reentrant rebuild is safe.
2764
+ function commitDrawPoint(p2) {
2765
+ const start = drDraft;
2766
+ drDraft = null; tfCandidates = null; // the new member is a snap target for the NEXT one — invalidate the shared snap cache
2767
+ if (drRubber) drRubber.visible = false; if (readout) readout.style.display = 'none'; // stays armed for the next member
2768
+ if (start && api && api.onAddMember3d) api.onAddMember3d(start, p2);
2769
+ }
2691
2770
  function drClick(e) {
2692
2771
  const r = wpPointAt(e); if (!r) return;
2693
- if (!drDraft) { drDraft = r.p; return; }
2772
+ if (!drDraft) { notePointerPick(); drDraft = r.p; return; } // start pick bumps the gen so an open first-point typed token can't survive
2694
2773
  const p = drShiftLock(r.p, e);
2695
- if (Math.hypot(p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]) < 50) return; // ~<2in — ignore a doubled click
2696
- if (api && api.onAddMember3d) api.onAddMember3d(drDraft, p);
2697
- drDraft = null; tfCandidates = null; // the new member is a snap target for the NEXT one — invalidate the shared snap cache
2698
- if (drRubber) drRubber.visible = false; readout.style.display = 'none'; // stays armed for the next member
2774
+ if (Math.hypot(p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]) < 50) return; // ~<2in — ignore a doubled click (pointer only; typed uses a sub-mm epsilon)
2775
+ commitDrawPoint(p);
2699
2776
  }
2700
2777
  function drPreview(e) {
2701
2778
  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
@@ -2804,14 +2881,14 @@ function onDown(e) {
2804
2881
  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
2805
2882
  if (e.button === 2) { rightDownXY = [e.clientX, e.clientY]; rightMoved = false; } // arm the click-vs-drag test for the snap menu
2806
2883
  if (e.button !== 0) return; // RIGHT/MIDDLE → OrbitControls (orbit/pan)
2807
- if (wpMode === 'face') { e.stopPropagation(); const r = wpFacePick(e.clientX, e.clientY); if (r) { workPlane = r; wpMode = null; canvasEl.style.cursor = 'default'; renderWorkPlane(); reflectWpBar(); if (api && api.toast) api.toast('Working plane set on the face'); } return; } // armed: one face click sets the plane
2884
+ if (wpMode === 'face') { e.stopPropagation(); const r = wpFacePick(e.clientX, e.clientY); if (r) { workPlane = r; wpMode = null; invalidatePointEntry('drift'); canvasEl.style.cursor = 'default'; renderWorkPlane(); reflectWpBar(); if (api && api.toast) api.toast('Working plane set on the face'); } return; } // armed: one face click sets the plane
2808
2885
  if (wpMode === '3pt') { e.stopPropagation();
2809
2886
  const r = dimPointAt(e); if (!r) return;
2810
2887
  wpDraft = wpDraft || []; wpDraft.push(r.p);
2811
2888
  showMarker(r.p, r.type);
2812
2889
  if (wpDraft.length === 3) { const wp = planeFrom3Points(wpDraft[0], wpDraft[1], wpDraft[2]);
2813
2890
  wpDraft = null; wpMode = null; marker.visible = false; canvasEl.style.cursor = 'default';
2814
- if (wp) { wp.kind = 'p3'; workPlane = wp; renderWorkPlane(); if (api && api.toast) api.toast('Working plane set from 3 points'); }
2891
+ if (wp) { wp.kind = 'p3'; workPlane = wp; invalidatePointEntry('drift'); renderWorkPlane(); if (api && api.toast) api.toast('Working plane set from 3 points'); }
2815
2892
  else if (api && api.toast) api.toast('Points are collinear — plane not set');
2816
2893
  reflectWpBar(); }
2817
2894
  return; }
@@ -3146,10 +3223,12 @@ const RO_AX = ['X', 'Y', 'Z'];
3146
3223
  function roFmt(mm) { if (Math.abs(mm) < 0.5) mm = 0; return api && api.fmtLen ? api.fmtLen(mm) : (mm / FT_MM).toFixed(2) + ' ft'; } // snap sub-1/16" float noise to 0 so a plane point never reads "-0""
3147
3224
  function roCoords(worldPt) {
3148
3225
  if (!readout || !readout._coord || !worldPt) return;
3149
- const local = worldToLocal(worldPt, frame3d || RO_IDENT); // identity → the point's global coords
3150
- const prime = frame3d ? '′' : ''; // U+2032 prime marks a local axis; plain X/Y/Z at global
3226
+ const pef = pointEntryFrame(); // ◇ Plane shadows the local frame; global = TRUE identity([0,0,0])
3227
+ const isLocal = pef.kind !== 'global';
3228
+ const local = worldToLocal(worldPt, pef.frame); // identity → the point's global coords
3229
+ const prime = isLocal ? '′' : ''; // U+2032 prime marks a local axis; plain X/Y/Z at global
3151
3230
  for (let i = 0; i < 3; i++) { readout._coordL[i].textContent = RO_AX[i] + prime + ' '; readout._coordV[i].textContent = roFmt(local[i]); }
3152
- readout._coord.classList.toggle('ro-local', !!frame3d); // cyan the row only when a local frame is set (reuses #csStat.local's accent)
3231
+ readout._coord.classList.toggle('ro-local', isLocal); // cyan the row for a local frame OR a ◇ Plane (reuses #csStat.local's accent)
3153
3232
  readout._coord.style.display = '';
3154
3233
  }
3155
3234
  // A single-point pick with no length yet (base point, first Add/Move/Copy/Dim click, frame 3-click set):
@@ -3271,6 +3350,7 @@ function updateStatusChip() {
3271
3350
 
3272
3351
  function show() { if (controls) controls.enabled = true; if (canvasEl) { canvasEl.style.display = 'block'; resize(); } if (!rafId) loop(); updateStatusChip(); refreshDims(); refreshOverlayDims(); renderFrameGizmo(); } // resume the render loop (reset orbit in case a gesture was stranded by a mid-drag hide)
3273
3352
  function hide() {
3353
+ invalidatePointEntry('hide'); // leaving 3D → drop any open typed entry + stale base/start
3274
3354
  if (dimMode3d) toggleDimTool(); // disarm the dim tool + sync its toolbar (no stale draft/armed state on return)
3275
3355
  if (clipMode) setClipMode(null); // disarm the clip-plane pick too (no stale armed state on return)
3276
3356
  if (insertMode) setInsertMode(false); // disarm a pending detail placement — else the first click on return would place it
@@ -3404,6 +3484,7 @@ window.Steel3DView = {
3404
3484
  armFrame3d, disarmFrame3d, repickFrame3d, setFrame3d, setFrameBasis, setFrameAngle, setFrameOrigin, clearFrame3d, frameInfo, frameArmed: () => frameMode, framePicking, framePickStep, frameHandlesScreen, // 3D local drawing frame (UCS stage 1)
3405
3485
  coordReadout: () => { if (!readout || !readout._coord || readout.style.display === 'none' || readout._coord.style.display === 'none') return null; return { local: readout._coord.classList.contains('ro-local'), values: readout._coordV.map((v) => v.textContent), labels: readout._coordL.map((l) => l.textContent.trim()), text: readout._coord.textContent }; }, // UCS stage 2 test probe: the live local-coordinate row (null when hidden)
3406
3486
  cmEscape, cmHasBase, cmClear3d, setCmAxis, cmLastClient, cmHudApply,
3487
+ drHudApply, pointEntryBegin, pointEntryEnd, drHasStart: () => !!drDraft, // UCS stage 3: shared typed point-entry HUD (Move/Copy + Add)
3407
3488
  drClear3d, drEscape: () => { if (drDraft) { drDraft = null; drClear3d(); return true; } return false; },
3408
3489
  toggleDimTool, setDimAxis, dimAxis, setDims3dVisible, dims3dVisible, refreshDims,
3409
3490
  setSnapOnly: setSnapOnly3d, snapOnly: () => snapOnly3d, dimToolOn: () => dimMode3d, rightDragged: () => rightMoved, // Tekla-style snap override (right-click menu lives in steel-editor.html)
@@ -312,6 +312,15 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
312
312
  #cmHud input{width:110px;height:24px;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:5px;padding:0 7px;font:12px system-ui}
313
313
  #cmHud input:focus{outline:none;border-color:var(--brand)}
314
314
  #cmHud.err input{border-color:#fca5a5}
315
+ #cmHudPill{display:inline-flex;align-items:center;gap:2px;padding:2px;height:20px;border-radius:4px;background:#0f172a;border:1px solid var(--line)}
316
+ #cmHud:not(.v3d) #cmHudPill{display:none} /* 2D Move/Copy is relative-only — no ABS pill (out of scope) */
317
+ .cmHudSeg{border:none;border-radius:3px;padding:2px 7px;font:inherit;font-size:10px;font-weight:600;letter-spacing:.03em;color:#94a3b8;background:transparent;cursor:pointer;transition:background .1s ease,color .1s ease}
318
+ .cmHudSeg:hover{background:rgba(148,163,184,.08);color:#cbd5e1}
319
+ .cmHudSeg.on{background:rgba(34,211,238,.16);box-shadow:inset 0 0 0 1px rgba(34,211,238,.55);color:#22d3ee;font-weight:700}
320
+ .cmHudSeg.on:hover{background:rgba(34,211,238,.22)}
321
+ .cmHudSeg:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
322
+ #cmHudPill.locked .cmHudSeg[data-mode="rel"]{display:none} /* Add first point: no anchor → ABS only, REL hidden (not disabled) */
323
+ #cmHudPill.locked .cmHudSeg[data-mode="abs"]{cursor:default}
315
324
  #lvModal .lvrow{display:flex;align-items:center;gap:10px;padding:8px 10px;border:1px solid transparent;border-radius:7px;cursor:pointer}
316
325
  #lvModal .lvrow:hover{background:var(--line)}
317
326
  #lvModal .lvrow.pick{background:var(--line);border-color:var(--brand)}
@@ -1189,7 +1198,7 @@ function parseLen(str){if(str==null)return null;
1189
1198
  if(s!==''){const m=s.match(/^([0-9]+(?:\.[0-9]+)?)?\s*([0-9]+)\/([0-9]+)$|^([0-9]+(?:\.[0-9]+)?)$/);
1190
1199
  if(!m)return null;
1191
1200
  if(m[4]!=null)inch=parseFloat(m[4]);else{if(m[1]!=null)inch+=parseFloat(m[1]);inch+=parseInt(m[2],10)/parseInt(m[3],10);}}
1192
- const t=ft*12+inch;return neg?-t:t;}
1201
+ const t=ft*12+inch;return Number.isFinite(t)?(neg?-t:t):null;} // fail closed on 1/0 (Infinity) or decimal overflow (1e999) so a bad value never reaches geometry
1193
1202
  function fmtFtIn(v){if(v==null||isNaN(v))return '';const neg=v<0;let sx=Math.round(Math.abs(v)*16);
1194
1203
  let ft=Math.floor(sx/192);sx-=ft*192;let inch=Math.floor(sx/16);let fr=sx-inch*16;
1195
1204
  let num=fr,den=16;while(num>0&&num%2===0){num/=2;den/=2;}const fs=num>0?(' '+num+'/'+den):'';
@@ -1362,10 +1371,15 @@ function linearOffsets(v,n){const o=[];for(let k=1;k<=n;k++)o.push([v[0]*k,v[1]*
1362
1371
  // Rectangular array: counts INCLUDE the original position; (0,0) is skipped so the grid adds n*m-1 copies.
1363
1372
  function arrayOffsets(vA,nA,vB,nB){const o=[];for(let i=0;i<nA;i++)for(let j=0;j<nB;j++){if(!i&&!j)continue;
1364
1373
  o.push([vA[0]*i+vB[0]*j,vA[1]*i+vB[1]*j,(vA[2]||0)*i+(vB[2]||0)*j]);}return o;}
1365
- // HUD input → {dist} (inches, along the live direction) or {comp:[dx,dy,dz] inches}. null = unparseable.
1374
+ // HUD input → {dist} (inches, along the live direction) or {comp:[x,y,z] inches, provided:[b,b,b]}. The
1375
+ // `provided` mask records which slots the user actually typed (","+Y → [false,true,false]) so ABS can hold
1376
+ // the anchor's coord on an omitted axis while REL/2D treat it as 0. null = unparseable.
1366
1377
  function parseVec(s){s=String(s==null?'':s).trim();if(!s)return null;
1367
- if(s.includes(',')){const p=s.split(',').map(t=>t.trim()===''?0:parseLen(t));if(p.some(x=>x==null)||p.length>3)return null;
1368
- return {comp:[p[0]||0,p[1]||0,p[2]||0]};}
1378
+ if(s.includes(',')){const toks=s.split(',');if(toks.length>3)return null;
1379
+ const comp=[0,0,0],provided=[false,false,false];
1380
+ for(let i=0;i<toks.length;i++){const t=toks[i].trim();if(t==='')continue;const v=parseLen(t);if(v==null)return null;comp[i]=v;provided[i]=true;}
1381
+ if(!provided.some(Boolean))return null; // a bare "," supplies no coordinate
1382
+ return {comp,provided};}
1369
1383
  const d=parseLen(s);return d==null?null:{dist:d};}
1370
1384
  // To-level TOS mapping (spec §4.5): default-follow ends land on the target level automatically;
1371
1385
  // explicit overrides shift by Δ so relative offsets survive. Columns keep their height (bos shifts by Δ).
@@ -3564,37 +3578,66 @@ function cmApplyOffsets(offs){const sel=sel2d();if(!sel.length){toast('Selection
3564
3578
  function cmCommit(v){cmApplyOffsets(cmOffsetsFor(v));}
3565
3579
  // --- numeric HUD (spec §3.3): type after the base pick → exact distance or dx,dy[,dz] (dz inches).
3566
3580
  // Live parse echo while typing; unparseable Enter flags the chip red (inline, not just a toast). ---
3567
- let cmHudEl=null;
3581
+ let cmHudEl=null,cmHudAbs=false,cmHudLock=false,cmHudConsumer='movecopy',cmHudPrimed=false; // UCS stage 3 typed-entry HUD state (per open)
3568
3582
  function cmHudIsOpen(){return !!(cmHudEl&&cmHudEl.style.display!=='none');}
3569
- function cmHudClose(){if(cmHudEl){cmHudEl.style.display='none';cmHudEl.classList.remove('err');const i=cmHudEl.querySelector('input');if(i)i.value='';}try{stage.focus({preventScroll:true});}catch(_){}}
3583
+ function cmHudClose(){if(cmHudEl){cmHudEl.style.display='none';cmHudEl.classList.remove('err');const i=cmHudEl.querySelector('input');if(i)i.value='';}
3584
+ if(view3d&&window.Steel3DView&&window.Steel3DView.pointEntryEnd)window.Steel3DView.pointEntryEnd(); // drop the view's captured token (a close is not a commit)
3585
+ try{stage.focus({preventScroll:true});}catch(_){}}
3586
+ function cmHudSetAbs(abs){if(cmHudLock)abs=true;cmHudAbs=!!abs;cmHudSyncPill();cmHudPlaceholder();if(cmHudEl)cmHudEcho();} // REL/ABS pill toggle — re-runs the same live parse/echo
3587
+ function cmHudSyncPill(){if(!cmHudEl)return;const pill=cmHudEl.querySelector('#cmHudPill');if(!pill)return;
3588
+ pill.classList.toggle('locked',cmHudLock); // Add 1st point → ABS only, REL hidden (not disabled)
3589
+ pill.querySelectorAll('.cmHudSeg').forEach(s=>{const on=((s.dataset.mode==='abs')===cmHudAbs);s.setAttribute('aria-checked',on?'true':'false');s.tabIndex=on?0:-1;s.classList.toggle('on',on);}); // roving tabindex: only the selected radio is Tab-reachable
3590
+ const abs=pill.querySelector('.cmHudSeg[data-mode="abs"]');if(abs)abs.setAttribute('data-tip',cmHudLock?'First point has no anchor to offset from — absolute only':'Absolute — X′,Y′,Z′ in the local frame (X,Y,Z if none)');}
3591
+ function cmHudPlaceholder(){if(!cmHudEl)return;const inp=cmHudEl.querySelector('input');if(!inp)return;
3592
+ inp.placeholder=cmHudAbs?(cmHudPrimed?"X′,Y′ · or X′,Y′,Z′":"X,Y · or X,Y,Z"):(cmHudConsumer==='add'?"dx,dy · or dx,dy,dz":"12'-6 · or dx,dy");}
3570
3593
  function cmHudEcho(){const inp=cmHudEl.querySelector('input'),lbl=cmHudEl.querySelector('#cmHudLbl');
3571
- const pv=parseVec(inp.value),n=(cmTool==='copy'&&!cmArrayMode&&cmCount>1)?(' ×'+cmCount):'';
3572
- lbl.textContent=(pv?(pv.dist!=null?('= '+fmtFtIn(pv.dist)):('= '+pv.comp.map(fmtFtIn).join(', ')))+n:n.trim());
3594
+ const pv=parseVec(inp.value),n=(cmTool==='copy'&&!cmArrayMode&&cmCount>1)?(' ×'+cmCount):'';let txt='';
3595
+ if(pv){if(pv.dist!=null){txt='= '+fmtFtIn(pv.dist);}
3596
+ else{const ax=!view3d?['','','']:(cmHudAbs?(cmHudPrimed?['X′','Y′','Z′']:['X','Y','Z']):['Δx','Δy','Δz']); // 3D echo carries the ′ prime + axis so the space is never ambiguous; 2D stays plain (unchanged)
3597
+ txt='= '+pv.comp.map((c,i)=>pv.provided[i]?((ax[i]?ax[i]+' ':'')+fmtFtIn(c)):null).filter(Boolean).join(', ');}}
3598
+ lbl.textContent=(txt?txt+n:n.trim());
3573
3599
  cmHudEl.classList.remove('err');}
3574
- function cmHudShow(seed){if(!cmDraft&&!(view3d&&window.Steel3DView&&window.Steel3DView.cmHasBase&&window.Steel3DView.cmHasBase()))return;
3600
+ function cmHudShow(seed){
3601
+ if(view3d&&window.Steel3DView&&window.Steel3DView.pointEntryBegin){ // 3D: capture the view's frame/anchor/aim token for this operation
3602
+ const consumer=cmTool?'movecopy':(mode==='add'?'add':null);if(!consumer)return;
3603
+ const b=window.Steel3DView.pointEntryBegin(consumer);if(!b||!b.ok)return;
3604
+ cmHudConsumer=consumer;cmHudLock=!!b.locked;cmHudAbs=!!(b.mode==='abs'||b.locked);cmHudPrimed=!!b.primed;
3605
+ }else{if(!cmDraft)return;cmHudConsumer='movecopy';cmHudLock=false;cmHudAbs=false;cmHudPrimed=false;} // 2D: Move/Copy relative-only (no ABS pill)
3575
3606
  if(!cmHudEl){cmHudEl=document.createElement('div');cmHudEl.id='cmHud';
3576
- const inp=document.createElement('input');inp.placeholder="12'-6 · or dx,dy";inp.autocomplete='off';inp.spellcheck=false;
3607
+ const pill=document.createElement('div');pill.id='cmHudPill';pill.setAttribute('role','radiogroup');pill.setAttribute('aria-label','Coordinate mode');
3608
+ const mkSeg=(v,label)=>{const bt=document.createElement('button');bt.type='button';bt.className='cmHudSeg';bt.dataset.mode=v;bt.textContent=label;bt.setAttribute('role','radio');
3609
+ bt.addEventListener('click',()=>{cmHudSetAbs(v==='abs');const inp=cmHudEl.querySelector('input');if(inp)inp.focus();});
3610
+ bt.addEventListener('keydown',ev=>{
3611
+ if(ev.key==='ArrowLeft'||ev.key==='ArrowRight'){ev.stopPropagation();ev.preventDefault();if(!cmHudLock){cmHudSetAbs(!cmHudAbs);const on=pill.querySelector('.cmHudSeg.on');if(on)on.focus();}}
3612
+ else if(ev.key==='Escape'){ev.stopPropagation();ev.preventDefault();cmHudClose();} // Escape closes the HUD even when a pill segment holds focus (not just the input)
3613
+ else if(ev.key==='Enter'){ev.stopPropagation();ev.preventDefault();cmHudCommit(cmHudEl.querySelector('input').value);}}); // Enter from the pill commits too, like the input
3614
+ return bt;};
3615
+ pill.append(mkSeg('rel','REL'),mkSeg('abs','ABS'));
3616
+ const inp=document.createElement('input');inp.autocomplete='off';inp.spellcheck=false;
3577
3617
  const lbl=document.createElement('span');lbl.id='cmHudLbl';
3578
- cmHudEl.append(inp,lbl);document.body.appendChild(cmHudEl);
3618
+ cmHudEl.append(pill,inp,lbl);document.body.appendChild(cmHudEl);
3579
3619
  inp.addEventListener('input',cmHudEcho);
3580
3620
  inp.addEventListener('keydown',ev=>{ev.stopPropagation();
3581
3621
  if(ev.key==='Enter'){ev.preventDefault();cmHudCommit(inp.value);}
3582
3622
  else if(ev.key==='Escape'){ev.preventDefault();cmHudClose();}});}
3623
+ cmHudEl.classList.toggle('v3d',!!view3d);
3624
+ cmHudSyncPill();cmHudPlaceholder();
3583
3625
  const scr3=view3d&&window.Steel3DView&&window.Steel3DView.cmLastClient?window.Steel3DView.cmLastClient():null;
3584
3626
  const scr=scr3||(cmLastEvt?[cmLastEvt.clientX,cmLastEvt.clientY]:[innerWidth/2,innerHeight/2]);
3585
- cmHudEl.style.left=Math.min(scr[0]+16,innerWidth-200)+'px';cmHudEl.style.top=Math.min(scr[1]+16,innerHeight-46)+'px';
3627
+ cmHudEl.style.left=Math.min(scr[0]+16,innerWidth-240)+'px';cmHudEl.style.top=Math.min(scr[1]+16,innerHeight-46)+'px';
3586
3628
  cmHudEl.style.display='flex';cmHudEl.classList.remove('err');
3587
3629
  const inp=cmHudEl.querySelector('input');inp.value=seed||'';cmHudEcho();inp.focus();
3588
3630
  try{inp.setSelectionRange(inp.value.length,inp.value.length);}catch(_){}}
3589
3631
  function cmHudCommit(str){const pv=parseVec(str);
3590
3632
  if(!pv){cmHudEl.classList.add('err');toast('Enter a length (12\'-6) or components (dx,dy)');return;}
3591
- if(view3d&&window.Steel3DView&&window.Steel3DView.cmHudApply){ // 3D: the view maps the value into the working-plane basis and commits via onTransform3d
3592
- const res=window.Steel3DView.cmHudApply(pv);
3593
- if(res&&res.err){cmHudEl.classList.add('err');toast(res.err);return;}
3594
- if(res&&res.staged){cmHudClose();panel();return;} // array direction A staged
3595
- cmHudClose();return;}
3633
+ if(view3d&&window.Steel3DView){ // 3D: the view resolves via the pure resolver + its token, commits via onTransform3d/onAddMember3d
3634
+ const fn=cmHudConsumer==='add'?window.Steel3DView.drHudApply:window.Steel3DView.cmHudApply;
3635
+ if(fn){const res=fn(pv,cmHudAbs);
3636
+ if(res&&res.err){cmHudEl.classList.add('err');toast(res.err);return;}
3637
+ if(res&&res.staged){cmHudClose();panel();return;} // array direction A staged
3638
+ cmHudClose();return;}}
3596
3639
  let v;
3597
- if(pv.comp){const u=P.frame?P.frame.u:[1,0],vv=[u[1],-u[0]]; // typed components live in the local frame; +Y = up the plan
3640
+ if(pv.comp){const u=P.frame?P.frame.u:[1,0],vv=[u[1],-u[0]]; // 2D typed components live in P.frame; +Y = up the plan
3598
3641
  const dxp=pv.comp[0]*FT/12,dyp=pv.comp[1]*FT/12;
3599
3642
  v=[dxp*u[0]+dyp*vv[0],dxp*u[1]+dyp*vv[1],pv.comp[2]||0];}
3600
3643
  else{if(!cmLastPtr){cmHudEl.classList.add('err');toast('Move the mouse to aim, or type dx,dy');return;}
@@ -3937,7 +3980,7 @@ svg.addEventListener('dblclick',e=>{ // dbl-click a grid bubble → rename tha
3937
3980
  gridRenameBubble(gb.dataset.gl!=null?'l':(gb.dataset.gv!=null?'v':'h'),+(gb.dataset.gl!=null?gb.dataset.gl:(gb.dataset.gv!=null?gb.dataset.gv:gb.dataset.gh)),gb.querySelector('circle'));}});
3938
3981
  function setMode(){document.body.classList.toggle('add',mode==='add');document.getElementById('mAdd').classList.toggle('on',mode==='add');
3939
3982
  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)
3940
- if(mode!=='add'){drawDraft=null;drawPrevClear();}} // leaving Add-member drops any in-progress start point + its preview
3983
+ 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)
3941
3984
  document.getElementById('mAdd').onclick=()=>{if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();
3942
3985
  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
3943
3986
  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
@@ -4034,7 +4077,7 @@ addEventListener('keydown',e=>{
4034
4077
  if(e.key==='Enter'&&dimMode&&dimChainPrev){e.preventDefault();dimChainPrev=null;dimPrevClear();render();return;} // Enter ends a running chain
4035
4078
  if(e.key==='Escape'&&dimMode){if(dimChainPrev){dimChainPrev=null;dimPrevClear();}else if(dimDraft){dimDraft=null;dimPrevClear();}else{dimMode=false;setDimMode();}render();return;} // Esc: end the chain → drop the in-progress dim → exit the tool
4036
4079
  if(e.key==='Escape'&&selDimIds.size){if(dimSplitMode){dimSplitMode=false;snapClear();render();}else{selDimIds.clear();render();}return;} // Esc on a selected dim: end split mode → else deselect
4037
- if(e.key==='Escape'&&view3d&&mode==='add'&&window.Steel3DView&&window.Steel3DView.drEscape&&window.Steel3DView.drEscape()){return;} // 3D draw: 1st Esc drops the in-progress start pick, 2nd exits add mode (falls through below)
4080
+ if(e.key==='Escape'&&view3d&&mode==='add'){if(cmHudIsOpen()){cmHudClose();return;}if(window.Steel3DView&&window.Steel3DView.drEscape&&window.Steel3DView.drEscape())return;} // 3D draw: Esc closes an open typed-entry HUD first, then drops the in-progress start pick, then exits add mode (falls through below)
4038
4081
  if(e.key==='Escape'&&!view3d&&mode==='add'&&drawDraft){drawDraft=null;drawPrevClear();render();return;} // 2D Add-member: 1st Esc drops the in-progress start point (2nd falls through below → exits the tool), like the Dimension tool
4039
4082
  if(e.key==='Escape'){if(geoMode){geoMode=null;setGeo();render();return;}if(mode==='add'){mode='sel';setMode();}picking=false;pickKind='profile';pickEnd=null;selIds.clear();selGridIds.clear();render();return;}
4040
4083
  if((e.key==='Delete'||e.key==='Backspace')&&view3d&&window.Steel3DView.selectedClips&&window.Steel3DView.selectedClips().length&&!selIds.size&&!sel3dDimIds.size&&!selDimIds.size&&!inForm){e.preventDefault();window.Steel3DView.deleteSelectedClips();return;} // 3D: Del removes the selected clip plane(s)/box(es) — only when nothing else is selected (clip selection is exclusive)
@@ -4063,7 +4106,8 @@ addEventListener('keydown',e=>{
4063
4106
  if(view3d&&window.Steel3DView&&window.Steel3DView.setCmAxis)window.Steel3DView.setCmAxis(ak);
4064
4107
  else{cmAxis=ak==='f'?'free':ak;cmRefreshPrev();}return;}
4065
4108
  const hasBase=cmDraft||(view3d&&window.Steel3DView&&window.Steel3DView.cmHasBase&&window.Steel3DView.cmHasBase());
4066
- if(hasBase&&/^[0-9.\-']$/.test(e.key)){e.preventDefault();cmHudShow(e.key);return;}}
4109
+ if(hasBase&&/^[0-9.\-',]$/.test(e.key)){e.preventDefault();cmHudShow(e.key);return;}} // comma included so a leading-comma entry (,Y) can open the HUD
4110
+ if(view3d&&mode==='add'&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&/^[0-9.\-',]$/.test(e.key)){e.preventDefault();cmHudShow(e.key);return;} // 3D Add-member: typing opens the shared point-entry HUD (own branch, OUTSIDE the Move/Copy guard)
4067
4111
  if(!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!dimMode){const ck=e.key.toLowerCase(); // M / C — arm Move / Copy (2D and 3D; dim-armed keys win above)
4068
4112
  if(ck==='m'){e.preventDefault();armCm('move',false);return;}
4069
4113
  if(ck==='c'){e.preventDefault();armCm('copy',false);return;}}
@@ -4253,6 +4297,8 @@ const view3dApi={
4253
4297
  disarmTransform:()=>{if(cmTool){disarmCm();render();}}, // the 3D dim tool arming kicks Move/Copy off the left-click
4254
4298
  // 3D draw-on-plane (spec §7): the editor's add-member mode + profile drive it; two plane picks (scene mm) come back here.
4255
4299
  addModeActive:()=>mode==='add',
4300
+ closeCmHud:()=>{if(cmHudIsOpen())cmHudClose();}, // the view closes an open typed-entry HUD on frame drift / rebuild (invalidatePointEntry)
4301
+
4256
4302
  disarmAdd:()=>{if(mode==='add'){mode='sel';setMode();render();}},
4257
4303
  onAddMember3d:(aMm,bMm)=>{const k=304.8/((P&&P.pt_per_ft>0)?P.pt_per_ft:1),r6=n=>Math.round(n*1e6)/1e6; // mm → wp px (Y FLIPPED) + elevation inches
4258
4304
  const wpA=[r6(aMm[0]/k),r6(-aMm[1]/k)],wpB=[r6(bMm[0]/k),r6(-bMm[1]/k)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.91.1",
3
+ "version": "0.92.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": {