@floless/app 0.95.0 → 0.95.2
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 +15 -0
- package/dist/web/steel-3d-view.js +143 -86
- package/dist/web/steel-editor.html +7 -5
- 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.95.
|
|
53109
|
+
define: true ? "0.95.2" : 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.95.
|
|
53119
|
+
return resolveChannel({ isSea: isSea2(), define: true ? "0.95.2" : void 0 });
|
|
53120
53120
|
}
|
|
53121
53121
|
|
|
53122
53122
|
// workflow-update.ts
|
|
@@ -359,6 +359,21 @@ export function sanitizeDims3d(arr) {
|
|
|
359
359
|
* valueMm = that component's length. Returns the drawn endpoints, the midpoint (where the label
|
|
360
360
|
* sits), and the measured length in mm.
|
|
361
361
|
*/
|
|
362
|
+
/**
|
|
363
|
+
* The axis key in `axesMap` whose direction the span a→b is most aligned with (largest |dot|). Pure.
|
|
364
|
+
* `axesMap` = { key: [x,y,z] world unit vector, ... } (a subset of the locked axes). Used to resolve a
|
|
365
|
+
* multi-axis dimension lock (X+Z) to the ONE axis the measured span runs most along. null iff the map is empty.
|
|
366
|
+
*/
|
|
367
|
+
export function dominantAxis3d(a, b, axesMap) {
|
|
368
|
+
const d = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
|
|
369
|
+
let best = null, bestScore = -1;
|
|
370
|
+
for (const k in axesMap) {
|
|
371
|
+
const v = axesMap[k], s = Math.abs(d[0] * v[0] + d[1] * v[1] + d[2] * v[2]);
|
|
372
|
+
if (s > bestScore) { bestScore = s; best = k; }
|
|
373
|
+
}
|
|
374
|
+
return best;
|
|
375
|
+
}
|
|
376
|
+
|
|
362
377
|
export function dim3dGeom(a, b, axis, axisDir) {
|
|
363
378
|
const p1 = [a[0], a[1], a[2]];
|
|
364
379
|
const u = (axis === 'x' || axis === 'y') ? unitOrNull(axisDir) : null; // z/free never project onto axisDir
|
|
@@ -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, candidateOnPlane } from './steel-3d-core.js';
|
|
20
|
+
import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane } 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)';
|
|
@@ -99,7 +99,7 @@ function candOnActiveWP(c, dragged, wp) {
|
|
|
99
99
|
return candidateOnPlane(c, dragged, wp.origin, wp.normal, WP_SNAP_TOL_MM);
|
|
100
100
|
}
|
|
101
101
|
let rightDownXY = null, rightMoved = false; // right button: dragged (= orbit/pan, no menu) vs clicked (= snap menu)
|
|
102
|
-
|
|
102
|
+
const dimLock = new Set(); // locked MEASURE axes (subset of x|y|z); empty = Free/aligned. Toggle+combine like Move/Copy's tfLock (measures along the resolved/dominant axis; the 2nd point still free-snaps).
|
|
103
103
|
let dims3dVisibleFlag = true; // show/hide placed dims
|
|
104
104
|
let dimDraft3d = null; // { a:[x,y,z] } once the first point is placed (awaiting the 2nd)
|
|
105
105
|
let dimLastAlt = false; // last-seen Alt state (the hover rAF rebuilds a synthetic event)
|
|
@@ -1607,10 +1607,10 @@ function onKey(e) {
|
|
|
1607
1607
|
if (k === 'd' && !e.ctrlKey && !e.metaKey && !e.altKey && !midGesture) { e.preventDefault(); toggleDimTool(); return; } // D arms/disarms the dimension tool
|
|
1608
1608
|
if (dimMode3d && !midGesture) {
|
|
1609
1609
|
if (k === 'escape') { e.preventDefault(); if (snapOnly3d) setSnapOnly3d(null); else if (dimDraft3d) { dimDraft3d = null; dimPreviewLine.visible = false; readout.style.display = 'none'; } else toggleDimTool(); return; } // Esc steps back: drop the snap override → cancel the in-progress dim → exit the tool (mirrors the 2D two-step)
|
|
1610
|
-
if (k === 'f' || k === 'x' || k === 'y' || k === 'z') { e.preventDefault(); setDimAxis(k
|
|
1610
|
+
if (k === 'f' || k === 'x' || k === 'y' || k === 'z') { e.preventDefault(); setDimAxis(k); return; } // toggle+combine the measure-axis lock: Free / X / Y / Z (setDimAxis refreshes the bar + chip)
|
|
1611
1611
|
}
|
|
1612
1612
|
// Named-view shortcuts mirror the ViewCube faces (parity with AWARE viewer-3d): T/F/R/B/L snap to an ortho view.
|
|
1613
|
-
if (VIEW_KEYS[k] && !cmActive() && !wpMode && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey) { e.preventDefault(); applyView(VIEW_KEYS[k]); return; } // while Move/Copy or a set-plane pick is armed, F
|
|
1613
|
+
if (VIEW_KEYS[k] && !cmActive() && (k !== 'f' || !addActive()) && !wpMode && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey) { e.preventDefault(); applyView(VIEW_KEYS[k]); return; } // while Move/Copy or a set-plane pick is armed, no view key fires (unchanged); while Add is armed only F is claimed (axis-lock clear) — T/R/B/L still switch views (review finding)
|
|
1614
1614
|
const a = ARROWS[e.key]; if (!a) return;
|
|
1615
1615
|
const [hx, hy] = a;
|
|
1616
1616
|
if (e.ctrlKey || e.metaKey) { e.preventDefault(); rotateView(-hx * Math.PI / 12, hy * Math.PI / 12); } // 15°
|
|
@@ -1627,8 +1627,28 @@ function toggleDimTool() {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
// snap override setter — notifies the host page so its header chip stays in sync with every clear path
|
|
1629
1629
|
function setSnapOnly3d(k) { snapOnly3d = k || null; if (api && api.onSnapOnlyChanged) api.onSnapOnlyChanged(); }
|
|
1630
|
-
|
|
1631
|
-
|
|
1630
|
+
// X/Y/Z each TOGGLE the measure axis in the lock set (press again to release; combine 2–3 → the dim measures along
|
|
1631
|
+
// whichever locked axis the span runs most along); F/free clears → aligned. Refreshes the bar + chip so a key press
|
|
1632
|
+
// then a click without moving measures what's shown.
|
|
1633
|
+
function setDimAxis(a) {
|
|
1634
|
+
if (a === 'free' || a === 'f') dimLock.clear();
|
|
1635
|
+
else if (a === 'x' || a === 'y' || a === 'z') { if (dimLock.has(a)) dimLock.delete(a); else dimLock.add(a); }
|
|
1636
|
+
reflectDimAxisBar(); updateStatusChip();
|
|
1637
|
+
if (dimMode3d) dimHoverPreview(dimLastAlt); // refresh the preview line SYNCHRONOUSLY so a key/button then an immediate click measures what's shown (mirrors setCmAxis; no RAF lag)
|
|
1638
|
+
}
|
|
1639
|
+
function dimAxis() { return [...dimLock]; } // the locked measure axes (empty = free/aligned)
|
|
1640
|
+
// The frame-aware label for a measure axis: X/Y/Z global, X′/Y′/Elev under a local frame, World X/World Y/Elev under
|
|
1641
|
+
// a ◇ Plane (the single source the buttons AND the chip use, so they never disagree — ui-ux review).
|
|
1642
|
+
function dimAxisLabel(a) {
|
|
1643
|
+
const framed = !!frame3d && !workPlane, planed = !!workPlane;
|
|
1644
|
+
if (a === 'x') return planed ? 'World X' : framed ? 'X′' : 'X';
|
|
1645
|
+
if (a === 'y') return planed ? 'World Y' : framed ? 'Y′' : 'Y';
|
|
1646
|
+
if (a === 'z') return (framed || planed) ? 'Elev' : 'Z';
|
|
1647
|
+
return '';
|
|
1648
|
+
}
|
|
1649
|
+
// "measuring" (NOT "locked") — a dimension only changes the MEASURED direction; the 2nd point still free-snaps
|
|
1650
|
+
// (unlike Move/Copy, whose pick is truly axis-constrained). Frame-aware via dimAxisLabel.
|
|
1651
|
+
function dimLockChipTxt() { const _l = ['x', 'y', 'z'].filter((a) => dimLock.has(a)); return _l.length ? ' · measuring ' + _l.map(dimAxisLabel).join(', ') : ''; }
|
|
1632
1652
|
function setDims3dVisible(on) { dims3dVisibleFlag = !!on; refreshDims(); }
|
|
1633
1653
|
function dims3dVisible() { return dims3dVisibleFlag; }
|
|
1634
1654
|
function reflectDimBar() {
|
|
@@ -1643,20 +1663,17 @@ function reflectDimBar() {
|
|
|
1643
1663
|
// · a ◇ Plane set (shadows the frame) → World X / World Y / Elev + a tip: dims IGNORE the plane (they go global)
|
|
1644
1664
|
function reflectDimAxisBar() {
|
|
1645
1665
|
const framed = !!frame3d && !workPlane, planed = !!workPlane;
|
|
1646
|
-
const LBL = {
|
|
1647
|
-
x: planed ? 'World X' : framed ? 'X′' : 'X',
|
|
1648
|
-
y: planed ? 'World Y' : framed ? 'Y′' : 'Y',
|
|
1649
|
-
z: (framed || planed) ? 'Elev' : 'Z',
|
|
1650
|
-
};
|
|
1651
1666
|
const TIP = {
|
|
1652
|
-
x: planed ? 'Dims measure WORLD X, not the ◇ Plane (X)' : framed ? 'Measure along the local frame X′ (X)' : '
|
|
1653
|
-
y: planed ? 'Dims measure WORLD Y, not the ◇ Plane (Y)' : framed ? 'Measure along the local frame Y′ (Y)' : '
|
|
1654
|
-
z: (framed || planed) ? 'World Z — stays vertical even with a tilted frame (Z); Alt = quick vertical' : '
|
|
1667
|
+
x: planed ? 'Dims measure WORLD X, not the ◇ Plane — combine with Y/Z (X)' : framed ? 'Measure along the local frame X′ — combine with Y/Z (X)' : 'Measure along X — combine with Y/Z (X)',
|
|
1668
|
+
y: planed ? 'Dims measure WORLD Y, not the ◇ Plane — combine with X/Z (Y)' : framed ? 'Measure along the local frame Y′ — combine with X/Z (Y)' : 'Measure along Y — combine with X/Z (Y)',
|
|
1669
|
+
z: (framed || planed) ? 'World Z — stays vertical even with a tilted frame; combine with X/Y (Z); Alt = quick vertical' : 'Measure along Z / vertical — combine with X/Y (Z); Alt = quick vertical',
|
|
1655
1670
|
};
|
|
1656
1671
|
document.querySelectorAll('#m3dDimAxis button').forEach((x) => {
|
|
1657
1672
|
const a = x.dataset.d3axis;
|
|
1658
|
-
|
|
1659
|
-
|
|
1673
|
+
const on = a === 'free' ? dimLock.size === 0 : dimLock.has(a);
|
|
1674
|
+
x.classList.toggle('on', on); // Free lit when nothing is locked; X/Y/Z lit per the lock set (multiple can be on)
|
|
1675
|
+
x.setAttribute('aria-pressed', String(on)); // multi-select toggle group → aria-pressed is the correct state (ui-ux review)
|
|
1676
|
+
if (a && dimAxisLabel(a)) { x.textContent = dimAxisLabel(a); x.dataset.tip = TIP[a]; } // frame-aware label (shared with the chip); free button untouched
|
|
1660
1677
|
});
|
|
1661
1678
|
}
|
|
1662
1679
|
// "Zoom to detail": double-click a part → zoom to a tight region around the click point so a connection
|
|
@@ -2324,6 +2341,7 @@ let wpMode = null; // 'face' | '3pt' — armed set-plane pick mode
|
|
|
2324
2341
|
let wpDraft = null; // 3pt picks collected so far
|
|
2325
2342
|
let wpVisible = true; // "Show plane" toggle (applies to an explicit plane)
|
|
2326
2343
|
let wpGroup = null;
|
|
2344
|
+
let wpExtent = null; // test-observability: the projected u/v footprint the last-rendered "Show plane" surface was sized to (null = fallback square)
|
|
2327
2345
|
// ---- 3D local drawing frame (UCS, stage 1): a SEPARATE rotate-about-Z frame for skewed framing.
|
|
2328
2346
|
// NOT the workPlane — an explicit ◇ Plane wins over it. null = global (world identity). Session-only,
|
|
2329
2347
|
// model-wide, never saved to the contract (the frame is a temporary aid; dims it authors persist, not it).
|
|
@@ -2604,10 +2622,10 @@ function orthoLockDelta(dx, dy) {
|
|
|
2604
2622
|
const du = dx * u[0] + dy * u[1], dv = dx * v[0] + dy * v[1];
|
|
2605
2623
|
return Math.abs(du) >= Math.abs(dv) ? [du * u[0], du * u[1]] : [dv * v[0], dv * v[1]];
|
|
2606
2624
|
}
|
|
2607
|
-
// The unified "Show plane" REFERENCE PLANE (Pawel 2026-07-13): a transparent
|
|
2608
|
-
// working plane the tools actually follow — a ◇ Plane if set, else the local frame (tilted), else horizontal
|
|
2609
|
-
// at the global origin. Sized to the Work area
|
|
2610
|
-
// top of it (renderFrameGizmo
|
|
2625
|
+
// The unified "Show plane" REFERENCE PLANE (Pawel 2026-07-13): a plain transparent surface (no grid) that MATCHES
|
|
2626
|
+
// the working plane the tools actually follow — a ◇ Plane if set, else the local frame (tilted), else horizontal
|
|
2627
|
+
// at the global origin. Sized to hug the current bounding box (Work area if set, else the model), projected onto
|
|
2628
|
+
// the plane's own u/v. The axes+origin gizmo always draws on top of it (renderFrameGizmo). Toggled by "Show plane".
|
|
2611
2629
|
function refPlaneBasis() {
|
|
2612
2630
|
if (workPlane) { const b = planeBasis(workPlane.normal, workPlane.xAxis); return { O: workPlane.origin, u: b.u, v: b.v, n: workPlane.normal }; }
|
|
2613
2631
|
if (frame3d) return { O: frame3d.origin, u: frame3d.xAxis, v: frame3d.yAxis, n: frame3d.normal };
|
|
@@ -2622,26 +2640,30 @@ function renderWorkPlane() {
|
|
|
2622
2640
|
// For a local frame / ◇ Plane these coincide; only at Global do they differ (plane at the active level's
|
|
2623
2641
|
// TOS, gizmo at world 0,0,0) — so the plane never lies about the work height (code-review High).
|
|
2624
2642
|
const wp = effectiveWP(), { u, v } = planeBasis(wp.normal, wp.xAxis), O = wp.origin, n = wp.normal;
|
|
2625
|
-
|
|
2643
|
+
// Project the bbox corners onto the plane's OWN u/v so a tilted/vertical (XZ/YZ) plane hugs its model in-plane,
|
|
2644
|
+
// not by world X/Y. The surface then spans exactly [uMin,uMax]×[vMin,vMax] (+ a small margin) — matching the box.
|
|
2626
2645
|
const box = (workArea && workArea.enabled && workArea.box && !workArea.box.isEmpty()) ? workArea.box : sceneBox;
|
|
2627
|
-
|
|
2628
|
-
|
|
2646
|
+
let uMin = -1524, uMax = 1524, vMin = -1524, vMax = 1524; // fallback square when there's no model yet
|
|
2647
|
+
wpExtent = null;
|
|
2648
|
+
if (box && !box.isEmpty()) {
|
|
2649
|
+
let a = Infinity, A = -Infinity, b = Infinity, B = -Infinity;
|
|
2629
2650
|
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]) {
|
|
2630
2651
|
const dx = x - O[0], dy = y - O[1], dz = z - O[2];
|
|
2631
2652
|
const pu = dx * u[0] + dy * u[1] + dz * u[2], pv = dx * v[0] + dy * v[1] + dz * v[2];
|
|
2632
|
-
|
|
2653
|
+
a = Math.min(a, pu); A = Math.max(A, pu); b = Math.min(b, pv); B = Math.max(B, pv);
|
|
2654
|
+
}
|
|
2655
|
+
if ([a, A, b, B].every(Number.isFinite)) { // a NaN/∞ box (malformed scene) falls through to the fallback square instead of corrupt geometry
|
|
2656
|
+
const m = 305; uMin = a - m; uMax = A + m; vMin = b - m; vMax = B + m; // ~1 ft margin so edge members aren't flush with the border
|
|
2657
|
+
wpExtent = { uSpan: A - a, vSpan: B - b, margin: m, workArea: box !== sceneBox }; // pre-margin footprint in the SAME basis the surface used (so a probe holds for work-area/tilted planes too)
|
|
2633
2658
|
}
|
|
2634
|
-
span = Math.max(uMax - uMin, vMax - vMin, 3048) * 1.15;
|
|
2635
2659
|
}
|
|
2636
|
-
const
|
|
2660
|
+
const w = Math.max(uMax - uMin, 1), h = Math.max(vMax - vMin, 1), uc = (uMin + uMax) / 2, vc = (vMin + vMax) / 2;
|
|
2637
2661
|
const g = new THREE.Group();
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
g.add(new THREE.
|
|
2643
|
-
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)];
|
|
2644
|
-
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)
|
|
2662
|
+
const surf = new THREE.Mesh(new THREE.PlaneGeometry(w, h), new THREE.MeshBasicMaterial({ color: 0x93c5fd, transparent: true, opacity: 0.1, side: THREE.DoubleSide, depthWrite: false })); // plain transparent surface, light blue — no grid (the gizmo carries the axes)
|
|
2663
|
+
surf.position.set(uc, vc, 0); // centered on the box footprint, not the plane origin
|
|
2664
|
+
g.add(surf);
|
|
2665
|
+
const edge = [new THREE.Vector3(uMin, vMin, 0), new THREE.Vector3(uMax, vMin, 0), new THREE.Vector3(uMax, vMax, 0), new THREE.Vector3(uMin, vMax, 0)];
|
|
2666
|
+
g.add(new THREE.LineLoop(new THREE.BufferGeometry().setFromPoints(edge), new THREE.LineBasicMaterial({ color: 0x93c5fd, transparent: true, opacity: 0.4 }))); // faint perimeter so the plane's extent still reads without a grid (ux)
|
|
2645
2667
|
g.applyMatrix4(new THREE.Matrix4().makeBasis(new THREE.Vector3(...u), new THREE.Vector3(...v), new THREE.Vector3(...n)));
|
|
2646
2668
|
g.position.set(O[0], O[1], O[2]);
|
|
2647
2669
|
wpGroup = g; scene.add(g); // on `scene` (like epGroup) so rebuild() never wipes it; not in meshById → picking ignores it
|
|
@@ -2704,7 +2726,9 @@ function setCmAxis(a, shiftHeld) {
|
|
|
2704
2726
|
// Refresh the ghost/readout NOW so a key press then a click WITHOUT moving commits what's shown. The
|
|
2705
2727
|
// editor's axis-key handler fires only with Alt UP, so use altKey:false (NOT the stale hover mirror
|
|
2706
2728
|
// dimLastAlt, which lags a modifier released without a pointer move); Shift comes live from the key event.
|
|
2707
|
-
|
|
2729
|
+
const ev = lastHoverXY ? { clientX: lastHoverXY[0], clientY: lastHoverXY[1], altKey: false, shiftKey: !!shiftHeld } : null;
|
|
2730
|
+
if (ev && tfDraft) tfPreview(ev); // Move/Copy ghost
|
|
2731
|
+
else if (ev && addActive() && drDraft) drPreview(ev); // Add-member rubber band — refresh so a key-then-click commits what's shown
|
|
2708
2732
|
updateStatusChip();
|
|
2709
2733
|
}
|
|
2710
2734
|
function cmClear3d() { tfDraft = null; tfCandidates = null; tfLock.clear(); tfPreviewClear(); if (canvasEl) canvasEl.style.cursor = 'default'; } // callable BEFORE init() (editor boot) — every touched handle is guarded
|
|
@@ -2731,8 +2755,9 @@ function frameBasis() { const wp = effectiveWP(), b = planeBasis(wp.normal, wp.x
|
|
|
2731
2755
|
// offset when the cursor nears the horizon (the axis grazes the view). Edge-on axis (its screen projection
|
|
2732
2756
|
// collapses because you're looking down it): a ~vertical axis falls back to screen-Y → Z (Top view); any
|
|
2733
2757
|
// other axis → no move. A ~vertical axis then snaps t to the framing levels. X/Y/Z + Alt normal-lock alike.
|
|
2734
|
-
function cmAxisLock(e, axisVec) {
|
|
2735
|
-
|
|
2758
|
+
function cmAxisLock(e, axisVec, base, opts) {
|
|
2759
|
+
base = base || tfDraft.base; // Move/Copy passes tfDraft.base; Add passes drDraft (shared line-lock)
|
|
2760
|
+
const n = _unit3(axisVec), bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
|
|
2736
2761
|
const sc = pxToWorldAt(120, base) || 1; // a world length that spans ~120 px at the base
|
|
2737
2762
|
const q = toScreen([base[0] + n[0] * sc, base[1] + n[1] * sc, base[2] + n[2] * sc]);
|
|
2738
2763
|
const sdx = q.x - bs.x, sdy = q.y - bs.y, slen = Math.hypot(sdx, sdy); // the axis's screen vector for `sc` world units
|
|
@@ -2747,7 +2772,7 @@ function cmAxisLock(e, axisVec) {
|
|
|
2747
2772
|
if (!Number.isFinite(t)) t = 0; // never commit a NaN offset
|
|
2748
2773
|
let p = [base[0] + n[0] * t, base[1] + n[1] * t, base[2] + n[2] * t];
|
|
2749
2774
|
let snap = false, type = null;
|
|
2750
|
-
if (Math.abs(n[2]) > 0.999) {
|
|
2775
|
+
if (Math.abs(n[2]) > 0.999 && !(opts && opts.noSnap)) { // ~vertical axis → snap the elevation to a framing level (WORLD-space: in Top view all levels share one screen point); Add+Alt passes noSnap so "no snap" holds even under a lock
|
|
2751
2776
|
const tol = pxToWorldAt(SNAP_TOL_PX, base);
|
|
2752
2777
|
let best = null, bestD = tol;
|
|
2753
2778
|
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; } }
|
|
@@ -2758,8 +2783,9 @@ function cmAxisLock(e, axisVec) {
|
|
|
2758
2783
|
// Among `axes` (basis keys), the ONE the cursor is dragging toward: the axis whose SCREEN direction best
|
|
2759
2784
|
// matches the cursor's screen move from the base (|cos|). Lets a 2-axis lock (X+Z) snap the move to X or Z
|
|
2760
2785
|
// (whichever you lean toward), and Shift pick the dominant in-plane axis — one straight axis, never diagonal.
|
|
2761
|
-
function dominantAmong(e, axes) {
|
|
2762
|
-
|
|
2786
|
+
function dominantAmong(e, axes, base) {
|
|
2787
|
+
base = base || tfDraft.base;
|
|
2788
|
+
const bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
|
|
2763
2789
|
const cx = (e.clientX - rect.left) - bs.x, cy = (e.clientY - rect.top) - bs.y, cl = Math.hypot(cx, cy) || 1;
|
|
2764
2790
|
const bv = frameBasis(), sc = pxToWorldAt(120, base) || 1; // world length spanning ~120 px → a well-conditioned axis screen vector
|
|
2765
2791
|
let best = axes[0], bestScore = -1;
|
|
@@ -2773,21 +2799,24 @@ function dominantAmong(e, axes) {
|
|
|
2773
2799
|
}
|
|
2774
2800
|
// The single axis the move is line-locked to ('u'|'v'|'n'), or null = free. Precedence: Alt (normal) >
|
|
2775
2801
|
// Shift (dominant in-plane) > the sticky lock set (the lone locked axis, or the dominant of two).
|
|
2776
|
-
function cmEffAxis(e) {
|
|
2777
|
-
|
|
2778
|
-
if (
|
|
2779
|
-
if (e && e.
|
|
2802
|
+
function cmEffAxis(e, base, opts) {
|
|
2803
|
+
base = base || (tfDraft && tfDraft.base);
|
|
2804
|
+
if (!base) return null;
|
|
2805
|
+
if (e && e.altKey && !(opts && opts.noAlt)) return 'n'; // Alt = normal-lock (Move/Copy); Add passes noAlt so its Alt stays "no snap"
|
|
2806
|
+
if (e && e.shiftKey) return dominantAmong(e, ['u', 'v'], base);
|
|
2780
2807
|
if (!tfLock.size) return null; // no lock → free
|
|
2781
|
-
return tfLock.size === 1 ? [...tfLock][0] : dominantAmong(e, [...tfLock]); // 1 = that axis; 2 or 3 = whichever locked axis the cursor drags toward
|
|
2782
|
-
}
|
|
2783
|
-
// Resolve
|
|
2784
|
-
// working-plane pick (with snapping). null = no valid pick (cursor off the plane, edge-on).
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2808
|
+
return tfLock.size === 1 ? [...tfLock][0] : dominantAmong(e, [...tfLock], base); // 1 = that axis; 2 or 3 = whichever locked axis the cursor drags toward
|
|
2809
|
+
}
|
|
2810
|
+
// Resolve a 2nd-point destination from a base: a line-lock along the effective axis (screen-space drag), else the
|
|
2811
|
+
// free working-plane pick (with snapping). null = no valid pick (cursor off the plane, edge-on). Shared by Move/Copy
|
|
2812
|
+
// (base = tfDraft.base) and Add-member (base = drDraft) — the SAME lock (tfLock), the tools being mutually exclusive.
|
|
2813
|
+
function cmDestPointFrom(e, base) {
|
|
2814
|
+
const ax = cmEffAxis(e, base);
|
|
2815
|
+
if (ax) return cmAxisLock(e, frameBasis()[ax], base);
|
|
2788
2816
|
const r = wpPointAt(e); if (!r) return null;
|
|
2789
2817
|
return { p: r.p, snap: r.snap, type: r.type };
|
|
2790
2818
|
}
|
|
2819
|
+
function cmDestPoint(e) { return cmDestPointFrom(e, tfDraft && tfDraft.base); } // Move/Copy destination; base may be null before the base pick (cmEffAxis then returns null → free) — do NOT deref tfDraft eagerly
|
|
2791
2820
|
// the offset list is the pure core `offsetsFor` (unit-tested for linear/grid) — counts INCLUDE the original, grid skips (0,0)
|
|
2792
2821
|
function tfOffsetsFor(v, st) { return offsetsFor(v, st, tfDraft ? tfDraft.vA : null); }
|
|
2793
2822
|
function tfGhostBuild(offs) {
|
|
@@ -2908,12 +2937,7 @@ function drHudApply(pv, abs) {
|
|
|
2908
2937
|
let drDraft = null; // first pick, scene mm
|
|
2909
2938
|
let drRubber = null;
|
|
2910
2939
|
const addActive = () => !!(api && api.addModeActive && api.addModeActive());
|
|
2911
|
-
function drClear3d() { drDraft = null; if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; } // callable pre-init (all handles guarded)
|
|
2912
|
-
function drShiftLock(p, e) { // Shift = ortho along the plane's local axes (same basis as Move/Copy)
|
|
2913
|
-
if (!e || !e.shiftKey || !drDraft) return p;
|
|
2914
|
-
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);
|
|
2915
|
-
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]];
|
|
2916
|
-
}
|
|
2940
|
+
function drClear3d() { drDraft = null; tfLock.clear(); if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; } // callable pre-init (all handles guarded); clears the shared axis lock on Add disarm (mirrors cmClear3d)
|
|
2917
2941
|
// The shared "commit the 2nd draw point" transition — used by both the pointer (drClick) and typed entry
|
|
2918
2942
|
// (drHudApply). Clears local draw state BEFORE the geometry callback so the reentrant rebuild is safe.
|
|
2919
2943
|
function commitDrawPoint(p2) {
|
|
@@ -2923,17 +2947,26 @@ function commitDrawPoint(p2) {
|
|
|
2923
2947
|
if (start && api && api.onAddMember3d) api.onAddMember3d(start, p2);
|
|
2924
2948
|
}
|
|
2925
2949
|
function drClick(e) {
|
|
2926
|
-
const
|
|
2927
|
-
|
|
2928
|
-
const p =
|
|
2950
|
+
if (!drDraft) { const r0 = wpPointAt(e); if (!r0) return; notePointerPick(); drDraft = r0.p; return; } // start pick = free (bumps the gen so an open first-point typed token can't survive)
|
|
2951
|
+
const r = drDestPoint(e); if (!r) return; // 2nd pick: X/Y/Z line-lock (or Alt normal) if locked, else free snap
|
|
2952
|
+
const p = r.p;
|
|
2929
2953
|
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)
|
|
2930
2954
|
commitDrawPoint(p);
|
|
2931
2955
|
}
|
|
2956
|
+
// Add-member 2nd-point resolver — the SAME axis-lock as Move/Copy (base = drDraft): drawing a member strictly along
|
|
2957
|
+
// local X/Y/Z (the 'z' key locks the normal), toggle+combine + Shift(dominant in-plane), with level-snap; else a
|
|
2958
|
+
// free working-plane snap. Add's Alt stays "no snap" (noAlt), NOT normal-lock — a member you draw off-geometry.
|
|
2959
|
+
function drDestPoint(e) {
|
|
2960
|
+
const ax = cmEffAxis(e, drDraft, { noAlt: true });
|
|
2961
|
+
if (ax) return cmAxisLock(e, frameBasis()[ax], drDraft, { noSnap: !!(e && e.altKey) }); // Add's Alt = no snap even under a lock (skip the vertical level-snap)
|
|
2962
|
+
const r = wpPointAt(e); if (!r) return null; // Alt held here → wpPointAt returns the raw plane hit (no snap), preserved
|
|
2963
|
+
return { p: r.p, snap: r.snap, type: r.type };
|
|
2964
|
+
}
|
|
2932
2965
|
function drPreview(e) {
|
|
2933
|
-
const
|
|
2966
|
+
if (!drDraft) { const r0 = wpPointAt(e); if (!r0) { if (readout) readout.style.display = 'none'; return; } if (r0.snap) showMarker(r0.p, r0.type); else marker.visible = false; roShowCoordOnly(r0.p, e.clientX, e.clientY); return; } // before the start pick: free snap + local coords
|
|
2967
|
+
const r = drDestPoint(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
|
|
2934
2968
|
if (r.snap) showMarker(r.p, r.type); else marker.visible = false;
|
|
2935
|
-
|
|
2936
|
-
const p = drShiftLock(r.p, e);
|
|
2969
|
+
const p = r.p;
|
|
2937
2970
|
if (!drRubber) { drRubber = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]), new THREE.LineBasicMaterial({ color: 0x22d3ee })); drRubber.material.depthTest = false; drRubber.renderOrder = 997; scene.add(drRubber); }
|
|
2938
2971
|
drRubber.geometry.setFromPoints([new THREE.Vector3(...drDraft), new THREE.Vector3(...p)]); drRubber.visible = true;
|
|
2939
2972
|
const L = Math.hypot(p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]);
|
|
@@ -3031,7 +3064,19 @@ function gridPlaneZ() {
|
|
|
3031
3064
|
}
|
|
3032
3065
|
// The axis to measure on: Alt held during the 2nd pick forces a pure-vertical (Z) measurement,
|
|
3033
3066
|
// overriding the sticky axis (else a sticky X/Y would collapse the Alt-locked point to zero length).
|
|
3034
|
-
|
|
3067
|
+
// The ONE axis a dimension measures along, resolving the lock set: Alt (held on the 2nd pick) forces vertical Z;
|
|
3068
|
+
// empty lock → 'free' (aligned a→b); one locked axis → that; 2–3 locked → the axis the span a→b runs most along
|
|
3069
|
+
// (dominantAxis3d, by |component along the frame axis|). The 2nd point itself still free-snaps; only the measured
|
|
3070
|
+
// direction is constrained. Frame-aware: the resolved axis feeds dimAxisDir/dim3dGeom exactly as before.
|
|
3071
|
+
function dimEffAxis(alt, a, b) {
|
|
3072
|
+
if (alt && dimDraft3d) return 'z';
|
|
3073
|
+
if (!dimLock.size) return 'free';
|
|
3074
|
+
if (dimLock.size === 1) return [...dimLock][0];
|
|
3075
|
+
if (!a || !b) return [...dimLock][0]; // no span yet (1st-point preview) → the first locked axis
|
|
3076
|
+
const map = {};
|
|
3077
|
+
for (const k of dimLock) map[k] = dimAxisDir(k) || (k === 'x' ? [1, 0, 0] : k === 'y' ? [0, 1, 0] : [0, 0, 1]); // dominance uses the SAME axis the measurement will (dimAxisDir: frame X/Y or world; z always world elevation) — never pick one axis and measure another (review finding)
|
|
3078
|
+
return dominantAxis3d(a, b, map);
|
|
3079
|
+
}
|
|
3035
3080
|
// UCS Stage 5: the world direction a frame-aware x|y dim measures along — the LOCAL frame's X/Y, captured at
|
|
3036
3081
|
// placement so the dim survives frame changes/reset/reload. null when: no local frame; a ◇ Plane shadows the frame
|
|
3037
3082
|
// (dims go global under a plane — never a SHADOWED frame3d, matching the chip/gizmo); or axis is z/free (world).
|
|
@@ -3073,7 +3118,7 @@ function onDown(e) {
|
|
|
3073
3118
|
const r = dimPointAt(e, dimDraft3d && dimDraft3d.a); if (!r) return;
|
|
3074
3119
|
if (!dimDraft3d) { dimDraft3d = { a: r.p }; dimCandidates3d = null; }
|
|
3075
3120
|
else {
|
|
3076
|
-
const a = dimDraft3d.a, b = r.p, axis =
|
|
3121
|
+
const a = dimDraft3d.a, b = r.p, axis = dimEffAxis(e.altKey, a, b), axisDir = dimAxisDir(axis);
|
|
3077
3122
|
const g = dim3dGeom(a, b, axis, axisDir);
|
|
3078
3123
|
dimDraft3d = null; dimPreviewLine.visible = false; marker.visible = false; readout.style.display = 'none'; dimCandidates3d = null;
|
|
3079
3124
|
if (g.valueMm > 1 && api && api.onAddDim3d) api.onAddDim3d({ id: api.newDim3dId(), a, b, axis, ...(axisDir ? { axisDir } : {}) });
|
|
@@ -3407,6 +3452,26 @@ function roShowCoordOnly(worldPt, x, y) {
|
|
|
3407
3452
|
roCoords(worldPt);
|
|
3408
3453
|
readout.style.left = (x + 14) + 'px'; readout.style.top = (y + 14) + 'px'; readout.style.display = 'block';
|
|
3409
3454
|
}
|
|
3455
|
+
// Live dim preview (snap marker + preview line + readout) from lastHoverXY — SYNCHRONOUS, so setDimAxis can refresh it
|
|
3456
|
+
// immediately on a key/button (not one animation frame later); `alt` is the live modifier (dim measures Z on Alt).
|
|
3457
|
+
function dimHoverPreview(alt) {
|
|
3458
|
+
if (!dimPreviewLine || !canvasEl || !lastHoverXY) return;
|
|
3459
|
+
const r = dimPointAt({ clientX: lastHoverXY[0], clientY: lastHoverXY[1], altKey: alt }, dimDraft3d && dimDraft3d.a);
|
|
3460
|
+
const snapped = !!(r && r.type);
|
|
3461
|
+
if (snapped) showMarker(r.p, r.type); else marker.visible = false; // reticle only on a real snap (free point rides the preview line)
|
|
3462
|
+
canvasEl.style.cursor = snapped ? 'none' : 'crosshair'; // at a snap the reticle IS the cursor (Tekla) — hide the native crosshair
|
|
3463
|
+
if (dimDraft3d && r) {
|
|
3464
|
+
const ax = dimEffAxis(alt, dimDraft3d.a, r.p);
|
|
3465
|
+
const g = dim3dGeom(dimDraft3d.a, r.p, ax, dimAxisDir(ax)); // live preview matches what the commit will store
|
|
3466
|
+
dimPreviewLine.geometry.setFromPoints([new THREE.Vector3(...g.p1), new THREE.Vector3(...g.p2)]); dimPreviewLine.visible = true;
|
|
3467
|
+
readout._dist.textContent = api.fmtLen ? api.fmtLen(g.valueMm) : (g.valueMm / 304.8).toFixed(2) + ' ft';
|
|
3468
|
+
readout._type.textContent = (r.type ? ' · ' + r.type : (alt ? ' ↕' : '')) + dimLockChipTxt(); // show the measure-axis lock (· measuring X′) alongside the snap type
|
|
3469
|
+
readout.style.left = (lastHoverXY[0] + 14) + 'px'; readout.style.top = (lastHoverXY[1] + 14) + 'px'; readout.style.display = 'block';
|
|
3470
|
+
roCoords(r.p); // local coords of the second dim point
|
|
3471
|
+
} else { dimPreviewLine.visible = false;
|
|
3472
|
+
if (r && !dimDraft3d) roShowCoordOnly(r.p, lastHoverXY[0], lastHoverXY[1]); // first dim point: coords-only chip
|
|
3473
|
+
else if (readout) readout.style.display = 'none'; } // no point (or a draft with the cursor off-plane) → clear the chip
|
|
3474
|
+
}
|
|
3410
3475
|
function onHoverMove(e) {
|
|
3411
3476
|
lastHoverXY = [e.clientX, e.clientY];
|
|
3412
3477
|
dimLastAlt = e.altKey; // remembered so the rAF body can rebuild a synthetic event
|
|
@@ -3444,25 +3509,7 @@ function onHoverMove(e) {
|
|
|
3444
3509
|
if (r) roShowCoordOnly(r.p, lastHoverXY[0], lastHoverXY[1]); else if (readout) readout.style.display = 'none'; } // local coords of the base point before it's picked
|
|
3445
3510
|
updateStatusChip(); return; }
|
|
3446
3511
|
if (clipMode) { canvasEl.style.cursor = 'crosshair'; if (clipMode === 'box') clipBoxPreviewAt(lastHoverXY[0], lastHoverXY[1]); return; } // armed clip pick: crosshair (+ live box preview while drawing)
|
|
3447
|
-
if (dimMode3d) {
|
|
3448
|
-
const ev = { clientX: lastHoverXY[0], clientY: lastHoverXY[1], altKey: dimLastAlt };
|
|
3449
|
-
const r = dimPointAt(ev, dimDraft3d && dimDraft3d.a);
|
|
3450
|
-
const snapped = !!(r && r.type);
|
|
3451
|
-
if (snapped) showMarker(r.p, r.type); else marker.visible = false; // reticle only on a real snap (free point rides the preview line) — parity with 2D snapClear
|
|
3452
|
-
canvasEl.style.cursor = snapped ? 'none' : 'crosshair'; // at a snap the reticle IS the cursor (Tekla) — hide the native crosshair so it doesn't double up on the marker
|
|
3453
|
-
if (dimDraft3d && r) {
|
|
3454
|
-
const ax = dimEffectiveAxis(dimLastAlt);
|
|
3455
|
-
const g = dim3dGeom(dimDraft3d.a, r.p, ax, dimAxisDir(ax)); // live preview matches what the commit will store
|
|
3456
|
-
dimPreviewLine.geometry.setFromPoints([new THREE.Vector3(...g.p1), new THREE.Vector3(...g.p2)]); dimPreviewLine.visible = true;
|
|
3457
|
-
readout._dist.textContent = api.fmtLen ? api.fmtLen(g.valueMm) : (g.valueMm / 304.8).toFixed(2) + ' ft';
|
|
3458
|
-
readout._type.textContent = r.type ? ' · ' + r.type : (dimLastAlt ? ' ↕' : '');
|
|
3459
|
-
readout.style.left = (lastHoverXY[0] + 14) + 'px'; readout.style.top = (lastHoverXY[1] + 14) + 'px'; readout.style.display = 'block';
|
|
3460
|
-
roCoords(r.p); // local coords of the second dim point
|
|
3461
|
-
} else { dimPreviewLine.visible = false;
|
|
3462
|
-
if (r && !dimDraft3d) roShowCoordOnly(r.p, lastHoverXY[0], lastHoverXY[1]); // first dim point: coords-only chip
|
|
3463
|
-
else if (readout) readout.style.display = 'none'; } // no point (or a draft with the cursor off-plane) → clear the chip, don't freeze the last readout
|
|
3464
|
-
return;
|
|
3465
|
-
}
|
|
3512
|
+
if (dimMode3d) { dimHoverPreview(dimLastAlt); return; } // dim tool: snap marker + live preview line + readout (extracted so setDimAxis can refresh it synchronously)
|
|
3466
3513
|
if (framePicking()) { // 3-click UCS set in progress: live rubber-band X/Y + Z-flip arrow, snap marker at the cursor
|
|
3467
3514
|
canvasEl.style.cursor = 'crosshair';
|
|
3468
3515
|
renderFramePickPreview({ clientX: lastHoverXY[0], clientY: lastHoverXY[1], altKey: dimLastAlt });
|
|
@@ -3493,6 +3540,8 @@ function onHoverMove(e) {
|
|
|
3493
3540
|
if (top !== hoverId) { setHover(top); updateStatusChip(); }
|
|
3494
3541
|
});
|
|
3495
3542
|
}
|
|
3543
|
+
// The shared axis-lock chip suffix (' · X, Y locked') from tfLock — used by both the Move/Copy and Add-member chips.
|
|
3544
|
+
function lockChipTxt() { const _lk = ['u', 'v', 'n'].filter((a) => tfLock.has(a)); return _lk.length ? ' · ' + _lk.map((a) => (a === 'u' ? 'X' : a === 'v' ? 'Y' : 'Z')).join(', ') + ' locked' : ''; }
|
|
3496
3545
|
function updateStatusChip() {
|
|
3497
3546
|
if (!hoverChip || !canvasEl) return;
|
|
3498
3547
|
const rect = canvasEl.getBoundingClientRect();
|
|
@@ -3500,8 +3549,8 @@ function updateStatusChip() {
|
|
|
3500
3549
|
const showId = hoverId || (selIds.size === 1 ? [...selIds][0] : null);
|
|
3501
3550
|
if (wpMode === 'face') txt = 'Click a member face — the working plane lands on it · Esc to cancel';
|
|
3502
3551
|
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] || '';
|
|
3503
|
-
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';
|
|
3504
|
-
else if (cmActive()) { const st = cmActive(),
|
|
3552
|
+
else if (addActive()) txt = drDraft ? 'Click the member end · X/Y/Z lock to the local axes, Shift straight · Esc drops the start' + lockChipTxt() : 'Draw a member on the working plane — click the start point · Esc exits';
|
|
3553
|
+
else if (cmActive()) { const st = cmActive(), lock = lockChipTxt();
|
|
3505
3554
|
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')
|
|
3506
3555
|
: (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; }
|
|
3507
3556
|
else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
|
|
@@ -3650,6 +3699,10 @@ window.Steel3DView = {
|
|
|
3650
3699
|
epScreen: (id) => { const m = memberById(id); if (!m || !canvasEl) return null; const g = memberGeometry(m, api.ptPerFt(), api.defaultTosMm()); const rect = canvasEl.getBoundingClientRect(); const proj = (p) => { const v = new THREE.Vector3(p[0], p[1], p[2]).project(camera); return { x: rect.left + (v.x * 0.5 + 0.5) * rect.width, y: rect.top + (-v.y * 0.5 + 0.5) * rect.height }; }; return { a: proj(g.line[0]), b: proj(g.line[1]) }; }, // project a member's endpoints to viewport px — test probe for endpoint-drag tests
|
|
3651
3700
|
refreshGrid: buildStructGrid, // grid edited in the panel → re-render without a full rebuild
|
|
3652
3701
|
gridInfo: () => ({ lines: structGridGroup ? 1 : 0, labels: gridLabelGroup ? gridLabelGroup.children.length : 0 }), // test helper
|
|
3702
|
+
wpProbe: () => { // test helper: the "Show plane" reference surface — asserts no grid, bbox-sized surface, light-blue colour. `extent` is the projected u/v footprint the surface was actually sized to (work-area/tilted-plane aware), null for the fallback square. Surface w == extent.uSpan + 2*extent.margin.
|
|
3703
|
+
if (!wpGroup) return { group: false, extent: wpExtent };
|
|
3704
|
+
return { group: true, extent: wpExtent, children: wpGroup.children.map((c) => ({ type: c.type, color: c.material && '#' + c.material.color.getHexString(), opacity: c.material && c.material.opacity, w: c.geometry && c.geometry.parameters ? c.geometry.parameters.width : null, h: c.geometry && c.geometry.parameters ? c.geometry.parameters.height : null })) };
|
|
3705
|
+
},
|
|
3653
3706
|
toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups,
|
|
3654
3707
|
setClipMode, clipMode: clipModeOn, addClipBox, toggleClip, removeClip, clearClips, getClips, renameClip, selectClip, setSelectedClips, selectedClips, deleteSelectedClips, clipState, setClipState,
|
|
3655
3708
|
isolateSelected, clearIsolation, isIsolated,
|
|
@@ -3660,7 +3713,7 @@ window.Steel3DView = {
|
|
|
3660
3713
|
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)
|
|
3661
3714
|
cmEscape, cmHasBase, cmClear3d, setCmAxis, cmLastClient, cmHudApply,
|
|
3662
3715
|
drHudApply, pointEntryBegin, pointEntryEnd, drHasStart: () => !!drDraft, // UCS stage 3: shared typed point-entry HUD (Move/Copy + Add)
|
|
3663
|
-
drClear3d, drEscape: () => { if (drDraft) { drDraft = null;
|
|
3716
|
+
drClear3d, drEscape: () => { if (drDraft) { drDraft = null; if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; return true; } return false; }, // Esc drops the START only — KEEP the axis lock (tfLock) so the next member reuses it (matches the chip + Move/Copy step-back); full disarm (drClear3d) clears the lock
|
|
3664
3717
|
toggleDimTool, setDimAxis, dimAxis, setDims3dVisible, dims3dVisible, refreshDims,
|
|
3665
3718
|
setSnapOnly: setSnapOnly3d, snapOnly: () => snapOnly3d, dimToolOn: () => dimMode3d, rightDragged: () => rightMoved, // Tekla-style snap override (right-click menu lives in steel-editor.html)
|
|
3666
3719
|
refreshOverlayDims,
|
|
@@ -3669,6 +3722,10 @@ window.Steel3DView = {
|
|
|
3669
3722
|
dims3dCount: () => (api && api.getDims3d ? (api.getDims3d() || []).length : 0),
|
|
3670
3723
|
dims3dRecords: () => (api && api.getDims3d ? (api.getDims3d() || []).map((d) => ({ id: d.id, axis: d.axis, axisDir: d.axisDir || null, valueMm: dim3dGeom(d.a, d.b, d.axis, d.axisDir).valueMm })) : []), // test probe: lightweight per-dim {axis, axisDir, rendered length} for E2E assertions (frame-aware capture + read==write)
|
|
3671
3724
|
dimAxisBarLabels: () => Array.from(document.querySelectorAll('#m3dDimAxis button')).map((b) => b.textContent), // test probe: the visible axis-control labels (3-state disclosure)
|
|
3725
|
+
dimLockSet: () => [...dimLock], // test probe: the dimension's locked measure axes (x|y|z)
|
|
3726
|
+
axisLockSet: () => [...tfLock], // test probe: the shared Move/Copy + Add line-lock set (u|v|n)
|
|
3727
|
+
addDraftPt: () => (drDraft ? [...drDraft] : null), // test probe: the Add-member first pick (scene mm), or null
|
|
3728
|
+
addDestAt: (x, y) => { if (!drDraft) return null; const r = drDestPoint({ clientX: x, clientY: y, shiftKey: false, altKey: false }); return r ? { p: r.p, snap: r.snap } : null; }, // test probe: the resolved 2nd draw point at a cursor (respects the axis lock) — read-only, no commit
|
|
3672
3729
|
selDims3dCount: () => (api && api.selDim3d ? (api.selDim3d() || []).length : 0), // test helper: how many 3D dims are selected
|
|
3673
3730
|
dim3dLabelOf: (i) => { const el = dimLabelPool[i]; if (!el || el.style.display === 'none') return null; const r = el.getBoundingClientRect(); return { x: r.left + r.width / 2, y: r.top + r.height / 2, text: el.textContent }; },
|
|
3674
3731
|
debug, probe, screenOf, centerOf, worldOf, snapCandidatesScreen, clipHandlesScreen,
|
|
@@ -731,7 +731,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
731
731
|
<!-- 3D Dimension cluster — relocated here from the 3D toolbar so Dimension has ONE home; shown only in 3D (applyViewState). Same ids so steel-3d-view.js reflectDimBar() still drives it. -->
|
|
732
732
|
<span id=dim3dWrap style="display:none;align-items:center;gap:8px">
|
|
733
733
|
<button id=m3dDim data-tip="Measure in 3D — click two snapped points (D); the axis buttons follow the active coordinate frame (X′/Y′/Elev local, World X/Y under a ◇ Plane); Alt = vertical; right-click = restrict snap">⊢ Dimension</button>
|
|
734
|
-
<div class=seg-group id=m3dDimAxis style="display:none"><button data-d3axis=free class=on data-tip="Free 3D measurement (F)">Free</button><button data-d3axis=x data-tip="Lock measurement to X (X)">X</button><button data-d3axis=y data-tip="Lock measurement to Y (Y)">Y</button><button data-d3axis=z data-tip="Lock to Z / vertical (Z); Alt = quick vertical">Z</button></div>
|
|
734
|
+
<div class=seg-group id=m3dDimAxis role=group aria-label="Dimension measure axis (X/Y/Z combine)" style="display:none"><button data-d3axis=free class=on aria-pressed=true data-tip="Free 3D measurement — clears the axis lock (F)">Free</button><button data-d3axis=x data-tip="Lock measurement to X (X)">X</button><button data-d3axis=y data-tip="Lock measurement to Y (Y)">Y</button><button data-d3axis=z data-tip="Lock to Z / vertical (Z); Alt = quick vertical">Z</button></div>
|
|
735
735
|
<button id=m3dDimShow data-tip="Show or hide placed 3D dimensions" style="display:none">Hide dims</button>
|
|
736
736
|
</span>
|
|
737
737
|
<div class=cmwrap>
|
|
@@ -880,7 +880,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
880
880
|
<input id=m3dWpOff inputmode=decimal placeholder="16'-6" autocomplete=off data-tip="Offset along the plane normal (ft-in)">
|
|
881
881
|
</div>
|
|
882
882
|
<hr>
|
|
883
|
-
<label data-tip="Show or hide the plane
|
|
883
|
+
<label data-tip="Show or hide the reference plane surface"><input type=checkbox id=m3dWpShow checked> Show plane</label>
|
|
884
884
|
<button data-wp=reset data-tip="Back to the active plan's level">Reset to level</button>
|
|
885
885
|
</div>
|
|
886
886
|
</div>
|
|
@@ -4185,7 +4185,7 @@ addEventListener('keydown',e=>{
|
|
|
4185
4185
|
if(hadReg)toast('Regular grid lines come from the grid spacing — remove them in “Grid lines…”. Only free grid lines are deletable here.');
|
|
4186
4186
|
return;}
|
|
4187
4187
|
if(!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==='d'&&!view3d){e.preventDefault();dimMode=!dimMode;setDimMode();render();setLastCmd('Dimension',()=>{if(!dimMode){dimMode=true;setDimMode();render();}});return;} // D — toggle the Dimension tool
|
|
4188
|
-
if(!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==='a'
|
|
4188
|
+
if(!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==='a'){e.preventDefault();document.getElementById('mAdd').click();return;} // A — toggle the Add-member tool in 2D AND 3D (mirrors D=Dimension; plain 'a', Ctrl+A is still select-all). The mAdd click owns the arm/disarm-conflicts + setLastCmd logic.
|
|
4189
4189
|
if(dimMode&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const dk=e.key.toLowerCase();
|
|
4190
4190
|
if(dk==='x'||dk==='y'||dk==='f'){e.preventDefault();dimSetAxis(dk==='f'?'free':dk);dimDraft&&svg.querySelector('#dimPrevG')&&dimRefreshPrev();return;}
|
|
4191
4191
|
if(dk==='c'){e.preventDefault();toggleDimChain();return;}} // C — toggle chained (continuous) dimensioning
|
|
@@ -4195,7 +4195,9 @@ addEventListener('keydown',e=>{
|
|
|
4195
4195
|
else{const wa=ak==='f'?'free':ak;cmAxis=(wa!=='free'&&cmAxis===wa)?'free':wa;cmRefreshPrev();}return;} // same axis key again toggles the lock off (F always frees)
|
|
4196
4196
|
const hasBase=cmDraft||(view3d&&window.Steel3DView&&window.Steel3DView.cmHasBase&&window.Steel3DView.cmHasBase());
|
|
4197
4197
|
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
|
|
4198
|
-
if(view3d&&mode==='add'&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey
|
|
4198
|
+
if(view3d&&mode==='add'&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ak=e.key.toLowerCase();
|
|
4199
|
+
if(ak==='x'||ak==='y'||ak==='z'||ak==='f'){e.preventDefault();if(window.Steel3DView&&window.Steel3DView.setCmAxis)window.Steel3DView.setCmAxis(ak,e.shiftKey);return;} // 3D Add-member: X/Y/Z/F line-lock the draw to a local axis (same shared lock as Move/Copy; 'z'=normal, Alt stays no-snap)
|
|
4200
|
+
if(/^[0-9.\-',]$/.test(e.key)){e.preventDefault();cmHudShow(e.key);return;}} // typing opens the shared point-entry HUD (own branch, OUTSIDE the Move/Copy guard)
|
|
4199
4201
|
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)
|
|
4200
4202
|
if(ck==='m'){e.preventDefault();armCm('move',false);return;}
|
|
4201
4203
|
if(ck==='c'){e.preventDefault();armCm('copy',false);return;}}
|
|
@@ -5488,7 +5490,7 @@ function wire3DBar(){if(bar3dWired||!window.Steel3DView)return;bar3dWired=true;
|
|
|
5488
5490
|
document.getElementById('m3dRef').onchange=e=>window.Steel3DView.setRefLine(e.target.checked); // View ▾ menu checkbox
|
|
5489
5491
|
const d3=window.Steel3DView;
|
|
5490
5492
|
document.getElementById('m3dDim').onclick=()=>{d3.toggleDimTool();setLastCmd('Dimension',()=>{const b=document.getElementById('m3dDim');if(b&&!b.classList.contains('on'))d3.toggleDimTool();});}; // toggleDimTool()'s reflectDimBar() owns the button .on class + axis/show visibility (single source, no duplicate DOM toggles)
|
|
5491
|
-
document.querySelectorAll('#m3dDimAxis button').forEach(b=>b.onclick=()=>
|
|
5493
|
+
document.querySelectorAll('#m3dDimAxis button').forEach(b=>b.onclick=()=>d3.setDimAxis(b.dataset.d3axis)); // toggle+combine the measure-axis lock; setDimAxis owns the multi-state button refresh (reflectDimAxisBar), not single-active seg3dActive
|
|
5492
5494
|
document.getElementById('m3dDimShow').onclick=()=>{const on=!d3.dims3dVisible();d3.setDims3dVisible(on);document.getElementById('m3dDimShow').textContent=on?'Hide dims':'Show dims';};
|
|
5493
5495
|
// Clip: the ⬡ Clip button opens a small menu (Add clip plane / box / Clear). While the plane-pick is armed the
|
|
5494
5496
|
// button becomes a cancel target (handled by onClipModeChange). Outside-click closes the menu (capture mousedown).
|