@floless/app 0.159.0 → 0.161.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.
Files changed (43) hide show
  1. package/dist/floless-server.cjs +76823 -65608
  2. package/dist/schemas/steel.model.v2.schema.json +24 -0
  3. package/dist/skills/floless-app-onboarding/SKILL.md +4 -3
  4. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +1 -2
  5. package/dist/skills/floless-app-rfi/SKILL.md +44 -3
  6. package/dist/skills/floless-app-steel-model/SKILL.md +2 -2
  7. package/dist/skills/floless-app-steel-takeoff/SKILL.md +417 -261
  8. package/dist/templates/steel-model.flo +6 -2
  9. package/dist/templates/viewer-3d-demo.flo +8 -2
  10. package/dist/web/app.css +342 -160
  11. package/dist/web/app.js +17 -51
  12. package/dist/web/aware.js +656 -574
  13. package/dist/web/chat-question-card.js +27 -1
  14. package/dist/web/chat.css +185 -30
  15. package/dist/web/chat.js +2099 -255
  16. package/dist/web/commands-drawing-check.js +1 -0
  17. package/dist/web/commands-filter.js +11 -0
  18. package/dist/web/commands-shell.js +1118 -134
  19. package/dist/web/commands-steel.js +41 -38
  20. package/dist/web/drawing-check-editor.js +76 -3
  21. package/dist/web/guide.js +8 -0
  22. package/dist/web/index.html +68 -42
  23. package/dist/web/instructor.js +17 -6
  24. package/dist/web/pages.js +158 -30
  25. package/dist/web/panels.js +19 -1
  26. package/dist/web/project-history.js +349 -0
  27. package/dist/web/project-reconciliation.js +1 -0
  28. package/dist/web/project-rfis.js +954 -0
  29. package/dist/web/project-workflows.js +236 -4
  30. package/dist/web/run-history.js +198 -0
  31. package/dist/web/run-page-view.js +12 -2
  32. package/dist/web/startup-admission.js +53 -7
  33. package/dist/web/steel-3d-core.js +144 -7
  34. package/dist/web/steel-3d-view.js +61 -5
  35. package/dist/web/steel-editor.html +510 -128
  36. package/dist/web/steel-filter.html +139 -0
  37. package/dist/web/steel-model-v2-commands.js +3 -3
  38. package/dist/web/steel-model-v2-projection.js +139 -4
  39. package/dist/web/steel-plan-transform.js +78 -0
  40. package/dist/web/tool-updates.js +5 -0
  41. package/dist/web/workspaces.js +1438 -159
  42. package/launch.mjs +36 -5
  43. package/package.json +7 -4
@@ -1102,9 +1102,9 @@ export function isUnknownElev(e) { return !!e && e.unknown === true; }
1102
1102
  * said out loud that the drawings did not settle it.
1103
1103
  *
1104
1104
  * It carries a real `known`, so anything that only asks "is there a number?" builds it, which is the
1105
- * whole point. Anything that asks "is this height EVIDENCE?" has to ask this too — pricing it,
1106
- * scoring it, aligning another member to it, or hanging a connection off it are all decisions that
1107
- * must not be made from a guess.
1105
+ * whole point. Anything that asks "is this height EVIDENCE?" has to ask this too — scoring it,
1106
+ * aligning another member to it, or hanging a connection off it are all decisions that must not be
1107
+ * made from a guess. The bill prices it, but only LABELLED as assumed (owner ruling 2026-10-24, #2735).
1108
1108
  */
1109
1109
  export function isAssumedElev(e) { return !!e && e.assumed === true; }
1110
1110
  /** Either spelling of "nobody has confirmed this height". */
@@ -1150,6 +1150,30 @@ export function sheetIncludesElevation(fromZ, toZ, elevMm, tol = MODEL_V2_TOL.CU
1150
1150
  */
1151
1151
  export const COLUMN_BELOW_REACH_MM = FT_TO_MM; // 12" = one foot, from the one definition of the foot (steel-units.js), not a second 304.8
1152
1152
 
1153
+ /**
1154
+ * The same convention for a project built to a metric standard: a round 300 mm, not the 304.8 a
1155
+ * converted foot lands on (owner ruling, Pawel, 2026-10-23 — asked as "should the minimum column stub
1156
+ * be a round 300 mm instead of the imperial 304.8 mm it inherits today?", answered yes).
1157
+ *
1158
+ * The number a UK detailer reads off this setting is a drafting convention in their own units; 304.8
1159
+ * is an artefact of where the default came from, and it showed through verbatim — a BS/EN project's
1160
+ * Inspect pane read "Columns ending up to 304.8 mm under this level are drawn dashed".
1161
+ *
1162
+ * KEYED ON THE PROJECT'S ENVIRONMENT, NOT ITS DISPLAY UNITS, and that is the load-bearing choice.
1163
+ * `displayUnits` is a per-person VIEW preference that flips at any time, while this resolver decides
1164
+ * what a SHEET DRAWS and is asked by the server's `membersOnSheet` as well as the browser — where no
1165
+ * display preference exists at all. Tying it to the view toggle would make switching units silently
1166
+ * change which columns appear on a drawing, and would let the two callers disagree. `environment` is
1167
+ * immutable, is a property of the project rather than of the reader, and is exactly the question
1168
+ * "which standard is this built to".
1169
+ */
1170
+ export const COLUMN_BELOW_REACH_MM_METRIC = 300;
1171
+
1172
+ /** The default reach for a project built to `environment` — metric standards get the round number. */
1173
+ export function defaultColumnBelowReach(environment) {
1174
+ return environment === 'UK' ? COLUMN_BELOW_REACH_MM_METRIC : COLUMN_BELOW_REACH_MM;
1175
+ }
1176
+
1153
1177
  /**
1154
1178
  * The most a person may set the reach to: 100 ft. A column that ends further under a floor than that is not "the
1155
1179
  * column below" this floor in any building, so a larger number is a typing mistake (a bare 8839 in a project that
@@ -1173,7 +1197,11 @@ export function isValidColumnBelowReach(mm) {
1173
1197
  */
1174
1198
  export function columnBelowReachOf(doc) {
1175
1199
  const stored = doc && typeof doc === 'object' ? doc.column_below_reach_mm : undefined;
1176
- return isValidColumnBelowReach(stored) ? stored : COLUMN_BELOW_REACH_MM;
1200
+ if (isValidColumnBelowReach(stored)) return stored;
1201
+ // Only the DEFAULT varies by standard. A stored reach is the person's own number and is returned
1202
+ // verbatim whatever the environment — converting it here would change a saved drawing convention
1203
+ // behind their back, and a project that switched standards cannot exist (environment is immutable).
1204
+ return defaultColumnBelowReach(doc && typeof doc === 'object' ? doc.environment : undefined);
1177
1205
  }
1178
1206
 
1179
1207
  /**
@@ -1184,13 +1212,14 @@ export function columnBelowReachOf(doc) {
1184
1212
  * - 'crossing' — the cut passes through the column (exactly `sheetIncludesElevation`, tolerance included).
1185
1213
  * - 'below' — the column ends under the cut by more than that tolerance and by no more than `reach`.
1186
1214
  * - 'far-below' — it ends further under the cut than `reach`: never drawn by this rule.
1187
- * - 'above' — it starts over the cut.
1215
+ * - 'near-above' — it starts over the cut by no more than `nearAbove` (#2815): a base read a little high.
1216
+ * - 'above' — it starts over the cut by more than that.
1188
1217
  * - 'unknown' — an endpoint elevation or the cut is not a known number. An unknown elevation is an RFI,
1189
1218
  * not a position, so it is never guessed onto a sheet (the §5.3 "nearest sheet" rule).
1190
1219
  *
1191
1220
  * Orientation-agnostic, like `sheetIncludesElevation`: the top is the higher of the two endpoints.
1192
1221
  */
1193
- export function columnCutRelation(fromZ, toZ, cutMm, reach = COLUMN_BELOW_REACH_MM) {
1222
+ export function columnCutRelation(fromZ, toZ, cutMm, reach = COLUMN_BELOW_REACH_MM, nearAbove = COLUMN_NEAR_CUT_MM) {
1194
1223
  const a = knownZ(fromZ), b = knownZ(toZ);
1195
1224
  if (a === null || b === null || !Number.isFinite(cutMm)) return 'unknown';
1196
1225
  if (sheetIncludesElevation(fromZ, toZ, cutMm)) return 'crossing';
@@ -1202,7 +1231,44 @@ export function columnCutRelation(fromZ, toZ, cutMm, reach = COLUMN_BELOW_REACH_
1202
1231
  const gap = Math.round((cutMm - top) * 1e6) / 1e6;
1203
1232
  return gap <= reach ? 'below' : 'far-below';
1204
1233
  }
1205
- return 'above';
1234
+ // The column STARTS over the cut. Within a reading tolerance it is the same floor (#2815); the gap is
1235
+ // rounded like the one above so a base exactly at the tolerance does not flip on arithmetic noise.
1236
+ const gapAbove = Math.round((Math.min(a, b) - cutMm) * 1e6) / 1e6;
1237
+ return gapAbove <= nearAbove ? 'near-above' : 'above';
1238
+ }
1239
+
1240
+ /**
1241
+ * How far ABOVE a plan's cut level a column's base may sit and still be drawn on that plan (#2815). The
1242
+ * mirror of `COLUMN_BELOW_REACH_MM`: that one forgives a top that stops under the floor, this one forgives a
1243
+ * base that was READ a little over it. On a vision-only sheet a base plan's level (BOB +99.350) and the
1244
+ * column bases read off the elevations (24-27 mm higher on ADNOC v4) are two readings of one floor, and a
1245
+ * strict cut emptied the whole base plan.
1246
+ *
1247
+ * NEEDS OWNER. 50 mm (2" imperial): half a millimetre of paper at 1:100, the least a vision read can
1248
+ * resolve, and about twice the 24-27 mm seen. It is a DISPLAY rule only: the column is drawn where it is, no
1249
+ * height is moved or rewritten, and the sheet's notice still says the level is the person's to fix. A column
1250
+ * further off is never guessed onto the sheet; the notice names the nearest ones and the gap and offers to
1251
+ * show them anyway. Keyed on the project's environment for the reason `defaultColumnBelowReach` is. Not in
1252
+ * the frozen `MODEL_V2_TOL`, which is merge/refusal semantics.
1253
+ */
1254
+ export const COLUMN_NEAR_CUT_MM_METRIC = 50;
1255
+ export const COLUMN_NEAR_CUT_MM = 2 * IN_TO_MM;
1256
+ export function defaultColumnNearCut(environment) {
1257
+ return environment === 'UK' ? COLUMN_NEAR_CUT_MM_METRIC : COLUMN_NEAR_CUT_MM;
1258
+ }
1259
+
1260
+ /**
1261
+ * The gap, in mm, between a column's nearest end and a cut level, and which side it is on: 0 when the cut
1262
+ * passes through it. null when an elevation is unknown (an unknown height is a question, not a distance).
1263
+ * What the "no column reaches this level" notice names the nearest columns by.
1264
+ */
1265
+ export function columnCutGap(fromZ, toZ, cutMm) {
1266
+ const a = knownZ(fromZ), b = knownZ(toZ);
1267
+ if (a === null || b === null || !Number.isFinite(cutMm)) return null;
1268
+ const lo = Math.min(a, b), hi = Math.max(a, b);
1269
+ if (cutMm > hi) return { mm: Math.round((cutMm - hi) * 1e6) / 1e6, side: 'below' };
1270
+ if (cutMm < lo) return { mm: Math.round((lo - cutMm) * 1e6) / 1e6, side: 'above' };
1271
+ return { mm: 0, side: 'at' };
1206
1272
  }
1207
1273
 
1208
1274
  /** Apply a similarity transform (from registerSheet) to a local [x,y] → world mm. */
@@ -2399,3 +2465,74 @@ export function clampSwingTheta(thetaReq, barriers, mode, snapRad) {
2399
2465
  const steps = Math.floor(Math.abs(limit) / step);
2400
2466
  return { theta: Math.sign(limit) * steps * step, clamped: true };
2401
2467
  }
2468
+
2469
+ /**
2470
+ * Which labels to hide so none prints on top of another (#2780 item 3).
2471
+ *
2472
+ * A dense frame puts a property label (`Profile: UC356X153`) on nearly every member and the chips land on each
2473
+ * other, so no one of them can be read. This keeps the labels that matter most and hides each label whose box
2474
+ * would overlap one already kept; the hidden ones come back as the view is zoomed or the camera moves in, because
2475
+ * the caller runs this again for every layout.
2476
+ *
2477
+ * Pure and unit-free: boxes are CENTRE (x, y) with width `w` and height `h`, in any one consistent space (screen
2478
+ * px in 3D, drawing units in 2D). `priority` is higher-wins (a selected member beats a long one beats a short
2479
+ * one); equal priorities keep input order, so the result is stable from one frame to the next. Greedy, with a
2480
+ * spatial hash so a model with thousands of labels is not quadratic.
2481
+ *
2482
+ * @param {Array<{ key: string|number, x: number, y: number, w: number, h: number, priority?: number }>} items
2483
+ * @param {number} [gap] extra clearance, in the same units, that two kept boxes must keep between them
2484
+ * @returns {Set<string|number>} the keys to HIDE
2485
+ */
2486
+ export function declutterLabelRects(items, gap = 0) {
2487
+ const hidden = new Set();
2488
+ const order = items
2489
+ .map((item, i) => ({ item, i }))
2490
+ .filter(({ item }) => item && [item.x, item.y, item.w, item.h].every(Number.isFinite))
2491
+ .sort((a, b) => ((b.item.priority || 0) - (a.item.priority || 0)) || (a.i - b.i));
2492
+ if (!order.length) return hidden;
2493
+ // Cells are sized for the TYPICAL label (the median of the larger side), not the widest: one oversized box would otherwise
2494
+ // make every cell as big as itself and every comparison pairwise. An oversized box simply spans more cells, which is
2495
+ // still correct.
2496
+ const sizes = order.map(({ item }) => Math.max(item.w, item.h)).sort((a, b) => a - b);
2497
+ const cell = Math.max(sizes[sizes.length >> 1], 1) + gap; // the MEDIAN: an outlier cannot move it
2498
+ const grid = new Map();
2499
+ const everyKept = [], bigKept = [];
2500
+ const cellKey = (cx, cy) => `${cx},${cy}`;
2501
+ for (const { item } of order) {
2502
+ const x0 = item.x - item.w / 2 - gap / 2, x1 = item.x + item.w / 2 + gap / 2;
2503
+ const y0 = item.y - item.h / 2 - gap / 2, y1 = item.y + item.h / 2 + gap / 2;
2504
+ const cx0 = Math.floor(x0 / cell), cx1 = Math.floor(x1 / cell), cy0 = Math.floor(y0 / cell), cy1 = Math.floor(y1 / cell);
2505
+ const hits = (k) => x0 < k.x1 && x1 > k.x0 && y0 < k.y1 && y1 > k.y0;
2506
+ // A box that would cover more than MAX_CELLS cells (one very long label among many small ones) is OVERSIZED: it is not
2507
+ // put in the hash (its cell count is unbounded), it is checked pairwise against every kept box, and every later box
2508
+ // checks the short oversized list too. Work stays bounded however large one box is.
2509
+ const cells = (cx1 - cx0 + 1) * (cy1 - cy0 + 1);
2510
+ const oversized = !(cells <= MAX_CELLS);
2511
+ let clash = false;
2512
+ if (oversized) {
2513
+ clash = everyKept.some(hits);
2514
+ } else {
2515
+ clash = bigKept.some(hits);
2516
+ for (let cx = cx0; cx <= cx1 && !clash; cx++) {
2517
+ for (let cy = cy0; cy <= cy1 && !clash; cy++) {
2518
+ for (const k of grid.get(cellKey(cx, cy)) || []) {
2519
+ if (hits(k)) { clash = true; break; }
2520
+ }
2521
+ }
2522
+ }
2523
+ }
2524
+ if (clash) { hidden.add(item.key); continue; }
2525
+ const kept = { x0, x1, y0, y1 };
2526
+ everyKept.push(kept);
2527
+ if (oversized) { bigKept.push(kept); continue; }
2528
+ for (let cx = cx0; cx <= cx1; cx++) {
2529
+ for (let cy = cy0; cy <= cy1; cy++) {
2530
+ const id = cellKey(cx, cy);
2531
+ const list = grid.get(id);
2532
+ if (list) list.push(kept); else grid.set(id, [kept]);
2533
+ }
2534
+ }
2535
+ }
2536
+ return hidden;
2537
+ }
2538
+ const MAX_CELLS = 16;
@@ -21,7 +21,7 @@ import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-m
21
21
  import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
22
22
  import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
23
23
  import { FT_TO_MM as FT_MM } from './steel-units.js';
24
- import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, projectToPlane, snapGridPoint, projectPointOnSegment2d, projectPointOnSegment3d, selectedFrontmostHit, worldEndpointCommit, SEG_DEGENERACY, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberShapeKind, memberExtrudes, memberSectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, translateEndpoints, livePositionState, 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
+ import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, projectToPlane, snapGridPoint, projectPointOnSegment2d, projectPointOnSegment3d, selectedFrontmostHit, worldEndpointCommit, SEG_DEGENERACY, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, declutterLabelRects, sectionKindOf, sectionTopology, memberShapeKind, memberExtrudes, memberSectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, translateEndpoints, livePositionState, 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';
25
25
  // `gridGeometry`, `gridCandidates3d` and `sheetScaleMm` live behind the host's model read boundary
26
26
  // because their display-scale argument is meaningless on a world-mm model grid.
27
27
  import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
@@ -543,13 +543,19 @@ function steelSelectionHitsAt(pointer, event) {
543
543
  return [{ entity: { kind: 'reference', sourceId: reference.referenceId }, selectable, rawVisible: true }];
544
544
  }
545
545
 
546
+ function steelNativeSelectionHits(ids) {
547
+ const allowed = api?.canSelectIds ? new Set(api.canSelectIds(ids)) : null;
548
+ return ids.map((sourceId) => ({ entity: { kind: 'native', sourceId },
549
+ selectable: allowed ? allowed.has(sourceId) : !api?.canSelectId || api.canSelectId(sourceId), rawVisible: true }));
550
+ }
551
+
546
552
  function steelMarqueeHits(rect) {
547
553
  const x0 = rect.mode === 'enclosed' ? rect.left : rect.right;
548
554
  const x1 = rect.mode === 'enclosed' ? rect.right : rect.left;
549
555
  const native = [...membersInRect(x0, rect.top, x1, rect.bottom, rect.mode === 'enclosed'), ...detailsInRect(x0, rect.top, x1, rect.bottom, rect.mode === 'enclosed')];
550
556
  for (const conn of connsInRect(x0, rect.top, x1, rect.bottom, rect.mode === 'enclosed')) native.push(...connChildIds(conn));
551
557
  return [
552
- ...[...new Set(native)].map((sourceId) => ({ entity: { kind: 'native', sourceId }, selectable: !api?.canSelectId || api.canSelectId(sourceId), rawVisible: true })),
558
+ ...steelNativeSelectionHits([...new Set(native)]),
553
559
  ...gridsInRect(x0, rect.top, x1, rect.bottom, rect.mode === 'enclosed').map((sourceId) => ({ entity: { kind: 'grid', sourceId }, selectable: !api?.canSelectGrid || api.canSelectGrid(), rawVisible: true })),
554
560
  ];
555
561
  }
@@ -801,7 +807,7 @@ function init(canvas, theApi, options = {}) {
801
807
  coordinator: steelSelectionCoordinatorPort(),
802
808
  hitsAt: steelSelectionHitsAt,
803
809
  allHits: () => [
804
- ...[...meshById].filter(([, mesh]) => mesh.visible).map(([sourceId]) => ({ entity: { kind: 'native', sourceId }, selectable: !api?.canSelectId || api.canSelectId(sourceId), rawVisible: true })),
810
+ ...steelNativeSelectionHits(visibleObjectIds()),
805
811
  ...[...structGridLines].filter(([, line]) => line.visible).map(([sourceId]) => ({ entity: { kind: 'grid', sourceId }, selectable: !api?.canSelectGrid || api.canSelectGrid(), rawVisible: true })),
806
812
  ],
807
813
  marqueeHits: steelMarqueeHits,
@@ -887,6 +893,7 @@ let unframedFrames = 0, unframedWarned = false; // a gate that never opens loo
887
893
  // and left selLenLabelHost out, which this closes.
888
894
  function hideLabelHosts() {
889
895
  for (const host of [dimLabelHost, memberLabelHost, propLabelHost, selLenLabelHost]) if (host) host.style.display = 'none';
896
+ if (propLabelNote) propLabelNote.style.display = 'none';
890
897
  }
891
898
  function renderSteelFrame() {
892
899
  if (!camFramed) {
@@ -3542,16 +3549,21 @@ function syncPropLabels() {
3542
3549
  const a = g.line[0], b = g.line[1];
3543
3550
  el._mid = place === 'start' ? a : place === 'end' ? b : [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
3544
3551
  el._memberId = m.id;
3552
+ el._sel = !!L.selected;
3553
+ el._len = Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
3545
3554
  el.textContent = L.lines.join('\n');
3555
+ el._w = 0; el._h = 0; // the text changed: measure again the next time it is shown
3546
3556
  el.style.display = 'block';
3547
3557
  }
3548
3558
  }
3549
3559
  // Project each label's anchor → screen px (called from the render loop, like the dim + member labels).
3550
3560
  function positionPropLabels() {
3551
3561
  if (!propLabelHost) return;
3552
- if (!propLabelSpec || (canvasEl && canvasEl.style.display === 'none')) { propLabelHost.style.display = 'none'; return; }
3562
+ if (!propLabelSpec || (canvasEl && canvasEl.style.display === 'none')) { propLabelHost.style.display = 'none'; setPropLabelNote(false); return; }
3553
3563
  propLabelHost.style.display = 'block';
3554
3564
  const rect = canvasEl.getBoundingClientRect();
3565
+ const shown = [];
3566
+ let crowdedCount = 0;
3555
3567
  for (const el of propLabelPool) {
3556
3568
  if (el.style.display === 'none' || !el._mid) continue;
3557
3569
  const mesh = meshById.get(el._memberId);
@@ -3562,7 +3574,49 @@ function positionPropLabels() {
3562
3574
  el.style.left = (rect.left + (v.x * 0.5 + 0.5) * rect.width) + 'px';
3563
3575
  el.style.top = (rect.top + (-v.y * 0.5 + 0.5) * rect.height) + 'px';
3564
3576
  el.style.visibility = 'visible';
3565
- }
3577
+ shown.push(el);
3578
+ }
3579
+ // A dense frame stacks a chip on nearly every member and none of them can be read (#2780): keep the labels that
3580
+ // matter (a selected member, then the longer member) and hide each one that would land on a kept one. Done here, in
3581
+ // screen px, every frame, so orbiting or zooming in brings the hidden ones back as they gain room.
3582
+ if (shown.length > 1) {
3583
+ const items = [];
3584
+ for (const el of shown) {
3585
+ if (!el._w || !el._h) { el._w = el.offsetWidth; el._h = el.offsetHeight; }
3586
+ // A label that was showing a frame ago gets a modest edge over a rival of similar length, so orbiting does not make
3587
+ // two neighbours swap in and out; a selected member still beats everything.
3588
+ items.push({ key: el._memberId, x: parseFloat(el.style.left), y: parseFloat(el.style.top), w: el._w, h: el._h, priority: el._sel ? 1e12 : (el._len || 0) * (el._kept ? 1.25 : 1) });
3589
+ }
3590
+ const crowded = declutterLabelRects(items, 2);
3591
+ for (const el of shown) {
3592
+ el._kept = !crowded.has(el._memberId);
3593
+ if (!el._kept) el.style.visibility = 'hidden';
3594
+ }
3595
+ crowdedCount = crowded.size;
3596
+ }
3597
+ setPropLabelNote(crowdedCount > 0);
3598
+ }
3599
+ let propLabelNote = null;
3600
+ /** The one-line note that says labels were hidden to keep the rest readable (the 2D plan has its own, `#plHint`). */
3601
+ function setPropLabelNote(on) {
3602
+ if (!on) { if (propLabelNote) propLabelNote.style.display = 'none'; return; }
3603
+ if (!propLabelNote) {
3604
+ propLabelNote = document.createElement('div');
3605
+ propLabelNote.id = 'm3dPropLabelNote';
3606
+ propLabelNote.setAttribute('role', 'status');
3607
+ propLabelNote.style.cssText = 'position:fixed;z-index:20;pointer-events:none;background:var(--panel,#0f172a);color:var(--mut,#94a3b8);border:1px solid var(--line,#334155);border-radius:6px;padding:3px 9px;font:11px var(--ui,system-ui)';
3608
+ propLabelNote.textContent = 'Some labels hidden — move closer to see more';
3609
+ document.body.appendChild(propLabelNote);
3610
+ }
3611
+ propLabelNote.style.display = 'block';
3612
+ // Placed from the canvas rect, which positionPropLabels has just read: re-measured only when it moved, so a crowded frame
3613
+ // does not force a layout every frame.
3614
+ const r = canvasEl.getBoundingClientRect();
3615
+ const key = r.left + ',' + r.bottom + ',' + r.width;
3616
+ if (propLabelNote._key === key) return;
3617
+ propLabelNote._key = key;
3618
+ propLabelNote.style.left = (r.left + r.width / 2 - propLabelNote.offsetWidth / 2) + 'px';
3619
+ propLabelNote.style.top = (r.bottom - 64) + 'px';
3566
3620
  }
3567
3621
 
3568
3622
  // ---- On-select member-length labels (⋯ Display → Show member length): the editor owns the TEXT (true 3D
@@ -9034,6 +9088,8 @@ function disposeSteel() {
9034
9088
  dimLabelHost = null; dimLabelPool.length = 0;
9035
9089
  if (memberLabelHost && memberLabelHost.parentNode) memberLabelHost.parentNode.removeChild(memberLabelHost);
9036
9090
  memberLabelHost = null; memberLabelPool.length = 0; labelsOnFlag = false; insertMode = false; insertPending = null; detailPlanePick = null; detailPlaneCandidates = null;
9091
+ if (propLabelNote && propLabelNote.parentNode) propLabelNote.parentNode.removeChild(propLabelNote);
9092
+ propLabelNote = null;
9037
9093
  if (propLabelHost && propLabelHost.parentNode) propLabelHost.parentNode.removeChild(propLabelHost);
9038
9094
  propLabelHost = null; propLabelPool.length = 0; propLabelSpec = null;
9039
9095
  if (selLenLabelHost && selLenLabelHost.parentNode) selLenLabelHost.parentNode.removeChild(selLenLabelHost);