@floless/app 0.91.1 → 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.
- package/dist/floless-server.cjs +2 -2
- package/dist/web/steel-3d-core.js +72 -0
- package/dist/web/steel-3d-view.js +179 -46
- package/dist/web/steel-editor.html +69 -23
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -53106,7 +53106,7 @@ function appVersion() {
|
|
|
53106
53106
|
return resolveVersion({
|
|
53107
53107
|
isSea: isSea2(),
|
|
53108
53108
|
sqVersionXml: readSqVersionXml(),
|
|
53109
|
-
define: true ? "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.
|
|
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]]);
|
|
@@ -243,6 +260,61 @@ export function frameFromAngle(origin, angleRad) {
|
|
|
243
260
|
return { origin: [origin[0], origin[1], origin[2]], xAxis: [c, s, 0], yAxis: [-s, c, 0], normal: [0, 0, 1] };
|
|
244
261
|
}
|
|
245
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Typed coordinate entry (UCS Stage 3) — the ONE pure seam Move/Copy + Add both route through. Given a
|
|
265
|
+
* parsed component triple + a `provided` mask (which slots the user actually typed), a mode, the anchor in
|
|
266
|
+
* WORLD, and the entry `frame`, return a finite world `{ point, vector }` (or `{ error }`). `vector` is the
|
|
267
|
+
* RELATIVE world offset (destination − anchor); array/linear repeat repeats THAT vector, so an absolute
|
|
268
|
+
* target is never re-applied N times. Every value is finite-checked here — the single guard against
|
|
269
|
+
* NaN/Infinity reaching the contract.
|
|
270
|
+
* ABS: local L = comps, each unprovided slot ← the anchor's local coord on that axis → point =
|
|
271
|
+
* localToWorld(L); vector = point − anchorWorld.
|
|
272
|
+
* REL: local Δ = comps, each unprovided slot ← 0 → vector = localVectorToWorld(Δ); point = anchor + vector.
|
|
273
|
+
*/
|
|
274
|
+
export function resolvePointEntry({ mode, comps, provided, anchorWorld, frame }) {
|
|
275
|
+
if (!Array.isArray(comps) || !Array.isArray(anchorWorld) || !frame) return { error: 'bad-input' };
|
|
276
|
+
const pv = provided || [true, true, true];
|
|
277
|
+
if (!pv.some(Boolean)) return { error: 'empty' }; // a bare "," supplies no coordinate — reject
|
|
278
|
+
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
|
|
279
|
+
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
|
|
280
|
+
if (!anchorWorld.every(Number.isFinite)) return { error: 'non-finite' };
|
|
281
|
+
const aLocal = worldToLocal(anchorWorld, frame);
|
|
282
|
+
let point, vector;
|
|
283
|
+
if (mode === 'abs') {
|
|
284
|
+
const L = [pv[0] ? c[0] : aLocal[0], pv[1] ? c[1] : aLocal[1], pv[2] ? c[2] : aLocal[2]];
|
|
285
|
+
point = localToWorld(L, frame);
|
|
286
|
+
vector = [point[0] - anchorWorld[0], point[1] - anchorWorld[1], point[2] - anchorWorld[2]];
|
|
287
|
+
} else {
|
|
288
|
+
const D = [pv[0] ? c[0] : 0, pv[1] ? c[1] : 0, pv[2] ? c[2] : 0];
|
|
289
|
+
vector = localVectorToWorld(D, frame);
|
|
290
|
+
point = [anchorWorld[0] + vector[0], anchorWorld[1] + vector[1], anchorWorld[2] + vector[2]];
|
|
291
|
+
}
|
|
292
|
+
if (!point.every(Number.isFinite) || !vector.every(Number.isFinite)) return { error: 'non-finite' };
|
|
293
|
+
return { point, vector };
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The Move/Copy offset list for a commit vector `v` (scene mm) — extracted pure so the 3D view's
|
|
298
|
+
* `tfOffsetsFor` is a thin caller and the linear/grid multiplication is unit-tested directly. (The editor's
|
|
299
|
+
* 2D `linearOffsets`/`arrayOffsets` are the same shape but not yet wired through this — a future cleanup.)
|
|
300
|
+
* `st` = { array, tool:'move'|'copy', count, countA, countB }. Counts INCLUDE the original; the array grid
|
|
301
|
+
* skips (0,0) so an n×m grid adds n*m−1 copies. `vA` (direction A, or null) supplied for a staged array.
|
|
302
|
+
*/
|
|
303
|
+
export function offsetsFor(v, st, vA) {
|
|
304
|
+
const z = (a) => a && a.length > 2 ? a[2] : 0; // 2D vectors omit Z → treat as 0
|
|
305
|
+
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; };
|
|
306
|
+
if (st.array) {
|
|
307
|
+
if (!vA) return lin(v, Math.max(0, st.countA - 1));
|
|
308
|
+
const o = [];
|
|
309
|
+
for (let i = 0; i < st.countA; i++) for (let j = 0; j < st.countB; j++) {
|
|
310
|
+
if (!i && !j) continue;
|
|
311
|
+
o.push([vA[0] * i + v[0] * j, vA[1] * i + v[1] * j, z(vA) * i + z(v) * j]);
|
|
312
|
+
}
|
|
313
|
+
return o;
|
|
314
|
+
}
|
|
315
|
+
return st.tool === 'copy' ? lin(v, st.count) : [v];
|
|
316
|
+
}
|
|
317
|
+
|
|
246
318
|
/**
|
|
247
319
|
* 3D dimension geometry (pure). a,b are scene mm [x,y,z]. axis ∈ free|x|y|z.
|
|
248
320
|
* 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, 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)';
|
|
@@ -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
|
|
@@ -1572,7 +1573,7 @@ function onKey(e) {
|
|
|
1572
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
|
|
1573
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)
|
|
1574
1575
|
if (e.key === 'Escape' && !dimMode3d && !cmActive() && ascendConn()) { e.preventDefault(); return; } // Esc ascends the connection drill: part → whole → nothing
|
|
1575
|
-
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)
|
|
1576
1577
|
const k = e.key.toLowerCase();
|
|
1577
1578
|
// Don't touch the dim tool while a member gesture (drag / box-select) owns the shared marker/readout —
|
|
1578
1579
|
// toggling would clear them mid-gesture. The gesture finishes on pointerup; the key is a no-op until then.
|
|
@@ -2262,12 +2263,59 @@ let framePickPts = null; // null = not picking; [] / [origin] / [origin,x
|
|
|
2262
2263
|
let framePreview = null; // THREE.Group: the live X/Y rubber-band + Z-flip arrow during a pick
|
|
2263
2264
|
const cloneFrame = (f) => ({ origin: [...f.origin], xAxis: [...f.xAxis], yAxis: [...f.yAxis], normal: [...f.normal] });
|
|
2264
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]; };
|
|
2265
2267
|
function frameZ() { return frame3d ? frame3d.origin[2] : (api ? api.defaultTosMm() : 0); }
|
|
2266
2268
|
function effectiveWP() {
|
|
2267
2269
|
if (workPlane) return workPlane; // explicit ◇ Plane wins (unchanged)
|
|
2268
2270
|
if (frame3d) return { origin: [...frame3d.origin], normal: [...frame3d.normal], xAxis: [...frame3d.xAxis], kind: 'frame' };
|
|
2269
2271
|
return { origin: [0, 0, api ? api.defaultTosMm() : 0], normal: [0, 0, 1], xAxis: [1, 0, 0] };
|
|
2270
2272
|
}
|
|
2273
|
+
// ---- Typed coordinate entry (UCS Stage 3) — the ONE authoritative point-entry frame + a generation-stamped
|
|
2274
|
+
// lifecycle. `pointEntryFrame()` is what the tools actually follow: a ◇ Plane shadows the local frame, and
|
|
2275
|
+
// the GLOBAL fallback is a TRUE identity (origin [0,0,0], not effectiveWP's active-TOS origin) so global
|
|
2276
|
+
// ABS/readout are true global. `kind` drives the ′-prime (shown when kind !== 'global'). ----
|
|
2277
|
+
function pointEntryFrame() {
|
|
2278
|
+
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] } }; }
|
|
2279
|
+
if (frame3d) return { kind: 'local', frame: frame3d }; // full basis already; token deep-clones it
|
|
2280
|
+
return { kind: 'global', frame: RO_IDENT }; // identity([0,0,0]) — reused, no per-call alloc
|
|
2281
|
+
}
|
|
2282
|
+
// A monotonic generation: any mutation that could change the entry frame, anchor, or scene bumps it, so a
|
|
2283
|
+
// token whose gen still matches at commit is proven un-drifted (frame/anchor snapshot stays valid).
|
|
2284
|
+
let pointEntryGen = 0;
|
|
2285
|
+
let pointEntryTok = null; // { consumer:'movecopy'|'add', gen, frame, kind, anchorWorld, aimWorld|null, addPhase } | null
|
|
2286
|
+
// Open: capture the frame/anchor/aim snapshot for one operation. Returns the initial HUD UI state, or null-ok.
|
|
2287
|
+
function pointEntryBegin(consumer) {
|
|
2288
|
+
const pef = pointEntryFrame();
|
|
2289
|
+
let anchorWorld, aimWorld = null, addPhase = null, locked = false, mode = 'rel';
|
|
2290
|
+
if (consumer === 'movecopy') {
|
|
2291
|
+
if (!cmActive() || !tfDraft || addActive()) return { ok: false };
|
|
2292
|
+
anchorWorld = [...tfDraft.base];
|
|
2293
|
+
aimWorld = tfLast ? [...tfLast] : null;
|
|
2294
|
+
} else { // add
|
|
2295
|
+
if (!addActive()) return { ok: false };
|
|
2296
|
+
if (drDraft) { anchorWorld = [...drDraft]; addPhase = 'second'; }
|
|
2297
|
+
else { anchorWorld = [...effectiveWP().origin]; addPhase = 'start'; locked = true; mode = 'abs'; } // 1st point has no anchor to offset from → ABS-only
|
|
2298
|
+
}
|
|
2299
|
+
pointEntryTok = { consumer, gen: pointEntryGen, frame: cloneFrame(pef.frame), kind: pef.kind, anchorWorld, aimWorld, addPhase };
|
|
2300
|
+
return { ok: true, mode, locked, kind: pef.kind, primed: pef.kind !== 'global' };
|
|
2301
|
+
}
|
|
2302
|
+
function pointEntryEnd() { pointEntryTok = null; } // editor closed the HUD (not a commit) → drop the token, no gen bump
|
|
2303
|
+
function pointEntryCommit() { pointEntryTok = null; pointEntryGen++; } // a successful commit: clear token + bump gen BEFORE the geometry callback (silent — no drift toast on the reentrant rebuild)
|
|
2304
|
+
// Any mutation that could change the entry frame/anchor/scene. hard = the scene/tool changed → also drop the
|
|
2305
|
+
// base/start so a stale anchor can't revalidate; soft (frame/workplane drift) keeps the world base.
|
|
2306
|
+
function invalidatePointEntry(reason) {
|
|
2307
|
+
const hadLive = !!pointEntryTok, hadStaged = !!(tfDraft && tfDraft.vA);
|
|
2308
|
+
pointEntryGen++; pointEntryTok = null;
|
|
2309
|
+
tfLast = null; tfLastClient = null; // drop the captured aim so a reopened {dist} demands a fresh hover under the new frame (Codex R5 #1)
|
|
2310
|
+
const hard = reason === 'rebuild' || reason === 'undo' || reason === 'view' || reason === 'hide';
|
|
2311
|
+
if (hard) { cmClear3d(); drClear3d(); }
|
|
2312
|
+
else if (tfDraft && tfDraft.vA) { tfDraft.vA = null; tfPreviewClear(); } // soft drift: drop staged direction A, keep the base (geometry didn't move)
|
|
2313
|
+
if (hadLive && api && api.closeCmHud) api.closeCmHud(); // close an open typed-entry HUD
|
|
2314
|
+
if (reason === 'drift' && (hadLive || hadStaged) && api && api.toast) api.toast('Frame changed — re-enter the value');
|
|
2315
|
+
}
|
|
2316
|
+
// A pointer base/start pick invalidates any open typed-entry token (silent — no toast): the anchor changed,
|
|
2317
|
+
// so a stale HUD from a prior phase/operation must not commit against the new draft.
|
|
2318
|
+
function notePointerPick() { if (pointEntryTok && api && api.closeCmHud) api.closeCmHud(); pointEntryTok = null; pointEntryGen++; }
|
|
2271
2319
|
// What the tools ACTUALLY follow — a set ◇ Plane shadows the local frame, so the chip never claims Local
|
|
2272
2320
|
// while a plane overrides it. Editor's Axes chip reads this in 3D. A horizontal frame reports its in-plane
|
|
2273
2321
|
// angle; a tilted frame reports its tilt (normal off-vertical) — a single angle can't describe a 3D orientation.
|
|
@@ -2281,7 +2329,7 @@ function frameInfo() {
|
|
|
2281
2329
|
}
|
|
2282
2330
|
return { mode: 'global' };
|
|
2283
2331
|
}
|
|
2284
|
-
function fireFrameChange() { renderFrameGizmo(); if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); }
|
|
2332
|
+
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
2333
|
// Set a HORIZONTAL frame at origin (numeric entry + gizmo materialize). origin defaults its Z to the active level.
|
|
2286
2334
|
function setFrame3d(originMm, angleDeg) {
|
|
2287
2335
|
const z = (originMm && originMm.length > 2) ? originMm[2] : frameZ();
|
|
@@ -2519,9 +2567,9 @@ function setWorkPlanePrincipal(kind, offsetMm) {
|
|
|
2519
2567
|
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
2568
|
if (!def) return;
|
|
2521
2569
|
workPlane = { origin: def.normal.map((c) => c * off), normal: def.normal, xAxis: def.xAxis, kind };
|
|
2522
|
-
wpMode = null; wpDraft = null; renderWorkPlane(); reflectWpBar();
|
|
2570
|
+
wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar();
|
|
2523
2571
|
}
|
|
2524
|
-
function clearWorkPlane() { workPlane = null; wpMode = null; wpDraft = null; renderWorkPlane(); reflectWpBar(); }
|
|
2572
|
+
function clearWorkPlane() { workPlane = null; wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar(); }
|
|
2525
2573
|
function toggleWorkPlaneVisible(on) { wpVisible = on === undefined ? !wpVisible : !!on; renderWorkPlane(); }
|
|
2526
2574
|
function workPlaneInfo() { return { set: !!workPlane, mode: wpMode, visible: wpVisible, plane: workPlane ? { origin: [...workPlane.origin], normal: [...workPlane.normal], xAxis: [...workPlane.xAxis] } : null }; }
|
|
2527
2575
|
// face pick: the clip tool's raycast, minus the camera-side flip — the plane lands ON the face.
|
|
@@ -2546,6 +2594,15 @@ function rayToWP(cx, cy, wp) {
|
|
|
2546
2594
|
const hit = new THREE.Vector3();
|
|
2547
2595
|
return raycaster.ray.intersectPlane(plane, hit) ? [hit.x, hit.y, hit.z] : null;
|
|
2548
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
|
+
}
|
|
2549
2606
|
|
|
2550
2607
|
// ---- 3D Move/Copy (spec §3+§6): the EDITOR owns the tool state (cmState via api); this side owns
|
|
2551
2608
|
// picking/preview in scene mm against the working plane, and hands commit offsets back. ----
|
|
@@ -2553,13 +2610,13 @@ let tfDraft = null; // {base:[mm], vA:[mm]|null}
|
|
|
2553
2610
|
let tfLastShift = false; // shiftKey mirror for the rAF-synthetic hover event
|
|
2554
2611
|
let tfLast = null; // last constrained preview point (HUD distance direction)
|
|
2555
2612
|
let tfLastClient = null; // last pointer client [x,y] (HUD placement)
|
|
2556
|
-
let tfAxis = 'free'; // 'free' | 'u' | 'v' — X/Y force
|
|
2613
|
+
let tfAxis = 'free'; // 'free' | 'u' | 'v' | 'n' — X/Y force in-plane, 'n' = normal-axis lock (UCS Stage 4)
|
|
2557
2614
|
let tfCandidates = null;
|
|
2558
2615
|
let tfGhost = null, tfRubber = null, tfRubberA = null, tfGhostMat = null;
|
|
2559
2616
|
const cmActive = () => (api && api.cmState ? api.cmState() : null);
|
|
2560
2617
|
const cmHasBase = () => !!tfDraft;
|
|
2561
2618
|
const cmLastClient = () => tfLastClient;
|
|
2562
|
-
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'; }
|
|
2563
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
|
|
2564
2621
|
function cmEscape() { if (!tfDraft) return false; if (tfDraft.vA) { tfDraft.vA = null; tfPreviewClear(); return true; } tfDraft = null; tfPreviewClear(); return true; }
|
|
2565
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
|
|
@@ -2586,15 +2643,49 @@ function tfConstrain(p, e) {
|
|
|
2586
2643
|
if (ax === 'v') return [b[0] + c.dv * v[0], b[1] + c.dv * v[1], b[2] + c.dv * v[2]];
|
|
2587
2644
|
return p;
|
|
2588
2645
|
}
|
|
2589
|
-
//
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
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
|
|
2597
2686
|
}
|
|
2687
|
+
// the offset list is the pure core `offsetsFor` (unit-tested for linear/grid) — counts INCLUDE the original, grid skips (0,0)
|
|
2688
|
+
function tfOffsetsFor(v, st) { return offsetsFor(v, st, tfDraft ? tfDraft.vA : null); }
|
|
2598
2689
|
function tfGhostBuild(offs) {
|
|
2599
2690
|
tfDisposeGhost(); // dispose the previous rebuild's own geometries (the >600 boxes) before dropping it
|
|
2600
2691
|
tfGhost = new THREE.Group();
|
|
@@ -2617,10 +2708,10 @@ function tfGhostBuild(offs) {
|
|
|
2617
2708
|
}
|
|
2618
2709
|
function tfPreview(e) {
|
|
2619
2710
|
const st = cmActive(); if (!st || !tfDraft) return;
|
|
2620
|
-
const
|
|
2621
|
-
const p =
|
|
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;
|
|
2622
2713
|
tfLast = p; tfLastClient = [e.clientX, e.clientY];
|
|
2623
|
-
if (
|
|
2714
|
+
if (q.snap) showMarker(p, q.type); else marker.visible = false;
|
|
2624
2715
|
const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
|
|
2625
2716
|
tfGhostBuild(tfOffsetsFor(v, st));
|
|
2626
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); }
|
|
@@ -2633,7 +2724,7 @@ function tfPreview(e) {
|
|
|
2633
2724
|
}
|
|
2634
2725
|
const L = Math.hypot(v[0], v[1], v[2]);
|
|
2635
2726
|
readout._dist.textContent = api.fmtLen ? api.fmtLen(L) : (L / FT_MM).toFixed(2) + ' ft';
|
|
2636
|
-
readout._type.textContent =
|
|
2727
|
+
readout._type.textContent = q.snap ? ' · ' + (q.type || 'snap') : (st.tool === 'copy' && !st.array && st.count > 1 ? ' ×' + st.count : '');
|
|
2637
2728
|
readout.style.left = (e.clientX + 14) + 'px'; readout.style.top = (e.clientY + 14) + 'px'; readout.style.display = 'block';
|
|
2638
2729
|
roCoords(p); // local coords of the destination point
|
|
2639
2730
|
}
|
|
@@ -2644,10 +2735,10 @@ function tfClick(e) {
|
|
|
2644
2735
|
if (api && api.disarmTransform) api.disarmTransform();
|
|
2645
2736
|
return false;
|
|
2646
2737
|
}
|
|
2647
|
-
const
|
|
2648
|
-
const p =
|
|
2738
|
+
const q = cmDestPoint(e); if (!q) return true;
|
|
2739
|
+
const p = q.p;
|
|
2649
2740
|
tfLastClient = [e.clientX, e.clientY];
|
|
2650
|
-
if (!tfDraft) { tfDraft = { base: p, vA: null }; tfCandidates = null; tfLast = p; return true; }
|
|
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
|
|
2651
2742
|
const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
|
|
2652
2743
|
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
2744
|
if (st.array && !tfDraft.vA) { tfDraft.vA = v; return true; }
|
|
@@ -2657,23 +2748,54 @@ function tfClick(e) {
|
|
|
2657
2748
|
tfDraft = null; tfPreviewClear();
|
|
2658
2749
|
return true;
|
|
2659
2750
|
}
|
|
2660
|
-
// HUD hand-off: the editor parses (inches)
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2751
|
+
// HUD hand-off (Move/Copy): the editor parses (inches) + the pill mode (`abs`); we resolve through the pure
|
|
2752
|
+
// resolvePointEntry against the token's frame snapshot. The token gen must still match (no drift) or the HUD
|
|
2753
|
+
// is stale. ABS resolves an absolute local coord (offset = dest − base); REL a delta; both feed the same
|
|
2754
|
+
// `offsetsFor` so a Copy array repeats the RELATIVE vector, never re-stacks an absolute target.
|
|
2755
|
+
function cmHudApply(pv, abs) {
|
|
2756
|
+
const t = pointEntryTok, st = cmActive();
|
|
2757
|
+
if (!t || t.consumer !== 'movecopy' || t.gen !== pointEntryGen || !st || !tfDraft || addActive()) return { err: 'Pick the base point again' };
|
|
2664
2758
|
let v;
|
|
2665
|
-
if (pv.comp) {
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2759
|
+
if (pv.comp) {
|
|
2760
|
+
const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.comp.map((c) => c * 25.4), provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
|
|
2761
|
+
if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
|
|
2762
|
+
v = r.vector;
|
|
2763
|
+
} else { // {dist} along the captured aim — REL / Move-Copy only
|
|
2764
|
+
if (abs) return { err: 'Type X′,Y′ for an absolute point' }; // a bare length is meaningless as an absolute coordinate
|
|
2765
|
+
if (!t.aimWorld) return { err: 'Move the mouse to aim, or type dx,dy' };
|
|
2766
|
+
const dir = [t.aimWorld[0] - t.anchorWorld[0], t.aimWorld[1] - t.anchorWorld[1], t.aimWorld[2] - t.anchorWorld[2]];
|
|
2767
|
+
const L = Math.hypot(dir[0], dir[1], dir[2]);
|
|
2768
|
+
if (!(L > 1e-6) || !Number.isFinite(pv.dist)) return { err: 'Move the mouse to aim, or type dx,dy' };
|
|
2769
|
+
const d = pv.dist * 25.4; v = [dir[0] / L * d, dir[1] / L * d, dir[2] / L * d];
|
|
2770
|
+
}
|
|
2771
|
+
if (!v.every(Number.isFinite)) return { err: 'Enter a valid value' };
|
|
2671
2772
|
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 }; }
|
|
2773
|
+
if (st.array && !tfDraft.vA) { tfDraft.vA = v; tfPreviewClear(); return { ok: true, staged: true }; } // stage direction A — same operation, does NOT bump gen
|
|
2673
2774
|
const offs = tfOffsetsFor(v, st);
|
|
2674
2775
|
if (!offs.length) { tfDraft = null; tfPreviewClear(); return { err: st.array ? 'A 1 × 1 array places no copies — raise a count' : 'Nothing to place' }; }
|
|
2675
|
-
|
|
2776
|
+
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
|
|
2777
|
+
pointEntryCommit(); // clear token + bump gen BEFORE the geometry callback so the reentrant rebuild can't false-toast
|
|
2676
2778
|
tfDraft = null; tfPreviewClear();
|
|
2779
|
+
api.onTransform3d(offs);
|
|
2780
|
+
return { ok: true };
|
|
2781
|
+
}
|
|
2782
|
+
// HUD hand-off (Add-member): 1st point (no drDraft) = ABS-only → set the draw start; 2nd point = resolve
|
|
2783
|
+
// against the start and commit. A bare length ({dist}) is rejected — Add has no aim direction to run it along.
|
|
2784
|
+
function drHudApply(pv, abs) {
|
|
2785
|
+
const t = pointEntryTok;
|
|
2786
|
+
if (!t || t.consumer !== 'add' || t.gen !== pointEntryGen || !addActive()) return { err: 'Arm Add again' };
|
|
2787
|
+
if (pv.dist != null) return { err: 'Type coordinates (X, Y) or a delta (dx, dy)' };
|
|
2788
|
+
const r = resolvePointEntry({ mode: abs ? 'abs' : 'rel', comps: pv.comp.map((c) => c * 25.4), provided: pv.provided, anchorWorld: t.anchorWorld, frame: t.frame });
|
|
2789
|
+
if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
|
|
2790
|
+
const p = r.point;
|
|
2791
|
+
if (t.addPhase === 'start') { // set the start; the tool stays armed for the 2nd point
|
|
2792
|
+
pointEntryCommit(); drDraft = p; tfCandidates = null;
|
|
2793
|
+
if (readout) readout.style.display = 'none';
|
|
2794
|
+
return { ok: true };
|
|
2795
|
+
}
|
|
2796
|
+
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)
|
|
2797
|
+
pointEntryCommit();
|
|
2798
|
+
commitDrawPoint(p);
|
|
2677
2799
|
return { ok: true };
|
|
2678
2800
|
}
|
|
2679
2801
|
|
|
@@ -2688,14 +2810,20 @@ function drShiftLock(p, e) { // Shift = ortho
|
|
|
2688
2810
|
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
2811
|
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
2812
|
}
|
|
2813
|
+
// The shared "commit the 2nd draw point" transition — used by both the pointer (drClick) and typed entry
|
|
2814
|
+
// (drHudApply). Clears local draw state BEFORE the geometry callback so the reentrant rebuild is safe.
|
|
2815
|
+
function commitDrawPoint(p2) {
|
|
2816
|
+
const start = drDraft;
|
|
2817
|
+
drDraft = null; tfCandidates = null; // the new member is a snap target for the NEXT one — invalidate the shared snap cache
|
|
2818
|
+
if (drRubber) drRubber.visible = false; if (readout) readout.style.display = 'none'; // stays armed for the next member
|
|
2819
|
+
if (start && api && api.onAddMember3d) api.onAddMember3d(start, p2);
|
|
2820
|
+
}
|
|
2691
2821
|
function drClick(e) {
|
|
2692
2822
|
const r = wpPointAt(e); if (!r) return;
|
|
2693
|
-
if (!drDraft) { drDraft = r.p; return; }
|
|
2823
|
+
if (!drDraft) { notePointerPick(); drDraft = r.p; return; } // start pick bumps the gen so an open first-point typed token can't survive
|
|
2694
2824
|
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
|
-
|
|
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
|
|
2825
|
+
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)
|
|
2826
|
+
commitDrawPoint(p);
|
|
2699
2827
|
}
|
|
2700
2828
|
function drPreview(e) {
|
|
2701
2829
|
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
|
|
@@ -2717,7 +2845,8 @@ function drPreview(e) {
|
|
|
2717
2845
|
function pxToWorldAt(px, pos) {
|
|
2718
2846
|
const h = (canvasEl && canvasEl.clientHeight) || 1;
|
|
2719
2847
|
if (camera === orthoCam) return px * ((orthoCam.top - orthoCam.bottom) / (orthoCam.zoom || 1)) / h;
|
|
2720
|
-
const
|
|
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);
|
|
2721
2850
|
return px * (2 * Math.tan(THREE.MathUtils.degToRad(perspCam.fov) / 2) * dist) / h;
|
|
2722
2851
|
}
|
|
2723
2852
|
const RETICLE_PX = 44; // on-screen size of the snap reticle (the full sprite); the ring/glyph fill the middle ~55%
|
|
@@ -2804,14 +2933,14 @@ function onDown(e) {
|
|
|
2804
2933
|
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
2934
|
if (e.button === 2) { rightDownXY = [e.clientX, e.clientY]; rightMoved = false; } // arm the click-vs-drag test for the snap menu
|
|
2806
2935
|
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
|
|
2936
|
+
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
2937
|
if (wpMode === '3pt') { e.stopPropagation();
|
|
2809
2938
|
const r = dimPointAt(e); if (!r) return;
|
|
2810
2939
|
wpDraft = wpDraft || []; wpDraft.push(r.p);
|
|
2811
2940
|
showMarker(r.p, r.type);
|
|
2812
2941
|
if (wpDraft.length === 3) { const wp = planeFrom3Points(wpDraft[0], wpDraft[1], wpDraft[2]);
|
|
2813
2942
|
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'); }
|
|
2943
|
+
if (wp) { wp.kind = 'p3'; workPlane = wp; invalidatePointEntry('drift'); renderWorkPlane(); if (api && api.toast) api.toast('Working plane set from 3 points'); }
|
|
2815
2944
|
else if (api && api.toast) api.toast('Points are collinear — plane not set');
|
|
2816
2945
|
reflectWpBar(); }
|
|
2817
2946
|
return; }
|
|
@@ -3146,10 +3275,12 @@ const RO_AX = ['X', 'Y', 'Z'];
|
|
|
3146
3275
|
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
3276
|
function roCoords(worldPt) {
|
|
3148
3277
|
if (!readout || !readout._coord || !worldPt) return;
|
|
3149
|
-
const
|
|
3150
|
-
const
|
|
3278
|
+
const pef = pointEntryFrame(); // ◇ Plane shadows the local frame; global = TRUE identity([0,0,0])
|
|
3279
|
+
const isLocal = pef.kind !== 'global';
|
|
3280
|
+
const local = worldToLocal(worldPt, pef.frame); // identity → the point's global coords
|
|
3281
|
+
const prime = isLocal ? '′' : ''; // U+2032 prime marks a local axis; plain X/Y/Z at global
|
|
3151
3282
|
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',
|
|
3283
|
+
readout._coord.classList.toggle('ro-local', isLocal); // cyan the row for a local frame OR a ◇ Plane (reuses #csStat.local's accent)
|
|
3153
3284
|
readout._coord.style.display = '';
|
|
3154
3285
|
}
|
|
3155
3286
|
// A single-point pick with no length yet (base point, first Add/Move/Copy/Dim click, frame 3-click set):
|
|
@@ -3249,7 +3380,7 @@ function updateStatusChip() {
|
|
|
3249
3380
|
if (wpMode === 'face') txt = 'Click a member face — the working plane lands on it · Esc to cancel';
|
|
3250
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] || '';
|
|
3251
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';
|
|
3252
|
-
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' : '';
|
|
3253
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')
|
|
3254
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; }
|
|
3255
3386
|
else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
|
|
@@ -3271,6 +3402,7 @@ function updateStatusChip() {
|
|
|
3271
3402
|
|
|
3272
3403
|
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
3404
|
function hide() {
|
|
3405
|
+
invalidatePointEntry('hide'); // leaving 3D → drop any open typed entry + stale base/start
|
|
3274
3406
|
if (dimMode3d) toggleDimTool(); // disarm the dim tool + sync its toolbar (no stale draft/armed state on return)
|
|
3275
3407
|
if (clipMode) setClipMode(null); // disarm the clip-plane pick too (no stale armed state on return)
|
|
3276
3408
|
if (insertMode) setInsertMode(false); // disarm a pending detail placement — else the first click on return would place it
|
|
@@ -3404,6 +3536,7 @@ window.Steel3DView = {
|
|
|
3404
3536
|
armFrame3d, disarmFrame3d, repickFrame3d, setFrame3d, setFrameBasis, setFrameAngle, setFrameOrigin, clearFrame3d, frameInfo, frameArmed: () => frameMode, framePicking, framePickStep, frameHandlesScreen, // 3D local drawing frame (UCS stage 1)
|
|
3405
3537
|
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
3538
|
cmEscape, cmHasBase, cmClear3d, setCmAxis, cmLastClient, cmHudApply,
|
|
3539
|
+
drHudApply, pointEntryBegin, pointEntryEnd, drHasStart: () => !!drDraft, // UCS stage 3: shared typed point-entry HUD (Move/Copy + Add)
|
|
3407
3540
|
drClear3d, drEscape: () => { if (drDraft) { drDraft = null; drClear3d(); return true; } return false; },
|
|
3408
3541
|
toggleDimTool, setDimAxis, dimAxis, setDims3dVisible, dims3dVisible, refreshDims,
|
|
3409
3542
|
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:[
|
|
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
|
|
1368
|
-
|
|
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='';}
|
|
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
|
-
|
|
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){
|
|
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
|
|
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-
|
|
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
|
|
3592
|
-
const
|
|
3593
|
-
if(
|
|
3594
|
-
|
|
3595
|
-
|
|
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
|
|
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
|
|
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'
|
|
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)
|
|
@@ -4058,12 +4101,13 @@ addEventListener('keydown',e=>{
|
|
|
4058
4101
|
if(dimMode&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const dk=e.key.toLowerCase();
|
|
4059
4102
|
if(dk==='x'||dk==='y'||dk==='f'){e.preventDefault();dimSetAxis(dk==='f'?'free':dk);dimDraft&&svg.querySelector('#dimPrevG')&&dimRefreshPrev();return;}
|
|
4060
4103
|
if(dk==='c'){e.preventDefault();toggleDimChain();return;}} // C — toggle chained (continuous) dimensioning
|
|
4061
|
-
if(cmTool&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ak=e.key.toLowerCase(); // Move/Copy armed: X/Y/F force the axis (
|
|
4062
|
-
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)
|
|
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)];
|