@floless/app 0.92.0 → 0.93.1
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 +19 -2
- package/dist/web/steel-3d-view.js +128 -56
- package/dist/web/steel-editor.html +69 -3
- 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.1" : 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.1" : void 0 });
|
|
53120
53120
|
}
|
|
53121
53121
|
|
|
53122
53122
|
// workflow-update.ts
|
|
@@ -113,7 +113,7 @@ export function snapElevation(z, levels, tol) {
|
|
|
113
113
|
|
|
114
114
|
// Lower wins when two candidates are both within tolerance. Grid intersections rank with member
|
|
115
115
|
// intersections (columns land on them); grid lines below member centerlines.
|
|
116
|
-
const PRECEDENCE = { vertex: 0, intersection: 1, 'grid-int': 1, midpoint: 2, centerline: 3, 'vertical-axis': 4, 'grid-line': 5, level: 1 };
|
|
116
|
+
const PRECEDENCE = { origin: 0, vertex: 0, intersection: 1, 'grid-int': 1, midpoint: 2, centerline: 3, 'vertical-axis': 4, 'grid-line': 5, level: 1 }; // origin = the local UCS origin, ties with a vertex (a deliberate reference point)
|
|
117
117
|
|
|
118
118
|
function closestOnSeg(p, a, b) {
|
|
119
119
|
const ab = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
|
|
@@ -125,7 +125,7 @@ function closestOnSeg(p, a, b) {
|
|
|
125
125
|
|
|
126
126
|
/** The 3D point a candidate proposes for the dragged point. */
|
|
127
127
|
function candidatePoint(c, dragged) {
|
|
128
|
-
if (c.type === 'vertex' || c.type === 'intersection' || c.type === 'midpoint' || c.type === 'level') return c.p; // fixed points
|
|
128
|
+
if (c.type === 'vertex' || c.type === 'intersection' || c.type === 'midpoint' || c.type === 'level' || c.type === 'origin') return c.p; // fixed points
|
|
129
129
|
if (c.type === 'vertical-axis') return [c.p[0], c.p[1], dragged[2]]; // lock plan X/Y to the axis, keep dragged Z
|
|
130
130
|
if (c.type === 'grid-int') return [c.p[0], c.p[1], dragged[2]]; // grid steers PLAN only — never yanks the elevation
|
|
131
131
|
if (c.type === 'grid-line') { const q = closestOnSeg(dragged, c.a, c.b); return [q[0], q[1], dragged[2]]; }
|
|
@@ -181,6 +181,23 @@ export function projectToPlane(p, origin, normal) {
|
|
|
181
181
|
return [p[0] - d * n[0], p[1] - d * n[1], p[2] - d * n[2]];
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Signed world distance t from axisP to the point on the axis line closest to the cursor ray
|
|
186
|
+
* (rayO + s·rayD) — the standard closest-approach of two lines. axisN is normalized internally,
|
|
187
|
+
* so t is a distance along the UNIT axis n̂ and the locked point is `axisP + t·n̂` (NOT axisP +
|
|
188
|
+
* t·axisN for a non-unit axisN). Returns null when the ray is ~parallel to the axis (Top-view
|
|
189
|
+
* degeneracy: |r̂·n̂| > ~0.999), where the closest-approach is singular and the caller must fall
|
|
190
|
+
* back to a screen-space map. rayD/axisN need not be unit — both are normalized here.
|
|
191
|
+
*/
|
|
192
|
+
export function rayAxisT(rayO, rayD, axisP, axisN) {
|
|
193
|
+
const r = _norm(rayD), n = _norm(axisN);
|
|
194
|
+
if (!r || !n) return null;
|
|
195
|
+
const b = _dot(r, n), denom = 1 - b * b; // 1 − cos²θ; → 0 as the ray aligns with the axis
|
|
196
|
+
if (denom < 2e-3) return null; // |r̂·n̂| > ~0.999 → singular; caller maps screen-Y → t
|
|
197
|
+
const w = [rayO[0] - axisP[0], rayO[1] - axisP[1], rayO[2] - axisP[2]];
|
|
198
|
+
return (_dot(n, w) - b * _dot(r, w)) / denom; // t = (e − b·d)/denom, unit basis so a=c=1
|
|
199
|
+
}
|
|
200
|
+
|
|
184
201
|
/** Plane from 3 picked points (Tekla flow): origin=a, xAxis toward b, normal = x̂ × (c−a). null when degenerate. */
|
|
185
202
|
export function planeFrom3Points(a, b, c) {
|
|
186
203
|
const xAxis = _norm([b[0] - a[0], b[1] - a[1], b[2] - a[2]]);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import * as THREE from 'three';
|
|
18
18
|
import { OrbitControls } from 'three/addons/OrbitControls.js';
|
|
19
19
|
import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
|
|
20
|
-
import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor } from './steel-3d-core.js';
|
|
20
|
+
import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, rayAxisT } from './steel-3d-core.js';
|
|
21
21
|
import { gridGeometry, gridCandidates3d, mmPerPx } from './grid-core.js';
|
|
22
22
|
|
|
23
23
|
let renderer, scene, perspCam, orthoCam, camera, controls, root, api, canvasEl, ro, rafId, grid, raycaster, downXY, lastPick = '(none)';
|
|
@@ -605,6 +605,7 @@ function buildFromScene(sc) {
|
|
|
605
605
|
box.expandByObject(mesh);
|
|
606
606
|
}
|
|
607
607
|
sceneBox = box.clone();
|
|
608
|
+
renderWorkPlane(); // re-draw the gizmo + reference plane sized to the (possibly new) model bounds
|
|
608
609
|
// Retain the dim-relevant parts (plates + copes) so the legend's DIMENSIONS overlays can be derived
|
|
609
610
|
// from the resolved geometry — fin-plate holes give bolt pitch/edge clearance, cuts give cope size.
|
|
610
611
|
// (computeOverlayDims scopes the plate path to group 'shear-plate' — base/washer plates are skipped there.)
|
|
@@ -627,15 +628,8 @@ let sceneGroups = [];
|
|
|
627
628
|
// opacity — no white grid (per the baseline). Rebuilt with the model so it always fits.
|
|
628
629
|
function buildGrid(box) {
|
|
629
630
|
if (grid) { scene.remove(grid); grid.geometry.dispose(); grid.material.dispose(); grid = null; }
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
const span = Math.max(size.x, size.y) * 1.6 || 5000;
|
|
633
|
-
grid = new THREE.GridHelper(span, 24, 0x1e293b, 0x1e293b); // --line (slate-800)
|
|
634
|
-
grid.material.transparent = true; grid.material.opacity = 0.35;
|
|
635
|
-
grid.rotation.x = Math.PI / 2; // GridHelper is XZ by default → rotate to XY for Z-up
|
|
636
|
-
const c = box.getCenter(new THREE.Vector3());
|
|
637
|
-
grid.position.set(c.x, c.y, box.min.z); // ground at the lowest member
|
|
638
|
-
scene.add(grid);
|
|
631
|
+
// Default 3D floor grid disabled (Pawel 2026-07-13): the plan grid (buildStructGrid — our own grid object)
|
|
632
|
+
// is the ground reference, so the built-in GridHelper is redundant clutter.
|
|
639
633
|
}
|
|
640
634
|
|
|
641
635
|
// Optional reference lines: the work-line (between the two end dots) of every member — the centreline
|
|
@@ -877,6 +871,7 @@ const gridTexCache = new Map(); // 'b:LABEL' bubble / 't:LABEL' tag -> CanvasTex
|
|
|
877
871
|
|
|
878
872
|
function allCandidates(excludeId) {
|
|
879
873
|
const base = snapCandidates(members(), api.ptPerFt(), api.defaultTosMm(), excludeId);
|
|
874
|
+
if (frame3d && !(pending && pending.frameDrag)) base.push({ type: 'origin', p: [...frame3d.origin], fromId: 'ucs-origin' }); // the local UCS origin is a snap target for every tool (Move/Copy, Add, Dimension); excluded while dragging the origin itself → no self-snap
|
|
880
875
|
try { return base.concat(gridCandidates3d(api.getGrid ? api.getGrid() : null, api.ptPerFt())); }
|
|
881
876
|
catch { return base; } // a malformed hand-edited grid must never break member dragging
|
|
882
877
|
}
|
|
@@ -1284,7 +1279,7 @@ function setClipState(s) {
|
|
|
1284
1279
|
else workArea = null;
|
|
1285
1280
|
selectedClipIds = new Set(s.selected || []);
|
|
1286
1281
|
if (typeof s.seq === 'number') clipSeq = Math.max(clipSeq, s.seq);
|
|
1287
|
-
applyClips(); renderClipGizmo(); renderWorkArea(); refreshWorkAreaVis();
|
|
1282
|
+
applyClips(); renderClipGizmo(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane();
|
|
1288
1283
|
if (api && api.onClipsChange) api.onClipsChange();
|
|
1289
1284
|
if (api && api.onWorkAreaChange) api.onWorkAreaChange(workAreaState()); // undo/redo of a work-area edit must resync the Work-area button + its sliders, not just the model
|
|
1290
1285
|
}
|
|
@@ -1466,7 +1461,7 @@ function setWorkAreaBox(box) {
|
|
|
1466
1461
|
if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
|
|
1467
1462
|
const whole = workArea ? workArea.whole : true; // keep the current cut/whole mode across a re-define; a brand-new work area defaults to "show whole parts" (no surprise slicing)
|
|
1468
1463
|
workArea = { enabled: true, whole, planes: boxToPlanes(box), box: box.clone() };
|
|
1469
|
-
applyClips(); renderWorkArea(); refreshWorkAreaVis();
|
|
1464
|
+
applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane();
|
|
1470
1465
|
if (api && api.onWorkAreaChange) api.onWorkAreaChange(workAreaState());
|
|
1471
1466
|
return true;
|
|
1472
1467
|
}
|
|
@@ -1479,7 +1474,7 @@ function workAreaToggle(on) {
|
|
|
1479
1474
|
if (!workArea) return on === false ? false : workAreaSetAll(); // first toggle-on with no box → bound the whole model
|
|
1480
1475
|
if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
|
|
1481
1476
|
workArea.enabled = on === undefined ? !workArea.enabled : !!on;
|
|
1482
|
-
applyClips(); renderWorkArea(); refreshWorkAreaVis();
|
|
1477
|
+
applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane();
|
|
1483
1478
|
if (api && api.onWorkAreaChange) api.onWorkAreaChange(workAreaState());
|
|
1484
1479
|
return workArea.enabled;
|
|
1485
1480
|
}
|
|
@@ -1493,7 +1488,7 @@ function workAreaSetWhole(on) {
|
|
|
1493
1488
|
if (api && api.onWorkAreaChange) api.onWorkAreaChange(workAreaState());
|
|
1494
1489
|
return workArea.whole;
|
|
1495
1490
|
}
|
|
1496
|
-
function clearWorkArea() { if (api && api.beginClipEdit && workArea) api.beginClipEdit(); workArea = null; applyClips(); renderWorkArea(); refreshWorkAreaVis(); if (api && api.onWorkAreaChange) api.onWorkAreaChange(null); }
|
|
1491
|
+
function clearWorkArea() { if (api && api.beginClipEdit && workArea) api.beginClipEdit(); workArea = null; applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane(); if (api && api.onWorkAreaChange) api.onWorkAreaChange(null); }
|
|
1497
1492
|
function workAreaState() { return workArea ? { on: workArea.enabled, whole: !!workArea.whole } : null; }
|
|
1498
1493
|
// The camera viewpoint as plain data — position + orbit target + projection + the ortho frustum half-height
|
|
1499
1494
|
// and zoom. A saved view restores it via setCameraState. (perspCam/orthoCam share position; orthoBaseH+zoom
|
|
@@ -1557,6 +1552,7 @@ function onKey(e) {
|
|
|
1557
1552
|
if (pending && pending.clipDrag && e.key === 'Escape') { e.preventDefault(); const p = pending; if (p.plane) p.clip.point = p.prePoint; else p.clip.box.copy(p.preBox); rebuildClipPlanes(p.clip); applyClips(); renderClipGizmo(); pending = dragging = null; if (controls) controls.enabled = true; if (readout) readout.style.display = 'none'; return; } // Esc mid-drag → undo the handle move
|
|
1558
1553
|
if (framePicking() && e.key === 'Escape') { e.preventDefault(); if (frame3d) { cancelFramePick(); fireFrameChange(); } else armFrame3d(false); return; } // Esc cancels the whole 3-click pick (discards partial clicks); no prior frame → also exit the tool
|
|
1559
1554
|
if (pending && pending.frameDrag && e.key === 'Escape') { e.preventDefault(); if (frame3d && pending.preFrame) frame3d = cloneFrame(pending.preFrame); pending = dragging = null; if (controls) controls.enabled = true; if (readout) readout.style.display = 'none'; fireFrameChange(); return; } // Esc mid-drag → revert the frame to its pre-drag basis
|
|
1555
|
+
if (frameMode && e.key === 'Escape' && !pending) { e.preventDefault(); disarmFrame3d(); return; } // armed but idle (frame set, gizmo grabbable for refine) → Esc exits the "Set local axes" tool (the frame stays; it just stops being editable). `!pending` so a mid-gesture Esc (member move / endpoint stretch, reachable while the tool is armed) still falls through to the cancel-and-revert below instead of silently committing (code-review) (frame set, gizmo grabbable for refine) → Esc exits the "Set local axes" tool (the frame stays; it just stops being editable). `!pending` so a mid-gesture Esc (member move / endpoint stretch, reachable while the tool is armed) still falls through to the cancel-and-revert below instead of silently committing (code-review)
|
|
1560
1556
|
if (pending && e.key === 'Escape' && (pending.epDrag || pending.origMm)) { // Esc mid-drag → cancel a member move / endpoint stretch and revert to the pre-drag state (no commit)
|
|
1561
1557
|
e.preventDefault();
|
|
1562
1558
|
if (pending.mesh && pending.meshPos0) pending.mesh.position.copy(pending.meshPos0); // put a live-moved (or Alt-vertical) member mesh back
|
|
@@ -1573,7 +1569,7 @@ function onKey(e) {
|
|
|
1573
1569
|
if (clipMode && e.key === 'Escape') { e.preventDefault(); if (clipMode === 'box' && clipBoxDraft) { if (clipBoxDraft.b) clipBoxDraft.b = null; else clipBoxDraft = null; setClipPreview(null); updateStatusChip(); } else setClipMode(null); return; } // Esc steps back: height→footprint→cancel, else disarms the pick
|
|
1574
1570
|
if (isolatedIds && e.key === 'Escape' && !dimMode3d) { e.preventDefault(); clearIsolation(); return; } // Esc exits isolate-selected (the dim tool's own Esc wins while it's armed)
|
|
1575
1571
|
if (e.key === 'Escape' && !dimMode3d && !cmActive() && ascendConn()) { e.preventDefault(); return; } // Esc ascends the connection drill: part → whole → nothing
|
|
1576
|
-
if ((e.key === ' ' && e.shiftKey) || ((e.key === 'z' || e.key === 'Z') && e.altKey)) { e.preventDefault(); frameSelection(); return; } // zoom-selected (Tekla Shift+Space / viewer Alt+Z)
|
|
1572
|
+
if ((e.key === ' ' && e.shiftKey) || ((e.key === 'z' || e.key === 'Z') && e.altKey && !tfDraft)) { e.preventDefault(); frameSelection(); return; } // zoom-selected (Tekla Shift+Space / viewer Alt+Z) — Alt+Z is suppressed while a Move/Copy base is active: there Alt is the normal-lock modifier, so a reflexive Alt+Z must not jerk the camera mid-move (UCS Stage 4)
|
|
1577
1573
|
const k = e.key.toLowerCase();
|
|
1578
1574
|
// Don't touch the dim tool while a member gesture (drag / box-select) owns the shared marker/readout —
|
|
1579
1575
|
// toggling would clear them mid-gesture. The gesture finishes on pointerup; the key is a no-op until then.
|
|
@@ -2263,6 +2259,7 @@ let framePickPts = null; // null = not picking; [] / [origin] / [origin,x
|
|
|
2263
2259
|
let framePreview = null; // THREE.Group: the live X/Y rubber-band + Z-flip arrow during a pick
|
|
2264
2260
|
const cloneFrame = (f) => ({ origin: [...f.origin], xAxis: [...f.xAxis], yAxis: [...f.yAxis], normal: [...f.normal] });
|
|
2265
2261
|
const _dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
2262
|
+
const _unit3 = (a) => { const L = Math.hypot(a[0], a[1], a[2]) || 1; return [a[0] / L, a[1] / L, a[2] / L]; };
|
|
2266
2263
|
function frameZ() { return frame3d ? frame3d.origin[2] : (api ? api.defaultTosMm() : 0); }
|
|
2267
2264
|
function effectiveWP() {
|
|
2268
2265
|
if (workPlane) return workPlane; // explicit ◇ Plane wins (unchanged)
|
|
@@ -2328,7 +2325,7 @@ function frameInfo() {
|
|
|
2328
2325
|
}
|
|
2329
2326
|
return { mode: 'global' };
|
|
2330
2327
|
}
|
|
2331
|
-
function fireFrameChange() { invalidatePointEntry('drift');
|
|
2328
|
+
function fireFrameChange() { invalidatePointEntry('drift'); if (!(pending && pending.frameDrag)) { tfCandidates = null; dimCandidates3d = null; } renderWorkPlane(); } // re-draws the gizmo + reference plane + fires the Axes chip; invalidates the typed HUD (drift) + the snap caches so the UCS-origin snap follows the frame — but NOT during a live origin drag (the drag's own snap cache, which excludes the origin, stays efficient)
|
|
2332
2329
|
// Set a HORIZONTAL frame at origin (numeric entry + gizmo materialize). origin defaults its Z to the active level.
|
|
2333
2330
|
function setFrame3d(originMm, angleDeg) {
|
|
2334
2331
|
const z = (originMm && originMm.length > 2) ? originMm[2] : frameZ();
|
|
@@ -2366,16 +2363,12 @@ let frameGizmo = null;
|
|
|
2366
2363
|
function disposeFrameGizmo() { if (!frameGizmo) return; if (overlayScene) overlayScene.remove(frameGizmo); frameGizmo.traverse((o) => { if (o.geometry) o.geometry.dispose(); if (o.material) o.material.dispose(); }); frameGizmo = null; }
|
|
2367
2364
|
function renderFrameGizmo() {
|
|
2368
2365
|
disposeFrameGizmo();
|
|
2369
|
-
if (!overlayScene
|
|
2370
|
-
const
|
|
2371
|
-
const O
|
|
2372
|
-
const u = new THREE.Vector3(...
|
|
2366
|
+
if (!overlayScene) return; // ALWAYS draw the gizmo (matches the reference plane); a ◇ Plane no longer removes it
|
|
2367
|
+
const on = frameMode && !workPlane; // grabbable/armed only when the LOCAL frame is the active basis (a ◇ Plane is picked, not gizmo-dragged)
|
|
2368
|
+
const { O, u: ux, v: uy, n: uz } = refPlaneBasis(); // effective basis the tools follow: ◇ Plane > local frame > global
|
|
2369
|
+
const u = new THREE.Vector3(...ux), v = new THREE.Vector3(...uy), n = new THREE.Vector3(...uz);
|
|
2373
2370
|
const g = new THREE.Group();
|
|
2374
|
-
const CELL = 1524, N =
|
|
2375
|
-
const verts = []; for (let i = 0; i <= N; i++) { const o = -half + i * CELL; verts.push(o, -half, 0, o, half, 0, -half, o, 0, half, o, 0); }
|
|
2376
|
-
const grid = new THREE.BufferGeometry(); grid.setAttribute('position', new THREE.Float32BufferAttribute(verts, 3));
|
|
2377
|
-
g.add(new THREE.LineSegments(grid, new THREE.LineBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: act ? 0.3 : 0.14 })));
|
|
2378
|
-
g.add(new THREE.Mesh(new THREE.PlaneGeometry(CELL * N, CELL * N), new THREE.MeshBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: act ? 0.1 : 0.05, side: THREE.DoubleSide, depthWrite: false })));
|
|
2371
|
+
const CELL = 1524, N = 2, half = (CELL * N) / 2; // half = axis length (5 ft). The gizmo is just axes + origin now — NO grid patch (the reference plane is the separate "Show plane").
|
|
2379
2372
|
const axis = (len, col, vx, vy, vz) => { const l = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(0, 0, 0), new THREE.Vector3(vx * len, vy * len, vz * len)]), new THREE.LineBasicMaterial({ color: col, transparent: true, opacity: 0.95 })); l.renderOrder = 997; return l; };
|
|
2380
2373
|
g.add(axis(half, 0xef4444, 1, 0, 0)); // local X = red
|
|
2381
2374
|
g.add(axis(half, 0x22c55e, 0, 1, 0)); // local Y = green
|
|
@@ -2399,15 +2392,16 @@ function sizeFrameHandle() {
|
|
|
2399
2392
|
for (const h of frameGizmo.children) if (h.userData && h.userData.frameHandle === 'origin') h.scale.setScalar(r);
|
|
2400
2393
|
}
|
|
2401
2394
|
// --- frame manipulator: grab + drag the gizmo's origin (translate) or ring (rotate about Z). Armed only. ---
|
|
2402
|
-
const FRAME_RING_R = (1524 *
|
|
2403
|
-
function frameGizmoOrigin() { return frame3d ? frame3d.origin : [0, 0,
|
|
2404
|
-
function pickFrameHandle(cx, cy) {
|
|
2405
|
-
if (!frameMode || !overlayScene || workPlane || !canvasEl) return null;
|
|
2395
|
+
const FRAME_RING_R = (1524 * 2 / 2) * 0.8; // ring radius (matches renderFrameGizmo's half*0.8, N=2)
|
|
2396
|
+
function frameGizmoOrigin() { return frame3d ? frame3d.origin : [0, 0, 0]; } // Global → true global 0,0,0
|
|
2397
|
+
function pickFrameHandle(cx, cy, allowPassive) { // → 'origin' | 'ring' | null (screen-space, like pickClipHandle). allowPassive: hit-test the un-armed (passive) gizmo too, for click-to-re-select.
|
|
2398
|
+
if ((!frameMode && !allowPassive) || !overlayScene || workPlane || !canvasEl) return null;
|
|
2406
2399
|
camera.updateMatrixWorld();
|
|
2407
2400
|
const rect = canvasEl.getBoundingClientRect(), px = cx - rect.left, py = cy - rect.top;
|
|
2408
2401
|
const O = frameGizmoOrigin();
|
|
2409
2402
|
const toS = (p) => { const w = new THREE.Vector3(p[0], p[1], p[2]).project(camera); return w.z > 1 ? null : [(w.x * 0.5 + 0.5) * rect.width, (-w.y * 0.5 + 0.5) * rect.height]; };
|
|
2410
2403
|
const os = toS(O); if (os && Math.hypot(os[0] - px, os[1] - py) <= 16) return 'origin';
|
|
2404
|
+
if (!frameMode) return null; // passive gizmo (allowPassive re-select): only the VISIBLE origin dot is grabbable — the rotation ring isn't drawn when idle, so don't hit-test its invisible band (would steal a member click / box-select and rotate by accident) (code-review)
|
|
2411
2405
|
const u = frame3d ? frame3d.xAxis : [1, 0, 0], v = frame3d ? frame3d.yAxis : [0, 1, 0]; let bestD = 12; // ring lies in the frame's X-Y plane — sample all THREE coords so a tilted ring's grab matches the drawn ring
|
|
2412
2406
|
for (let i = 0; i < 48; i++) { const ph = i / 48 * Math.PI * 2, c = Math.cos(ph), s = Math.sin(ph);
|
|
2413
2407
|
const ss = toS([O[0] + FRAME_RING_R * (c * u[0] + s * v[0]), O[1] + FRAME_RING_R * (c * u[1] + s * v[1]), O[2] + FRAME_RING_R * (c * u[2] + s * v[2])]);
|
|
@@ -2533,28 +2527,46 @@ function orthoLockDelta(dx, dy) {
|
|
|
2533
2527
|
const du = dx * u[0] + dy * u[1], dv = dx * v[0] + dy * v[1];
|
|
2534
2528
|
return Math.abs(du) >= Math.abs(dv) ? [du * u[0], du * u[1]] : [dv * v[0], dv * v[1]];
|
|
2535
2529
|
}
|
|
2530
|
+
// The unified "Show plane" REFERENCE PLANE (Pawel 2026-07-13): a transparent, gridded plane that MATCHES the
|
|
2531
|
+
// working plane the tools actually follow — a ◇ Plane if set, else the local frame (tilted), else horizontal
|
|
2532
|
+
// at the global origin. Sized to the Work area (if set) else the model. The axes+origin gizmo always draws on
|
|
2533
|
+
// top of it (renderFrameGizmo, never shadowed). Toggled by "Show plane" (wpVisible).
|
|
2534
|
+
function refPlaneBasis() {
|
|
2535
|
+
if (workPlane) { const b = planeBasis(workPlane.normal, workPlane.xAxis); return { O: workPlane.origin, u: b.u, v: b.v, n: workPlane.normal }; }
|
|
2536
|
+
if (frame3d) return { O: frame3d.origin, u: frame3d.xAxis, v: frame3d.yAxis, n: frame3d.normal };
|
|
2537
|
+
return { O: frameGizmoOrigin(), u: [1, 0, 0], v: [0, 1, 0], n: [0, 0, 1] }; // Global → horizontal at 0,0,0
|
|
2538
|
+
}
|
|
2536
2539
|
function renderWorkPlane() {
|
|
2537
|
-
renderFrameGizmo(); //
|
|
2538
|
-
if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); //
|
|
2540
|
+
renderFrameGizmo(); // the axes+origin gizmo always draws (matches the plane; never shadowed)
|
|
2541
|
+
if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); // refresh the Axes chip: "Plane" when a plane is set, back to Local/Global when cleared
|
|
2539
2542
|
if (wpGroup) { scene.remove(wpGroup); wpGroup.traverse((o) => { if (o.geometry) o.geometry.dispose(); if (o.material) o.material.dispose(); }); wpGroup = null; }
|
|
2540
|
-
if (!
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
+
if (!wpVisible || !scene) return; // "Show plane" off → no reference plane (works at Global too now, not only for a ◇ Plane)
|
|
2544
|
+
// Draw AT the true pick plane (effectiveWP = where a click actually lands), NOT the 0,0,0 gizmo origin.
|
|
2545
|
+
// For a local frame / ◇ Plane these coincide; only at Global do they differ (plane at the active level's
|
|
2546
|
+
// TOS, gizmo at world 0,0,0) — so the plane never lies about the work height (code-review High).
|
|
2547
|
+
const wp = effectiveWP(), { u, v } = planeBasis(wp.normal, wp.xAxis), O = wp.origin, n = wp.normal;
|
|
2548
|
+
const CELL = 1524; let span = 6096; // size to the Work area if set, else the model bbox, + a margin
|
|
2549
|
+
const box = (workArea && workArea.enabled && workArea.box && !workArea.box.isEmpty()) ? workArea.box : sceneBox;
|
|
2550
|
+
if (box && !box.isEmpty()) { // project the bbox corners onto the plane's OWN u/v so a tilted/vertical (XZ/YZ) plane spans its model in-plane, not by world X/Y (code-review)
|
|
2551
|
+
let uMin = Infinity, uMax = -Infinity, vMin = Infinity, vMax = -Infinity;
|
|
2552
|
+
for (const x of [box.min.x, box.max.x]) for (const y of [box.min.y, box.max.y]) for (const z of [box.min.z, box.max.z]) {
|
|
2553
|
+
const dx = x - O[0], dy = y - O[1], dz = z - O[2];
|
|
2554
|
+
const pu = dx * u[0] + dy * u[1] + dz * u[2], pv = dx * v[0] + dy * v[1] + dz * v[2];
|
|
2555
|
+
uMin = Math.min(uMin, pu); uMax = Math.max(uMax, pu); vMin = Math.min(vMin, pv); vMax = Math.max(vMax, pv);
|
|
2556
|
+
}
|
|
2557
|
+
span = Math.max(uMax - uMin, vMax - vMin, 3048) * 1.15;
|
|
2558
|
+
}
|
|
2559
|
+
const N = Math.min(160, Math.max(2, Math.ceil(span / CELL))), half = (CELL * N) / 2; // N capped: a huge (or degenerate) bbox must never allocate thousands of lines, rebuilt every frame-drag move (code-review)
|
|
2543
2560
|
const g = new THREE.Group();
|
|
2544
2561
|
const verts = [];
|
|
2545
2562
|
for (let i = 0; i <= N; i++) { const o = -half + i * CELL; verts.push(o, -half, 0, o, half, 0, -half, o, 0, half, o, 0); }
|
|
2546
2563
|
const grid = new THREE.BufferGeometry(); grid.setAttribute('position', new THREE.Float32BufferAttribute(verts, 3));
|
|
2547
|
-
g.add(new THREE.LineSegments(grid, new THREE.LineBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: 0.
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
ay.renderOrder = 996; g.add(ay); // the shorter, dimmer ray = local Y (tells the axes apart on a skewed plane)
|
|
2554
|
-
const od = new THREE.Mesh(new THREE.SphereGeometry(60, 12, 8), new THREE.MeshBasicMaterial({ color: 0x3b82f6 }));
|
|
2555
|
-
g.add(od); // origin dot
|
|
2556
|
-
g.applyMatrix4(new THREE.Matrix4().makeBasis(new THREE.Vector3(...u), new THREE.Vector3(...v), new THREE.Vector3(...wp.normal)));
|
|
2557
|
-
g.position.set(wp.origin[0], wp.origin[1], wp.origin[2]);
|
|
2564
|
+
g.add(new THREE.LineSegments(grid, new THREE.LineBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: 0.2 })));
|
|
2565
|
+
g.add(new THREE.Mesh(new THREE.PlaneGeometry(CELL * N, CELL * N), new THREE.MeshBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: 0.05, side: THREE.DoubleSide, depthWrite: false }))); // just a transparent plane + grid (the gizmo carries the axes)
|
|
2566
|
+
const edge = [new THREE.Vector3(-half, -half, 0), new THREE.Vector3(half, -half, 0), new THREE.Vector3(half, half, 0), new THREE.Vector3(-half, half, 0)];
|
|
2567
|
+
g.add(new THREE.LineLoop(new THREE.BufferGeometry().setFromPoints(edge), new THREE.LineBasicMaterial({ color: 0x3b82f6, transparent: true, opacity: 0.42 }))); // brighter perimeter so the plane's extent reads now that it's sized to the work-area/model (ux review)
|
|
2568
|
+
g.applyMatrix4(new THREE.Matrix4().makeBasis(new THREE.Vector3(...u), new THREE.Vector3(...v), new THREE.Vector3(...n)));
|
|
2569
|
+
g.position.set(O[0], O[1], O[2]);
|
|
2558
2570
|
wpGroup = g; scene.add(g); // on `scene` (like epGroup) so rebuild() never wipes it; not in meshById → picking ignores it
|
|
2559
2571
|
}
|
|
2560
2572
|
function reflectWpBar() { const b = document.getElementById('m3dWp'); if (b) { b.classList.toggle('on', !!wpMode || !!workPlane);
|
|
@@ -2593,6 +2605,15 @@ function rayToWP(cx, cy, wp) {
|
|
|
2593
2605
|
const hit = new THREE.Vector3();
|
|
2594
2606
|
return raycaster.ray.intersectPlane(plane, hit) ? [hit.x, hit.y, hit.z] : null;
|
|
2595
2607
|
}
|
|
2608
|
+
// The cursor's world-space pick ray {o, d} (d unit), mirroring rayToWP's NDC → raycaster setup.
|
|
2609
|
+
function cameraRay(cx, cy) {
|
|
2610
|
+
camera.updateMatrixWorld();
|
|
2611
|
+
const rect = canvasEl.getBoundingClientRect(); if (!rect.width || !rect.height) return null;
|
|
2612
|
+
const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
|
|
2613
|
+
raycaster.setFromCamera(ndc, camera);
|
|
2614
|
+
const o = raycaster.ray.origin, d = raycaster.ray.direction;
|
|
2615
|
+
return { o: [o.x, o.y, o.z], d: [d.x, d.y, d.z] };
|
|
2616
|
+
}
|
|
2596
2617
|
|
|
2597
2618
|
// ---- 3D Move/Copy (spec §3+§6): the EDITOR owns the tool state (cmState via api); this side owns
|
|
2598
2619
|
// picking/preview in scene mm against the working plane, and hands commit offsets back. ----
|
|
@@ -2600,13 +2621,13 @@ let tfDraft = null; // {base:[mm], vA:[mm]|null}
|
|
|
2600
2621
|
let tfLastShift = false; // shiftKey mirror for the rAF-synthetic hover event
|
|
2601
2622
|
let tfLast = null; // last constrained preview point (HUD distance direction)
|
|
2602
2623
|
let tfLastClient = null; // last pointer client [x,y] (HUD placement)
|
|
2603
|
-
let tfAxis = 'free'; // 'free' | 'u' | 'v' — X/Y force
|
|
2624
|
+
let tfAxis = 'free'; // 'free' | 'u' | 'v' | 'n' — X/Y force in-plane, 'n' = normal-axis lock (UCS Stage 4)
|
|
2604
2625
|
let tfCandidates = null;
|
|
2605
2626
|
let tfGhost = null, tfRubber = null, tfRubberA = null, tfGhostMat = null;
|
|
2606
2627
|
const cmActive = () => (api && api.cmState ? api.cmState() : null);
|
|
2607
2628
|
const cmHasBase = () => !!tfDraft;
|
|
2608
2629
|
const cmLastClient = () => tfLastClient;
|
|
2609
|
-
function setCmAxis(a) { tfAxis = a === 'x' ? 'u' : a === 'y' ? 'v' : 'free'; }
|
|
2630
|
+
function setCmAxis(a) { tfAxis = a === 'x' ? 'u' : a === 'y' ? 'v' : a === 'z' ? 'n' : 'free'; }
|
|
2610
2631
|
function cmClear3d() { tfDraft = null; tfCandidates = null; tfAxis = 'free'; tfPreviewClear(); if (canvasEl) canvasEl.style.cursor = 'default'; } // callable BEFORE init() (editor boot) — every touched handle is guarded
|
|
2611
2632
|
function cmEscape() { if (!tfDraft) return false; if (tfDraft.vA) { tfDraft.vA = null; tfPreviewClear(); return true; } tfDraft = null; tfPreviewClear(); return true; }
|
|
2612
2633
|
function tfDisposeGhost() { if (!tfGhost) return; if (scene) scene.remove(tfGhost); for (const c of tfGhost.children) { if (c.userData._ownGeom && c.geometry) c.geometry.dispose(); } tfGhost = null; } // clones share the source geometry/material; only the >600 fallback BoxGeometry is per-ghost → dispose those (flagged _ownGeom) so the preview can't leak
|
|
@@ -2633,6 +2654,47 @@ function tfConstrain(p, e) {
|
|
|
2633
2654
|
if (ax === 'v') return [b[0] + c.dv * v[0], b[1] + c.dv * v[1], b[2] + c.dv * v[2]];
|
|
2634
2655
|
return p;
|
|
2635
2656
|
}
|
|
2657
|
+
// Move/Copy normal-axis lock (UCS Stage 4): with a base picked, hold Alt (transient) or press Z (sticky)
|
|
2658
|
+
// to constrain the move to the working frame's normal. Project the cursor ray onto base + t·normal and
|
|
2659
|
+
// commit that. Top-view degeneracy (view ray ~∥ normal → rayAxisT returns null): fall back to a TRUE
|
|
2660
|
+
// screen-Y → distance map from the base's screen position. A ~vertical normal then snaps to framing
|
|
2661
|
+
// levels (same feel as the plain-drag Alt-elevation move).
|
|
2662
|
+
function cmNormalLock(e) {
|
|
2663
|
+
const base = tfDraft.base, n = _unit3(effectiveWP().normal);
|
|
2664
|
+
const ray = cameraRay(e.clientX, e.clientY);
|
|
2665
|
+
let t = ray ? rayAxisT(ray.o, ray.d, base, n) : null;
|
|
2666
|
+
if (t == null) { // singular → screen-Y drives the distance
|
|
2667
|
+
const bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
|
|
2668
|
+
const dy = bs.y - (e.clientY - rect.top); // cursor above the base → +normal (fixed sign)
|
|
2669
|
+
t = dy * pxToWorldAt(1, base);
|
|
2670
|
+
// ponytail: uses the horizontal px→world scale as the vertical proxy (a straight-down view has no true
|
|
2671
|
+
// vertical scale). Fine for the rare look-down-the-normal case; the level snap fixes the landing.
|
|
2672
|
+
}
|
|
2673
|
+
if (!Number.isFinite(t)) t = 0; // never commit a NaN offset — a non-finite scale/ray pins the destination to the base (no move)
|
|
2674
|
+
let p = [base[0] + n[0] * t, base[1] + n[1] * t, base[2] + n[2] * t];
|
|
2675
|
+
let snap = false, type = null;
|
|
2676
|
+
if (Math.abs(n[2]) > 0.999) { // ~vertical normal → snap the elevation to a framing level
|
|
2677
|
+
// World-space snap (NOT screen-space): in Top view every level projects to the same screen point, so a
|
|
2678
|
+
// screen snap can't tell them apart and would pin to one level regardless of the cursor. Snap p.z to the
|
|
2679
|
+
// nearest level within a screen-proportional world tolerance, then re-solve t so the point stays exactly
|
|
2680
|
+
// on base + t·normal (the normal may tilt a hair even at |n.z| > 0.999).
|
|
2681
|
+
const tol = pxToWorldAt(SNAP_TOL_PX, base);
|
|
2682
|
+
let best = null, bestD = tol;
|
|
2683
|
+
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; } }
|
|
2684
|
+
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'; }
|
|
2685
|
+
}
|
|
2686
|
+
return { p, snap, type };
|
|
2687
|
+
}
|
|
2688
|
+
// Resolve the Move/Copy destination with axis precedence: Alt (normal) > Shift (in-plane) > sticky tfAxis.
|
|
2689
|
+
// Returns { p, snap, type }; snap means p landed ON a candidate (show the reticle). null = no valid pick
|
|
2690
|
+
// (cursor off the plane, edge-on) for the in-plane path — the normal-lock path never needs the plane.
|
|
2691
|
+
function cmDestPoint(e) {
|
|
2692
|
+
const alt = !!(e && e.altKey), shift = !!(e && e.shiftKey);
|
|
2693
|
+
if (tfDraft && (alt || (tfAxis === 'n' && !shift))) return cmNormalLock(e);
|
|
2694
|
+
const r = wpPointAt(e); if (!r) return null;
|
|
2695
|
+
const p = tfConstrain(r.p, e);
|
|
2696
|
+
return { p, snap: r.snap && tfAxis === 'free' && !shift, type: r.type }; // in-plane force moves p off the raw snap → no reticle
|
|
2697
|
+
}
|
|
2636
2698
|
// the offset list is the pure core `offsetsFor` (unit-tested for linear/grid) — counts INCLUDE the original, grid skips (0,0)
|
|
2637
2699
|
function tfOffsetsFor(v, st) { return offsetsFor(v, st, tfDraft ? tfDraft.vA : null); }
|
|
2638
2700
|
function tfGhostBuild(offs) {
|
|
@@ -2657,10 +2719,10 @@ function tfGhostBuild(offs) {
|
|
|
2657
2719
|
}
|
|
2658
2720
|
function tfPreview(e) {
|
|
2659
2721
|
const st = cmActive(); if (!st || !tfDraft) return;
|
|
2660
|
-
const
|
|
2661
|
-
const p =
|
|
2722
|
+
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
|
|
2723
|
+
const p = q.p;
|
|
2662
2724
|
tfLast = p; tfLastClient = [e.clientX, e.clientY];
|
|
2663
|
-
if (
|
|
2725
|
+
if (q.snap) showMarker(p, q.type); else marker.visible = false;
|
|
2664
2726
|
const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
|
|
2665
2727
|
tfGhostBuild(tfOffsetsFor(v, st));
|
|
2666
2728
|
if (!tfRubber) { tfRubber = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]), new THREE.LineBasicMaterial({ color: 0x22d3ee })); tfRubber.material.depthTest = false; tfRubber.renderOrder = 997; scene.add(tfRubber); }
|
|
@@ -2673,7 +2735,7 @@ function tfPreview(e) {
|
|
|
2673
2735
|
}
|
|
2674
2736
|
const L = Math.hypot(v[0], v[1], v[2]);
|
|
2675
2737
|
readout._dist.textContent = api.fmtLen ? api.fmtLen(L) : (L / FT_MM).toFixed(2) + ' ft';
|
|
2676
|
-
readout._type.textContent =
|
|
2738
|
+
readout._type.textContent = q.snap ? ' · ' + (q.type || 'snap') : (st.tool === 'copy' && !st.array && st.count > 1 ? ' ×' + st.count : '');
|
|
2677
2739
|
readout.style.left = (e.clientX + 14) + 'px'; readout.style.top = (e.clientY + 14) + 'px'; readout.style.display = 'block';
|
|
2678
2740
|
roCoords(p); // local coords of the destination point
|
|
2679
2741
|
}
|
|
@@ -2684,8 +2746,8 @@ function tfClick(e) {
|
|
|
2684
2746
|
if (api && api.disarmTransform) api.disarmTransform();
|
|
2685
2747
|
return false;
|
|
2686
2748
|
}
|
|
2687
|
-
const
|
|
2688
|
-
const p =
|
|
2749
|
+
const q = cmDestPoint(e); if (!q) return true;
|
|
2750
|
+
const p = q.p;
|
|
2689
2751
|
tfLastClient = [e.clientX, e.clientY];
|
|
2690
2752
|
if (!tfDraft) { notePointerPick(); tfDraft = { base: p, vA: null }; tfCandidates = null; tfLast = p; return true; } // base pick bumps the gen so a stale typed token can't survive
|
|
2691
2753
|
const v = [p[0] - tfDraft.base[0], p[1] - tfDraft.base[1], p[2] - tfDraft.base[2]];
|
|
@@ -2794,7 +2856,8 @@ function drPreview(e) {
|
|
|
2794
2856
|
function pxToWorldAt(px, pos) {
|
|
2795
2857
|
const h = (canvasEl && canvasEl.clientHeight) || 1;
|
|
2796
2858
|
if (camera === orthoCam) return px * ((orthoCam.top - orthoCam.bottom) / (orthoCam.zoom || 1)) / h;
|
|
2797
|
-
const
|
|
2859
|
+
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)
|
|
2860
|
+
const dist = p3 ? camera.position.distanceTo(p3) : camera.position.distanceTo(controls.target);
|
|
2798
2861
|
return px * (2 * Math.tan(THREE.MathUtils.degToRad(perspCam.fov) / 2) * dist) / h;
|
|
2799
2862
|
}
|
|
2800
2863
|
const RETICLE_PX = 44; // on-screen size of the snap reticle (the full sprite); the ring/glyph fill the middle ~55%
|
|
@@ -2900,6 +2963,10 @@ function onDown(e) {
|
|
|
2900
2963
|
if (clipMode === 'box') { e.stopPropagation(); onClipBoxClick(e); return; } // armed: 2-corner clip-box draw on the floor plane
|
|
2901
2964
|
if (framePicking()) { e.stopPropagation(); controls.enabled = true; framePickClick(e); return; } // 3-click UCS set: this click collects the origin / X point / Y point
|
|
2902
2965
|
if (frameMode) { let fh = null; try { fh = pickFrameHandle(e.clientX, e.clientY); } catch { fh = null; } if (fh) { e.stopPropagation(); controls.enabled = false; startFrameDrag(fh, e); return; } } // grab the local-frame origin/ring (armed) → drag it; an empty click falls through (orbit)
|
|
2966
|
+
if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !selectedClipIds.size) { // passive gizmo, no tool armed → clicking its origin/ring re-selects the local frame for editing (NOT reached by box-select or select-all, which only touch members)
|
|
2967
|
+
let fh = null; try { fh = pickFrameHandle(e.clientX, e.clientY, true); } catch { fh = null; }
|
|
2968
|
+
if (fh) { e.stopPropagation(); controls.enabled = false; armFrame3d(true); startFrameDrag(fh, e); return; } // re-arm the tool + grab the clicked handle so a click-drag manipulates immediately
|
|
2969
|
+
}
|
|
2903
2970
|
if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(e.clientX, e.clientY); } catch { ch = null; } if (ch) { e.stopPropagation(); controls.enabled = false; downXY = [e.clientX, e.clientY]; startClipDrag(ch, e); return; } } // grab a clip handle (plane dot / box face) → drag it
|
|
2904
2971
|
if (dimMode3d) { // 2-click dimension placement (not a drag): pick A, then B → place
|
|
2905
2972
|
e.stopPropagation(); controls.enabled = true;
|
|
@@ -3162,7 +3229,7 @@ function onUp(e) {
|
|
|
3162
3229
|
const moved = downXY ? Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) : Infinity; downXY = null;
|
|
3163
3230
|
if (!p) return;
|
|
3164
3231
|
if (p.clipDrag) return; // a clip handle drag is applied live during onMoveClip; nothing to commit on up (controls re-enabled above)
|
|
3165
|
-
if (p.frameDrag) { if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; return; } // local-frame origin/rotation is applied live during onMoveFrame; session-only, nothing to commit — clear the snap marker/readout
|
|
3232
|
+
if (p.frameDrag) { if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; tfCandidates = null; dimCandidates3d = null; return; } // local-frame origin/rotation is applied live during onMoveFrame; session-only, nothing to commit — clear the snap marker/readout AND re-null the snap caches (they were rebuilt sans the UCS origin during the drag) so the next Move/Dimension snaps TO the moved origin again (code-review)
|
|
3166
3233
|
if (p.epDrag) { // end-node drag → write just that endpoint's wp; a click (no drag) just selects the member
|
|
3167
3234
|
if (wasDragging && p.newPt && api && api.onMoveEndpoint) { if (api.onSelect) api.onSelect(p.id, false); api.onMoveEndpoint(p.id, p.end, planPointToWp(p.newPt, p.ppf)); }
|
|
3168
3235
|
else if (api && api.onSelect) api.onSelect(p.id, false);
|
|
@@ -3305,6 +3372,10 @@ function onHoverMove(e) {
|
|
|
3305
3372
|
canvasEl.style.cursor = fh ? 'grab' : 'crosshair';
|
|
3306
3373
|
return;
|
|
3307
3374
|
}
|
|
3375
|
+
if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !selectedClipIds.size) { // hovering the PASSIVE gizmo (nothing armed) → pointer cursor hints "click to edit the local axes again"
|
|
3376
|
+
let fh = null; try { fh = pickFrameHandle(lastHoverXY[0], lastHoverXY[1], true); } catch { fh = null; }
|
|
3377
|
+
if (fh) { canvasEl.style.cursor = 'pointer'; return; }
|
|
3378
|
+
}
|
|
3308
3379
|
if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(lastHoverXY[0], lastHoverXY[1]); } catch { ch = null; } if (ch) { canvasEl.style.cursor = 'move'; return; } } // over a clip handle → move cursor
|
|
3309
3380
|
let ep = null; try { ep = pickEndpoint(lastHoverXY[0], lastHoverXY[1]); } catch { ep = null; }
|
|
3310
3381
|
if (ep) { // over an end node → ring + move cursor; keep its member's dots shown
|
|
@@ -3328,7 +3399,7 @@ function updateStatusChip() {
|
|
|
3328
3399
|
if (wpMode === 'face') txt = 'Click a member face — the working plane lands on it · Esc to cancel';
|
|
3329
3400
|
else if (wpMode === '3pt') txt = ['Click the plane origin (snapped) · Esc to cancel', 'Click the local-X direction point · Esc to cancel', 'Click a point on the plane’s Y side · Esc to cancel'][(wpDraft || []).length] || '';
|
|
3330
3401
|
else if (addActive()) txt = drDraft ? 'Click the member end · Shift straight · Esc drops the start' : 'Draw a member on the working plane — click the start point · Esc exits';
|
|
3331
|
-
else if (cmActive()) { const st = cmActive(), lock = tfAxis === 'u' ? ' · X locked' : tfAxis === 'v' ? ' · Y locked' : '';
|
|
3402
|
+
else if (cmActive()) { const st = cmActive(), lock = tfAxis === 'u' ? ' · X locked' : tfAxis === 'v' ? ' · Y locked' : tfAxis === 'n' ? ' · Z locked' : '';
|
|
3332
3403
|
txt = (!tfDraft ? ((st.tool === 'move' ? 'Move' : (st.array ? 'Copy array' : 'Copy')) + ' — click the base point on the working plane · type after the pick for an exact value')
|
|
3333
3404
|
: (st.array && !tfDraft.vA ? 'Click the direction-A point — or type its spacing' : st.array ? 'Click the direction-B point — the grid previews live' : 'Click the destination — X/Y lock to the plane axes · Esc cancels')) + lock; }
|
|
3334
3405
|
else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
|
|
@@ -3402,6 +3473,7 @@ function dispose() {
|
|
|
3402
3473
|
gridTexCache.clear();
|
|
3403
3474
|
clearRoot();
|
|
3404
3475
|
if (workAreaHelper) { if (overlayScene) overlayScene.remove(workAreaHelper); workAreaHelper.geometry.dispose(); workAreaHelper.material.dispose(); workAreaHelper = null; }
|
|
3476
|
+
if (wpGroup) { if (scene) scene.remove(wpGroup); wpGroup.traverse((o) => { if (o.geometry) o.geometry.dispose(); if (o.material) o.material.dispose(); }); wpGroup = null; } // the reference plane can exist by default now → dispose it too (code-review)
|
|
3405
3477
|
clearConnEnvelope(); clearClipGizmo(); setClipPreview(null); disposeFramePreview(); disposeFrameGizmo(); overlayScene = null; // dispose the frame gizmo/preview THREE resources before dropping the scene (Codex)
|
|
3406
3478
|
clips = []; workArea = null; clipMode = null; selectedClipIds.clear(); clipBoxDraft = null; // clips live on the renderer; drop them with the renderer
|
|
3407
3479
|
if (renderer) renderer.dispose();
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
.detrow{display:flex;gap:6px;margin:2px 0}
|
|
32
32
|
.detf{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0;font-size:11px;color:var(--mut)}
|
|
33
33
|
.detf input{width:100%}
|
|
34
|
+
/* F14 definition-points: local-frame coord row — reuses the #csStat.local cyan wash (no new colour) */
|
|
35
|
+
.dp-local{background:rgba(34,211,238,.06);border:1px solid rgba(34,211,238,.35);border-radius:6px;padding:4px 4px 2px}
|
|
36
|
+
.dp-local .detf span{color:#22d3ee}
|
|
34
37
|
#detOpacity{accent-color:var(--brand);flex:1;min-width:0}
|
|
35
38
|
#zoombar #zPct{min-width:40px;text-align:right;color:var(--mut);font-variant-numeric:tabular-nums}
|
|
36
39
|
/* Connection Component breadcrumb (Slice A) — a floating chip over the 3D canvas, same recipe as #zoombar. */
|
|
@@ -2746,6 +2749,50 @@ function panel(){
|
|
|
2746
2749
|
<div class=row><button class=ghostw id=brSwap data-tip="Flip which end is the lower (double-arrow) end — display only, no geometry change">⇄ Swap lower ↔ higher end</button>
|
|
2747
2750
|
<div class=hint style="margin:4px 0 0">Changes which end shows the double arrowhead. <b>Display only</b> — no geometry moves.</div></div>
|
|
2748
2751
|
<div class=hint style="margin:8px 0 0">Split / Extend / Trim don't apply to a brace — drag an end handle to move a work point, or set the Offset above.</div>`;
|
|
2752
|
+
// --- Definition points (F14): the member's start/end work points in GLOBAL + current-view LOCAL coords,
|
|
2753
|
+
// editable. Global (ft-in): x=wpx·12/ppf, y=−wpy·12/ppf (Y-flip to world), z=this end's elevation (in).
|
|
2754
|
+
// LOCAL = relative to the active frame — 3D→frame3d (Steel3DView.frameInfo, mm), 2D→P.frame (planar, plan-px);
|
|
2755
|
+
// same view-scoped resolution updCS() uses. Typing a value moves that endpoint through the same edit() path as
|
|
2756
|
+
// every geometry pill (undo + 2D + 3D + autosave). Inline w2l/l2w mirror steel-3d-core (this script isn't a module).
|
|
2757
|
+
const _dpPpf=(P&&P.pt_per_ft>0)?P.pt_per_ft:1;
|
|
2758
|
+
const _dpFI=(view3d&&window.Steel3DView&&window.Steel3DView.frameInfo)?window.Steel3DView.frameInfo():null;
|
|
2759
|
+
const _dp3d=!!(_dpFI&&_dpFI.mode==='local'); // a 3D UCS (frame3d) is set
|
|
2760
|
+
const _dp2d=!!(!view3d&&P&&P.frame); // 2D local axes (P.frame) set
|
|
2761
|
+
// A column is a single plan point at a fixed elevation; under a TILTED 3D frame local X′/Y′ would be Z-coupled
|
|
2762
|
+
// (no clean 2-DOF answer), so show the column's local row only for a planar frame (2D, or a horizontal 3D UCS).
|
|
2763
|
+
const _dpLocal=(_dp3d||_dp2d)&&(!col||_dp2d||(_dp3d&&_dpFI.horizontal));
|
|
2764
|
+
const _dpZin=i=>col?(i===0?(Number.isFinite(+m.col.bos)?+m.col.bos:0):(Number.isFinite(+m.col.tos)?+m.col.tos:defaultTOS)):effEndTos(m.ends[i]);
|
|
2765
|
+
const _dpGlobal=i=>[m.wp[i][0]*12/_dpPpf,-m.wp[i][1]*12/_dpPpf,_dpZin(i)]; // end i → world point, inches
|
|
2766
|
+
const _dpToLocal=g=>{ // world-in [x,y,z] → local-in, or null
|
|
2767
|
+
if(_dp3d){const o=_dpFI.origin,X=_dpFI.xAxis,Y=_dpFI.yAxis,Z=_dpFI.normal,d=[g[0]*25.4-o[0],g[1]*25.4-o[1],g[2]*25.4-o[2]];
|
|
2768
|
+
return [(d[0]*X[0]+d[1]*X[1]+d[2]*X[2])/25.4,(d[0]*Y[0]+d[1]*Y[1]+d[2]*Y[2])/25.4,(d[0]*Z[0]+d[1]*Z[1]+d[2]*Z[2])/25.4];}
|
|
2769
|
+
if(_dp2d){const o=P.frame.o,u=P.frame.u,px=g[0]*_dpPpf/12,py=-g[1]*_dpPpf/12,dx=px-o[0],dy=py-o[1];
|
|
2770
|
+
return [(dx*u[0]+dy*u[1])*12/_dpPpf,(dx*u[1]-dy*u[0])*12/_dpPpf,g[2]];} // v=[uy,−ux]; Z′=global Z (planar frame)
|
|
2771
|
+
return null;};
|
|
2772
|
+
const _dpFromLocal=l=>{ // local-in [x,y,z] → world-in, or null
|
|
2773
|
+
if(_dp3d){const o=_dpFI.origin,X=_dpFI.xAxis,Y=_dpFI.yAxis,Z=_dpFI.normal,L=[l[0]*25.4,l[1]*25.4,l[2]*25.4];
|
|
2774
|
+
return [(o[0]+L[0]*X[0]+L[1]*Y[0]+L[2]*Z[0])/25.4,(o[1]+L[0]*X[1]+L[1]*Y[1]+L[2]*Z[1])/25.4,(o[2]+L[0]*X[2]+L[1]*Y[2]+L[2]*Z[2])/25.4];}
|
|
2775
|
+
if(_dp2d){const o=P.frame.o,u=P.frame.u,du=l[0]*_dpPpf/12,dv=l[1]*_dpPpf/12,px=o[0]+du*u[0]+dv*u[1],py=o[1]+du*u[1]-dv*u[0];
|
|
2776
|
+
return [px*12/_dpPpf,-py*12/_dpPpf,l[2]];}
|
|
2777
|
+
return null;};
|
|
2778
|
+
// Commit a new world-in point Pt=[x,y,z] to end i. Column stays plumb (both wp) and leaves BOS/TOS to the
|
|
2779
|
+
// Elevation section (Pt[2] unused for a column); a beam writes wp[i], and touches this end's TOS ONLY when the
|
|
2780
|
+
// world Z actually changed — so a plain X/Y move keeps the end following the sheet default (a local-axis edit
|
|
2781
|
+
// under a tilted 3D frame legitimately changes Z and DOES clear the default, which this comparison allows).
|
|
2782
|
+
const _dpCommit=(i,Pt)=>edit(()=>{const nx=Pt[0]*_dpPpf/12,ny=-Pt[1]*_dpPpf/12;
|
|
2783
|
+
if(col){m.wp[0]=[nx,ny];m.wp[1]=[nx,ny];}
|
|
2784
|
+
else{m.wp[i]=[nx,ny];if(Math.abs(Pt[2]-effEndTos(m.ends[i]))>1e-6){m.ends[i].tos=Pt[2];m.ends[i].tosDef=false;}}});
|
|
2785
|
+
const _dpAxes=col?['X','Y']:['X','Y','Z']; // a column has one plan point → X/Y only
|
|
2786
|
+
const _dpPH='5 3/4" · 1'-0 1/4"';
|
|
2787
|
+
const _dpIn=(id,lbl,vin)=>{const v=Math.abs(vin)<1e-6?0:vin;return `<label class=detf><span>${lbl}</span><input id=${id} inputmode=decimal placeholder="${_dpPH}" value="${esc(fmtFtIn(v))}" autocomplete=off></label>`;}; // snap float-noise to 0 (no "-0"" from a local round-trip)
|
|
2788
|
+
const _dpBlock=(i,head)=>{const g=_dpGlobal(i),loc=_dpLocal?_dpToLocal(g):null;
|
|
2789
|
+
const grow=`<div class=detrow>${_dpAxes.map((ax,a)=>_dpIn('dpG_'+i+'_'+a,ax,g[a])).join('')}</div>`;
|
|
2790
|
+
const lrow=loc?`<div class=elab style="color:#22d3ee;margin:4px 0 0">Local frame</div><div class="detrow dp-local">${_dpAxes.map((ax,a)=>_dpIn('dpL_'+i+'_'+a,ax+'′',loc[a])).join('')}</div>`:'';
|
|
2791
|
+
return head+(loc?'<div class=elab style="margin:2px 0 0">Global</div>':'')+grow+lrow;};
|
|
2792
|
+
const defPts=`<div class=divrow><hr><span class=sect style="margin:0" data-tip="The member's start & end work points in global coordinates${_dpLocal?' and the current local frame':''}. Type a value to move that end.">Definition points</span><hr></div>`
|
|
2793
|
+
+(col
|
|
2794
|
+
? `<div class=hint style="margin:0 0 4px">A column runs plumb — one plan position; its elevation (bottom → top) is set above.</div>`+_dpBlock(0,`<div class=sect>Plan position</div>`)
|
|
2795
|
+
: _dpBlock(0,`<div class=sect>${dotS}Start</div>`)+`<div class=divrow><hr></div>`+_dpBlock(1,`<div class=sect>${dotE}End</div>`));
|
|
2749
2796
|
p.innerHTML=`<h3>Member ${esc(m.id)}</h3>
|
|
2750
2797
|
${typeFilterHTML()}
|
|
2751
2798
|
${memberTypeField('mTypeS',[m])}
|
|
@@ -2755,6 +2802,7 @@ function panel(){
|
|
|
2755
2802
|
<div class=row><button class=ghostw id=verifyBtn${m.verified?' style="border-color:#166534;color:#86efac"':''} data-tip="Mark this member human-confirmed → 100% in the confidence report">${m.verified?'✓ Verified — human-confirmed':'Mark verified'}</button></div>
|
|
2756
2803
|
${mfSug.length?`<div class="row" style="border:1px solid #a855f7;border-radius:6px;padding:7px 8px;background:rgba(168,85,247,.07)"><div class=elab style="color:#c4b5fd;margin:0">Moment-frame girder · ${_lvl==='roof'?'roof':'2nd floor'} (from Frames)</div><div style="display:flex;flex-wrap:wrap;gap:5px;margin-top:5px">${mfSug.map(s=>`<button class="ghost mfsug${s===m.profile?' on':''}" data-s="${esc(s)}">${esc(s)}</button>`).join('')}</div></div>`:''}
|
|
2757
2804
|
${elev}
|
|
2805
|
+
${defPts}
|
|
2758
2806
|
${bpSect}${spSect}${copeSect}
|
|
2759
2807
|
${col?'':`<div class=divrow><hr><span class=sect style="margin:0" data-tip="Where the section sits on the reference line (between the end dots). Top = top-of-steel (dots on the top flange); Middle = centroid; Bottom = underside.">Profile Position <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
2760
2808
|
<div class=seg2 style="margin-top:0"><button id=posTop class="${pos==='top'?'on':''}">Top</button><button id=posMid class="${pos==='middle'?'on':''}">Middle</button><button id=posBot class="${pos==='bottom'?'on':''}">Bottom</button></div>`}
|
|
@@ -2852,6 +2900,20 @@ function panel(){
|
|
|
2852
2900
|
{const ck=document.getElementById('spck_e'+e);if(ck)ck.onchange=ev=>edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};jj.params.stiffener=ev.target.checked;jj.source='user';});}
|
|
2853
2901
|
{const rm=document.getElementById('sprm_e'+e);if(rm)rm.onclick=()=>edit(()=>{C.joints=(C.joints||[]).filter(x=>x!==j);});}} // Remove is undoable
|
|
2854
2902
|
}
|
|
2903
|
+
// Definition points (F14) — each coord commits through edit() (undo + 2D + 3D + autosave). Enter = commit(blur),
|
|
2904
|
+
// Escape = revert; a non-parseable value flags the field red and doesn't commit (mirrors the grid panel's wire()).
|
|
2905
|
+
// stopPropagation keeps ft-in keystrokes off the global shortcut/repeat-last handler.
|
|
2906
|
+
{const dpWire=(id,i,a,isLocal)=>{const inp=document.getElementById(id);if(!inp)return;const orig=inp.value;
|
|
2907
|
+
inp.onkeydown=e=>{e.stopPropagation();if(e.key==='Enter'){e.preventDefault();inp.blur();}else if(e.key==='Escape'){e.preventDefault();inp.value=orig;inp.blur();}};
|
|
2908
|
+
inp.onchange=()=>{const vin=parseLen(inp.value);
|
|
2909
|
+
if(vin==null||!Number.isFinite(vin)){inp.style.borderColor='#fca5a5';return;} // bad parse → flag, don't commit
|
|
2910
|
+
inp.style.borderColor='';
|
|
2911
|
+
const g=_dpGlobal(i);let Pt;
|
|
2912
|
+
if(isLocal){const loc=_dpToLocal(g)||[0,0,0];loc[a]=vin;Pt=_dpFromLocal(loc);}
|
|
2913
|
+
else{Pt=g.slice();Pt[a]=vin;}
|
|
2914
|
+
if(Pt)_dpCommit(i,Pt);};};
|
|
2915
|
+
const wireEnd=i=>_dpAxes.forEach((ax,a)=>{dpWire('dpG_'+i+'_'+a,i,a,false);if(_dpLocal)dpWire('dpL_'+i+'_'+a,i,a,true);});
|
|
2916
|
+
wireEnd(0);if(!col)wireEnd(1);}
|
|
2855
2917
|
document.getElementById('del').onclick=()=>edit(()=>{P.members=P.members.filter(x=>x.id!==m.id);selIds.clear();if(selDimIds.size){P.dims=P.dims.filter(d=>!selDimIds.has(d.id));selDimIds.clear();}}); // also drop any dims a mixed marquee selected
|
|
2856
2918
|
{const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{m.verified=!m.verified;});}
|
|
2857
2919
|
}
|
|
@@ -4101,8 +4163,8 @@ addEventListener('keydown',e=>{
|
|
|
4101
4163
|
if(dimMode&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const dk=e.key.toLowerCase();
|
|
4102
4164
|
if(dk==='x'||dk==='y'||dk==='f'){e.preventDefault();dimSetAxis(dk==='f'?'free':dk);dimDraft&&svg.querySelector('#dimPrevG')&&dimRefreshPrev();return;}
|
|
4103
4165
|
if(dk==='c'){e.preventDefault();toggleDimChain();return;}} // C — toggle chained (continuous) dimensioning
|
|
4104
|
-
if(cmTool&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ak=e.key.toLowerCase(); // Move/Copy armed: X/Y/F force the axis (
|
|
4105
|
-
if(ak==='x'||ak==='y'||ak==='f'){e.preventDefault();
|
|
4166
|
+
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
|
|
4167
|
+
if(ak==='x'||ak==='y'||ak==='f'||(ak==='z'&&view3d)){e.preventDefault(); // Z is 3D-only (the normal-axis lock); 2D has no Z, and Alt+Z stays Zoom-Selected (never reaches here — this block requires !altKey)
|
|
4106
4168
|
if(view3d&&window.Steel3DView&&window.Steel3DView.setCmAxis)window.Steel3DView.setCmAxis(ak);
|
|
4107
4169
|
else{cmAxis=ak==='f'?'free':ak;cmRefreshPrev();}return;}
|
|
4108
4170
|
const hasBase=cmDraft||(view3d&&window.Steel3DView&&window.Steel3DView.cmHasBase&&window.Steel3DView.cmHasBase());
|
|
@@ -4218,7 +4280,11 @@ document.getElementById('cpLevelB').onclick=()=>openLevelModal('copy');
|
|
|
4218
4280
|
// member Inspector can show a read-only "Cope (auto)" note (a coped beam otherwise looks like an error).
|
|
4219
4281
|
let copesByMember={}, partsById={};
|
|
4220
4282
|
const view3dApi={
|
|
4221
|
-
onFrame3dChange:()=>{updCS();if(typeof csSyncF3d==='function')csSyncF3d();
|
|
4283
|
+
onFrame3dChange:()=>{updCS();if(typeof csSyncF3d==='function')csSyncF3d();
|
|
4284
|
+
// F14: the Definition-points local (X′/Y′/Z′) row reads the 3D frame — refresh the inspector when the
|
|
4285
|
+
// frame changes outside a render() path (notably Reset-to-global, which only fires this callback). Skip
|
|
4286
|
+
// while the frame tool is armed (it owns the panel) and outside 3D / select mode.
|
|
4287
|
+
if(view3d&&mode==='sel'&&!(window.Steel3DView&&window.Steel3DView.frameArmed&&window.Steel3DView.frameArmed()))panel();}, // the 3D local frame moved/armed/reset → resync the Axes chip + the numeric fields
|
|
4222
4288
|
// POST the in-progress contract so the model reflects unsaved edits; throws on a bad contract.
|
|
4223
4289
|
fetchScene:async()=>{const r=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/scene',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({contract:C})});const j=await r.json();if(!j.ok)throw new Error(j.error||'scene render failed');
|
|
4224
4290
|
// The bake reports everything it could NOT emit in `skipped[]`, and we used to discard it entirely — so a
|