@floless/app 0.128.1 → 0.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +475 -71
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +49 -1
- package/dist/web/app.css +0 -1
- package/dist/web/aware.js +88 -6
- package/dist/web/frame-theme.js +60 -0
- package/dist/web/steel-3d-view.js +439 -69
- package/dist/web/steel-canvas-guidance.js +39 -0
- package/dist/web/steel-editor.html +241 -20
- package/dist/web/steel-filter.html +96 -23
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ import * as THREE from 'three';
|
|
|
18
18
|
import { OrbitControls } from 'three/addons/OrbitControls.js';
|
|
19
19
|
import { RoomEnvironment } from 'three/addons/RoomEnvironment.js';
|
|
20
20
|
import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-materials.js';
|
|
21
|
+
import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
|
|
21
22
|
import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
|
|
22
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 } from './steel-3d-core.js';
|
|
23
24
|
// `gridGeometry`, `gridCandidates3d` and `mmPerPx` moved behind the host's model read half (unit 5, P7d):
|
|
@@ -30,7 +31,7 @@ let shadowGround = null, shadowsEnabled = false; // the `shadowed` mode's grou
|
|
|
30
31
|
let pending = null, dragging = null, marker = null, readout = null; // pending = member gesture; readout = drag dimension overlay
|
|
31
32
|
let boxSel = null, rubber = null; // LEFT-drag-on-empty rubber-band multi-select
|
|
32
33
|
let selectionTrace = null; // last ordinary pointer-selection route (read-only E2E diagnostic)
|
|
33
|
-
let hoverId = null, hoverGlowIds = [], hoverChip = null, hoverRAF = 0, lastHoverXY = null; // hover readout + cursor; hoverGlowIds = every mesh currently wearing the sky glow (the WHOLE connection when hovering one of its parts)
|
|
34
|
+
let hoverId = null, hoverGlowIds = [], hoverChip = null, hoverChipShell = null, hoverChipToggle = null, hoverChipIdleCollapsed = false, hoverRAF = 0, lastHoverXY = null; // hover readout + cursor; hoverGlowIds = every mesh currently wearing the sky glow (the WHOLE connection when hovering one of its parts)
|
|
34
35
|
let epGroup = null; // yellow/magenta endpoint markers (start/end direction dots)
|
|
35
36
|
let epGeom = null, epMatStart = null, epMatEnd = null; // shared across all endpoint dots (no per-rebuild churn)
|
|
36
37
|
let epRing = null, epPreview = null, epMovedLine = null; // white ring on the active end node + member rubber (epPreview) + the "moved" leader (epMovedLine) while dragging an end
|
|
@@ -189,6 +190,11 @@ function init(canvas, theApi) {
|
|
|
189
190
|
// centre far away. ponytail: on-axis depth re-pivot, not a true off-axis orbit-about-cursor (OrbitControls
|
|
190
191
|
// always keeps the pivot screen-centred — that would need a custom control); add that only if this isn't enough.
|
|
191
192
|
controls.addEventListener('start', repivotToCursor);
|
|
193
|
+
// The progressive preview auto-frames ONCE, and must not do it to someone who has taken the camera.
|
|
194
|
+
// `start` is the honest signal for "the user did this": it fires on orbit, zoom and pan alike and
|
|
195
|
+
// never on our own `fitCamera`. It matters because the import modal offers "Continue in background"
|
|
196
|
+
// the moment the read starts, so a user can be navigating while the first batch is still arriving.
|
|
197
|
+
controls.addEventListener('start', () => { xrefPreviewCamTouched = true; });
|
|
192
198
|
// The measure's snap set is FRUSTUM-FILTERED, so unlike every other cached candidate list it goes stale
|
|
193
199
|
// the moment the camera moves — orbit past a corner and a cached set would keep offering it (projected
|
|
194
200
|
// to nonsense) while the corners now on screen were absent. Cheap: the rebuild only happens on the next
|
|
@@ -291,10 +297,29 @@ function init(canvas, theApi) {
|
|
|
291
297
|
selLenLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:3;display:none';
|
|
292
298
|
document.body.appendChild(selLenLabelHost);
|
|
293
299
|
document.body.appendChild(propLabelHost);
|
|
294
|
-
//
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
document.
|
|
300
|
+
// The steel editor provides a shared bottom dock: the status disclosure owns the left, while the
|
|
301
|
+
// non-shrinking Select/Snap controls own the right. The shared renderer also serves vector-3d.html,
|
|
302
|
+
// which has no dock and intentionally keeps its existing read-only bottom-centre chip.
|
|
303
|
+
const statusDock = document.getElementById('bottomDockLeft');
|
|
304
|
+
hoverChip = document.createElement('span');
|
|
305
|
+
if (statusDock) {
|
|
306
|
+
try { hoverChipIdleCollapsed = localStorage.getItem('steel:canvasStatusCollapsed:v1') === '1'; } catch (_) { hoverChipIdleCollapsed = false; }
|
|
307
|
+
hoverChipShell = document.createElement('div'); hoverChipShell.id = 'canvasStatus';
|
|
308
|
+
hoverChipToggle = document.createElement('button'); hoverChipToggle.type = 'button'; hoverChipToggle.id = 'canvasStatusToggle';
|
|
309
|
+
hoverChipToggle.setAttribute('aria-controls', 'canvasStatusText');
|
|
310
|
+
hoverChipToggle.innerHTML = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg>';
|
|
311
|
+
hoverChip.id = 'canvasStatusText'; hoverChip.setAttribute('role', 'status'); hoverChip.setAttribute('aria-live', 'polite');
|
|
312
|
+
hoverChipToggle.onclick = () => {
|
|
313
|
+
if (hoverChipToggle.getAttribute('aria-disabled') === 'true') return;
|
|
314
|
+
hoverChipIdleCollapsed = !hoverChipIdleCollapsed;
|
|
315
|
+
try { localStorage.setItem('steel:canvasStatusCollapsed:v1', hoverChipIdleCollapsed ? '1' : '0'); } catch (_) {}
|
|
316
|
+
updateStatusChip(); hoverChipToggle.focus();
|
|
317
|
+
};
|
|
318
|
+
hoverChipShell.append(hoverChipToggle, hoverChip); statusDock.appendChild(hoverChipShell);
|
|
319
|
+
} else {
|
|
320
|
+
hoverChip.style.cssText = 'position:fixed;display:none;pointer-events:none;z-index:55;background:var(--panel,#0f172a);color:var(--mut,#94a3b8);border:1px solid var(--line,#334155);border-radius:6px;padding:5px 12px;font:12px system-ui;white-space:nowrap;max-width:60vw;overflow:hidden;text-overflow:ellipsis;box-shadow:0 2px 8px rgba(0,0,0,.45)';
|
|
321
|
+
document.body.appendChild(hoverChip);
|
|
322
|
+
}
|
|
298
323
|
// rubber-band overlay for LEFT-drag box-select on empty space
|
|
299
324
|
rubber = document.createElement('div');
|
|
300
325
|
rubber.style.cssText = 'position:fixed;display:none;pointer-events:none;z-index:58;border:1px solid var(--brand,#3b82f6);background:rgba(59,130,246,.12)';
|
|
@@ -818,7 +843,7 @@ function applyCopes(mesh, cuts) {
|
|
|
818
843
|
|
|
819
844
|
function buildFromScene(sc) {
|
|
820
845
|
clearRoot();
|
|
821
|
-
clipCandidates = null; clipLevels = null; invalidateModelCache(); // the model changed (edit/undo/redo) — drop the clip-draw snap cache so a draw in progress re-snaps against the CURRENT members/grid/levels, never stale ones
|
|
846
|
+
clipCandidates = null; clipLevels = null; invalidateClipFloor(); invalidateModelCache(); // the model changed (edit/undo/redo) — drop the clip-draw snap cache AND the measured floor so a draw in progress re-snaps against the CURRENT members/grid/levels, never stale ones
|
|
822
847
|
resetConnState(); // a fresh scene rebuilds selection from scratch — drop any stale connection envelope/context
|
|
823
848
|
for (const mat of baseMat.values()) mat.dispose(); // shared per-profile materials from the prior build
|
|
824
849
|
groupColor.clear(); baseMat.clear();
|
|
@@ -902,7 +927,11 @@ function buildFromScene(sc) {
|
|
|
902
927
|
if (hadVisibilityFilter !== hasVisibilityFilter()) notifyVisibilityChange(); // keep the host's recovery control honest when an edit removes the last hidden/isolated mesh
|
|
903
928
|
applyGroupVisibility(); applyDisplayMode();
|
|
904
929
|
built = true;
|
|
905
|
-
|
|
930
|
+
// Fit only on entering 3D (rebuild(true)) — NOT on every edit. Frames whatever is on screen, so a
|
|
931
|
+
// project whose references are already cached opens on the borrowed model rather than on nothing.
|
|
932
|
+
// (A reference whose geometry is still streaming in arrives after this and is not re-framed; landing
|
|
933
|
+
// an auto-fit on late-arriving geometry would yank a camera the user may already have moved.)
|
|
934
|
+
if (fitPending) { fitCamera(visibleWorldBox()); fitPending = false; }
|
|
906
935
|
}
|
|
907
936
|
let sceneGroups = [];
|
|
908
937
|
|
|
@@ -1083,6 +1112,136 @@ function xrefMatrix(placement) {
|
|
|
1083
1112
|
.multiply(new THREE.Matrix4().makeScale(s, s, s));
|
|
1084
1113
|
}
|
|
1085
1114
|
|
|
1115
|
+
// ── The progressive PREVIEW, and why it is a sibling rather than a reference ──
|
|
1116
|
+
//
|
|
1117
|
+
// A reference import draws as it loads (aware-aeco/aware#405): AWARE announces segments while it is
|
|
1118
|
+
// still tessellating, and these are the meshes for them. The whole design rests on this geometry NOT
|
|
1119
|
+
// being a reference — both server routes refuse AFTER the read (`objectVerdict`, the filter receipt),
|
|
1120
|
+
// so anything drawn early is drawn before FloLess knows it may be kept.
|
|
1121
|
+
//
|
|
1122
|
+
// IT IS A SIBLING OF `xrefGroup`, NEVER A CHILD, and that is what makes "not selectable" structural
|
|
1123
|
+
// instead of a rule someone has to remember. Every reference-interaction entry point reads that group
|
|
1124
|
+
// directly — `pickReferenceAt` raycasts `xrefGroup.children`, while `referenceCandidates` and
|
|
1125
|
+
// `referenceBounds` reach their meshes through `xrefById` — so a preview parented under it would be
|
|
1126
|
+
// pickable, snappable and measurable no matter what any other code said. Keeping it out of BOTH is
|
|
1127
|
+
// what answers all three. It is absent from `xrefById` for that reason, and from
|
|
1128
|
+
// the editor's `refGeom`, whose mere presence gates the measure tool, the move action and the panel's
|
|
1129
|
+
// loaded state.
|
|
1130
|
+
//
|
|
1131
|
+
// It is therefore not in `disposeReferenceMaterials`' sweep either: it owns exactly one material and
|
|
1132
|
+
// disposes it itself.
|
|
1133
|
+
|
|
1134
|
+
let xrefPreviewGroup = null; // the preview's meshes, or null when nothing is previewing
|
|
1135
|
+
let xrefPreviewMat = null; // its ONE material — the preview is uniform, so one is enough
|
|
1136
|
+
let xrefPreviewCount = 0; // objects drawn so far, for the caller's progress copy
|
|
1137
|
+
let xrefPreviewFramed = false; // whether the one-time frame has happened
|
|
1138
|
+
/**
|
|
1139
|
+
* Has the user driven the camera since this preview began?
|
|
1140
|
+
*
|
|
1141
|
+
* Set from OrbitControls' `start`, which fires on every orbit/zoom/pan the USER initiates and never
|
|
1142
|
+
* on a programmatic `fitCamera` — so the auto-frame below cannot mistake its own move for the user's.
|
|
1143
|
+
* `change` would be the wrong event for exactly that reason: `fitCamera` raises it.
|
|
1144
|
+
*/
|
|
1145
|
+
let xrefPreviewCamTouched = false;
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* Draw one batch of preview objects.
|
|
1149
|
+
*
|
|
1150
|
+
* `objects` is `[{positions, indices}]` and carries nothing else — no ids, no colours, no metadata —
|
|
1151
|
+
* because nothing may ask this layer a question about an object it is showing. Appends to whatever is
|
|
1152
|
+
* already drawn rather than rebuilding: `setReferences` re-uploads every buffer it owns, which is
|
|
1153
|
+
* correct once but would be quadratic per batch and would flicker the whole model on every arrival.
|
|
1154
|
+
*
|
|
1155
|
+
* `placement` is the reference's proposed placement, applied to the group exactly as a real reference's
|
|
1156
|
+
* is, so the preview sits where the finished model will.
|
|
1157
|
+
*/
|
|
1158
|
+
function appendReferencePreview(objects, placement) {
|
|
1159
|
+
if (!scene || !Array.isArray(objects) || !objects.length) return 0;
|
|
1160
|
+
if (!xrefPreviewGroup) {
|
|
1161
|
+
xrefPreviewGroup = new THREE.Group();
|
|
1162
|
+
// BEHIND our steel, exactly as a reference is: `renderOrder` -1 with `depthWrite:false`. A preview
|
|
1163
|
+
// that occluded the model it exists to be compared against would be worse than no preview.
|
|
1164
|
+
xrefPreviewGroup.renderOrder = -1;
|
|
1165
|
+
xrefPreviewGroup.applyMatrix4(xrefMatrix(placement));
|
|
1166
|
+
scene.add(xrefPreviewGroup);
|
|
1167
|
+
// UNIFORM GREY, NOT THE FILE'S COLOURS, and that is a statement rather than a shortcut. It is the
|
|
1168
|
+
// same "not your content" slate this app already spends on references, it reads honestly as
|
|
1169
|
+
// provisional — the real colours appear when the import commits — and it lets the server strip
|
|
1170
|
+
// colour runs from the wire entirely. One material, because there is only ever one colour.
|
|
1171
|
+
xrefPreviewMat = newXrefMaterial(XREF_COLOR, 0.5);
|
|
1172
|
+
xrefPreviewMat.opacity = 0.5;
|
|
1173
|
+
xrefPreviewCount = 0;
|
|
1174
|
+
xrefPreviewFramed = false;
|
|
1175
|
+
// Cleared when a preview BEGINS, not on dispose: the question is whether the user has moved the
|
|
1176
|
+
// camera during THIS import, and a flag left standing from an earlier one would silently decline
|
|
1177
|
+
// to frame a reference that needs it.
|
|
1178
|
+
xrefPreviewCamTouched = false;
|
|
1179
|
+
}
|
|
1180
|
+
for (const o of objects) {
|
|
1181
|
+
if (!o || !Array.isArray(o.positions) || !o.positions.length) continue;
|
|
1182
|
+
const g = new THREE.BufferGeometry();
|
|
1183
|
+
g.setAttribute('position', new THREE.Float32BufferAttribute(o.positions, 3));
|
|
1184
|
+
if (Array.isArray(o.indices) && o.indices.length) g.setIndex(o.indices);
|
|
1185
|
+
g.computeVertexNormals();
|
|
1186
|
+
xrefPreviewGroup.add(new THREE.Mesh(g, xrefPreviewMat));
|
|
1187
|
+
xrefPreviewCount++;
|
|
1188
|
+
}
|
|
1189
|
+
// No explicit redraw: this view runs a continuous rAF loop (see `loop`), so adding to the scene is
|
|
1190
|
+
// all a batch has to do to appear.
|
|
1191
|
+
return xrefPreviewCount;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Frame the preview ONCE, and only if the user has not taken the camera themselves.
|
|
1196
|
+
*
|
|
1197
|
+
* Without this a model whose origin sits far from ours previews entirely off-screen and the feature
|
|
1198
|
+
* delivers nothing for exactly the coordination files it was built for. With it unconditional, it
|
|
1199
|
+
* would yank the camera away from someone who started navigating while the read ran. So: once, on the
|
|
1200
|
+
* first batch, and never again — the terminal `frameReference` on the committed reference is unchanged.
|
|
1201
|
+
*
|
|
1202
|
+
* It does NOT touch `sceneBox` or any saved view: the preview is not part of the scene's extent, and
|
|
1203
|
+
* a view saved while one was on screen must not remember it.
|
|
1204
|
+
*/
|
|
1205
|
+
function frameReferencePreview() {
|
|
1206
|
+
if (!xrefPreviewGroup || xrefPreviewFramed || !xrefPreviewGroup.children.length) return false;
|
|
1207
|
+
// THE GUARD THE PARAGRAPH ABOVE PROMISED. It was documented and not implemented — the function
|
|
1208
|
+
// checked only that it had not already framed — so "and only if the user has not taken the camera
|
|
1209
|
+
// themselves" was a false sentence about the code beneath it. (UX review caught the divergence.)
|
|
1210
|
+
// Marked framed either way: declining once is the decision, not a retry to make on the next batch.
|
|
1211
|
+
xrefPreviewFramed = true;
|
|
1212
|
+
if (xrefPreviewCamTouched) return false;
|
|
1213
|
+
const box = new THREE.Box3().setFromObject(xrefPreviewGroup);
|
|
1214
|
+
if (box.isEmpty()) return false;
|
|
1215
|
+
fitCamera(box);
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Remove the preview and free everything it holds.
|
|
1221
|
+
*
|
|
1222
|
+
* CALLED BEFORE the authoritative geometry is built, never after, so peak GPU is the larger of the two
|
|
1223
|
+
* and not their sum. Idempotent: every terminal path in the editor calls it, which is the point.
|
|
1224
|
+
*/
|
|
1225
|
+
function clearReferencePreview() {
|
|
1226
|
+
if (!xrefPreviewGroup) return;
|
|
1227
|
+
try {
|
|
1228
|
+
xrefPreviewGroup.traverse((o) => { o.geometry?.dispose?.(); });
|
|
1229
|
+
scene?.remove(xrefPreviewGroup);
|
|
1230
|
+
xrefPreviewMat?.dispose?.();
|
|
1231
|
+
} finally {
|
|
1232
|
+
// RESET IN `finally`, because a half-disposed group that stays referenced is worse than a leak.
|
|
1233
|
+
// If a dispose throws and these stay set, the NEXT import's `appendReferencePreview` sees a live
|
|
1234
|
+
// group, skips its whole init block, and appends the new model into the old group — the old
|
|
1235
|
+
// placement matrix, a stale count, and `xrefPreviewFramed` still true so it never frames. On a
|
|
1236
|
+
// refused import that geometry then stays on the canvas for a model FloLess declined, in a group
|
|
1237
|
+
// no selection can reach because it is deliberately outside `xrefById`. (Silent-failure review.)
|
|
1238
|
+
xrefPreviewGroup = null;
|
|
1239
|
+
xrefPreviewMat = null;
|
|
1240
|
+
xrefPreviewCount = 0;
|
|
1241
|
+
xrefPreviewFramed = false;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1086
1245
|
/** Unique world points for snapping, quantised so a tessellated corner is one target and not thirty. */
|
|
1087
1246
|
function xrefSnapPoints(objects) {
|
|
1088
1247
|
const seen = new Set(); const out = [];
|
|
@@ -1144,6 +1303,8 @@ function disposeReferenceMaterials() {
|
|
|
1144
1303
|
*/
|
|
1145
1304
|
function setReferences(list) {
|
|
1146
1305
|
refMeasureCands = null; // the measure's frustum-filtered snap set is derived from this — see setReferencePlacement
|
|
1306
|
+
invalidateClipFloor(); // the reference layer IS part of the clip-box floor: a reference arriving, being re-read, hidden or removed moves it
|
|
1307
|
+
|
|
1147
1308
|
if (!scene) return;
|
|
1148
1309
|
if (!xrefGroup) { xrefGroup = new THREE.Group(); scene.add(xrefGroup); }
|
|
1149
1310
|
disposeReferenceMaterials();
|
|
@@ -1210,9 +1371,10 @@ function setReferences(list) {
|
|
|
1210
1371
|
xrefGroup.add(group);
|
|
1211
1372
|
|
|
1212
1373
|
const { points, capped: keptCapped } = xrefSnapPoints(objects);
|
|
1213
|
-
// NO CACHED `bounds` HERE. It was stored and never read — `referenceBounds` recomputes —
|
|
1214
|
-
//
|
|
1215
|
-
//
|
|
1374
|
+
// NO CACHED `bounds` HERE. It was stored and never read — `referenceBounds` recomputes — so it was
|
|
1375
|
+
// a second answer to a question that already had one, kept up to date by nobody. (An earlier version
|
|
1376
|
+
// of this note also blamed the stored copy for measuring "without un-hiding"; that half was wrong,
|
|
1377
|
+
// and `referenceBounds` now records why: `setFromObject` never looks at `.visible` in the first place.)
|
|
1216
1378
|
xrefById.set(ref.id, {
|
|
1217
1379
|
group, display: ref.display || {}, name: ref.name || ref.id,
|
|
1218
1380
|
points, total: points.length, capped: keptCapped, keptCapped,
|
|
@@ -1323,6 +1485,7 @@ function applyReferenceDisplay(id, display) {
|
|
|
1323
1485
|
const visible = entry.display.visible !== false;
|
|
1324
1486
|
const opacity = Number.isFinite(entry.display.opacity) ? Math.max(0, Math.min(1, entry.display.opacity)) : 0.5;
|
|
1325
1487
|
entry.group.visible = visible;
|
|
1488
|
+
invalidateClipFloor(); // visibility decides whether this reference counts towards the clip-box floor at all — the eye toggle moves it
|
|
1326
1489
|
|
|
1327
1490
|
// HIDING A REFERENCE DROPS ANY OBJECT DRILLED INTO IT — the other door into the state `pickReferenceAt`
|
|
1328
1491
|
// refuses to create. That function now filters hidden groups so you cannot SELECT what you cannot see;
|
|
@@ -1460,6 +1623,7 @@ function setReferencePlacement(id, placement) {
|
|
|
1460
1623
|
entry.group.position.set(0, 0, 0); entry.group.quaternion.identity(); entry.group.scale.set(1, 1, 1);
|
|
1461
1624
|
entry.group.applyMatrix4(xrefMatrix(placement));
|
|
1462
1625
|
entry.group.updateMatrixWorld(true);
|
|
1626
|
+
invalidateClipFloor(); // this reference just MOVED, so any floor measured from where it used to be is now wrong
|
|
1463
1627
|
if (refMeasure3d && refMeasure3d.refId === id) {
|
|
1464
1628
|
// The cache holds points BAKED through the old matrix, so every one of them now points at where
|
|
1465
1629
|
// the geometry used to be. Camera 'change' is the only other invalidation and no camera moved.
|
|
@@ -1712,18 +1876,22 @@ function referenceProbe(id) {
|
|
|
1712
1876
|
};
|
|
1713
1877
|
}
|
|
1714
1878
|
|
|
1715
|
-
/**
|
|
1879
|
+
/**
|
|
1880
|
+
* World bounds of one reference — what zoom-to frames, and what the off-screen check measures.
|
|
1881
|
+
*
|
|
1882
|
+
* IT MEASURES A HIDDEN REFERENCE, and needs no help to: "where is it and how big is it" is exactly the
|
|
1883
|
+
* question you ask about something you cannot see, and `Box3.setFromObject` answers it regardless of
|
|
1884
|
+
* visibility. It used to un-hide the group first, on the stated grounds that `setFromObject` "skips
|
|
1885
|
+
* invisible children" — it does not. `expandByObject` never reads `.visible`; it recurses over every
|
|
1886
|
+
* child unconditionally (three.core.js). The un-hide/restore pair was therefore inert, and the comment
|
|
1887
|
+
* asserting the opposite sat on the first bounds function a reader reaches, three lines from
|
|
1888
|
+
* `visibleWorldBox`, which has to filter visibility ITSELF precisely because the claim is false.
|
|
1889
|
+
* A hidden reference returns null here only when it has no geometry at all, same as a visible one.
|
|
1890
|
+
*/
|
|
1716
1891
|
function referenceBounds(id) {
|
|
1717
1892
|
const entry = xrefById.get(id);
|
|
1718
1893
|
if (!entry || !entry.group.children.length) return null;
|
|
1719
|
-
// UN-HIDE FIRST. `Box3.setFromObject` skips invisible children, so a hidden reference measured null —
|
|
1720
|
-
// and "where is it and how big is it" is exactly the question you ask about something you cannot see.
|
|
1721
|
-
// `frameReference` already did this; this did not, so the panel's size line and the off-screen check
|
|
1722
|
-
// both went blank the moment you hid a row.
|
|
1723
|
-
const wasVisible = entry.group.visible;
|
|
1724
|
-
entry.group.visible = true;
|
|
1725
1894
|
const box = new THREE.Box3().setFromObject(entry.group);
|
|
1726
|
-
entry.group.visible = wasVisible;
|
|
1727
1895
|
return box.isEmpty() ? null : { min: box.min.toArray(), max: box.max.toArray() };
|
|
1728
1896
|
}
|
|
1729
1897
|
|
|
@@ -1738,7 +1906,7 @@ function referenceBounds(id) {
|
|
|
1738
1906
|
* ask about something you cannot currently see.
|
|
1739
1907
|
*/
|
|
1740
1908
|
function frameReference(id) {
|
|
1741
|
-
const b = referenceBounds(id); //
|
|
1909
|
+
const b = referenceBounds(id); // measures regardless of visibility, so this frames a hidden reference too
|
|
1742
1910
|
if (!b) return false;
|
|
1743
1911
|
fitCamera(new THREE.Box3(new THREE.Vector3(...b.min), new THREE.Vector3(...b.max)));
|
|
1744
1912
|
return true;
|
|
@@ -1833,6 +2001,7 @@ function setInsertMode(on, pending) {
|
|
|
1833
2001
|
if (insertMode) { if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); setClipMode(null); disarmFrame3d(); }
|
|
1834
2002
|
if (canvasEl) canvasEl.style.cursor = insertMode ? 'crosshair' : 'default';
|
|
1835
2003
|
if (api && api.onInsertModeChange) api.onInsertModeChange(insertMode);
|
|
2004
|
+
updateStatusChip();
|
|
1836
2005
|
}
|
|
1837
2006
|
function insertModeOn() { return insertMode; }
|
|
1838
2007
|
|
|
@@ -1861,6 +2030,7 @@ function setBasePickMode(colId) {
|
|
|
1861
2030
|
if (canvasEl) canvasEl.style.cursor = basePickCol ? 'crosshair' : 'default';
|
|
1862
2031
|
if (!basePickCol) { if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; }
|
|
1863
2032
|
if (api && api.onBasePickModeChange) api.onBasePickModeChange(basePickModeOn());
|
|
2033
|
+
updateStatusChip();
|
|
1864
2034
|
}
|
|
1865
2035
|
function basePickModeOn() { return !!basePickCol; }
|
|
1866
2036
|
// A point along the target column's VERTICAL axis at the cursor, elevation snapped to the level datums.
|
|
@@ -2223,8 +2393,16 @@ function fitCamera(box, dir) {
|
|
|
2223
2393
|
// far must always clear the WHOLE model, not just the framed box — else a tight detail-zoom (dbl-click) puts the
|
|
2224
2394
|
// rest of the model behind the far plane and slices it with a view-perpendicular cut that reads as a skewed
|
|
2225
2395
|
// section. Size far from the scene bounds seen from the final camera position; the fit box only sets distance/zoom.
|
|
2226
|
-
|
|
2227
|
-
|
|
2396
|
+
// …and the WHOLE scene includes a borrowed reference model, which is routinely the thing furthest from
|
|
2397
|
+
// the steel (site coordinates put one 74 m up and 40 m out) — sized on our own parts alone it is the
|
|
2398
|
+
// reference that falls behind the far plane and gets sliced.
|
|
2399
|
+
const sceneSph = visibleWorldBox().getBoundingSphere(new THREE.Sphere());
|
|
2400
|
+
// An EMPTY box's sphere reports radius -1, which would SUBTRACT from the far distance rather than add
|
|
2401
|
+
// to it. Reachable, and by an ordinary route: `frameReference` deliberately frames a HIDDEN reference,
|
|
2402
|
+
// so the framed box is non-empty while there is nothing VISIBLE to measure. Frame a compact one far
|
|
2403
|
+
// from the origin and the distance term dominates, so the -1 lands straight in `far`.
|
|
2404
|
+
const sceneR = sceneSph.radius > 0 ? sceneSph.radius : 0;
|
|
2405
|
+
const far = Math.max(dist + r * 4, perspCam.position.distanceTo(sceneSph.center) + sceneR) * 1.02;
|
|
2228
2406
|
perspCam.near = near; perspCam.far = far; perspCam.updateProjectionMatrix();
|
|
2229
2407
|
orthoCam.near = near; orthoCam.far = far; orthoCam.zoom = 1;
|
|
2230
2408
|
orthoBaseH = fit.orthoH; // tight, aspect-preserving box fit (no ortho under-frame)
|
|
@@ -2255,7 +2433,7 @@ let rebuildSeq = 0;
|
|
|
2255
2433
|
async function rebuild(fit = false) {
|
|
2256
2434
|
if (!api) return;
|
|
2257
2435
|
invalidatePointEntry('rebuild'); // synchronous, BEFORE the first await — the scene is changing; drop any open typed entry + stale base (never on stale async completion)
|
|
2258
|
-
clipCandidates = null; clipLevels = null; invalidateModelCache(); // …and the clip-draw snap cache, synchronously here too (not only in buildFromScene): every edit/undo/redo funnels through rebuild(), so a draw in progress can't snap against pre-edit candidates during the async fetchScene window
|
|
2436
|
+
clipCandidates = null; clipLevels = null; invalidateClipFloor(); invalidateModelCache(); // …and the clip-draw snap cache + measured floor, synchronously here too (not only in buildFromScene): every edit/undo/redo funnels through rebuild(), so a draw in progress can't snap against pre-edit candidates during the async fetchScene window
|
|
2259
2437
|
if (marker && clipMode === 'box') marker.visible = false; // a model change under an armed box draw invalidates the reticle position — drop it (the next hover re-snaps)
|
|
2260
2438
|
if (fit) fitPending = true; // entering 3D re-fits; an edit-triggered rebuild keeps the camera put
|
|
2261
2439
|
const seq = ++rebuildSeq;
|
|
@@ -2552,22 +2730,90 @@ function setClipMode(m) { // arm/disarm a clip pick: 'plane' (clic
|
|
|
2552
2730
|
if (m && dimMode3d) toggleDimTool();
|
|
2553
2731
|
if (m) { if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); disarmFrame3d(); } // clip shares the left-click — disarm Move/Copy + Add + the local frame so their picks don't steal it (onDown routes them first)
|
|
2554
2732
|
clipMode = (m === 'plane' || m === 'box') ? m : null;
|
|
2555
|
-
clipBoxDraft = null; clipCandidates = null; clipLevels = null; setClipPreview(null); setClipPlanePreview(null); if (marker) marker.visible = false; // drop the per-draw snap cache + any live snap marker when arming/disarming
|
|
2733
|
+
clipBoxDraft = null; clipCandidates = null; clipLevels = null; invalidateClipFloor(); setClipPreview(null); setClipPlanePreview(null); if (marker) marker.visible = false; // drop the per-draw snap cache + measured floor + any live snap marker when arming/disarming
|
|
2556
2734
|
if (canvasEl) canvasEl.style.cursor = clipMode ? 'crosshair' : 'default';
|
|
2557
2735
|
updateStatusChip();
|
|
2558
2736
|
if (api && api.onClipModeChange) api.onClipModeChange(clipMode);
|
|
2559
2737
|
return clipMode;
|
|
2560
2738
|
}
|
|
2561
2739
|
function clipModeOn() { return clipMode; }
|
|
2740
|
+
/**
|
|
2741
|
+
* The face a plane may be anchored to under (cx,cy) — the nearest of OUR steel if any of it is hit at
|
|
2742
|
+
* all, and only failing that the nearest reference (IFC) face. Deliberately NOT "the nearest face": see
|
|
2743
|
+
* the precedence paragraph.
|
|
2744
|
+
*
|
|
2745
|
+
* SHARED BY BOTH PLANE TOOLS — the Clip plane pick and the working-plane face pick. They had this same
|
|
2746
|
+
* gap and were fixed in parallel by two branches that could not see each other, each growing its own
|
|
2747
|
+
* copy of this function (`clipFaceHitAt` here, `faceHitAt` beside `wpFacePick`) with the same body and
|
|
2748
|
+
* the same reasoning. The second one to land collapsed them, which is what the first one's comment asked
|
|
2749
|
+
* for. What is left to each caller is the resulting normal: away from the camera for a clip (keep the
|
|
2750
|
+
* far side, reveal the section), toward it for a working plane (you are about to draw on it).
|
|
2751
|
+
*
|
|
2752
|
+
* THEY ALSO DISAGREE ABOUT HOW TO MEASURE THAT, which is NOT a second convention — one of them is
|
|
2753
|
+
* wrong. `clipPlaneAtScreen` tests the normal against `camera.position - hit.point`; `wpFacePick` tests
|
|
2754
|
+
* it against the ray that actually struck the face. In a perspective view the two agree. In this view's
|
|
2755
|
+
* ORTHOGRAPHIC mode they do not: for a hit off to the side, `camera.position - hit.point` is not the
|
|
2756
|
+
* direction you are looking from, so the clip tool can keep the wrong side of a face out at the edge of
|
|
2757
|
+
* a wide model. That is a pre-existing bug on the clip side, left alone here because this branch is not
|
|
2758
|
+
* where it should be fixed — but it is written down rather than smoothed over, because an earlier
|
|
2759
|
+
* version of this paragraph claimed the two callers differ in "exactly one thing" and that sentence is
|
|
2760
|
+
* an invitation to unify them on the wrong one. (Raised by Codex review of the merge.)
|
|
2761
|
+
*
|
|
2762
|
+
* REFERENCE GEOMETRY IS PICKABLE HERE AT ALL, and it was not before. This raycast saw `meshById` alone,
|
|
2763
|
+
* so arming Clip plane and clicking an IFC wall produced no hover ghost and placed no plane — the tool
|
|
2764
|
+
* simply did not react to the reference layer — and a project holding a coordination model but no steel
|
|
2765
|
+
* of its own could not be sectioned at all, since there was nothing in the pick set to click. A borrowed
|
|
2766
|
+
* building is usually the biggest thing on screen and very often the only thing at the cut, so it is
|
|
2767
|
+
* exactly what a user reaches for the clip tool to open up.
|
|
2768
|
+
*
|
|
2769
|
+
* OUR OWN STEEL STILL WINS AN OVERLAP — the same rule `pickReferenceAt` follows, and in Solid the
|
|
2770
|
+
* renderer is why: a reference draws at `renderOrder` -1 with `depthWrite:false`, so wherever the two
|
|
2771
|
+
* overlap the BEAM is the pixel on screen. Taking the nearest hit across both sets instead would anchor
|
|
2772
|
+
* the plane to a surface the user cannot see at the point they clicked.
|
|
2773
|
+
*
|
|
2774
|
+
* IN WIRE AND X-RAY THAT PIXEL ARGUMENT DOES NOT HOLD, and the rule is deliberately kept anyway. Wire
|
|
2775
|
+
* sets the fill `mat.visible = false` (the mesh stays raycastable, carrying only its outline), so a
|
|
2776
|
+
* reference behind a wireframe member IS what you see there. But `meshHitsAt` filters on `m.visible` —
|
|
2777
|
+
* the MESH — so ordinary selection has always resolved that same pixel to the member, and reaching the
|
|
2778
|
+
* reference needs the member to miss. Making the clip pick the exception would produce a display mode
|
|
2779
|
+
* in which pointing at one pixel selects a beam and clips an IFC. Agreeing with selection everywhere is
|
|
2780
|
+
* worth more than agreeing with the framebuffer in two modes. (Raised by Codex review.)
|
|
2781
|
+
*
|
|
2782
|
+
* A HIT ON THE CUT-AWAY SIDE OF AN EXISTING CLIP IS SKIPPED, in both sets. That surface is not on screen
|
|
2783
|
+
* either — the clip already removed it — so a second plane placed on it would appear to float in the
|
|
2784
|
+
* emptiness the first one opened.
|
|
2785
|
+
*
|
|
2786
|
+
* THE NATIVE CAST IS `meshHitsAt` ITSELF, not a copy of it. This function used to spell that raycast out
|
|
2787
|
+
* again — same visibility filter, same `isPointClipped` filter, the same NDC expression character for
|
|
2788
|
+
* character — while its comment claimed selection resolves a pixel the same way. Two implementations of
|
|
2789
|
+
* one rule can only agree until someone edits one of them, so the claim is now structural. (Raised by
|
|
2790
|
+
* review.) The reference cast stays here because nothing else wants it in this shape: `pickReferenceAt`
|
|
2791
|
+
* answers "which object", this wants "which face".
|
|
2792
|
+
*
|
|
2793
|
+
* A hidden reference is not pickable, and the hidden groups are filtered out rather than left to THREE,
|
|
2794
|
+
* which tests only `layers` and would happily return an invisible one.
|
|
2795
|
+
*/
|
|
2796
|
+
function faceHitAt(cx, cy) {
|
|
2797
|
+
if (!canvasEl) return null;
|
|
2798
|
+
// BEFORE `meshHitsAt`, which has no such guard: a zero-sized canvas divides through to NaN, and a
|
|
2799
|
+
// raycast down a NaN ray answers nothing while looking like an ordinary miss.
|
|
2800
|
+
const rect = canvasEl.getBoundingClientRect(); if (!rect.width || !rect.height) return null;
|
|
2801
|
+
const own = meshHitsAt(cx, cy).find((h) => !!h.face);
|
|
2802
|
+
if (own) return own;
|
|
2803
|
+
if (!xrefGroup || !xrefGroup.children.length) return null;
|
|
2804
|
+
// RE-AIMED RATHER THAN INHERITED. `meshHitsAt` has just pointed the shared `raycaster` at this very
|
|
2805
|
+
// pixel, so reusing it would work today and break silently the day that function stops being the last
|
|
2806
|
+
// thing to touch it.
|
|
2807
|
+
camera.updateMatrixWorld(); xrefGroup.updateMatrixWorld(true);
|
|
2808
|
+
raycaster.setFromCamera(new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1), camera);
|
|
2809
|
+
return raycaster.intersectObjects(xrefGroup.children.filter((g) => g.visible), true)
|
|
2810
|
+
.find((h) => !!h.face && !isPointClipped([h.point.x, h.point.y, h.point.z])) || null;
|
|
2811
|
+
}
|
|
2562
2812
|
// The plane a face-pick would produce at (cx,cy): { n (keep-side normal, pointing away from the camera), point } or
|
|
2563
2813
|
// null on a miss. Shared by the actual pick and the hover preview so the ghost always matches what a click places.
|
|
2564
2814
|
function clipPlaneAtScreen(cx, cy) {
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
|
|
2568
|
-
raycaster.setFromCamera(ndc, camera);
|
|
2569
|
-
const hit = raycaster.intersectObjects([...meshById.values()].filter((m) => m.visible), false)[0];
|
|
2570
|
-
if (!hit || !hit.face) return null; // missed a face → no plane
|
|
2815
|
+
const hit = faceHitAt(cx, cy);
|
|
2816
|
+
if (!hit) return null; // missed a face → no plane
|
|
2571
2817
|
const n = hit.face.normal.clone().transformDirection(hit.object.matrixWorld).normalize(); // face normal → world
|
|
2572
2818
|
if (n.dot(camera.position.clone().sub(hit.point)) > 0) n.negate(); // point AWAY from the camera → keep the FAR side, cut away what's between you and the clicked surface (reveal the section)
|
|
2573
2819
|
return { n, point: hit.point.clone() };
|
|
@@ -2612,14 +2858,6 @@ function addClipBoxFromBox(box) { // commit a clip box from an explicit Bo
|
|
|
2612
2858
|
applyClips(); selectClip(id); if (api && api.onClipsChange) api.onClipsChange();
|
|
2613
2859
|
return id;
|
|
2614
2860
|
}
|
|
2615
|
-
function addClipBox(pad = 150) { // convenience: a clip box from the selection's bounds (or the whole model)
|
|
2616
|
-
const box = new THREE.Box3();
|
|
2617
|
-
if (selIds.size) for (const id of selIds) { const m = meshById.get(id); if (m && m.visible) box.expandByObject(m); }
|
|
2618
|
-
if (box.isEmpty()) box.copy(sceneBox);
|
|
2619
|
-
if (box.isEmpty()) return null;
|
|
2620
|
-
box.expandByScalar(pad);
|
|
2621
|
-
return addClipBoxFromBox(box);
|
|
2622
|
-
}
|
|
2623
2861
|
function toggleClip(id, on) { const c = clips.find((x) => x.id === id); if (!c) return; if (api && api.beginClipEdit) api.beginClipEdit(); c.enabled = on === undefined ? !c.enabled : !!on; applyClips(); renderClipGizmo(); if (api && api.onClipsChange) api.onClipsChange(); }
|
|
2624
2862
|
// Rename a clip. Returns false if the name is empty or already used by ANOTHER clip (case-insensitive) — the
|
|
2625
2863
|
// caller (legend inline edit) keeps the old name + warns. Undoable.
|
|
@@ -2786,14 +3024,40 @@ function onMoveClip(e) {
|
|
|
2786
3024
|
}
|
|
2787
3025
|
// 3-step clip-box draw: click the two FOOTPRINT corners on the floor, then move up/down to PULL the height and
|
|
2788
3026
|
// click to commit (CAD "rectangle then extrude"). clipBoxDraft: {a} → {a,b} → committed.
|
|
2789
|
-
|
|
3027
|
+
/**
|
|
3028
|
+
* The elevation the two footprint corners are picked on: the bottom of everything on screen.
|
|
3029
|
+
*
|
|
3030
|
+
* IT READS `visibleWorldBox`, NOT `sceneBox` — the floor of the model you are looking at, which on a
|
|
3031
|
+
* project holding only a borrowed IFC used to be z=0 while the building sat hundreds of feet away. The
|
|
3032
|
+
* rectangle was then drawn in empty space below the model and the box committed around nothing.
|
|
3033
|
+
*
|
|
3034
|
+
* HELD FOR THE SPAN OF ONE DRAW, in `clipFloorZ`, because `clipBoxPreviewAt` asks on every mousemove and
|
|
3035
|
+
* the answer walks every mesh of every visible reference. Same per-draw cache the snap candidates use
|
|
3036
|
+
* two lines down, dropped by the same `setClipMode` on every arm and disarm — so it cannot outlive the
|
|
3037
|
+
* draw it was measured for, and a reference that arrives, moves, or is hidden between draws is picked
|
|
3038
|
+
* up by the next one. `0` only when there is genuinely nothing visible to stand on.
|
|
3039
|
+
*/
|
|
3040
|
+
function clipBoxFloorZ() {
|
|
3041
|
+
if (clipFloorZ === null) { const b = visibleWorldBox(); clipFloorZ = b.isEmpty() ? 0 : b.min.z; }
|
|
3042
|
+
return clipFloorZ;
|
|
3043
|
+
}
|
|
2790
3044
|
function clipBoxFrom(a, b, zlo, ztop) {
|
|
2791
3045
|
return new THREE.Box3(new THREE.Vector3(Math.min(a[0], b[0]), Math.min(a[1], b[1]), Math.min(zlo, ztop)), new THREE.Vector3(Math.max(a[0], b[0]), Math.max(a[1], b[1]), Math.max(zlo, ztop)));
|
|
2792
3046
|
}
|
|
2793
3047
|
// The clip-box draw's snap targets, built ONCE per draw (allCandidates does O(n²) beam-intersection work — the
|
|
2794
3048
|
// dim/Move tools cache it too, tfCandidates/dimCandidates3d). Members can't change mid-draw, so setClipMode drops
|
|
2795
3049
|
// the cache on every arm/disarm. A malformed member/grid degrades to no snap (raw floor), never a broken tool.
|
|
2796
|
-
let clipCandidates = null, clipLevels = null;
|
|
3050
|
+
let clipCandidates = null, clipLevels = null, clipFloorZ = null;
|
|
3051
|
+
/**
|
|
3052
|
+
* Drop the measured clip-box floor — call this wherever the geometry it was measured FROM can change.
|
|
3053
|
+
*
|
|
3054
|
+
* It is separate from the snap-candidate caches beside it because it invalidates on a strictly wider
|
|
3055
|
+
* set of events: the candidates are built from members and the grid, but the floor is built from the
|
|
3056
|
+
* members AND every visible reference model, so a reference arriving, moving or being hidden makes it
|
|
3057
|
+
* stale while leaving the candidates perfectly good. Missing those was the first version of this cache:
|
|
3058
|
+
* `setClipMode` alone looks sufficient, and is, right up until the world moves under an armed tool.
|
|
3059
|
+
*/
|
|
3060
|
+
function invalidateClipFloor() { clipFloorZ = null; }
|
|
2797
3061
|
function clipBoxSnapCands() { if (!clipCandidates) { try { clipCandidates = allCandidates(null); } catch { clipCandidates = []; } } return clipCandidates; }
|
|
2798
3062
|
function clipBoxLevels() { if (!clipLevels) { try { clipLevels = MODEL().levels(null); } catch { clipLevels = []; } } return clipLevels; } // model-wide: the clip box spans every sheet, so it must be able to snap to an off-sheet endpoint
|
|
2799
3063
|
// A footprint corner from the cursor: the floor point under it, PULLED to a member/grid/UCS snap when one is
|
|
@@ -2851,7 +3115,8 @@ function clipBoxPreviewAt(cx, cy) { // live preview: snap marker + a flat fo
|
|
|
2851
3115
|
// ---- working area (Tekla-style) ----
|
|
2852
3116
|
// One box that bounds the view: shown as a wireframe cuboid AND it sections the model (parts outside it hide),
|
|
2853
3117
|
// composing with any clip planes/boxes through applyClips (workArea.planes are added when enabled). "Set to all
|
|
2854
|
-
// objects" =
|
|
3118
|
+
// objects" = everything on screen, borrowed reference models included; "define from selection" = a padded box
|
|
3119
|
+
// around the selection (your own parts, since only those are selectable).
|
|
2855
3120
|
let workAreaHelper = null; // THREE.Box3Helper wireframe for the work area (recreated on each box change)
|
|
2856
3121
|
function renderWorkArea() {
|
|
2857
3122
|
if (workAreaHelper) { if (overlayScene) overlayScene.remove(workAreaHelper); workAreaHelper.geometry.dispose(); workAreaHelper.material.dispose(); workAreaHelper = null; }
|
|
@@ -2870,7 +3135,7 @@ function setWorkAreaBox(box) {
|
|
|
2870
3135
|
if (api && api.onWorkAreaChange) api.onWorkAreaChange(workAreaState());
|
|
2871
3136
|
return true;
|
|
2872
3137
|
}
|
|
2873
|
-
function workAreaSetAll() { return setWorkAreaBox(
|
|
3138
|
+
function workAreaSetAll() { return setWorkAreaBox(visibleWorldBox()); } // "set work area to all objects" — ALL objects, so a visible reference model counts; steel-only made this return false (a dead control) on a project holding only a borrowed IFC
|
|
2874
3139
|
function workAreaFromSelection(pad = 150) { // define a new work area around the selection
|
|
2875
3140
|
const box = new THREE.Box3(); for (const id of selIds) { const m = meshById.get(id); if (m && visibleIgnoringWorkArea(m)) box.expandByObject(m); } // include a part hidden ONLY by the current work area — the new box supersedes it (a group/isolate-hidden part is still excluded)
|
|
2876
3141
|
if (box.isEmpty()) return false; box.expandByScalar(pad); return setWorkAreaBox(box);
|
|
@@ -2907,10 +3172,14 @@ function setCameraState(s) {
|
|
|
2907
3172
|
if (camera === orthoCam) { if (s.orthoH > 0) orthoBaseH = s.orthoH; orthoCam.zoom = s.zoom > 0 ? s.zoom : 1; reframeOrtho(); }
|
|
2908
3173
|
// keep near/far clearing the whole scene from the restored spot (mirror fitCamera's sizing so a far-out
|
|
2909
3174
|
// saved view doesn't clip the model behind the far plane).
|
|
2910
|
-
const sph =
|
|
3175
|
+
const sph = visibleWorldBox().getBoundingSphere(new THREE.Sphere());
|
|
2911
3176
|
const dist = camera.position.distanceTo(controls.target) || 1;
|
|
2912
3177
|
const near = Math.max(dist / 2000, 0.5);
|
|
2913
|
-
|
|
3178
|
+
// `sph.radius || dist` READ THE EMPTY CASE BACKWARDS: an empty Box3's bounding sphere reports radius
|
|
3179
|
+
// -1, and -1 is truthy, so the fallback never fired and `far` was computed from a NEGATIVE radius —
|
|
3180
|
+
// restoring a saved view of a project with no native steel put the far plane in front of the model.
|
|
3181
|
+
const r = sph.radius > 0 ? sph.radius : dist;
|
|
3182
|
+
const far = Math.max(dist + r * 4, camera.position.distanceTo(sph.center) + r) * 1.02;
|
|
2914
3183
|
perspCam.near = near; perspCam.far = far; perspCam.updateProjectionMatrix();
|
|
2915
3184
|
orthoCam.near = near; orthoCam.far = far; orthoCam.updateProjectionMatrix();
|
|
2916
3185
|
controls.update();
|
|
@@ -2950,17 +3219,61 @@ function sectionViewState(boxData, direction, label) {
|
|
|
2950
3219
|
};
|
|
2951
3220
|
}
|
|
2952
3221
|
|
|
3222
|
+
/**
|
|
3223
|
+
* WHERE MY STEEL IS — our own parts and nothing else. Deliberately NOT `visibleWorldBox`.
|
|
3224
|
+
*
|
|
3225
|
+
* The editor calls this `nativeModelBounds`, and `refMoveToOrigin` uses it to move a borrowed model
|
|
3226
|
+
* NEXT TO the steel. Fold references in here and that centre would include the very reference being
|
|
3227
|
+
* moved, so "put it beside my steel" would resolve to "put it where it already is". The view-generation
|
|
3228
|
+
* callers want the same steel-only reading.
|
|
3229
|
+
*/
|
|
2953
3230
|
function sceneBounds() {
|
|
2954
3231
|
if (!sceneBox || sceneBox.isEmpty()) return null;
|
|
2955
3232
|
return { min: sceneBox.min.toArray(), max: sceneBox.max.toArray() };
|
|
2956
3233
|
}
|
|
2957
3234
|
|
|
2958
|
-
|
|
3235
|
+
/**
|
|
3236
|
+
* WHAT IS ON SCREEN — our steel unioned with every VISIBLE reference model.
|
|
3237
|
+
*
|
|
3238
|
+
* `sceneBox` is filled by `expandByObject` over the contract's elements and by nothing else, so every
|
|
3239
|
+
* consumer that meant "everything" quietly meant "everything of ours". On a project whose visible
|
|
3240
|
+
* content is a borrowed IFC that is not a small error, it is the entire answer: Fit and Home were
|
|
3241
|
+
* silent no-ops there (`cameraFitForBox` returns null on an empty box), "set work area to all objects"
|
|
3242
|
+
* returned false, and the clip-box draw picked its two footprint corners on a floor at z=0 while the
|
|
3243
|
+
* building stood hundreds of feet above it. Overlaying somebody's coordination model before modelling
|
|
3244
|
+
* any steel of your own is a normal first move, and it left half the view controls dead.
|
|
3245
|
+
*
|
|
3246
|
+
* THE VISIBILITY FILTER IS OURS, NOT THREE'S — the one thing here that is easy to get wrong by trusting
|
|
3247
|
+
* a comment. `Box3.expandByObject` never reads `.visible`; it walks every child unconditionally. So
|
|
3248
|
+
* hiding a reference has to be honoured HERE or a hidden building still drags the clip floor down,
|
|
3249
|
+
* with nothing on screen to explain why. Filtered per group, the same line `clipFaceHitAt` and
|
|
3250
|
+
* `pickReferenceAt` draw.
|
|
3251
|
+
*
|
|
3252
|
+
* NOT CACHED, on purpose. Reference geometry streams in behind the native steel and a reference can be
|
|
3253
|
+
* moved, hidden, or re-read at any moment, so a stored box would be stale long before it was slow. Every
|
|
3254
|
+
* caller here is bound to a user action — Fit, a view preset, the ViewCube, defining a work area — not to
|
|
3255
|
+
* a frame or a resize. The one caller that could not afford the walk is the clip-box draw, which asks on
|
|
3256
|
+
* every mousemove, and it holds the single number it needs for the span of one draw (see
|
|
3257
|
+
* `invalidateClipFloor` for what releases it).
|
|
3258
|
+
*/
|
|
3259
|
+
function visibleWorldBox() {
|
|
3260
|
+
const box = sceneBox.clone();
|
|
3261
|
+
if (xrefGroup) {
|
|
3262
|
+
// The group's OWN place in the world, cheaply (parents only): `setFromObject` already refreshes
|
|
3263
|
+
// every descendant matrix itself, so walking the children again here would double the cost of the
|
|
3264
|
+
// measurement on the largest models in the scene.
|
|
3265
|
+
xrefGroup.updateWorldMatrix(true, false);
|
|
3266
|
+
for (const g of xrefGroup.children) if (g.visible) box.union(new THREE.Box3().setFromObject(g));
|
|
3267
|
+
}
|
|
3268
|
+
return box;
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
function frameAll() { fitCamera(visibleWorldBox()); }
|
|
2959
3272
|
const VIEWS = { top: [0, 0, 1], bottom: [0, 0, -1], front: [0, -1, 0], back: [0, 1, 0], right: [1, 0, 0], left: [-1, 0, 0], iso: [0.55, -0.8, 0.5] };
|
|
2960
|
-
function applyView(name) { const d = VIEWS[name]; if (d) fitCamera(
|
|
3273
|
+
function applyView(name) { const d = VIEWS[name]; if (d) fitCamera(visibleWorldBox(), new THREE.Vector3(d[0], d[1], d[2])); }
|
|
2961
3274
|
// Fit just the selection (Tekla "Zoom selected" / Shift+Space); falls back to fit-all when nothing's picked.
|
|
2962
3275
|
function frameSelection() {
|
|
2963
|
-
if (!selIds.size) { fitCamera(
|
|
3276
|
+
if (!selIds.size) { fitCamera(visibleWorldBox()); return; }
|
|
2964
3277
|
const box = new THREE.Box3();
|
|
2965
3278
|
for (const id of selIds) { const m = meshById.get(id); if (m && m.visible) box.expandByObject(m); }
|
|
2966
3279
|
if (!box.isEmpty()) fitCamera(box);
|
|
@@ -3065,6 +3378,7 @@ function toggleDimTool() {
|
|
|
3065
3378
|
if (!dimMode3d) { dimDraft3d = null; dimCandidates3d = null; dimPreviewLine.visible = false; marker.visible = false; readout.style.display = 'none'; canvasEl.style.cursor = 'default'; setSnapOnly3d(null); } // disarming ends the operation → the snap override reverts to all snaps
|
|
3066
3379
|
else { if (clipMode) setClipMode(null); if (wpMode) armWorkPlanePick(wpMode); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); drClear3d(); disarmFrame3d(); controls.enabled = true; canvasEl.style.cursor = 'crosshair'; } // arming the dim tool disarms the clip pick, a set-plane pick, Move/Copy, Add-member AND the local frame (all share the left-click + Esc)
|
|
3067
3380
|
reflectDimBar();
|
|
3381
|
+
updateStatusChip();
|
|
3068
3382
|
return dimMode3d;
|
|
3069
3383
|
}
|
|
3070
3384
|
// Arm/disarm the grid panel's "Add single line" pick for the 3D view. The early-out keeps re-arming a no-op:
|
|
@@ -3749,7 +4063,7 @@ function initCube() {
|
|
|
3749
4063
|
const p = mesh.worldToLocal(hit.point.clone()), snap = (x) => Math.abs(x) > 0.6 ? Math.sign(x) : 0;
|
|
3750
4064
|
const dv = new THREE.Vector3(snap(p.x), snap(p.y), snap(p.z));
|
|
3751
4065
|
if (Math.abs(dv.x) + Math.abs(dv.y) + Math.abs(dv.z) <= 1) { const f = CUBE_FACES[hit.face.materialIndex]; if (f) applyView(f.view); } // a face → ortho view
|
|
3752
|
-
else fitCamera(
|
|
4066
|
+
else fitCamera(visibleWorldBox(), dv); // an edge/corner → iso-style view from that world direction (the same bounds the face path frames through applyView — steel-only here would frame a cube FACE onto a reference model but a cube EDGE onto nothing)
|
|
3753
4067
|
});
|
|
3754
4068
|
cube = { renderer: cr, scene: cs, cam: cc, mesh };
|
|
3755
4069
|
}
|
|
@@ -4182,7 +4496,7 @@ function frameInfo() {
|
|
|
4182
4496
|
}
|
|
4183
4497
|
return { mode: 'global' };
|
|
4184
4498
|
}
|
|
4185
|
-
function fireFrameChange() { invalidatePointEntry('drift'); if (!(pending && pending.frameDrag)) { tfCandidates = null; dimCandidates3d = null; } renderWorkPlane(); reflectDimAxisBar(); } // re-draws the gizmo + reference plane + fires the Axes chip; relabels the dim-axis bar (X′/Y′/Elev follows the frame); 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)
|
|
4499
|
+
function fireFrameChange() { invalidatePointEntry('drift'); if (!(pending && pending.frameDrag)) { tfCandidates = null; dimCandidates3d = null; } renderWorkPlane(); reflectDimAxisBar(); updateStatusChip(); } // re-draws the gizmo + reference plane + fires the Axes chip; relabels the dim-axis bar (X′/Y′/Elev follows the frame); 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)
|
|
4186
4500
|
// Set a HORIZONTAL frame at origin (numeric entry + gizmo materialize). origin defaults its Z to the active level.
|
|
4187
4501
|
function setFrame3d(originMm, angleDeg) {
|
|
4188
4502
|
const z = (originMm && originMm.length > 2) ? originMm[2] : frameZ();
|
|
@@ -4337,7 +4651,7 @@ function framePicking() { return framePickPts !== null; }
|
|
|
4337
4651
|
function framePickStep() { return framePickPts ? framePickPts.length : null; } // 0=origin · 1=X · 2=Y | null when not picking
|
|
4338
4652
|
function cancelFramePick() { framePickPts = null; disposeFramePreview(); if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; }
|
|
4339
4653
|
function disposeFramePreview() { if (!framePreview) return; if (overlayScene) overlayScene.remove(framePreview); framePreview.traverse((o) => { if (o.geometry) o.geometry.dispose(); if (o.material) o.material.dispose(); }); framePreview = null; }
|
|
4340
|
-
function fireFramePickChange() { if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); } // the panel hint
|
|
4654
|
+
function fireFramePickChange() { if (api && api.onFrame3dChange) api.onFrame3dChange(frameInfo()); updateStatusChip(); } // the panel hint and canvas guidance follow the pick step; frame3d is unchanged so the chip/gizmo stay put
|
|
4341
4655
|
function framePickClick(e) {
|
|
4342
4656
|
const r = dimPointAt(e); if (!r) return; // a valid snapped/plane point
|
|
4343
4657
|
if (framePickPts.length === 1 && Math.hypot(r.p[0] - framePickPts[0][0], r.p[1] - framePickPts[0][1], r.p[2] - framePickPts[0][2]) < 5) { // X point == origin → there's no X axis; reject HERE with an accurate message (else every later Y pick fails on a≈b)
|
|
@@ -4434,26 +4748,50 @@ function renderWorkPlane() {
|
|
|
4434
4748
|
function reflectWpBar() { const b = document.getElementById('m3dWp'); if (b) { b.classList.toggle('on', !!wpMode || !!workPlane);
|
|
4435
4749
|
const kind = workPlane && workPlane.kind ? { face: 'Face', p3: '3pt', xy: 'XY', xz: 'XZ', yz: 'YZ' }[workPlane.kind] || '' : '';
|
|
4436
4750
|
b.textContent = wpMode ? '◇ Plane ✕' : (kind ? '◇ Plane: ' + kind + ' ▾' : '◇ Plane ▾'); } reflectDimAxisBar(); } // the label reads the active plane without opening the menu (ux review); relabel the dim-axis bar (a set/cleared plane flips X/Y between World and local)
|
|
4437
|
-
function armWorkPlanePick(mode) { if (wpMode === mode) { wpMode = null; wpDraft = null; } else { wpMode = mode; wpDraft = null; dropGridLinePick3d(); dropRefMeasure3d(); if (dimMode3d) toggleDimTool(); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); disarmFrame3d(); } marker.visible = false; canvasEl.style.cursor = wpMode ? 'crosshair' : 'default'; reflectWpBar(); } // a set-plane pick shares the left-click — disarm Move/Copy + Add + the local frame (their onDown routes run first)
|
|
4751
|
+
function armWorkPlanePick(mode) { if (wpMode === mode) { wpMode = null; wpDraft = null; } else { wpMode = mode; wpDraft = null; dropGridLinePick3d(); dropRefMeasure3d(); if (dimMode3d) toggleDimTool(); if (api && api.disarmTransform) api.disarmTransform(); if (api && api.disarmAdd) api.disarmAdd(); cmClear3d(); drClear3d(); disarmFrame3d(); } marker.visible = false; canvasEl.style.cursor = wpMode ? 'crosshair' : 'default'; reflectWpBar(); updateStatusChip(); } // a set-plane pick shares the left-click — disarm Move/Copy + Add + the local frame (their onDown routes run first)
|
|
4438
4752
|
function setWorkPlanePrincipal(kind, offsetMm) {
|
|
4439
4753
|
const off = offsetMm || 0;
|
|
4440
4754
|
const def = { xy: { normal: [0, 0, 1], xAxis: [1, 0, 0] }, xz: { normal: [0, 1, 0], xAxis: [1, 0, 0] }, yz: { normal: [1, 0, 0], xAxis: [0, 1, 0] } }[kind];
|
|
4441
4755
|
if (!def) return;
|
|
4442
4756
|
workPlane = { origin: def.normal.map((c) => c * off), normal: def.normal, xAxis: def.xAxis, kind };
|
|
4443
|
-
wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar();
|
|
4757
|
+
wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar(); updateStatusChip();
|
|
4444
4758
|
}
|
|
4445
|
-
function clearWorkPlane() { workPlane = null; wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar(); }
|
|
4759
|
+
function clearWorkPlane() { workPlane = null; wpMode = null; wpDraft = null; invalidatePointEntry('drift'); renderWorkPlane(); reflectWpBar(); updateStatusChip(); }
|
|
4446
4760
|
function toggleWorkPlaneVisible(on) { wpVisible = on === undefined ? !wpVisible : !!on; try { localStorage.setItem('steel:wpVisible:v1', wpVisible ? '1' : '0'); } catch { /* storage can be unavailable; keep the session preference */ } renderWorkPlane(); }
|
|
4447
4761
|
function workPlaneInfo() { return { set: !!workPlane, mode: wpMode, visible: wpVisible, plane: workPlane ? { origin: [...workPlane.origin], normal: [...workPlane.normal], xAxis: [...workPlane.xAxis] } : null }; }
|
|
4448
|
-
|
|
4762
|
+
/**
|
|
4763
|
+
* face pick: the same face → plane conversion the clip tool does, over the same `faceHitAt`, with the
|
|
4764
|
+
* opposite normal convention — the plane lands ON the face, facing you.
|
|
4765
|
+
*
|
|
4766
|
+
* THE NORMAL IS TURNED TO FACE THE VIEWER, which is not cosmetic. `planeBasis` derives v as n × u, so
|
|
4767
|
+
* the sign of n decides which way the plane's local +Y and +Z run — and that is Move/Copy's Z lock, the
|
|
4768
|
+
* dimension axes, and the direction Add-member offsets. Reference geometry is drawn `DoubleSide`
|
|
4769
|
+
* precisely because somebody else's IFC winding is not ours to trust, so without this a wall whose
|
|
4770
|
+
* triangles happen to wind inward would hand back a plane whose +Z points into the wall — dimensionally
|
|
4771
|
+
* perfect and backwards.
|
|
4772
|
+
*
|
|
4773
|
+
* IT IS NOT A NO-OP FOR EVERYTHING OF OURS, and an earlier version of this comment claimed it was.
|
|
4774
|
+
* Ordinary members and their cuts are `FrontSide`, so THREE culls back-facing triangles and every hit
|
|
4775
|
+
* it could return for one was already facing the camera — for those the flip provably changes nothing.
|
|
4776
|
+
* But `meshById` also holds two `DoubleSide` kinds: `custom` connection meshes (tessellated with
|
|
4777
|
+
* untrusted winding, same reason as a reference) and placed `image` detail planes, whose normal comes
|
|
4778
|
+
* from an authored `el.n` that may point either way. Clicking one of those from behind used to hand
|
|
4779
|
+
* back a plane pointing away from you and now does not. That is the same correction for the same
|
|
4780
|
+
* reason, not an accident of applying the flip too widely — but it IS a change to existing behaviour,
|
|
4781
|
+
* so it is stated here and pinned by a test rather than left to be discovered. (Raised by Codex review.)
|
|
4782
|
+
*
|
|
4783
|
+
* MEASURED AGAINST THE RAY, not `camera.position - point`: this view has an orthographic mode, where
|
|
4784
|
+
* the camera's position is not the direction you are looking from for an off-axis point. The ray is the
|
|
4785
|
+
* one `faceHitAt` just cast — aimed at this very pixel on both of its paths, by `meshHitsAt` on the
|
|
4786
|
+
* native one and by its own `setFromCamera` on the reference one — and it is what actually struck the
|
|
4787
|
+
* face. (The clip tool answers the same question with `camera.position - point`, which is why the two
|
|
4788
|
+
* disagree in an off-axis ortho view; that is a bug on its side, not a convention.)
|
|
4789
|
+
*/
|
|
4449
4790
|
function wpFacePick(cx, cy) {
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
|
|
4453
|
-
raycaster.setFromCamera(ndc, camera);
|
|
4454
|
-
const hit = raycaster.intersectObjects([...meshById.values()].filter((m) => m.visible), false)[0];
|
|
4455
|
-
if (!hit || !hit.face) return null;
|
|
4791
|
+
const hit = faceHitAt(cx, cy);
|
|
4792
|
+
if (!hit) return null;
|
|
4456
4793
|
const n = hit.face.normal.clone().transformDirection(hit.object.matrixWorld).normalize();
|
|
4794
|
+
if (n.dot(raycaster.ray.direction) > 0) n.negate(); // wound away from the viewer → turn it around
|
|
4457
4795
|
const b = planeBasis([n.x, n.y, n.z]);
|
|
4458
4796
|
return { origin: [hit.point.x, hit.point.y, hit.point.z], normal: [n.x, n.y, n.z], xAxis: b.u, kind: 'face' };
|
|
4459
4797
|
}
|
|
@@ -4903,7 +5241,7 @@ function onDown(e) {
|
|
|
4903
5241
|
if (readout) { readout.style.display = 'none'; if (readout._coord) readout._coord.style.display = 'none'; } // UCS Stage 2: hide the whole readout chip so a drag never shows a lingering coordinate (or an empty coord-only shell); the drag/next hover re-shows it
|
|
4904
5242
|
if (e.button === 2) { rightDownXY = [e.clientX, e.clientY]; rightMoved = false; } // arm the click-vs-drag test for the snap menu
|
|
4905
5243
|
if (e.button !== 0) return; // RIGHT/MIDDLE → OrbitControls (orbit/pan)
|
|
4906
|
-
if (wpMode === 'face') { e.stopPropagation(); const r = wpFacePick(e.clientX, e.clientY); if (r) { workPlane = r; wpMode = null; invalidatePointEntry('drift'); canvasEl.style.cursor = 'default'; renderWorkPlane(); reflectWpBar(); if (api && api.toast) api.toast('Working plane set on the face'); } return; } // armed: one face click sets the plane
|
|
5244
|
+
if (wpMode === 'face') { e.stopPropagation(); const r = wpFacePick(e.clientX, e.clientY); if (r) { workPlane = r; wpMode = null; invalidatePointEntry('drift'); canvasEl.style.cursor = 'default'; renderWorkPlane(); reflectWpBar(); updateStatusChip(); if (api && api.toast) api.toast('Working plane set on the face'); } return; } // armed: one face click sets the plane
|
|
4907
5245
|
if (wpMode === '3pt') { e.stopPropagation();
|
|
4908
5246
|
const r = dimPointAt(e); if (!r) return;
|
|
4909
5247
|
wpDraft = wpDraft || []; wpDraft.push(r.p);
|
|
@@ -4913,7 +5251,7 @@ function onDown(e) {
|
|
|
4913
5251
|
if (wp) { wp.kind = 'p3'; workPlane = wp; invalidatePointEntry('drift'); renderWorkPlane(); if (api && api.toast) api.toast('Working plane set from 3 points'); }
|
|
4914
5252
|
else if (api && api.toast) api.toast('Points are collinear — plane not set');
|
|
4915
5253
|
reflectWpBar(); }
|
|
4916
|
-
return; }
|
|
5254
|
+
updateStatusChip(); return; }
|
|
4917
5255
|
if (addActive()) { e.stopPropagation(); controls.enabled = true; drClick(e); return; } // Add-member armed (editor state) → two plane picks draw a member
|
|
4918
5256
|
if (cmActive()) { if (tfClick(e)) { e.stopPropagation(); controls.enabled = true; return; } } // Move/Copy armed (editor state) → picks land on the working plane; an empty-selection click falls through to select
|
|
4919
5257
|
if (basePickCol) { e.stopPropagation(); const r = basePickPoint(e.clientX, e.clientY); if (r) { if (api && api.onBasePick) api.onBasePick(r); setBasePickMode(null); } return; } // Mode B: commit + disarm only on a valid on-column pick; an off-column click is ignored (stays armed) — Esc cancels
|
|
@@ -4986,7 +5324,7 @@ function onDown(e) {
|
|
|
4986
5324
|
if (g.valueMm > 1 && api && api.onAddDim3d) api.onAddDim3d({ id: api.newDim3dId(), a, b, axis, ...(axisDir ? { axisDir } : {}) });
|
|
4987
5325
|
else if (g.valueMm <= 1 && axis !== 'free') { dimDraft3d = { a }; if (api && api.toast) api.toast('No length along the locked axis — move the second point or switch axis'); } // any AXIS-LOCKED projection (world X/Y/Z/Elev or local X′/Y′) collapsed to ~0 despite a real 2nd pick — e.g. two points at the same level with Z / Alt-vertical → keep the first anchor + explain, don't silently drop the pick. A coincident 'free' double-click stays a silent no-op.
|
|
4988
5326
|
}
|
|
4989
|
-
return;
|
|
5327
|
+
updateStatusChip(); return;
|
|
4990
5328
|
}
|
|
4991
5329
|
downXY = [e.clientX, e.clientY];
|
|
4992
5330
|
let id = null; try { id = pickAt(e.clientX, e.clientY); } catch { id = null; }
|
|
@@ -5642,6 +5980,16 @@ function updateStatusChip() {
|
|
|
5642
5980
|
if (!hoverChip || !canvasEl) return;
|
|
5643
5981
|
const rect = canvasEl.getBoundingClientRect();
|
|
5644
5982
|
let txt = '';
|
|
5983
|
+
// Idle hover/help may be collapsed. Instructions for an armed tool or an in-flight gesture are
|
|
5984
|
+
// operationally critical, so they stay visible until that action ends, then return to the saved idle state.
|
|
5985
|
+
const toolGuidance = canvasToolGuidanceState({
|
|
5986
|
+
teklaDragActive: !!(teklaDrag && teklaDrag.active), workPlaneMode: wpMode,
|
|
5987
|
+
addActive: !!addActive(), transformActive: !!cmActive(), referenceMeasureActive: !!refMeasure3d,
|
|
5988
|
+
gridLinePickActive: !!gridLinePick3d, clipMode, dimensionMode: dimMode3d,
|
|
5989
|
+
dimensionHasStart: !!dimDraft3d, insertMode, insertName: insertPending && insertPending.name,
|
|
5990
|
+
basePickColumn: basePickCol, frameMode, framePickStep: framePickStep(), geometryMode: geoMode(),
|
|
5991
|
+
});
|
|
5992
|
+
const forceOpen = toolGuidance.forceOpen;
|
|
5645
5993
|
const selectionStatus=objectSelectionStatus(selIds.size,selectedGridIds.size),showId=hoverId||(!selectionStatus&&selIds.size===1?[...selIds][0]:null);
|
|
5646
5994
|
// The badge follows the cursor and so clips away at the window edge — from there this chip is the
|
|
5647
5995
|
// only thing still telling the user what releasing will do.
|
|
@@ -5652,7 +6000,7 @@ function updateStatusChip() {
|
|
|
5652
6000
|
? `Release to insert ${n} ${noun} into ${HOST_SHORT[teklaDrag.target]} · release here or Esc to cancel`
|
|
5653
6001
|
: `Release over Tekla, Revit, SketchUp or Rhino to insert ${n} ${noun} · release here or Esc to cancel`;
|
|
5654
6002
|
}
|
|
5655
|
-
else if (wpMode === 'face') txt = 'Click
|
|
6003
|
+
else if (wpMode === 'face') txt = 'Click any face — member or reference — the working plane lands on it · Esc to cancel';
|
|
5656
6004
|
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] || '';
|
|
5657
6005
|
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';
|
|
5658
6006
|
else if (cmActive()) { const st = cmActive(), lock = lockChipTxt();
|
|
@@ -5669,6 +6017,7 @@ function updateStatusChip() {
|
|
|
5669
6017
|
else if (gridLinePick3d) txt = gridLinePick3d.a ? 'Click the second point of the grid line · Esc to cancel' : 'Click the first point of the grid line · Esc to cancel'; // must sit above the showId/default branches, else an armed two-click tool shows the hovered member or the drag-move hint the user can't act on
|
|
5670
6018
|
else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
|
|
5671
6019
|
else if (clipMode === 'box') txt = !clipBoxDraft ? 'Click the first floor corner of the clip box · Esc to cancel' : !clipBoxDraft.b ? 'Click the opposite floor corner · Esc to cancel' : 'Move up/down to set the height, then click · Esc to step back';
|
|
6020
|
+
else if (toolGuidance.text) txt = toolGuidance.text;
|
|
5672
6021
|
else if (showId) { const m = memberById(showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
|
|
5673
6022
|
else if (selectionStatus) txt = selectionStatus;
|
|
5674
6023
|
else if (isIsolated()) txt = `Isolated: ${(isolatedIds ? isolatedIds.size : 0) + (isolatedGridIds ? isolatedGridIds.size : 0)} · Show all to restore`;
|
|
@@ -5680,9 +6029,19 @@ function updateStatusChip() {
|
|
|
5680
6029
|
else { const canDrag = api && api.dragMoveEnabled && api.dragMoveEnabled();
|
|
5681
6030
|
txt = (canDrag ? 'Drag to move · Ctrl+drag to copy · ' : 'Click to select · ') + 'ends to stretch · Alt+drag elevation · right-drag orbit · dbl-click to zoom in'; }
|
|
5682
6031
|
hoverChip.textContent = txt;
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
6032
|
+
if (hoverChipShell) {
|
|
6033
|
+
const open = forceOpen || !hoverChipIdleCollapsed, shown = canvasEl.style.display !== 'none';
|
|
6034
|
+
hoverChipShell.classList.toggle('collapsed', !open); hoverChipShell.style.display = shown ? 'flex' : 'none';
|
|
6035
|
+
hoverChip.dataset.tip = txt;
|
|
6036
|
+
hoverChipToggle.classList.toggle('open', open); hoverChipToggle.setAttribute('aria-expanded', String(open));
|
|
6037
|
+
hoverChipToggle.setAttribute('aria-disabled', String(forceOpen));
|
|
6038
|
+
const label = forceOpen ? 'Tool guidance stays visible until the current action ends' : open ? 'Collapse canvas guidance' : 'Expand canvas guidance';
|
|
6039
|
+
hoverChipToggle.setAttribute('aria-label', label); hoverChipToggle.dataset.tip = label;
|
|
6040
|
+
} else {
|
|
6041
|
+
hoverChip.style.left = (rect.left + rect.width / 2) + 'px'; hoverChip.style.transform = 'translateX(-50%)';
|
|
6042
|
+
hoverChip.style.top = (rect.bottom - 30) + 'px';
|
|
6043
|
+
hoverChip.style.display = canvasEl.style.display === 'none' ? 'none' : 'block';
|
|
6044
|
+
}
|
|
5686
6045
|
}
|
|
5687
6046
|
|
|
5688
6047
|
function show() { if (controls) controls.enabled = true; if (canvasEl) { canvasEl.style.display = 'block'; resize(); } if (!rafId) loop(); updateStatusChip(); refreshDims(); refreshOverlayDims(); renderFrameGizmo(); } // resume the render loop (reset orbit in case a gesture was stranded by a mid-drag hide)
|
|
@@ -5703,7 +6062,7 @@ function hide() {
|
|
|
5703
6062
|
if (propLabelHost) propLabelHost.style.display = 'none'; // property labels ride the same loop — hide synchronously so none strand over the 2D UI
|
|
5704
6063
|
clearCopyGhost(); // drop a stale Ctrl+drag copy ghost on the way out
|
|
5705
6064
|
endTeklaDrag(); // and a live drag-out to Tekla — a stranded one would leave its badge on screen and swallow every later pointer move
|
|
5706
|
-
if (canvasEl) canvasEl.style.display = 'none'; if (hoverChip) hoverChip.style.display = 'none'; if (rafId) { cancelAnimationFrame(rafId); rafId = null; }
|
|
6065
|
+
if (canvasEl) canvasEl.style.display = 'none'; if (hoverChipShell) hoverChipShell.style.display = 'none'; else if (hoverChip) hoverChip.style.display = 'none'; if (rafId) { cancelAnimationFrame(rafId); rafId = null; }
|
|
5707
6066
|
}
|
|
5708
6067
|
function isReady() { return built; }
|
|
5709
6068
|
|
|
@@ -5716,6 +6075,10 @@ function dispose() {
|
|
|
5716
6075
|
refMeasureLabel = null; refMeasure3d = null; refMeasureKept = null; refMeasureCands = null;
|
|
5717
6076
|
modelReads = null; // the resolved read half belongs to the host that was torn down; a re-init must ask the new one (unit 5, P7d)
|
|
5718
6077
|
endTeklaDrag(); // release the pointer capture and take the badge with us
|
|
6078
|
+
// The progressive preview is a SIBLING of `xrefGroup`, so the reference teardown below never sees
|
|
6079
|
+
// it — a view disposed mid-import would leak its meshes and their material. It owns its own
|
|
6080
|
+
// disposal for exactly that reason; this is the one caller that has to remember to ask.
|
|
6081
|
+
clearReferencePreview();
|
|
5719
6082
|
if (rafId) cancelAnimationFrame(rafId);
|
|
5720
6083
|
if (hoverRAF) cancelAnimationFrame(hoverRAF);
|
|
5721
6084
|
if (ro) ro.disconnect();
|
|
@@ -5726,7 +6089,8 @@ function dispose() {
|
|
|
5726
6089
|
window.removeEventListener('keydown', onKey);
|
|
5727
6090
|
window.removeEventListener('keydown', onModifierChange);
|
|
5728
6091
|
window.removeEventListener('keyup', onModifierChange);
|
|
5729
|
-
for (const ovl of [readout, hoverChip, rubber, dimLabelHost]) if (ovl && ovl.parentNode) ovl.parentNode.removeChild(ovl);
|
|
6092
|
+
for (const ovl of [readout, hoverChipShell || hoverChip, rubber, dimLabelHost]) if (ovl && ovl.parentNode) ovl.parentNode.removeChild(ovl);
|
|
6093
|
+
hoverChip = hoverChipShell = hoverChipToggle = null;
|
|
5730
6094
|
dimLabelHost = null; dimLabelPool.length = 0;
|
|
5731
6095
|
if (memberLabelHost && memberLabelHost.parentNode) memberLabelHost.parentNode.removeChild(memberLabelHost);
|
|
5732
6096
|
memberLabelHost = null; memberLabelPool.length = 0; labelsOnFlag = false; insertMode = false; insertPending = null;
|
|
@@ -5898,6 +6262,7 @@ window.Steel3DView = {
|
|
|
5898
6262
|
setProjection, projection, setDisplayMode, mode: () => displayMode, frameAll, frameSelection, applyView,
|
|
5899
6263
|
setRefLine, refLine: () => refLineOn,
|
|
5900
6264
|
setInsertMode, insertMode: insertModeOn, // arm/query the detail-placement pick (Slice 4)
|
|
6265
|
+
refreshStatus: updateStatusChip, // editor-owned armed modes (Extend/Trim, Split) refresh the disclosure immediately
|
|
5901
6266
|
setBasePickMode, basePickMode: basePickModeOn, // arm/query the Mode B column-base pick (level-snapped elevation)
|
|
5902
6267
|
selectWholeConn, clearConnSel, ascendConn, connContext, connEnvelopeOn: () => !!connEnvelope, // Connection Components (Slice A): whole-select / drill / ascend + test probes
|
|
5903
6268
|
// Reference models (#278) — an editor-only layer. `setReferences` takes the geometry the editor
|
|
@@ -5906,6 +6271,11 @@ window.Steel3DView = {
|
|
|
5906
6271
|
setReferences, setReferenceDisplay: applyReferenceDisplay, setReferencePlacement, selectReference, referenceProbe,
|
|
5907
6272
|
selectedReference: () => xrefSelected, frameReference, referenceBounds, referenceInfo,
|
|
5908
6273
|
pickReferenceAt,
|
|
6274
|
+
// The progressive preview (aware-aeco/aware#405) — geometry drawn while AWARE is still tessellating
|
|
6275
|
+
// it. Deliberately a separate trio from the reference verbs above, because it is a separate layer:
|
|
6276
|
+
// nothing here writes `xrefById`, and nothing above can see what these draw. See the section header.
|
|
6277
|
+
appendReferencePreview, clearReferencePreview, frameReferencePreview,
|
|
6278
|
+
referencePreviewCount: () => xrefPreviewCount,
|
|
5909
6279
|
// Stage A: drilling into ONE object inside a reference. `selectReferenceObject` is what Ctrl+click and
|
|
5910
6280
|
// (later) an object-tree row both call, so the two routes cannot drift into different selections.
|
|
5911
6281
|
selectReferenceObject, selectedReferenceObject,
|
|
@@ -5944,7 +6314,7 @@ window.Steel3DView = {
|
|
|
5944
6314
|
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 })) };
|
|
5945
6315
|
},
|
|
5946
6316
|
toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], selectionHiddenIds: () => [...selectionHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups, visibleMemberIds, visibleObjectIds, visibleGridIds,
|
|
5947
|
-
setClipMode, clipMode: clipModeOn,
|
|
6317
|
+
setClipMode, clipMode: clipModeOn, toggleClip, removeClip, clearClips, getClips, renameClip, selectClip, setSelectedClips, selectedClips, deleteSelectedClips, clipState, setClipState,
|
|
5948
6318
|
isolateSelected, hideSelected, clearIsolation, isIsolated, hasVisibilityFilter,
|
|
5949
6319
|
cameraState, setCameraState, sectionViewState, sceneBounds, objectsPaneState, applyObjectsPaneState, // saved-view snapshot surface (Views Organizer + F11 generated cuts)
|
|
5950
6320
|
workAreaSetAll, workAreaFromSelection, workAreaToggle, workAreaSetWhole, clearWorkArea, workAreaState,
|