@floless/app 0.118.0 → 0.120.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 +1482 -710
- package/dist/schemas/steel.model.v2.schema.json +43 -0
- package/dist/web/app.css +76 -4
- package/dist/web/aware.js +5 -0
- package/dist/web/index.html +14 -0
- package/dist/web/steel-3d-core.js +21 -0
- package/dist/web/steel-3d-view.js +361 -1
- package/dist/web/steel-editor.html +782 -5
- package/dist/web/workspaces.js +327 -13
- package/package.json +2 -1
|
@@ -38,6 +38,49 @@
|
|
|
38
38
|
"dims3d": { "type": "array", "items": { "$ref": "#/$defs/dim3" }, "description": "Draft-only 3D dimensions, world mm. Model-global. NOT baked into the lock / IFC / BOM." },
|
|
39
39
|
"detail_placements": { "type": "array", "items": { "$ref": "#/$defs/detailPlacement" }, "description": "Draft-only placed 2D detail images. Ids are SHEET-unique, not global." },
|
|
40
40
|
"views": { "type": "array", "items": { "$ref": "#/$defs/view" }, "description": "Draft-only saved views. Editor state, model-global. NOT baked." },
|
|
41
|
+
"reference_models": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"description": "BORROWED GEOMETRY WE NEVER OWN — external models (an architect's IFC) overlaid in the 3D editor so you can see them, snap to them and build against them. Each entry is a POINTER plus how it is placed and displayed; the GEOMETRY is never here. It is tessellated into the project's reserved internal cache and rebuilt on open, because the contract is persisted, versioned and re-sent on every 3D rebuild. A reference never reaches a BOM, an export of our steel, a connection, or the lock (contract-bake strips this key). Converting a reference CREATES a native member and leaves the reference untouched. Draft-and-display state, like `views`.",
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"additionalProperties": false,
|
|
47
|
+
"required": ["id", "file", "name"],
|
|
48
|
+
"properties": {
|
|
49
|
+
"id": { "type": "string", "minLength": 1 },
|
|
50
|
+
"file": { "type": "string", "minLength": 1, "description": "Project-RELATIVE path to the copied original. Never absolute: an absolute path leaks the author's disk and breaks on any other machine. Traversal is rejected at the route, not merely by convention." },
|
|
51
|
+
"name": { "type": "string", "description": "The file's display name — NOT the authoring path embedded in the IFC header, which is somebody's OneDrive layout." },
|
|
52
|
+
"placement": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"description": "Applied in the order scale -> rotate -> move, pivoting on the insertion point so changing scale after positioning does not make the model run away.",
|
|
56
|
+
"properties": {
|
|
57
|
+
"origin": { "type": "array", "items": { "type": "number" }, "minItems": 3, "maxItems": 3, "description": "World mm." },
|
|
58
|
+
"rotation": { "type": "number", "description": "Degrees about Z." },
|
|
59
|
+
"scale": { "type": "number", "exclusiveMinimum": 0, "description": "UNIFORM only. One factor for X, Y and Z — non-uniform scale on a 3D model is almost always a broken export, and it silently corrupts every profile and angle." }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"units": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"additionalProperties": false,
|
|
65
|
+
"description": "What the file said about its units. PROVENANCE, not a conversion factor: web-ifc reads IfcUnitAssignment itself and normalises geometry before floless sees a vertex (measured 2026-07-25), so nothing scales the mesh by this.",
|
|
66
|
+
"properties": {
|
|
67
|
+
"declared": { "type": ["string", "null"], "description": "Verbatim, e.g. \"MILLI.METRE\". null means the file did not say." },
|
|
68
|
+
"override": { "type": ["string", "null"], "description": "Set only when the user overrode a file that LIES about its units." }
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"display": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"properties": {
|
|
75
|
+
"visible": { "type": "boolean" },
|
|
76
|
+
"opacity": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
77
|
+
"locked": { "type": "boolean", "description": "Freezes move/rotate/scale/delete/reload. Does NOT affect visibility or snapping — lock means 'do not let me move this by mistake', not 'stop using it'." },
|
|
78
|
+
"snap": { "type": "boolean", "description": "INDEPENDENT of `visible`. A hidden reference still snaps unless this is false: hiding is a visual act (get it out of my way) and you still want to land on their grid intersection." }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
41
84
|
"prop_labels": { "$ref": "#/$defs/propLabels", "description": "Draft-only display state: which member properties render as text chips. CLOSED because `ids` holds member ids." },
|
|
42
85
|
"dim_overlays": { "type": "object", "additionalProperties": true, "description": "Draft-only per-overlay toggles (bolt_pitch, edge_clearance, …). Booleans only, no ids." },
|
|
43
86
|
"dim_style": { "type": "object", "additionalProperties": true, "description": "Draft-only dimension style (end/bg/place). No ids." },
|
package/dist/web/app.css
CHANGED
|
@@ -2621,6 +2621,40 @@
|
|
|
2621
2621
|
[data-theme="light"] .trace .lvl.err { color: #dc2626; }
|
|
2622
2622
|
[data-theme="light"] .dag-label-bg { fill: var(--bg); stroke: var(--border); }
|
|
2623
2623
|
|
|
2624
|
+
/* Scrollbars — BOTH engines, globally: the same TECHNIQUE the four standalone surfaces
|
|
2625
|
+
(steel-editor / steel-filter / vector-editor / vector-3d) have always used.
|
|
2626
|
+
|
|
2627
|
+
The technique, not the values. Those four declare `width:10px`, `border-radius:6px`, a
|
|
2628
|
+
hard-coded #475569/#5b6b85 and a `content-box` inset; this surface keeps its own baseline
|
|
2629
|
+
numbers (8px, 4px) and its tokens (var(--border-strong)), because the aware-demo extraction
|
|
2630
|
+
fixed those for the 19 containers here that already set the standard properties. Matching a
|
|
2631
|
+
DIFFERENT locked surface's pixels would itself be a baseline deviation.
|
|
2632
|
+
|
|
2633
|
+
The `::-webkit-scrollbar` block below is Chromium/Safari only; it carries NOTHING to Firefox,
|
|
2634
|
+
which reads the standard `scrollbar-width`/`scrollbar-color`. Without the `*` rule those
|
|
2635
|
+
properties had to be repeated on every scroll container by hand, and 20 of the 39 containers on
|
|
2636
|
+
this surface never got them — `.messages` (the chat pane), `.dashboard`, `.wf-list`, `pre.code`,
|
|
2637
|
+
`html`/`body` among them — so Firefox drew its native light bar straight through the dark theme.
|
|
2638
|
+
Three CSS comments and two specs in docs/superpowers record maintainers hitting this and
|
|
2639
|
+
patching ONE container each time; the `*` rule is the root fix, and CLAUDE.md asks for exactly
|
|
2640
|
+
it ("prefer a global `*` scrollbar rule per surface so new containers inherit it").
|
|
2641
|
+
|
|
2642
|
+
Keep BOTH blocks. The standard properties do not reach Safari before 18.2, and the webkit block
|
|
2643
|
+
does not reach Firefox at all — neither is redundant.
|
|
2644
|
+
|
|
2645
|
+
WHAT THIS COSTS, measured in Chromium 141 rather than assumed. Where a browser supports both,
|
|
2646
|
+
the standard properties suppress the ENTIRE `::-webkit-scrollbar*` block below, not just its
|
|
2647
|
+
width. So on Chromium: the gutter goes 8px → 10px, the thumb 8px → 6px with an inset, and
|
|
2648
|
+
`::-webkit-scrollbar-thumb:hover { background: var(--text-dim) }` stops applying — hover becomes
|
|
2649
|
+
Chromium's own rgb(92,103,119) instead of the authored --text-dim. The resting thumb colour is
|
|
2650
|
+
unchanged (`--border-strong`, via scrollbar-color).
|
|
2651
|
+
|
|
2652
|
+
That is a real change to the locked baseline, and it is accepted deliberately: the 19 containers
|
|
2653
|
+
that already set the standard properties have rendered exactly this way all along, as have all
|
|
2654
|
+
four standalone surfaces. This rule makes the remaining 20 MATCH them rather than introducing a
|
|
2655
|
+
new look — the alternative, keeping the webkit hover on those 20, is precisely the per-container
|
|
2656
|
+
divergence that left Firefox unthemed for three repairs running. */
|
|
2657
|
+
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
|
|
2624
2658
|
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
2625
2659
|
::-webkit-scrollbar-track { background: transparent; }
|
|
2626
2660
|
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
|
|
@@ -2707,10 +2741,10 @@ body {
|
|
|
2707
2741
|
#compile-btn:hover { color: var(--text); border-color: var(--accent); }
|
|
2708
2742
|
#compile-btn:disabled { color: var(--text-dim); border-color: var(--border-strong); cursor: default; opacity: 0.6; }
|
|
2709
2743
|
|
|
2710
|
-
/* Bake into agent
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2744
|
+
/* (The #bake-btn "Bake into agent" header button left the header with the Graft UI
|
|
2745
|
+
— 668cae68, "Bake is REMOVED from the header" — and is #menu-bake-item in the ≡ menu
|
|
2746
|
+
now, so its toolbar styles were removed with it. NOT #149: that one moved Agents,
|
|
2747
|
+
Routines and the view toggle, which is what the two sibling comments above cite.) */
|
|
2714
2748
|
/* Bake modal preview: agent name + inputs chips (mirror the canvas node-input chips). */
|
|
2715
2749
|
#bake-modal .bake-name code { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
|
|
2716
2750
|
#bake-modal .bake-inputs { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
@@ -3789,6 +3823,44 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
|
|
|
3789
3823
|
display:flex; align-items:center; justify-content:center; position:relative; color:var(--accent); font-size:24px; }
|
|
3790
3824
|
.ws-card .ws-kind { position:absolute; top:8px; left:8px; font-size:9px; text-transform:uppercase; letter-spacing:.1em;
|
|
3791
3825
|
color:var(--accent-bright); background:var(--surface); border:1px solid var(--accent-dim); padding:2px 7px; border-radius:4px; }
|
|
3826
|
+
/* ── Project thumbnail (the picture on the card) ──────────────────────────────────────────────
|
|
3827
|
+
With a picture the 88px band becomes a real <button> — the ONE place on the card where a click
|
|
3828
|
+
does something other than open the project. That deviation is only fair if it is announced BEFORE
|
|
3829
|
+
the click, which is what the ⤢ chip and the zoom-in cursor are for; without them the region would
|
|
3830
|
+
look identical to the rest of the card and behave differently, which is the worst of both.
|
|
3831
|
+
The .ws-kind badge needs no change to survive an arbitrary photo underneath: it is already an
|
|
3832
|
+
OPAQUE chip (--surface + a border), so its contrast is with its own background, not the image.
|
|
3833
|
+
The ring is inset (outline-offset:-2px) because .ws-card sets overflow:hidden and would otherwise
|
|
3834
|
+
clip a keyboard focus ring drawn outside the band. */
|
|
3835
|
+
.ws-card button.ws-thumb { appearance:none; width:100%; padding:0; overflow:hidden; cursor:zoom-in;
|
|
3836
|
+
border:0; border-bottom:1px solid var(--border); font:inherit; }
|
|
3837
|
+
.ws-card button.ws-thumb:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
|
|
3838
|
+
.ws-card .ws-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
|
|
3839
|
+
.ws-card .ws-thumb-expand { position:absolute; right:8px; bottom:8px; width:22px; height:22px;
|
|
3840
|
+
display:flex; align-items:center; justify-content:center; border-radius:5px; font-size:12px;
|
|
3841
|
+
background:color-mix(in srgb, var(--bg) 70%, transparent); border:1px solid var(--border-strong);
|
|
3842
|
+
color:var(--text); opacity:0; transition:opacity .12s ease; pointer-events:none; }
|
|
3843
|
+
.ws-card button.ws-thumb:hover .ws-thumb-expand,
|
|
3844
|
+
.ws-card button.ws-thumb:focus-visible .ws-thumb-expand { opacity:1; }
|
|
3845
|
+
@media (prefers-reduced-motion: reduce) { .ws-card .ws-thumb-expand { transition:none; } }
|
|
3846
|
+
/* A stored picture that will not decode. Degrades to a muted line rather than leaving a broken-image
|
|
3847
|
+
glyph in a card that otherwise claims to have one — same treatment, and the same lowercase voice,
|
|
3848
|
+
as .e-thumb-failed on the render preview. The element is swapped back to a plain <span>, so the
|
|
3849
|
+
"view larger" affordance disappears with the thing it would have shown. */
|
|
3850
|
+
.ws-card .ws-thumb-failed { font-size:11px; color:var(--text-dim); cursor:pointer; }
|
|
3851
|
+
|
|
3852
|
+
/* The enlarge viewer. Sized to the picture (width:auto) rather than the modal's fixed 480px, and
|
|
3853
|
+
capped so a tall image scrolls nothing — it just fits. */
|
|
3854
|
+
.modal.ws-thumb-viewer { width:auto; max-width:min(920px, 92vw); max-height:88vh; padding:0;
|
|
3855
|
+
display:flex; flex-direction:column; overflow:hidden; }
|
|
3856
|
+
.ws-thumb-head { display:flex; align-items:center; justify-content:space-between; gap:12px;
|
|
3857
|
+
padding:12px 14px; border-bottom:1px solid var(--border); background:var(--surface-2); }
|
|
3858
|
+
.ws-thumb-head .modal-title { margin-bottom:0; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
3859
|
+
#ws-thumb-close { font-size:18px; line-height:1; padding:4px 10px; flex:none; }
|
|
3860
|
+
.ws-thumb-stage { min-height:0; display:flex; align-items:center; justify-content:center;
|
|
3861
|
+
padding:14px; background:var(--bg); }
|
|
3862
|
+
/* contain, not cover: this view exists precisely to see the whole picture undistorted. */
|
|
3863
|
+
.ws-thumb-stage img { max-width:100%; max-height:calc(88vh - 110px); object-fit:contain; display:block; border-radius:4px; }
|
|
3792
3864
|
.ws-card .ws-body { padding:11px 13px 13px; display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
|
|
3793
3865
|
/* The project NAME is user-supplied and unbounded, and CSS Grid stretches every card in a row to the
|
|
3794
3866
|
tallest — so one long name reflows the whole grid. Measured: a 69-character name wrapped to two
|
package/dist/web/aware.js
CHANGED
|
@@ -5831,6 +5831,11 @@
|
|
|
5831
5831
|
return 'AWARE requires Node.js, which was not found on this machine. Install Node.js (nodejs.org), then try again.';
|
|
5832
5832
|
case 'eacces':
|
|
5833
5833
|
return "Couldn't install because this location requires administrator permissions. Run FloLess as administrator, or install Node.js globally yourself and try again.";
|
|
5834
|
+
case 'toolchain-unverified':
|
|
5835
|
+
// Deliberately NOT the no-node copy: the check never finished, so we have no
|
|
5836
|
+
// idea whether Node.js is missing. Telling someone to install what they already
|
|
5837
|
+
// have is the exact bug this reason exists to prevent.
|
|
5838
|
+
return "Couldn't check whether Node.js is installed — the check didn't finish, which usually means the machine was busy. Nothing is necessarily missing; try again.";
|
|
5834
5839
|
case 'offline':
|
|
5835
5840
|
return 'No network connection was detected. Connect to the internet, then try again.';
|
|
5836
5841
|
case 'smoke-failed':
|
package/dist/web/index.html
CHANGED
|
@@ -564,6 +564,20 @@
|
|
|
564
564
|
</div>
|
|
565
565
|
</div>
|
|
566
566
|
|
|
567
|
+
<!-- Project thumbnail viewer — the picture on a Workspaces card, shown large.
|
|
568
|
+
VIEW-ONLY, deliberately: Add/Replace/Remove live on the card's ⋯ menu, which is the one
|
|
569
|
+
place this app offers project management (the header picker's own comment spells that rule
|
|
570
|
+
out). A second set of the same actions here would split that authority in two. -->
|
|
571
|
+
<div class="modal-backdrop" id="ws-thumb-modal" role="dialog" aria-modal="true" aria-labelledby="ws-thumb-title">
|
|
572
|
+
<div class="modal ws-thumb-viewer" tabindex="-1">
|
|
573
|
+
<div class="ws-thumb-head">
|
|
574
|
+
<div class="modal-title" id="ws-thumb-title">Thumbnail</div>
|
|
575
|
+
<button type="button" id="ws-thumb-close" data-tip="Close">×</button>
|
|
576
|
+
</div>
|
|
577
|
+
<div class="ws-thumb-stage"><img id="ws-thumb-full" alt=""></div>
|
|
578
|
+
</div>
|
|
579
|
+
</div>
|
|
580
|
+
|
|
567
581
|
<div class="toast-container" id="toast-container"></div>
|
|
568
582
|
|
|
569
583
|
<!-- Reusable styled prompt/form modal — used for node inputs (double-click an
|
|
@@ -305,12 +305,32 @@ function closestOnSeg(p, a, b) {
|
|
|
305
305
|
return [a[0] + ab[0] * t, a[1] + ab[1] * t, a[2] + ab[2] * t];
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
// Once per candidate TYPE, not once per session: a single global latch meant the first malformed kind
|
|
309
|
+
// silenced every later one, so a second, unrelated breakage would arrive with no trace at all. Keyed by
|
|
310
|
+
// type because that is what identifies the producer, and the set cannot grow per pointer move.
|
|
311
|
+
const warnedSkipped = new Set();
|
|
308
312
|
/** The 3D point a candidate proposes for the dragged point. */
|
|
309
313
|
function candidatePoint(c, dragged) {
|
|
310
314
|
if (c.type === 'vertex' || c.type === 'intersection' || c.type === 'midpoint' || c.type === 'level' || c.type === 'origin' || c.type === 'origin-grid') return c.p; // fixed points (origin-grid = a quantized lattice node, UCS Stage 6)
|
|
311
315
|
if (c.type === 'vertical-axis') return [c.p[0], c.p[1], dragged[2]]; // lock plan X/Y to the axis, keep dragged Z
|
|
312
316
|
if (c.type === 'grid-int') return [c.p[0], c.p[1], dragged[2]]; // grid steers PLAN only — never yanks the elevation
|
|
313
317
|
if (c.type === 'grid-line') { const q = closestOnSeg(dragged, c.a, c.b); return [q[0], q[1], dragged[2]]; }
|
|
318
|
+
// A CANDIDATE WITH NO SEGMENT IS NOT A SEGMENT. The fall-through treats anything unrecognised as a
|
|
319
|
+
// centreline and dereferences `a`/`b`; a candidate carrying only a point (an unknown or mistyped
|
|
320
|
+
// `type`) therefore threw INSIDE the pointer-move handler, killing the whole draw preview — which is
|
|
321
|
+
// exactly what a mistyped reference candidate did until the QA pass found it. The caller already
|
|
322
|
+
// promises that a reference "must never break member dragging"; that promise cannot be kept from the
|
|
323
|
+
// caller alone, because this throw happens later, in `snapPoint`, outside its try.
|
|
324
|
+
//
|
|
325
|
+
// SKIPPED, NOT SUBSTITUTED. The first cut returned `c.p || dragged`, and review was right that this is
|
|
326
|
+
// worse than the throw for a genuine centreline built without its `b`: falling back to `dragged` puts
|
|
327
|
+
// the candidate at distance ZERO from the cursor, so it wins on the spot and reports a confident snap
|
|
328
|
+
// that moved nothing — and, placed first, beats the valid centreline behind it. A candidate we cannot
|
|
329
|
+
// evaluate must lose, not win. `null` is the "no opinion" answer; `snapPoint` drops it.
|
|
330
|
+
if (!c.a || !c.b) {
|
|
331
|
+
if (!warnedSkipped.has(c.type)) { warnedSkipped.add(c.type); console.warn('[snap] skipping a malformed candidate — no segment to measure', c.type); }
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
314
334
|
return closestOnSeg(dragged, c.a, c.b); // centerline
|
|
315
335
|
}
|
|
316
336
|
|
|
@@ -325,6 +345,7 @@ export function snapPoint(dragged, candidates, toScreen, tolPx) {
|
|
|
325
345
|
let best = null, bestPt = null, bestPrec = Infinity, bestD = Infinity;
|
|
326
346
|
for (const c of candidates || []) {
|
|
327
347
|
const pt = candidatePoint(c, dragged);
|
|
348
|
+
if (!pt) continue; // structurally unevaluable — it must lose, not snap to the cursor
|
|
328
349
|
const s = toScreen(pt);
|
|
329
350
|
const d = Math.hypot(s.x - ds.x, s.y - ds.y);
|
|
330
351
|
if (d > tolPx) continue;
|
|
@@ -861,6 +861,330 @@ function buildRefLines() {
|
|
|
861
861
|
}
|
|
862
862
|
function setRefLine(on) { refLineOn = !!on; buildRefLines(); }
|
|
863
863
|
|
|
864
|
+
// ---- Reference models (#278): borrowed geometry, on an EDITOR-ONLY layer --------------------
|
|
865
|
+
//
|
|
866
|
+
// An IFC somebody else authored, overlaid so you can see it, snap to it and build against it. It is
|
|
867
|
+
// never ours: it reaches no BOM, no export of our steel, no connection and no lock.
|
|
868
|
+
//
|
|
869
|
+
// THAT PROPERTY IS STRUCTURAL HERE, NOT FILTERED. This geometry never passes through
|
|
870
|
+
// `contractToScene` — the projector that feeds BOTH this editor and every exporter — so an exporter
|
|
871
|
+
// cannot reach it even by mistake. It arrives from its own route (`/api/steel/:appId/reference/:id/
|
|
872
|
+
// geometry`) straight into `xrefGroup`, a sibling of `root` that nothing but this section touches.
|
|
873
|
+
// The alternative (load it into the shared scene, tag it, filter it out downstream) puts the one rule
|
|
874
|
+
// that defines the feature one forgotten filter away from breaking.
|
|
875
|
+
//
|
|
876
|
+
// It is also why native behaviour is untouched by construction rather than by care: `meshHitsAt`
|
|
877
|
+
// raycasts `meshById` only, and reference meshes are never in that map, so member picking, drag,
|
|
878
|
+
// box-select and Ctrl+A cannot see them however this layer changes.
|
|
879
|
+
|
|
880
|
+
let xrefGroup = null; // one child Group per reference, each holding its meshes
|
|
881
|
+
const xrefById = new Map(); // id -> { group, display, points, capped, total, bounds }
|
|
882
|
+
let xrefSelected = null; // the whole-selected reference, or null
|
|
883
|
+
let xrefCandWarned = false; // one warning per session if snap candidates ever fail
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Slate-400 — the muted grey this app already spends on "not your content".
|
|
887
|
+
*
|
|
888
|
+
* DELIBERATELY NOWHERE NEAR THE BRAND BLUE at any opacity. `rgba(59,130,246,…)` is this app's
|
|
889
|
+
* dedicated "this is selected / this is mine" wash (`.lrow.solo`, `.ci-row.sel`, `.vwrow.active`), and
|
|
890
|
+
* a translucent overlay tinted towards it would read as "part of my selection" — exactly backwards
|
|
891
|
+
* from the one thing this feature must never let a user believe.
|
|
892
|
+
*/
|
|
893
|
+
const XREF_COLOR = 0x94a3b8;
|
|
894
|
+
/** Vertices closer than this collapse into one snap point — a tessellated corner is many coincident ones. */
|
|
895
|
+
const XREF_SNAP_QUANT_MM = 0.5;
|
|
896
|
+
/**
|
|
897
|
+
* A ceiling on how many reference points may enter a drag's snap candidate list.
|
|
898
|
+
*
|
|
899
|
+
* `snapPoint` PROJECTS EVERY CANDIDATE, on every mouse move. Member and grid candidates are naturally
|
|
900
|
+
* bounded; a tessellated building is not — a federated coordination model can carry a million vertices,
|
|
901
|
+
* and handing those to a per-move loop would turn a drag into a slideshow. So the list is bounded, and
|
|
902
|
+
* `capped` is reported through the debug probe and the panel rather than being silently applied: a
|
|
903
|
+
* limit nobody can see reads as "snapping is broken here", which is worse than a limit that is stated.
|
|
904
|
+
*/
|
|
905
|
+
const XREF_SNAP_BUDGET = 6000;
|
|
906
|
+
/**
|
|
907
|
+
* How many unique vertices are KEPT AT ALL, per reference.
|
|
908
|
+
*
|
|
909
|
+
* The budget above bounded the wrong thing, and review was right that the comment claimed otherwise:
|
|
910
|
+
* it capped the OUTPUT while `xrefSnapPoints` had already materialised every unique vertex as a string
|
|
911
|
+
* key and an array, and `referenceCandidates` had already transformed and accumulated every in-frustum
|
|
912
|
+
* point before sorting. At the 8M-vertex ceiling the reader itself permits, that is millions of
|
|
913
|
+
* allocations at load and a full scan-and-sort on every pointer move — a frozen tab, from a cap whose
|
|
914
|
+
* stated purpose was to prevent one.
|
|
915
|
+
*
|
|
916
|
+
* So the work is bounded where the work happens: dedup stops accepting new points here. What is kept is
|
|
917
|
+
* the first N in file order, which is arbitrary but honest, and `capped` says so.
|
|
918
|
+
*/
|
|
919
|
+
const XREF_SNAP_KEEP = 40_000;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Y-UP INTO Z-UP, and this is the one thing here that was found by measuring rather than by reading.
|
|
923
|
+
*
|
|
924
|
+
* The reader's two commands disagree about which axis is up, inside one agent. `probe` reports
|
|
925
|
+
* `example-steel-framing.ifc` as 12000 x 6000 x **4500** — Z is the 4500 mm column height, read
|
|
926
|
+
* straight off the file's own IFCCARTESIANPOINTs. The mesh `read-model` returns for the same file
|
|
927
|
+
* measures 12150 x **4625** x 6150: height has moved into Y. web-ifc hands back a Y-up tessellation
|
|
928
|
+
* while the bbox stays in the file's frame.
|
|
929
|
+
*
|
|
930
|
+
* Our scene is Z-up (`contractToScene` emits `meta.up='z'`), so without this every reference lies on
|
|
931
|
+
* its side — which is exactly what the acceptance list's first case is for: our own export, loaded
|
|
932
|
+
* back, must coincide with the native model. It did not.
|
|
933
|
+
*
|
|
934
|
+
* Corrected HERE rather than by scaling or by asking the user, because it is a frame convention and
|
|
935
|
+
* this is the renderer that owns the frame. Filed against AWARE separately: the disagreement between
|
|
936
|
+
* `probe`'s bbox and `read-model`'s mesh belongs in the agent, not in every consumer of it.
|
|
937
|
+
*/
|
|
938
|
+
const XREF_Y_UP_TO_Z_UP = new THREE.Matrix4().makeRotationX(Math.PI / 2);
|
|
939
|
+
|
|
940
|
+
/** Scale about the insertion point, then rotate about Z, then move — the order the schema documents. */
|
|
941
|
+
function xrefMatrix(placement) {
|
|
942
|
+
const p = placement || {};
|
|
943
|
+
const s = Number.isFinite(p.scale) && p.scale > 0 ? p.scale : 1;
|
|
944
|
+
const rot = (Number.isFinite(p.rotation) ? p.rotation : 0) * Math.PI / 180;
|
|
945
|
+
const o = Array.isArray(p.origin) && p.origin.length === 3 ? p.origin : [0, 0, 0];
|
|
946
|
+
return new THREE.Matrix4()
|
|
947
|
+
.makeTranslation(o[0] || 0, o[1] || 0, o[2] || 0)
|
|
948
|
+
.multiply(new THREE.Matrix4().makeRotationZ(rot))
|
|
949
|
+
.multiply(new THREE.Matrix4().makeScale(s, s, s))
|
|
950
|
+
.multiply(XREF_Y_UP_TO_Z_UP); // innermost: the reader's frame becomes ours BEFORE anything is placed
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/** Unique world points for snapping, quantised so a tessellated corner is one target and not thirty. */
|
|
954
|
+
function xrefSnapPoints(objects) {
|
|
955
|
+
const seen = new Set(); const out = [];
|
|
956
|
+
for (const o of objects || []) {
|
|
957
|
+
const pos = o.positions || [];
|
|
958
|
+
for (let i = 0; i + 2 < pos.length; i += 3) {
|
|
959
|
+
if (out.length >= XREF_SNAP_KEEP) return { points: out, capped: true }; // bail BEFORE allocating more
|
|
960
|
+
const k = `${Math.round(pos[i] / XREF_SNAP_QUANT_MM)},${Math.round(pos[i + 1] / XREF_SNAP_QUANT_MM)},${Math.round(pos[i + 2] / XREF_SNAP_QUANT_MM)}`;
|
|
961
|
+
if (seen.has(k)) continue;
|
|
962
|
+
seen.add(k); out.push([pos[i], pos[i + 1], pos[i + 2]]);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return { points: out, capped: false };
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* (Re)build the whole reference layer from what the editor holds.
|
|
970
|
+
*
|
|
971
|
+
* `list` is `[{ id, name, objects, placement, display }]` — `objects` straight from the geometry route,
|
|
972
|
+
* `placement`/`display` from the contract. A reference whose geometry has not arrived yet (the cold
|
|
973
|
+
* cache streaming in behind the native steel) simply carries no `objects` and renders nothing, which is
|
|
974
|
+
* the honest encoding of "not here yet" and keeps project open from ever blocking on someone else's model.
|
|
975
|
+
*/
|
|
976
|
+
function setReferences(list) {
|
|
977
|
+
if (!scene) return;
|
|
978
|
+
if (!xrefGroup) { xrefGroup = new THREE.Group(); scene.add(xrefGroup); }
|
|
979
|
+
for (const child of [...xrefGroup.children]) {
|
|
980
|
+
child.traverse?.((o) => { o.geometry?.dispose?.(); o.material?.dispose?.(); });
|
|
981
|
+
xrefGroup.remove(child);
|
|
982
|
+
}
|
|
983
|
+
xrefById.clear();
|
|
984
|
+
|
|
985
|
+
for (const ref of list || []) {
|
|
986
|
+
if (!ref || !ref.id) continue;
|
|
987
|
+
const group = new THREE.Group();
|
|
988
|
+
group.userData.referenceId = ref.id;
|
|
989
|
+
// BEHIND everything of ours. `renderOrder` -1 plus `depthWrite:false` means our steel always wins
|
|
990
|
+
// the pixel where they overlap — a reference that occludes the model it exists to be compared
|
|
991
|
+
// against is worse than no reference.
|
|
992
|
+
group.renderOrder = -1;
|
|
993
|
+
const objects = Array.isArray(ref.objects) ? ref.objects : [];
|
|
994
|
+
for (const o of objects) {
|
|
995
|
+
const g = new THREE.BufferGeometry();
|
|
996
|
+
g.setAttribute('position', new THREE.Float32BufferAttribute(o.positions || [], 3));
|
|
997
|
+
if (Array.isArray(o.indices) && o.indices.length) g.setIndex(o.indices);
|
|
998
|
+
g.computeVertexNormals();
|
|
999
|
+
const mesh = new THREE.Mesh(g, new THREE.MeshStandardMaterial({
|
|
1000
|
+
color: XREF_COLOR, metalness: 0, roughness: 0.95,
|
|
1001
|
+
transparent: true, opacity: 1, depthWrite: false, side: THREE.DoubleSide,
|
|
1002
|
+
}));
|
|
1003
|
+
mesh.userData.referenceId = ref.id;
|
|
1004
|
+
group.add(mesh);
|
|
1005
|
+
}
|
|
1006
|
+
group.applyMatrix4(xrefMatrix(ref.placement));
|
|
1007
|
+
xrefGroup.add(group);
|
|
1008
|
+
|
|
1009
|
+
const { points, capped: keptCapped } = xrefSnapPoints(objects);
|
|
1010
|
+
// NO CACHED `bounds` HERE. It was stored and never read — `referenceBounds` recomputes — and the
|
|
1011
|
+
// stored copy was measured without un-hiding, so it was null for a hidden reference while
|
|
1012
|
+
// `frameReference` correctly un-hides first. Two answers to one question, one of them wrong.
|
|
1013
|
+
xrefById.set(ref.id, {
|
|
1014
|
+
group, display: ref.display || {}, name: ref.name || ref.id,
|
|
1015
|
+
points, total: points.length, capped: keptCapped, keptCapped,
|
|
1016
|
+
});
|
|
1017
|
+
applyReferenceDisplay(ref.id, ref.display || {});
|
|
1018
|
+
}
|
|
1019
|
+
if (xrefSelected && !xrefById.has(xrefSelected)) xrefSelected = null;
|
|
1020
|
+
paintReferenceSelection();
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Apply one reference's display state.
|
|
1025
|
+
*
|
|
1026
|
+
* `visible` and `snap` are INDEPENDENT and the independence is a product decision, not an oversight:
|
|
1027
|
+
* you hide a reference to get it out of your way while you keep building TO it. Hiding therefore
|
|
1028
|
+
* touches only what is drawn — `snap` is read separately, by `allCandidates`, and does not consult
|
|
1029
|
+
* this at all.
|
|
1030
|
+
*
|
|
1031
|
+
* `locked` is not read here either. It freezes EDITS (move/rotate/scale/delete/reload), which are
|
|
1032
|
+
* refused where they are performed; a locked reference stays exactly as visible and as snappable as an
|
|
1033
|
+
* unlocked one.
|
|
1034
|
+
*/
|
|
1035
|
+
function applyReferenceDisplay(id, display) {
|
|
1036
|
+
const entry = xrefById.get(id); if (!entry) return;
|
|
1037
|
+
entry.display = display || {};
|
|
1038
|
+
const visible = entry.display.visible !== false;
|
|
1039
|
+
const opacity = Number.isFinite(entry.display.opacity) ? Math.max(0, Math.min(1, entry.display.opacity)) : 0.5;
|
|
1040
|
+
entry.group.visible = visible;
|
|
1041
|
+
entry.group.traverse((o) => { if (o.material) { o.material.opacity = opacity; o.material.needsUpdate = true; } });
|
|
1042
|
+
paintReferenceSelection();
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Re-place one reference without touching a single vertex.
|
|
1047
|
+
*
|
|
1048
|
+
* The separate cheap path matters: `setReferences` re-uploads every buffer, and a whole tessellated
|
|
1049
|
+
* building is tens of megabytes of GPU traffic. Dragging the scale field or nudging the origin must
|
|
1050
|
+
* not pay that on every keystroke — a transform is a 4×4 matrix, so it is applied as one.
|
|
1051
|
+
*/
|
|
1052
|
+
function setReferencePlacement(id, placement) {
|
|
1053
|
+
const entry = xrefById.get(id); if (!entry) return;
|
|
1054
|
+
entry.group.matrix.identity();
|
|
1055
|
+
entry.group.position.set(0, 0, 0); entry.group.quaternion.identity(); entry.group.scale.set(1, 1, 1);
|
|
1056
|
+
entry.group.applyMatrix4(xrefMatrix(placement));
|
|
1057
|
+
entry.group.updateMatrixWorld(true);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/** The whole-model selection highlight: an emissive lift, never the brand wash (see XREF_COLOR). */
|
|
1061
|
+
function paintReferenceSelection() {
|
|
1062
|
+
for (const [id, entry] of xrefById) {
|
|
1063
|
+
const on = id === xrefSelected;
|
|
1064
|
+
entry.group.traverse((o) => {
|
|
1065
|
+
if (!o.material || !o.material.emissive) return;
|
|
1066
|
+
o.material.emissive.setHex(on ? 0xe2e8f0 : 0x000000);
|
|
1067
|
+
o.material.emissiveIntensity = on ? 0.35 : 0;
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* The reference under the pointer, or null.
|
|
1074
|
+
*
|
|
1075
|
+
* Raycast SEPARATELY from `meshHitsAt`, and consulted only when that found nothing — so a reference
|
|
1076
|
+
* standing in front of a beam never steals the beam's click. The plan's acceptance list asks for the
|
|
1077
|
+
* negative ("native selection unchanged") and this is where it is earned rather than hoped for.
|
|
1078
|
+
*
|
|
1079
|
+
* A HIDDEN reference is not pickable: `visible` is false on its group, and unlike snapping, picking
|
|
1080
|
+
* something you cannot see has no case to make for itself.
|
|
1081
|
+
*/
|
|
1082
|
+
function pickReferenceAt(cx, cy) {
|
|
1083
|
+
if (!xrefGroup || !xrefGroup.children.length || !canvasEl) return null;
|
|
1084
|
+
camera.updateMatrixWorld(); xrefGroup.updateMatrixWorld(true);
|
|
1085
|
+
const rect = canvasEl.getBoundingClientRect();
|
|
1086
|
+
raycaster.setFromCamera(new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1), camera);
|
|
1087
|
+
const hit = raycaster.intersectObjects(xrefGroup.children, true)
|
|
1088
|
+
.filter((h) => !isPointClipped([h.point.x, h.point.y, h.point.z]))[0];
|
|
1089
|
+
return hit ? (hit.object.userData.referenceId || null) : null;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
function selectReference(id) {
|
|
1093
|
+
xrefSelected = xrefById.has(id) ? id : null;
|
|
1094
|
+
paintReferenceSelection();
|
|
1095
|
+
if (api && api.onReferenceSelect) api.onReferenceSelect(xrefSelected);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/** World bounds of one reference — what zoom-to frames, and what the off-screen check measures. */
|
|
1099
|
+
function referenceBounds(id) {
|
|
1100
|
+
const entry = xrefById.get(id);
|
|
1101
|
+
if (!entry || !entry.group.children.length) return null;
|
|
1102
|
+
// UN-HIDE FIRST. `Box3.setFromObject` skips invisible children, so a hidden reference measured null —
|
|
1103
|
+
// and "where is it and how big is it" is exactly the question you ask about something you cannot see.
|
|
1104
|
+
// `frameReference` already did this; this did not, so the panel's size line and the off-screen check
|
|
1105
|
+
// both went blank the moment you hid a row.
|
|
1106
|
+
const wasVisible = entry.group.visible;
|
|
1107
|
+
entry.group.visible = true;
|
|
1108
|
+
const box = new THREE.Box3().setFromObject(entry.group);
|
|
1109
|
+
entry.group.visible = wasVisible;
|
|
1110
|
+
return box.isEmpty() ? null : { min: box.min.toArray(), max: box.max.toArray() };
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Frame one reference.
|
|
1115
|
+
*
|
|
1116
|
+
* THE MOST IMPORTANT CONTROL IN THE FEATURE, which is not obvious until you measure a real file: the
|
|
1117
|
+
* Motebello sample is correctly sized and sits 74 m up and 40 m out, entirely off-screen. Without this
|
|
1118
|
+
* the import looks like it silently failed, and the user's next move is to load it again.
|
|
1119
|
+
*
|
|
1120
|
+
* It frames a HIDDEN reference too, deliberately — "show me where it is" is exactly the question you
|
|
1121
|
+
* ask about something you cannot currently see.
|
|
1122
|
+
*/
|
|
1123
|
+
function frameReference(id) {
|
|
1124
|
+
const b = referenceBounds(id); // un-hides to measure, so this frames a hidden reference too
|
|
1125
|
+
if (!b) return false;
|
|
1126
|
+
fitCamera(new THREE.Box3(new THREE.Vector3(...b.min), new THREE.Vector3(...b.max)));
|
|
1127
|
+
return true;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* The reference snap candidates for a drag, in the shape `snapPoint` consumes.
|
|
1132
|
+
*
|
|
1133
|
+
* IGNORES `visible` BY DESIGN and honours `snap` alone — a hidden reference still snaps unless its own
|
|
1134
|
+
* snap toggle is off (§10.3). Frustum-filtered first, so the list is what is actually in view rather
|
|
1135
|
+
* than the whole building, then capped nearest-first with the cap recorded on the entry so the panel
|
|
1136
|
+
* can say it out loud.
|
|
1137
|
+
*/
|
|
1138
|
+
function referenceCandidates() {
|
|
1139
|
+
if (!xrefById.size || !camera) return [];
|
|
1140
|
+
camera.updateMatrixWorld();
|
|
1141
|
+
const frustum = new THREE.Frustum().setFromProjectionMatrix(
|
|
1142
|
+
new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse),
|
|
1143
|
+
);
|
|
1144
|
+
const out = [];
|
|
1145
|
+
for (const [id, entry] of xrefById) {
|
|
1146
|
+
entry.capped = false;
|
|
1147
|
+
if (entry.display.snap === false) continue;
|
|
1148
|
+
const m = entry.group.matrixWorld;
|
|
1149
|
+
const v = new THREE.Vector3();
|
|
1150
|
+
let taken = 0;
|
|
1151
|
+
// STOPS AT THE BUDGET rather than collecting everything and sorting. The nearest-first sort was a
|
|
1152
|
+
// nicety that cost an O(n log n) over every in-frustum point on EVERY pointer move; taking the
|
|
1153
|
+
// first N in view is the same order of usefulness at a bounded cost, and `capped` reports it.
|
|
1154
|
+
for (const p of entry.points) {
|
|
1155
|
+
if (taken >= XREF_SNAP_BUDGET) { entry.capped = true; break; }
|
|
1156
|
+
v.set(p[0], p[1], p[2]).applyMatrix4(m);
|
|
1157
|
+
if (!frustum.containsPoint(v)) continue;
|
|
1158
|
+
// 'vertex', WHICH IS THE CANDIDATE TYPE — 'end' is the snap PREFERENCE key it maps to
|
|
1159
|
+
// (SNAP3D_PREF), and emitting that instead was a real bug the independent QA pass caught: nothing
|
|
1160
|
+
// understands 'end' as a type, so `candidatePoint` fell through to its segment arm and dereferenced
|
|
1161
|
+
// the `a`/`b` a point candidate does not have, throwing on every pointer move with a drawing tool
|
|
1162
|
+
// armed. It also meant reference points ignored the user's Endpoint-snap toggle entirely. Our own
|
|
1163
|
+
// member ends are 'vertex' (steel-3d-core `memberCandidates`), and a reference's corners are the
|
|
1164
|
+
// same kind of thing.
|
|
1165
|
+
out.push({ type: 'vertex', p: [v.x, v.y, v.z], fromId: `ref:${id}` });
|
|
1166
|
+
taken++;
|
|
1167
|
+
}
|
|
1168
|
+
if (entry.keptCapped) entry.capped = true; // it was already truncated at load
|
|
1169
|
+
}
|
|
1170
|
+
return out;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/** Test/panel probe: what the layer is actually holding, per reference. */
|
|
1174
|
+
function referenceInfo() {
|
|
1175
|
+
return [...xrefById.entries()].map(([id, e]) => ({
|
|
1176
|
+
id, name: e.name,
|
|
1177
|
+
meshes: e.group.children.length,
|
|
1178
|
+
visible: e.group.visible,
|
|
1179
|
+
opacity: e.group.children[0]?.material?.opacity ?? null,
|
|
1180
|
+
snap: e.display.snap !== false,
|
|
1181
|
+
locked: !!e.display.locked,
|
|
1182
|
+
selected: id === xrefSelected,
|
|
1183
|
+
snapPoints: e.total, snapCapped: e.capped || !!e.keptCapped,
|
|
1184
|
+
bounds: referenceBounds(id),
|
|
1185
|
+
}));
|
|
1186
|
+
}
|
|
1187
|
+
|
|
864
1188
|
// ---- Insert a vectored detail (Slice 4): arm a placement pick; the editor owns the entry ----
|
|
865
1189
|
// Mirrors setClipMode's arm/disarm. `pending` = {name,url} the editor's Insert menu queued; the
|
|
866
1190
|
// placement click raycasts a member face (anchor) or the ground plane and hands the point + basis +
|
|
@@ -1092,6 +1416,23 @@ function allCandidates(excludeId) {
|
|
|
1092
1416
|
// model data, and it keeps its position between them so the candidate ORDER is unchanged.
|
|
1093
1417
|
const base = MODEL().memberCandidates(excludeId);
|
|
1094
1418
|
if (frame3d && !(pending && pending.frameDrag)) base.push({ type: 'origin', p: [...frame3d.origin], fromId: 'ucs-origin' }); // the local UCS origin is a snap target for every tool (Move/Copy, Add, Dimension); excluded while dragging the origin itself → no self-snap
|
|
1419
|
+
// Reference models, appended AFTER ours — and this comment used to claim more than the code delivers,
|
|
1420
|
+
// so it is worth being exact. A reference's points are `vertex`, the same rank as our own member ends
|
|
1421
|
+
// (PRECEDENCE 0), so between the two it is NEAREST-ON-SCREEN that wins, exactly as it would between
|
|
1422
|
+
// two of our own candidates. What the ordering buys is the TIE: `snapPoint` improves on the incumbent
|
|
1423
|
+
// only when the distance is strictly smaller, so at equal distance the first candidate stands, and
|
|
1424
|
+
// ours are first. That is the right split. Ranking references permanently below ours would mean a
|
|
1425
|
+
// member end 8 px away silently stealing the corner the user was aiming at, in a feature whose whole
|
|
1426
|
+
// point is building against that corner — while the tie going to our own geometry keeps the default
|
|
1427
|
+
// honest when the two coincide. (Before the snap-type fix this read as though ours always won; that
|
|
1428
|
+
// was never true in practice, because the mistyped candidate threw before any of it was reached.)
|
|
1429
|
+
try { base.push(...referenceCandidates()); }
|
|
1430
|
+
catch (e) {
|
|
1431
|
+
// A reference must never break member dragging — but a SILENT stop means snapping to the reference
|
|
1432
|
+
// quietly dies for the rest of the session and the user has no way to know why. Warned once, so a
|
|
1433
|
+
// per-move failure cannot flood the console.
|
|
1434
|
+
if (!xrefCandWarned) { xrefCandWarned = true; console.warn('[reference] snap candidates unavailable', e); }
|
|
1435
|
+
}
|
|
1095
1436
|
try { return base.concat(MODEL().gridCandidates()); }
|
|
1096
1437
|
catch { return base; } // a malformed hand-edited grid must never break member dragging
|
|
1097
1438
|
}
|
|
@@ -2673,7 +3014,16 @@ const CYCLE_TOL_PX = 8;
|
|
|
2673
3014
|
function resetCycle() { cycleAnchor = null; cycleIds = []; cycleIdx = 0; }
|
|
2674
3015
|
function clickSelect(cx, cy, ctrl) {
|
|
2675
3016
|
let hits = []; try { hits = pickAllAt(cx, cy); } catch { hits = []; }
|
|
2676
|
-
if (
|
|
3017
|
+
if (hits.length) selectReference(null); // anything of OURS under the cursor drops a reference selection
|
|
3018
|
+
if (!hits.length) {
|
|
3019
|
+
// Nothing of ours here — only NOW may a reference answer. Consulted second, never first, so a
|
|
3020
|
+
// reference standing in front of a beam can never steal the beam's click; that is how "native
|
|
3021
|
+
// selection behaviour is unchanged" is earned structurally rather than tested for and hoped.
|
|
3022
|
+
// A whole reference is the only selectable unit: it is one borrowed thing, not a set of parts.
|
|
3023
|
+
let ref = null; try { ref = pickReferenceAt(cx, cy); } catch { ref = null; }
|
|
3024
|
+
if (ref) { resetCycle(); selectReference(ref); return; }
|
|
3025
|
+
resetCycle(); selectReference(null); if (!ctrl) clearConnSel(); return; // empty → deselect (clears any connection too); Ctrl/Shift+empty-click preserves the selection (parity with 2D + the additive intent — a near-miss shouldn't wipe it)
|
|
3026
|
+
}
|
|
2677
3027
|
if (ctrl) { resetCycle(); resetConnState(); if (api && api.onSelect) api.onSelect(hits[0], true); return; } // additive toggles the nearest RAW part (leaves connection mode)
|
|
2678
3028
|
const same = cycleAnchor && Math.hypot(cx - cycleAnchor[0], cy - cycleAnchor[1]) <= CYCLE_TOL_PX
|
|
2679
3029
|
&& cycleIds.length === hits.length && cycleIds.every((v, i) => v === hits[i]);
|
|
@@ -4448,6 +4798,10 @@ function dispose() {
|
|
|
4448
4798
|
for (const o of [epRing, epPreview, epMovedLine, refGroup, dimPreviewLine]) if (o) { if (o.geometry) o.geometry.dispose(); if (o.material) o.material.dispose(); }
|
|
4449
4799
|
epGeom = epMatStart = epMatEnd = epRing = epPreview = epMovedLine = refGroup = null;
|
|
4450
4800
|
dims3dGroup = dimPreviewLine = overlayDimsGroup = null;
|
|
4801
|
+
// The reference layer owns real GPU buffers — a whole tessellated building's worth. Leaving them
|
|
4802
|
+
// attached to a torn-down scene is the kind of leak that only shows up after the fifth 2D↔3D switch.
|
|
4803
|
+
if (xrefGroup) { xrefGroup.traverse((o) => { o.geometry?.dispose?.(); o.material?.dispose?.(); }); if (scene) scene.remove(xrefGroup); }
|
|
4804
|
+
xrefGroup = null; xrefById.clear(); xrefSelected = null;
|
|
4451
4805
|
clearStructGrid();
|
|
4452
4806
|
clearWireEdges();
|
|
4453
4807
|
for (const tex of gridTexCache.values()) tex.dispose();
|
|
@@ -4550,6 +4904,12 @@ window.Steel3DView = {
|
|
|
4550
4904
|
setInsertMode, insertMode: insertModeOn, // arm/query the detail-placement pick (Slice 4)
|
|
4551
4905
|
setBasePickMode, basePickMode: basePickModeOn, // arm/query the Mode B column-base pick (level-snapped elevation)
|
|
4552
4906
|
selectWholeConn, clearConnSel, ascendConn, connContext, connEnvelopeOn: () => !!connEnvelope, // Connection Components (Slice A): whole-select / drill / ascend + test probes
|
|
4907
|
+
// Reference models (#278) — an editor-only layer. `setReferences` takes the geometry the editor
|
|
4908
|
+
// fetched from the reference route; nothing here ever passes through contractToScene, which is what
|
|
4909
|
+
// keeps borrowed geometry out of every export by construction rather than by filtering.
|
|
4910
|
+
setReferences, setReferenceDisplay: applyReferenceDisplay, setReferencePlacement, selectReference,
|
|
4911
|
+
selectedReference: () => xrefSelected, frameReference, referenceBounds, referenceInfo,
|
|
4912
|
+
pickReferenceAt,
|
|
4553
4913
|
setLabelsOn, labelsOn: () => labelsOnFlag, // member mark/id label overlay toggle
|
|
4554
4914
|
syncMemberLabels, // editor calls after a mark/id edit to refresh labels
|
|
4555
4915
|
setPropLabels, // right-click property labels: editor pushes { labels:[{id,lines}], placement }
|