@floless/app 0.134.0 → 0.134.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 +4995 -2851
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +93 -6
- package/dist/web/app.css +34 -8
- package/dist/web/aware.js +590 -102
- package/dist/web/commands-filter.js +79 -5
- package/dist/web/commands-shell.js +98 -11
- package/dist/web/commands-steel.js +7 -7
- package/dist/web/index.html +17 -15
- package/dist/web/instructor.js +89 -34
- package/dist/web/steel-3d-core.js +242 -3
- package/dist/web/steel-3d-view.js +261 -13
- package/dist/web/steel-editor.html +230 -11
- package/dist/web/steel-filter-core.js +189 -16
- package/dist/web/steel-filter.html +865 -46
- package/dist/web/steel-model-commands.js +23 -2
- package/dist/web/steel-model-v2-commands.js +124 -0
- package/dist/web/workspaces.js +369 -69
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ import { RoomEnvironment } from 'three/addons/RoomEnvironment.js';
|
|
|
20
20
|
import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-materials.js';
|
|
21
21
|
import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
|
|
22
22
|
import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
|
|
23
|
-
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, POSITION_OFFSET_SNAP_MM, POSITION_ROT_SNAP_DEG, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
23
|
+
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, slideEndpoints, swingBasis, swingEndpoint, swingBarriers, clampSwingTheta, POSITION_SWING_MARGIN_RAD, POSITION_OFFSET_SNAP_MM, POSITION_ROT_SNAP_DEG, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
24
24
|
// `gridGeometry`, `gridCandidates3d` and `mmPerPx` live behind the host's model read boundary because
|
|
25
25
|
// their display-scale argument is meaningless on a world-mm model grid.
|
|
26
26
|
import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
|
|
@@ -4672,7 +4672,9 @@ function onDblClick(e) {
|
|
|
4672
4672
|
pending = dragging = null; posInteraction = 'idle'; hidePositionLeader();
|
|
4673
4673
|
if (controls) controls.enabled = true; // defensive: normal dblclick sequencing already re-enabled controls via onUp, but if this branch is reached abnormally and the HUD does NOT open below, never strand the camera disabled (openPositionHud → setPositionTyping(true) re-freezes it when it does open)
|
|
4674
4674
|
const scr = positionGizmoHandlesScreen();
|
|
4675
|
-
const p = scr && (ph === 'depth' ? scr.depthTip : ph === 'width' ? scr.widthTip
|
|
4675
|
+
const p = scr && (ph === 'depth' ? scr.depthTip : ph === 'width' ? scr.widthTip
|
|
4676
|
+
: ph === 'slide' ? scr.slideTip : ph === 'swingPlan' ? scr.swingPlanHandle
|
|
4677
|
+
: ph === 'swingElev' ? scr.swingElevHandle : scr.rotHandle);
|
|
4676
4678
|
if (p && api && api.openPositionHud) api.openPositionHud([...selIds][0], ph, [p.x, p.y]);
|
|
4677
4679
|
return;
|
|
4678
4680
|
}
|
|
@@ -5691,8 +5693,26 @@ const POS_HANDLE_TIP = {
|
|
|
5691
5693
|
depth: 'Slides the section along its depth axis. Drag, or double-click to type an exact value — ¼" snap; hold Shift for no snap.',
|
|
5692
5694
|
width: 'Slides the section along its width axis. Drag, or double-click to type an exact value — ¼" snap; hold Shift for no snap.',
|
|
5693
5695
|
rot: 'Rolls the section about the reference line. Drag, or double-click to type an exact angle — 5° snap; hold Shift for no snap.',
|
|
5694
|
-
|
|
5696
|
+
// Slice 3b.1 — the three that move the reference LINE (and so the member itself), not the profile on it.
|
|
5697
|
+
// Each leads with that consequence, because it is the difference a detailer must not have to guess.
|
|
5698
|
+
slide: 'Slides the member along its own axis — both work points move together, length unchanged. Drag, or double-click to type an exact value — ¼" snap; hold Shift for no snap.',
|
|
5699
|
+
swingPlan: 'Swings the member in plan about its start point — the far end moves, the slope is kept. Drag, or double-click to type an exact angle — 5° snap; hold Shift for no snap.',
|
|
5700
|
+
swingElev: 'Tilts the member up or down about its start point — the far end moves, its plan direction is kept. Drag, or double-click to type an exact angle — 5° snap; hold Shift for no snap.',
|
|
5701
|
+
// Was unreachable until 3b.1 (pickPositionGizmoHandle could only answer depth/width/rot), and its old
|
|
5702
|
+
// wording — "This point never moves" — became false the moment the member-axis arrow shipped.
|
|
5703
|
+
anchor: 'Reference-line start — the profile offsets and both swings pivot here. The member-axis arrow slides it along with the far end; the dot itself is not a handle.',
|
|
5695
5704
|
};
|
|
5705
|
+
// The reference-line handles' geometry (ui-ux pass). BOTH swing arcs are inherently centred on the member
|
|
5706
|
+
// axis — each rotates x̂ within its own plane — so at ±x̂ two same-radius arcs would COINCIDE and the
|
|
5707
|
+
// screen-space nearest-point pick would be arbitrary. Hence two lobes per arc, flanking +x̂ only, with a
|
|
5708
|
+
// dead zone over the axis itself: nearest arc point to the slide arrow's tip ≈42 px, plan lobe to elevation
|
|
5709
|
+
// lobe ≈55 px, both clear of the 26 px combined pick tolerance. Nothing is lost by not drawing near −x̂
|
|
5710
|
+
// (dragging the member "from behind" is not a real interaction), and the pointer may still be dragged past
|
|
5711
|
+
// the drawn lobe — the arc is the affordance, not the limit.
|
|
5712
|
+
const POS_SWING_R = 1.15; // both swing arcs, outside the 1.0 arrows and the 0.72 roll arc
|
|
5713
|
+
const POS_LOBE_START = 1 / 12; // 15° off the member axis, in PI units
|
|
5714
|
+
const POS_LOBE_SWEEP = 1 / 3; // ...through to 75°
|
|
5715
|
+
const POS_SWING_MARGIN_RAD = POSITION_SWING_MARGIN_RAD; // shared with the typed path — see steel-3d-core; if the two drift, a number the drag allows gets refused when typed
|
|
5696
5716
|
function disposePositionGizmo() {
|
|
5697
5717
|
hidePositionLeader(); // the transient drag leader never outlives a gizmo rebuild
|
|
5698
5718
|
if (!positionGizmo) return;
|
|
@@ -5748,6 +5768,31 @@ function renderPositionGizmo() {
|
|
|
5748
5768
|
pts.push(yv.clone().multiplyScalar(Math.cos(p) * R).add(zv.clone().multiplyScalar(Math.sin(p) * R))); }
|
|
5749
5769
|
const arc = new THREE.Line(new THREE.BufferGeometry().setFromPoints(pts), new THREE.LineBasicMaterial({ color: 0xef4444 }));
|
|
5750
5770
|
arc.material.depthTest = false; arc.renderOrder = 997; arc.userData = { posHandle: 'rot', arc: true }; g.add(arc);
|
|
5771
|
+
// --- Reference-line handles (slice 3b.1) ---------------------------------------------------------
|
|
5772
|
+
// These move the member's WORK POINTS; the three above move the profile within a fixed reference line.
|
|
5773
|
+
// COLOUR IS BY AXIS, not by that family split: the shipped mapping is already blue=Z(depth),
|
|
5774
|
+
// green=Y(width), red=X (the roll arc rotates ABOUT x), each axis carrying only one of its two degrees
|
|
5775
|
+
// of freedom. These complete the pairs — red for the X translate (pairing with the red X roll arc, told
|
|
5776
|
+
// apart by shape exactly as the blue/green arrows already are), green for the rotation about Y, blue for
|
|
5777
|
+
// the plan swing. The last is a LABELLED approximation: it rotates about basis-up, which equals the local
|
|
5778
|
+
// zAxis only for a level unrolled member — which is why its copy says "in plan" and never "depth axis".
|
|
5779
|
+
// The palette is locked; this adds no hue.
|
|
5780
|
+
if (st.handles && st.handles.slide && st.handles.slide.available) arrow(st.xAxis, 0xef4444, 'slide');
|
|
5781
|
+
const swingArc = (axisArr, col, tag) => {
|
|
5782
|
+
const b = axisArr && swingBasis(st.anchor, st.end, axisArr);
|
|
5783
|
+
if (!b) { console.warn('steel-3d: a swing arc the editor reports as available has no swing plane —', tag); return; } // must not vanish silently: the handle would then be un-drawable, un-pickable and un-diagnosable
|
|
5784
|
+
for (const side of [1, -1]) {
|
|
5785
|
+
const pts = [];
|
|
5786
|
+
for (let i = 0; i <= 36; i++) {
|
|
5787
|
+
const p = side * (POS_LOBE_START + (i / 36) * POS_LOBE_SWEEP) * Math.PI, c = Math.cos(p) * POS_SWING_R, s = Math.sin(p) * POS_SWING_R;
|
|
5788
|
+
pts.push(new THREE.Vector3(b.e1[0] * c + b.e2[0] * s, b.e1[1] * c + b.e2[1] * s, b.e1[2] * c + b.e2[2] * s));
|
|
5789
|
+
}
|
|
5790
|
+
const lobe = new THREE.Line(new THREE.BufferGeometry().setFromPoints(pts), new THREE.LineBasicMaterial({ color: col }));
|
|
5791
|
+
lobe.material.depthTest = false; lobe.renderOrder = 997; lobe.userData = { posHandle: tag, arc: true }; g.add(lobe);
|
|
5792
|
+
}
|
|
5793
|
+
};
|
|
5794
|
+
if (st.handles && st.handles.swingPlan && st.handles.swingPlan.available) swingArc(st.up, 0x3b82f6, 'swingPlan');
|
|
5795
|
+
if (st.handles && st.handles.swingElev && st.handles.swingElev.available) swingArc(st.yAxis, 0x22c55e, 'swingElev');
|
|
5751
5796
|
// Anchor dot (amber) — the reference-line start the whole gizmo pivots on.
|
|
5752
5797
|
const dot = new THREE.Mesh(new THREE.SphereGeometry(0.08, 12, 8), new THREE.MeshBasicMaterial({ color: 0xf59e0b }));
|
|
5753
5798
|
dot.material.depthTest = false; dot.renderOrder = 999; dot.userData = { posHandle: 'anchor' }; g.add(dot);
|
|
@@ -5791,7 +5836,20 @@ function positionGizmoHandlesScreen() {
|
|
|
5791
5836
|
const rotArr = [posGizmoState.yAxis[0] * 0.51 + posGizmoState.zAxis[0] * 0.51,
|
|
5792
5837
|
posGizmoState.yAxis[1] * 0.51 + posGizmoState.zAxis[1] * 0.51,
|
|
5793
5838
|
posGizmoState.yAxis[2] * 0.51 + posGizmoState.zAxis[2] * 0.51];
|
|
5794
|
-
|
|
5839
|
+
// Slice 3b.1 grab points. The swing grabs sit mid-lobe (45° off the member axis) on the +side lobe —
|
|
5840
|
+
// the same point the pick samples nearest, so an E2E drag from here lands on the handle it named.
|
|
5841
|
+
const swingGrab = (axisArr) => {
|
|
5842
|
+
const b = axisArr && posGizmoState.end && swingBasis(posGizmoState.anchor, posGizmoState.end, axisArr);
|
|
5843
|
+
if (!b) return null;
|
|
5844
|
+
const p = (POS_LOBE_START + POS_LOBE_SWEEP / 2) * Math.PI, c = Math.cos(p), s = Math.sin(p);
|
|
5845
|
+
return at([b.e1[0] * c + b.e2[0] * s, b.e1[1] * c + b.e2[1] * s, b.e1[2] * c + b.e2[2] * s], POS_SWING_R);
|
|
5846
|
+
};
|
|
5847
|
+
const h = posGizmoState.handles;
|
|
5848
|
+
return { anchor: toS(O), depthTip: at(posGizmoState.zAxis, 1), widthTip: at(posGizmoState.yAxis, 1), rotHandle: at(rotArr, 1),
|
|
5849
|
+
slideTip: h && h.slide && h.slide.available ? at(posGizmoState.xAxis, 1) : null,
|
|
5850
|
+
swingPlanHandle: h && h.swingPlan && h.swingPlan.available ? swingGrab(posGizmoState.up) : null,
|
|
5851
|
+
swingElevHandle: h && h.swingElev && h.swingElev.available ? swingGrab(posGizmoState.yAxis) : null,
|
|
5852
|
+
handles: h || null, available: true };
|
|
5795
5853
|
}
|
|
5796
5854
|
function setPositionGizmoVisible(on) { positionGizmoVisible = !!on; syncGizmoVisibility(); } // ⋯ Display toggle → editor pushes the flag (also (un)hides the frame gizmo)
|
|
5797
5855
|
// The editor's docked numeric HUD is open on a handle → freeze the camera so orbit/zoom can't drift the anchor
|
|
@@ -5845,20 +5903,69 @@ function posGizmoArcAngle(e, st) {
|
|
|
5845
5903
|
const d = new THREE.Vector3().subVectors(hit, O);
|
|
5846
5904
|
return Math.atan2(d.dot(new THREE.Vector3(st.zAxis[0], st.zAxis[1], st.zAxis[2])), d.dot(new THREE.Vector3(st.yAxis[0], st.yAxis[1], st.yAxis[2])));
|
|
5847
5905
|
}
|
|
5906
|
+
/**
|
|
5907
|
+
* The pointer's angle in a swing's own plane, measured in the FROZEN in-plane basis: `atan2(d·e2, d·e1)`
|
|
5908
|
+
* with `e1 × e2 = axis`. Because the basis is right-handed about the rotation axis, a positive angle is
|
|
5909
|
+
* the same sweep whichever side of the screen the camera is on — which a screen-pixel delta cannot give,
|
|
5910
|
+
* and which is why the arc is drawn in this same basis. null when the ray is parallel to the plane.
|
|
5911
|
+
*/
|
|
5912
|
+
function posSwingAngle(e, st, axisArr, basis) {
|
|
5913
|
+
if (!axisArr || !basis) return null;
|
|
5914
|
+
const ray = posGizmoRay(e);
|
|
5915
|
+
const O = new THREE.Vector3(st.anchor[0], st.anchor[1], st.anchor[2]);
|
|
5916
|
+
const plane = new THREE.Plane().setFromNormalAndCoplanarPoint(new THREE.Vector3(axisArr[0], axisArr[1], axisArr[2]).normalize(), O);
|
|
5917
|
+
const hit = new THREE.Vector3(); if (!ray.intersectPlane(plane, hit)) return null;
|
|
5918
|
+
const d = new THREE.Vector3().subVectors(hit, O);
|
|
5919
|
+
return Math.atan2(d.dot(new THREE.Vector3(basis.e2[0], basis.e2[1], basis.e2[2])),
|
|
5920
|
+
d.dot(new THREE.Vector3(basis.e1[0], basis.e1[1], basis.e1[2])));
|
|
5921
|
+
}
|
|
5848
5922
|
function pickPositionGizmoHandle(cx, cy) {
|
|
5849
5923
|
if (!positionGizmoVisible || !posGizmoState || !canvasEl) return null;
|
|
5850
5924
|
const h = positionGizmoHandlesScreen(); if (!h) return null;
|
|
5851
5925
|
const hit = (pt) => pt && !pt.behind && Math.hypot(pt.x - cx, pt.y - cy) <= 14;
|
|
5852
5926
|
if (hit(h.depthTip)) return 'depth';
|
|
5853
5927
|
if (hit(h.widthTip)) return 'width';
|
|
5854
|
-
//
|
|
5928
|
+
// Sighting straight down the member axis collapses the slide arrow to a point AND takes both swing arc
|
|
5929
|
+
// planes edge-on at once — a genuinely degenerate view. Refuse those three picks there rather than try to
|
|
5930
|
+
// out-geometry it, exactly as the depth/width arrows already refuse their own edge-on drag.
|
|
5931
|
+
const axisOk = h.anchor && !h.anchor.behind && h.slideTip && !h.slideTip.behind
|
|
5932
|
+
&& Math.hypot(h.slideTip.x - h.anchor.x, h.slideTip.y - h.anchor.y) >= POS_EDGE_ON_PX;
|
|
5933
|
+
if (axisOk && hit(h.slideTip)) return 'slide';
|
|
5855
5934
|
const O = posGizmoState.anchor, sc = pxToWorldAt(POS_GIZMO_REACH_PX, new THREE.Vector3(O[0], O[1], O[2]));
|
|
5856
|
-
const rect = canvasEl.getBoundingClientRect()
|
|
5935
|
+
const rect = canvasEl.getBoundingClientRect();
|
|
5936
|
+
// Sample an arc in screen space and take the nearest point within tolerance.
|
|
5937
|
+
const nearestOn = (samples) => { let best = 12;
|
|
5938
|
+
for (const w0 of samples) { const w = w0.project(camera);
|
|
5939
|
+
if (w.z > 1) continue; const sx = rect.left + (w.x * 0.5 + 0.5) * rect.width, sy = rect.top + (-w.y * 0.5 + 0.5) * rect.height;
|
|
5940
|
+
const dd = Math.hypot(sx - cx, sy - cy); if (dd < best) best = dd; }
|
|
5941
|
+
return best < 12; };
|
|
5942
|
+
const yv = posGizmoState.yAxis, zv = posGizmoState.zAxis, roll = [];
|
|
5857
5943
|
for (let i = 0; i <= 36; i++) { const p = (-0.75 + (i / 36) * 1.5) * Math.PI, c = Math.cos(p) * 0.72, s = Math.sin(p) * 0.72;
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5944
|
+
roll.push(new THREE.Vector3(O[0] + (yv[0] * c + zv[0] * s) * sc, O[1] + (yv[1] * c + zv[1] * s) * sc, O[2] + (yv[2] * c + zv[2] * s) * sc)); }
|
|
5945
|
+
if (nearestOn(roll)) return 'rot';
|
|
5946
|
+
if (!axisOk) return null;
|
|
5947
|
+
const lobeSamples = (axisArr) => {
|
|
5948
|
+
const b = posGizmoState.end && axisArr && swingBasis(posGizmoState.anchor, posGizmoState.end, axisArr);
|
|
5949
|
+
if (!b) return [];
|
|
5950
|
+
const out = [];
|
|
5951
|
+
for (const side of [1, -1]) for (let i = 0; i <= 36; i++) {
|
|
5952
|
+
const p = side * (POS_LOBE_START + (i / 36) * POS_LOBE_SWEEP) * Math.PI, c = Math.cos(p) * POS_SWING_R * sc, s = Math.sin(p) * POS_SWING_R * sc;
|
|
5953
|
+
out.push(new THREE.Vector3(O[0] + b.e1[0] * c + b.e2[0] * s, O[1] + b.e1[1] * c + b.e2[1] * s, O[2] + b.e1[2] * c + b.e2[2] * s));
|
|
5954
|
+
}
|
|
5955
|
+
return out; };
|
|
5956
|
+
if (h.swingPlanHandle && nearestOn(lobeSamples(posGizmoState.up))) return 'swingPlan';
|
|
5957
|
+
if (h.swingElevHandle && nearestOn(lobeSamples(posGizmoState.yAxis))) return 'swingElev';
|
|
5958
|
+
return null;
|
|
5959
|
+
}
|
|
5960
|
+
// The amber anchor dot, hit-tested SEPARATELY and consulted ONLY by the hover/tooltip path. Deliberately
|
|
5961
|
+
// not part of `pickPositionGizmoHandle`: that function's answers arm a drag in onDown, and the dot is not
|
|
5962
|
+
// draggable — a mousedown on it must keep falling through to ordinary click-select, exactly as it always
|
|
5963
|
+
// has. Two independent checks over the same pixels, with different consumers. (Before 3b.1 the anchor's
|
|
5964
|
+
// tooltip copy existed but could never be shown, because nothing ever answered 'anchor'.)
|
|
5965
|
+
function pickPositionAnchorHover(cx, cy) {
|
|
5966
|
+
if (!positionGizmoVisible || !posGizmoState || !canvasEl) return false;
|
|
5967
|
+
const h = positionGizmoHandlesScreen();
|
|
5968
|
+
return !!(h && h.anchor && !h.anchor.behind && Math.hypot(h.anchor.x - cx, h.anchor.y - cy) <= 11);
|
|
5862
5969
|
}
|
|
5863
5970
|
function startPositionGizmoDrag(kind, e) {
|
|
5864
5971
|
const id = [...selIds][0], st = api.positionGizmoState(id);
|
|
@@ -5867,11 +5974,49 @@ function startPositionGizmoDrag(kind, e) {
|
|
|
5867
5974
|
// a fall-through click on empty space would strand the camera). code-review: silent-failure #1.
|
|
5868
5975
|
if (!st || !st.available) { pending = null; if (controls) controls.enabled = true; return; }
|
|
5869
5976
|
const mesh = meshById.get(id);
|
|
5977
|
+
const mesh0 = { meshPos0: mesh ? mesh.position.clone() : null, meshQuat0: mesh ? mesh.quaternion.clone() : null };
|
|
5978
|
+
// --- Reference-line gestures (slice 3b.1): freeze EVERYTHING the gesture depends on, right here.
|
|
5979
|
+
// The rotation axis, the drag-start far endpoint, the in-plane basis and the plumb barriers are all
|
|
5980
|
+
// constants for the whole gesture, so each tick applies the TOTAL angle to the frozen endpoint rather
|
|
5981
|
+
// than composing per-tick rotations (which drifts, and makes the 5° snap chatter). The barriers in
|
|
5982
|
+
// particular are closed-form and cannot change while the geometry is frozen — computing them once here
|
|
5983
|
+
// instead of per pointer-move keeps the drag path O(1).
|
|
5984
|
+
if (kind === 'slide' || kind === 'swingPlan' || kind === 'swingElev') {
|
|
5985
|
+
const avail = st.handles && st.handles[kind];
|
|
5986
|
+
if (!avail || !avail.available) {
|
|
5987
|
+
// A VISIBLE, hovering, tooltipped handle that does nothing on press is confusing — the handles are
|
|
5988
|
+
// hit-tested from the cached state while this re-reads fresh, so a model change in between can make
|
|
5989
|
+
// one dead. Say so, exactly as openPositionHud already does for the same stale-cache case, instead
|
|
5990
|
+
// of returning into silence. (console.debug alone is invisible at Chrome's default level.)
|
|
5991
|
+
const why = (avail && avail.reason) || 'That handle isn’t available on this member.';
|
|
5992
|
+
console.warn('steel-3d: reference-line handle refused —', why);
|
|
5993
|
+
positionGizmoReadout(e, why, '');
|
|
5994
|
+
pending = null; if (controls) controls.enabled = true; return;
|
|
5995
|
+
}
|
|
5996
|
+
const swingAxis = kind === 'swingPlan' ? st.up : kind === 'swingElev' ? st.yAxis : null;
|
|
5997
|
+
const basis = swingAxis ? swingBasis(st.anchor, st.end, swingAxis) : null;
|
|
5998
|
+
// Only the ELEVATION swing can reach plumb: a plan swing preserves the member's distance from the
|
|
5999
|
+
// degeneracy cone exactly, so it can neither enter nor leave it and needs no barrier at all.
|
|
6000
|
+
const barriers = kind === 'swingElev' ? swingBarriers(st.anchor, st.end, st.yAxis, st.up, POS_SWING_MARGIN_RAD) : null;
|
|
6001
|
+
if (kind !== 'slide' && (!basis || (kind === 'swingElev' && !barriers))) {
|
|
6002
|
+
const why = 'This member can’t be swung from its current direction — set its geometry in the Inspect panel.';
|
|
6003
|
+
console.warn('steel-3d: reference-line swing refused — no usable', basis ? 'plumb barrier' : 'swing plane');
|
|
6004
|
+
positionGizmoReadout(e, why, '');
|
|
6005
|
+
pending = null; if (controls) controls.enabled = true; return;
|
|
6006
|
+
}
|
|
6007
|
+
const startScalar = kind === 'slide' ? posGizmoAxisScalar(e, st, st.xAxis) : posSwingAngle(e, st, swingAxis, basis);
|
|
6008
|
+
pending = { posGizmo: { id, axis: kind, state: st, refline: true, base: 0, startScalar, newVal: 0,
|
|
6009
|
+
swingAxis, basis, barriers, accumRad: 0, prevAng: startScalar, ...mesh0 } };
|
|
6010
|
+
posInteraction = 'dragging';
|
|
6011
|
+
posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip();
|
|
6012
|
+
downXY = [e.clientX, e.clientY];
|
|
6013
|
+
return;
|
|
6014
|
+
}
|
|
5870
6015
|
const base = kind === 'depth' ? st.positionOffset : kind === 'width' ? st.positionHOffset : st.rot;
|
|
5871
6016
|
const startScalar = kind === 'rot' ? posGizmoArcAngle(e, st) : posGizmoAxisScalar(e, st, kind === 'depth' ? st.zAxis : st.yAxis);
|
|
5872
6017
|
pending = { posGizmo: { id, axis: kind, state: st, base, startScalar, newVal: base,
|
|
5873
6018
|
accumRad: 0, prevAng: kind === 'rot' ? startScalar : null, // rot: accumulate the arc CONTINUOUSLY (unwrapAngleStep) so a ±180° seam crossing never jumps ~2π
|
|
5874
|
-
|
|
6019
|
+
...mesh0 } };
|
|
5875
6020
|
posInteraction = 'dragging';
|
|
5876
6021
|
posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip(); // the hover handler is inert during a drag — clear any lingering handle tip so it doesn't sit where the readout will land
|
|
5877
6022
|
downXY = [e.clientX, e.clientY];
|
|
@@ -5890,6 +6035,7 @@ function onMovePositionGizmo(e) {
|
|
|
5890
6035
|
if (!dragging && Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) <= DRAG_TOL_PX) return;
|
|
5891
6036
|
dragging = pending;
|
|
5892
6037
|
const pg = pending.posGizmo, st = pg.state, mesh = meshById.get(pg.id);
|
|
6038
|
+
if (pg.refline) { onMoveRefLineGizmo(e, pg, st, mesh); return; }
|
|
5893
6039
|
if (pg.axis === 'rot') {
|
|
5894
6040
|
const ang = posGizmoArcAngle(e, st);
|
|
5895
6041
|
if (ang == null) { positionGizmoReadout(e, 'View is edge-on — orbit, or set the value in Inspect', ''); return; }
|
|
@@ -5942,6 +6088,68 @@ function onMovePositionGizmo(e) {
|
|
|
5942
6088
|
const shownVal = api && api.fmtLen ? api.fmtLen(val) : Math.round(val) + ' mm';
|
|
5943
6089
|
positionGizmoReadout(e, (pg.axis === 'depth' ? 'Depth ' : 'Width ') + shownVal, ''); // label-first + panel's own unit (fmtLen), to match the Inspect panel exactly
|
|
5944
6090
|
}
|
|
6091
|
+
/*
|
|
6092
|
+
* The reference-line gestures (slice 3b.1). These move the member's WORK POINTS, so the live preview is a
|
|
6093
|
+
* RIGID transform of the existing mesh — a translation for the slide, one rotation about the anchor for a
|
|
6094
|
+
* swing. Nothing is rebuilt mid-drag, which is also why the view never has to freeze the depth face: a
|
|
6095
|
+
* rigid transform cannot re-derive it. The fold is decided once, at commit, in the editor.
|
|
6096
|
+
*
|
|
6097
|
+
* Every gesture reports a DELTA (mm along the axis, or radians about the frozen axis); `onUp` turns that
|
|
6098
|
+
* into absolute world work points through the same pure helpers the tests exercise.
|
|
6099
|
+
*/
|
|
6100
|
+
function onMoveRefLineGizmo(e, pg, st, mesh) {
|
|
6101
|
+
// The member axis going edge-on collapses the slide arrow AND both arc planes at once. Refuse rather than
|
|
6102
|
+
// let mm-per-pixel run away, matching the shipped depth/width refusal word for word.
|
|
6103
|
+
const scr = positionGizmoHandlesScreen();
|
|
6104
|
+
if (scr && scr.anchor && scr.slideTip && !scr.slideTip.behind
|
|
6105
|
+
&& Math.hypot(scr.slideTip.x - scr.anchor.x, scr.slideTip.y - scr.anchor.y) < POS_EDGE_ON_PX) {
|
|
6106
|
+
positionGizmoReadout(e, 'View is edge-on — orbit, or set the value in Inspect', ''); return;
|
|
6107
|
+
}
|
|
6108
|
+
if (pg.axis === 'slide') {
|
|
6109
|
+
const s = posGizmoAxisScalar(e, st, st.xAxis);
|
|
6110
|
+
if (s == null) { positionGizmoReadout(e, 'View is edge-on — orbit, or set the value in Inspect', ''); return; }
|
|
6111
|
+
if (pg.startScalar == null) { pg.startScalar = s; return; } // grab was edge-on → set the reference on the first valid hit
|
|
6112
|
+
const raw = s - pg.startScalar;
|
|
6113
|
+
const delta = e.shiftKey ? raw : snapToStep(raw, POS_SNAP_MM);
|
|
6114
|
+
pg.newVal = delta;
|
|
6115
|
+
if (mesh && pg.meshPos0) {
|
|
6116
|
+
mesh.position.set(pg.meshPos0.x + st.xAxis[0] * delta, pg.meshPos0.y + st.xAxis[1] * delta, pg.meshPos0.z + st.xAxis[2] * delta);
|
|
6117
|
+
}
|
|
6118
|
+
updatePositionLeader([st.anchor[0] + st.xAxis[0] * s, st.anchor[1] + st.xAxis[1] * s, st.anchor[2] + st.xAxis[2] * s]);
|
|
6119
|
+
positionGizmoReadout(e, 'Slide ' + (api && api.fmtLen ? api.fmtLen(delta) : Math.round(delta) + ' mm'), '');
|
|
6120
|
+
return;
|
|
6121
|
+
}
|
|
6122
|
+
// --- swing: rotate the member DIRECTION about the frozen axis, moving only the far work point.
|
|
6123
|
+
const ang = posSwingAngle(e, st, pg.swingAxis, pg.basis);
|
|
6124
|
+
if (ang == null) { positionGizmoReadout(e, 'View is edge-on — orbit, or set the value in Inspect', ''); return; }
|
|
6125
|
+
if (pg.startScalar == null) { pg.startScalar = ang; pg.prevAng = ang; return; }
|
|
6126
|
+
if (pg.prevAng == null) pg.prevAng = ang;
|
|
6127
|
+
// Accumulate CONTINUOUSLY, as the shipped roll arc does, so crossing the ±180° seam adds an increment
|
|
6128
|
+
// rather than ~2π. Then snap the DELTA (the member's own heading is generically off-grid, so snapping an
|
|
6129
|
+
// absolute would yank the steel to the 5° grid on the very first tick).
|
|
6130
|
+
pg.accumRad += unwrapAngleStep(pg.prevAng, ang); pg.prevAng = ang;
|
|
6131
|
+
let theta = e.shiftKey ? pg.accumRad : snapToStep(pg.accumRad * 180 / Math.PI, POS_SNAP_DEG) * Math.PI / 180;
|
|
6132
|
+
if (pg.barriers) {
|
|
6133
|
+
const c = clampSwingTheta(theta, pg.barriers, e.shiftKey ? 'free' : 'snapped', POS_SNAP_DEG * Math.PI / 180);
|
|
6134
|
+
if (!c) { positionGizmoReadout(e, 'That would swing the member through plumb', ''); return; } // reachable since the clamp began refusing a direction with no legal travel, rather than substituting a wrong-signed limit
|
|
6135
|
+
theta = c.theta; pg.clamped = c.clamped;
|
|
6136
|
+
}
|
|
6137
|
+
pg.newVal = theta;
|
|
6138
|
+
if (mesh && pg.meshPos0 && pg.meshQuat0) { // exact rigid preview: one rotation about the anchor
|
|
6139
|
+
const axis = new THREE.Vector3(pg.swingAxis[0], pg.swingAxis[1], pg.swingAxis[2]).normalize();
|
|
6140
|
+
const q = new THREE.Quaternion().setFromAxisAngle(axis, theta);
|
|
6141
|
+
const O = new THREE.Vector3(st.anchor[0], st.anchor[1], st.anchor[2]);
|
|
6142
|
+
mesh.position.copy(pg.meshPos0.clone().sub(O).applyQuaternion(q).add(O));
|
|
6143
|
+
mesh.quaternion.copy(q.clone().multiply(pg.meshQuat0));
|
|
6144
|
+
}
|
|
6145
|
+
const tip = swingEndpoint(st.anchor, st.end, pg.swingAxis, theta);
|
|
6146
|
+
if (tip) updatePositionLeader(tip);
|
|
6147
|
+
const degRaw = theta * 180 / Math.PI;
|
|
6148
|
+
const deg = e.shiftKey ? (Math.abs(degRaw) < 10 ? degRaw.toFixed(1) : Math.round(degRaw)) : Math.round(degRaw); // Shift is the no-snap mode, so rounding the readout to a whole degree would report a value the commit does not use
|
|
6149
|
+
// "Swing" and "Tilt", never "Rotation" — that label belongs to the roll arc, and reusing it would blur
|
|
6150
|
+
// which of the two red-family handles is live mid-drag.
|
|
6151
|
+
positionGizmoReadout(e, (pg.axis === 'swingPlan' ? 'Swing ' : 'Tilt ') + deg + '°' + (pg.clamped ? ' (limit)' : ''), '');
|
|
6152
|
+
}
|
|
5945
6153
|
// --- frame manipulator: grab + drag the gizmo's origin (translate) or ring (rotate about Z). Armed only. ---
|
|
5946
6154
|
const FRAME_RING_R = (1524 * 2 / 2) * 0.8; // ring radius (matches renderFrameGizmo's half*0.8, N=2)
|
|
5947
6155
|
function frameGizmoOrigin() { return frame3d ? frame3d.origin : [0, 0, 0]; } // Global → true global 0,0,0
|
|
@@ -6721,6 +6929,14 @@ function onDown(e) {
|
|
|
6721
6929
|
if (positionGizmoVisible && posGizmoState) {
|
|
6722
6930
|
let pgh = null; try { pgh = pickPositionGizmoHandle(e.clientX, e.clientY); } catch (err) { console.error('steel-3d: position-gizmo hit-test failed', err); pgh = null; } // match the grid/mesh hit-test logging (no silent swallow)
|
|
6723
6931
|
if (pgh) { e.stopPropagation(); controls.enabled = false; startPositionGizmoDrag(pgh, e); if (pending) return; }
|
|
6932
|
+
// The amber anchor is not draggable, but a press on it must not COST the user their selection either.
|
|
6933
|
+
// The dot floats half a section depth above the steel, so a click there usually misses the member mesh
|
|
6934
|
+
// and reaches empty space — which clears the selection and takes the whole gizmo with it. That was
|
|
6935
|
+
// survivable while the dot was silent; now that it explains itself on hover, people click it. So
|
|
6936
|
+
// consume the gesture and stay put, exactly as a filtered grid does. A drag past the tolerance still
|
|
6937
|
+
// becomes a marquee (below), so an 11px dot cannot blanket-block box selection.
|
|
6938
|
+
let onAnchorDown = false; try { onAnchorDown = pickPositionAnchorHover(e.clientX, e.clientY); } catch (err) { console.error('steel-3d: position-anchor hit-test failed', err); onAnchorDown = false; }
|
|
6939
|
+
if (onAnchorDown) { e.stopPropagation(); controls.enabled = false; pending = { posAnchor: true }; return; }
|
|
6724
6940
|
}
|
|
6725
6941
|
let id = null; try { id = pickAt(e.clientX, e.clientY); } catch { id = null; }
|
|
6726
6942
|
// Geometry-edit mode (Trim/Extend or Split armed in the inspector): a click does the edit, no drag.
|
|
@@ -6990,7 +7206,7 @@ function onMove(e) {
|
|
|
6990
7206
|
if (pending && pending.frameDrag) { onMoveFrame(e); return; } // dragging the local-frame origin / rotation ring
|
|
6991
7207
|
if (pending && pending.posGizmo) { onMovePositionGizmo(e); return; } // dragging a Profile Position handle (depth/width offset or roll)
|
|
6992
7208
|
if (!pending || pending.geo) return;
|
|
6993
|
-
if (pending.gridId||pending.filteredGrid||pending.filteredReference) { const d=Math.hypot(e.clientX-downXY[0],e.clientY-downXY[1]);if(d<=DRAG_TOL_PX)return;pending=null;controls.enabled=true;boxSel={x:downXY[0],y:downXY[1]};onBoxMove(e);return; } // a filtered-reference/grid click stays inert, but once it moves the same press becomes a normal marquee so an overlay cannot blanket-disable box selection
|
|
7209
|
+
if (pending.gridId||pending.filteredGrid||pending.filteredReference||pending.posAnchor) { const d=Math.hypot(e.clientX-downXY[0],e.clientY-downXY[1]);if(d<=DRAG_TOL_PX)return;pending=null;controls.enabled=true;boxSel={x:downXY[0],y:downXY[1]};onBoxMove(e);return; } // a filtered-reference/grid click stays inert, but once it moves the same press becomes a normal marquee so an overlay cannot blanket-disable box selection
|
|
6994
7210
|
if (pending.epDrag) { onMoveEndpoint(e); return; }
|
|
6995
7211
|
if (!pending.grab || !pending.origMm) return;
|
|
6996
7212
|
if (!dragging && Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) <= DRAG_TOL_PX) return;
|
|
@@ -7174,7 +7390,7 @@ function onUp(e) {
|
|
|
7174
7390
|
controls.enabled = true;
|
|
7175
7391
|
const moved = downXY ? Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) : Infinity; downXY = null;
|
|
7176
7392
|
if (!p) return;
|
|
7177
|
-
if(p.filteredGrid||p.filteredReference)return;
|
|
7393
|
+
if(p.filteredGrid||p.filteredReference||p.posAnchor)return; // an anchor-dot press is inert BY DESIGN: no drag, and no selection change either
|
|
7178
7394
|
if(p.gridId){if(moved>DRAG_TOL_PX)return;if(!p.add)resetConnState();if(api&&api.onSelectBatch)api.onSelectBatch({memberIds:[],gridIds:[p.gridId]},p.add);else if(api&&api.onSelectGrid)api.onSelectGrid(p.gridId,p.add);return;}
|
|
7179
7395
|
if (p.clipDrag) return; // a clip handle drag is applied live during onMoveClip; nothing to commit on up (controls re-enabled above)
|
|
7180
7396
|
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)
|
|
@@ -7183,6 +7399,31 @@ function onUp(e) {
|
|
|
7183
7399
|
hidePositionLeader();
|
|
7184
7400
|
posInteraction = 'idle';
|
|
7185
7401
|
const pg = p.posGizmo;
|
|
7402
|
+
if (pg.refline) { // slice 3b.1 — the handles that move the WORK POINTS, committed as absolute world mm
|
|
7403
|
+
const st = pg.state;
|
|
7404
|
+
const moved = pg.newVal != null && Math.abs(pg.newVal) > 1e-12;
|
|
7405
|
+
if (wasDragging && moved && api && api.commitMemberEndpoints) {
|
|
7406
|
+
// Rebuild the absolute points from the FROZEN drag-start geometry and the total delta, through the
|
|
7407
|
+
// same pure helpers the unit tests pin — never from whatever the mesh preview happens to show.
|
|
7408
|
+
let spec = null;
|
|
7409
|
+
if (pg.axis === 'slide') {
|
|
7410
|
+
const r = slideEndpoints(st.anchor, st.end, st.xAxis, pg.newVal);
|
|
7411
|
+
if (r) spec = { from: r.from, to: r.to, gesture: 'slide', expect: st.fingerprint };
|
|
7412
|
+
} else {
|
|
7413
|
+
const to = swingEndpoint(st.anchor, st.end, pg.swingAxis, pg.newVal);
|
|
7414
|
+
if (to) spec = { to, gesture: pg.axis, expect: st.fingerprint };
|
|
7415
|
+
}
|
|
7416
|
+
if (!spec) console.warn('steel-3d: a reference-line gesture produced no commit — geometry helper returned null', pg.axis, pg.newVal);
|
|
7417
|
+
// The editor's own refusals toast; a THROW here (a member the world-mm primitive cannot address)
|
|
7418
|
+
// would otherwise escape this pointer handler and strand the moved preview over an unchanged model,
|
|
7419
|
+
// which is precisely the failure the primitive's own comment set out to prevent.
|
|
7420
|
+
let ok = false;
|
|
7421
|
+
try { ok = !!(spec && api.commitMemberEndpoints(pg.id, spec, null)); }
|
|
7422
|
+
catch (err) { console.error('steel-3d: reference-line commit failed', err); ok = false; }
|
|
7423
|
+
if (!ok) { restorePositionGizmoMesh(pg); renderPositionGizmo(); } // refused (stale gesture, unknown elevation, a frame it would break) → put the preview back
|
|
7424
|
+
} else { restorePositionGizmoMesh(pg); renderPositionGizmo(); }
|
|
7425
|
+
return;
|
|
7426
|
+
}
|
|
7186
7427
|
// rot is compared by ANGULAR equality (mod 360): a drag that loops the arc back to the member's own roll
|
|
7187
7428
|
// (Δ = 360°) reads as no move and must commit nothing / push no undo entry (Fable 5 test 1). depth/width
|
|
7188
7429
|
// stay a linear compare.
|
|
@@ -7372,6 +7613,13 @@ function onHoverMove(e) {
|
|
|
7372
7613
|
if (ph) { canvasEl.style.cursor = 'grab';
|
|
7373
7614
|
if (api && api.showHandleTip) api.showHandleTip(POS_HANDLE_TIP[ph], lastHoverXY[0], lastHoverXY[1]);
|
|
7374
7615
|
posHovered = true; return; }
|
|
7616
|
+
// The anchor is hover-only: it explains itself but never arms a drag, so it is checked here and NOT
|
|
7617
|
+
// in pickPositionGizmoHandle. Cursor stays default — a grab cursor would promise a drag that a
|
|
7618
|
+
// mousedown here does not perform (it falls through to click-select, as it always has).
|
|
7619
|
+
let onAnchor = false; try { onAnchor = pickPositionAnchorHover(lastHoverXY[0], lastHoverXY[1]); } catch { onAnchor = false; }
|
|
7620
|
+
if (onAnchor) {
|
|
7621
|
+
if (api && api.showHandleTip) api.showHandleTip(POS_HANDLE_TIP.anchor, lastHoverXY[0], lastHoverXY[1]);
|
|
7622
|
+
posHovered = true; return; }
|
|
7375
7623
|
if (posHovered) { posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip(); }
|
|
7376
7624
|
} else if (posHovered) { posHovered = false; if (api && api.hideHandleTip) api.hideHandleTip(); } // gizmo disappeared while a tip was up
|
|
7377
7625
|
if (frame3d && !frameMode && !geoMode() && !cmActive() && !addActive() && !dimMode3d && !clipMode && !wpMode && !basePickCol && !insertMode && !refMeasure3d && !selectedClipIds.size) { // hovering the PASSIVE gizmo (nothing armed) → pointer cursor hints "click to edit the local axes again"
|