@floless/app 0.168.0 → 0.169.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 (49) hide show
  1. package/cli-actions.mjs +8 -1
  2. package/dist/floless-server.cjs +83100 -68895
  3. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  4. package/dist/templates/college-phase-exporter.flo +7 -2
  5. package/dist/templates/trimble-list-projects.flo +10 -2
  6. package/dist/web/agent-steps.js +2 -2
  7. package/dist/web/agents.js +49 -13
  8. package/dist/web/app.css +44 -3
  9. package/dist/web/app.js +47 -4
  10. package/dist/web/aware-update-client.js +4 -4
  11. package/dist/web/aware.js +401 -31
  12. package/dist/web/chat.css +10 -0
  13. package/dist/web/chat.js +223 -22
  14. package/dist/web/commands-drawing-check.js +3 -0
  15. package/dist/web/commands-shell.js +111 -4
  16. package/dist/web/commands-steel.js +9 -2
  17. package/dist/web/commands-vector.js +69 -0
  18. package/dist/web/drawing-check-editor.html +10 -0
  19. package/dist/web/drawing-check-editor.js +502 -182
  20. package/dist/web/failure-copy.js +20 -2
  21. package/dist/web/flo-3d.js +310 -0
  22. package/dist/web/flo-card.js +72 -0
  23. package/dist/web/guide.js +3 -1
  24. package/dist/web/index.html +26 -4
  25. package/dist/web/instructor.js +3 -0
  26. package/dist/web/model-editor-steel-adapter.js +41 -1
  27. package/dist/web/model-viewport-toolbar.js +11 -0
  28. package/dist/web/pages.js +17 -14
  29. package/dist/web/panels.js +1 -1
  30. package/dist/web/project-history.js +2 -2
  31. package/dist/web/project-modules.js +3 -3
  32. package/dist/web/project-reconciliation.js +1 -1
  33. package/dist/web/project-rfis.js +2 -2
  34. package/dist/web/project-workflows.js +6 -4
  35. package/dist/web/renderers.js +6 -0
  36. package/dist/web/report-csp.js +68 -0
  37. package/dist/web/revit-editor.js +1 -1
  38. package/dist/web/run-history.js +2 -3
  39. package/dist/web/steel-3d-flo.js +309 -0
  40. package/dist/web/steel-3d-view.js +159 -0
  41. package/dist/web/steel-editor.html +130 -9
  42. package/dist/web/terminal-requests.js +78 -0
  43. package/dist/web/tool-updates.js +3 -2
  44. package/dist/web/vector-3d.html +1 -1
  45. package/dist/web/vector-editor.html +50 -8
  46. package/dist/web/workspace-root-management.js +1 -1
  47. package/dist/web/workspaces.js +626 -140
  48. package/launch.mjs +5 -0
  49. package/package.json +8 -8
@@ -0,0 +1,309 @@
1
+ // Flo on the steel model (3D). web/flo-3d.js builds and moves Flo; this decides where Flo stands and which mood
2
+ // it shows, from what is already true in the editor:
3
+ // - it perches on the model: on load, on the top of the highest member nearest the middle;
4
+ // - when the person selects a member, Flo hops onto it;
5
+ // - when AI Chat is working on this project, Flo shows the same mood the chat's own Flo shows (thinking or
6
+ // working), and Your call while the AI waits for the person's answer or approval (the shell pushes this);
7
+ // - after the model changed underneath the editor (the AI wrote it), Flo visits each member that changed.
8
+ // Flo is decoration and decides nothing: it is never picked as a member, never in Fit or snapping, and a click on
9
+ // it only tips its hat. Flo is off until the person turns it on (3D toolbar → Labels → Show Flo); the page owns that switch
10
+ // and the Minimize beside Flo, and tells this module only whether Flo is shown.
11
+ //
12
+ // Where Flo stands is reported to the caller (onPerch), so the view can show Flo's card about that member: on
13
+ // landing on a member the person selected (for as long as it stays selected) and at each stop of a tour of what
14
+ // changed. Never on the first drop onto the model, which is not about any member.
15
+
16
+ import { createFlo3D } from './flo-3d.js';
17
+
18
+ const MODEL_R_OF_DIAG = 0.011; // Flo's ring radius as a share of the model's diagonal...
19
+ const MODEL_R_MIN = 140, MODEL_R_MAX = 900; // ...in mm: a toy on a beam, never a giant on a shed
20
+ const MIN_SCREEN_R_PX = 13; // and never smaller than this on screen
21
+ const VISIT_MAX = 10; // a big change is shown by its first ten members, not all of them
22
+ const VISIT_DWELL_S = 1.2; // long enough on each changed member to read Flo's card about it
23
+ const SUCCESS_S = 2.4;
24
+ const REMEMBER_KEY = 'flo3d:before:'; // sessionStorage, per editor URL: the model as it was before a reload
25
+ const REMEMBER_TTL_MS = 120_000;
26
+ const SETTLE_MS = 250; // a click-through of members moves Flo once, when it stops
27
+ const ALONG = 0.3; // a beam's perch: this far along it, clear of the label and the ends
28
+ const LEAVE_S = 0.2; // Minimize: Flo shrinks away this fast (instant under reduced motion)
29
+
30
+ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox, pxToWorldAt, floPose, reducedMotion, enabled: startEnabled = false, onPerch = () => {} }) {
31
+ const now = () => performance.now() / 1000;
32
+ const flo = createFlo3D(THREE, {
33
+ floPose, up: new THREE.Vector3(0, 0, 1), reducedMotion,
34
+ });
35
+ let enabled = !!startEnabled;
36
+ let perched = null; // the member whose card is showing (onPerch), or null
37
+ let placed = false, standingOn = null, modelR = 300, sizeK = 1; // sizeK: the person's Flo size (Labels menu), 1 = as designed
38
+ let shellMood = 'idle';
39
+ let tour = null; // { ids, i, waitUntil }
40
+ let successUntil = 0;
41
+ let leaving = null; // { t0 } while Flo shrinks away after Minimize
42
+ let reduced = !!reducedMotion;
43
+ let prevSel = new Set(), settleTimer = null;
44
+ const ray = new THREE.Raycaster();
45
+ const down = new THREE.Vector3(0, 0, -1);
46
+
47
+ flo.object.visible = enabled;
48
+ scene.add(flo.object);
49
+
50
+ // The point on top of a member where Flo stands: straight down onto the member, on the cap of a column, and on a
51
+ // beam or brace a third of the way along it, so Flo stays clear of the member's label (at its middle) and of
52
+ // the connections at its ends that the person is looking at. Null for a member that is not drawn, or a
53
+ // connection part (Flo never lands on bolts and plates).
54
+ function perchOf(id) {
55
+ const mesh = meshById.get(id);
56
+ if (!mesh || !mesh.visible || String(id).startsWith('det:') || mesh.userData.derived) return null;
57
+ mesh.updateMatrixWorld(true);
58
+ const box = new THREE.Box3().setFromObject(mesh);
59
+ if (box.isEmpty()) return null;
60
+ const c = box.getCenter(new THREE.Vector3()), size = box.getSize(new THREE.Vector3());
61
+ if (size.x > size.z * 1.5 || size.y > size.z * 1.5) {
62
+ if (size.x >= size.y) c.x = box.min.x + size.x * ALONG; else c.y = box.min.y + size.y * ALONG;
63
+ // a sloping member: the footprint's diagonal, so the point stays on it
64
+ if (Math.min(size.x, size.y) > Math.max(size.x, size.y) * 0.25) { c.x = box.min.x + size.x * ALONG; c.y = box.min.y + size.y * ALONG; }
65
+ }
66
+ ray.set(new THREE.Vector3(c.x, c.y, box.max.z + 10), down);
67
+ const hit = ray.intersectObject(mesh, false)[0];
68
+ if (hit) return hit.point.clone();
69
+ // a diagonal whose footprint runs the other way
70
+ const flip = box.min.y + size.y * (1 - ALONG);
71
+ ray.set(new THREE.Vector3(c.x, flip, box.max.z + 10), down);
72
+ const hit2 = ray.intersectObject(mesh, false)[0];
73
+ return hit2 ? hit2.point.clone() : new THREE.Vector3(c.x, c.y, box.max.z);
74
+ }
75
+
76
+ // Where Flo starts: the highest member, and of those near the top the one nearest the middle of the model.
77
+ function home() {
78
+ const box = getSceneBox();
79
+ if (!box || box.isEmpty()) return null;
80
+ const mid = box.getCenter(new THREE.Vector3());
81
+ const span = Math.max(1, box.max.z - box.min.z);
82
+ let best = null, bestScore = Infinity;
83
+ for (const [id, mesh] of meshById) {
84
+ if (!mesh.visible || String(id).startsWith('det:') || mesh.userData.derived) continue;
85
+ const b = new THREE.Box3().setFromObject(mesh);
86
+ if (b.isEmpty()) continue;
87
+ const c = b.getCenter(new THREE.Vector3());
88
+ const score = (box.max.z - b.max.z) / span * 4 + Math.hypot(c.x - mid.x, c.y - mid.y) / Math.max(1, box.getSize(new THREE.Vector3()).length());
89
+ if (score < bestScore) { bestScore = score; best = id; }
90
+ }
91
+ return best;
92
+ }
93
+
94
+ function sizeFromModel() {
95
+ const box = getSceneBox();
96
+ if (!box || box.isEmpty()) return;
97
+ const diag = box.getSize(new THREE.Vector3()).length();
98
+ modelR = Math.min(MODEL_R_MAX, Math.max(MODEL_R_MIN, diag * MODEL_R_OF_DIAG));
99
+ }
100
+
101
+ function moodNow(t) {
102
+ if (tour) return 'working';
103
+ if (t < successUntil) return 'success';
104
+ return shellMood;
105
+ }
106
+
107
+ function perch(id, why) {
108
+ if (id === perched) return;
109
+ perched = id;
110
+ onPerch(id, why);
111
+ }
112
+
113
+ // Hop onto a member; `why` ('select' or 'tour') shows Flo's card about it on landing, none shows no card.
114
+ function goTo(id, t, onLand, why) {
115
+ const p = perchOf(id);
116
+ if (!p) { if (onLand) onLand(); return false; }
117
+ standingOn = id;
118
+ perch(null);
119
+ flo.hopTo(p, () => { if (why && enabled && (why !== 'select' || prevSel.has(id))) perch(id, why); if (onLand) onLand(); }, t);
120
+ return true;
121
+ }
122
+
123
+ // The geometry the person sees, per member, rounded to the millimetre: enough to tell which members a change
124
+ // touched without reading the contract.
125
+ function signature() {
126
+ const out = {};
127
+ const b = new THREE.Box3();
128
+ for (const [id, mesh] of meshById) {
129
+ if (String(id).startsWith('det:')) continue;
130
+ b.setFromObject(mesh);
131
+ if (b.isEmpty()) continue;
132
+ out[id] = [b.min.x, b.min.y, b.min.z, b.max.x, b.max.y, b.max.z].map(Math.round).join(',') + '|' + (mesh.userData.profile || '');
133
+ }
134
+ return out;
135
+ }
136
+
137
+ // Called just before the editor reloads for a change made elsewhere (the AI wrote the model): keep what the
138
+ // model looked like, so the reloaded Flo can visit what changed.
139
+ function remember() {
140
+ try { sessionStorage.setItem(REMEMBER_KEY + location.search, JSON.stringify({ at: Date.now(), sig: signature(), standingOn })); } catch { /* full or blocked: Flo just starts at home */ }
141
+ }
142
+
143
+ function takeRemembered() {
144
+ let saved = null;
145
+ try {
146
+ const raw = sessionStorage.getItem(REMEMBER_KEY + location.search);
147
+ sessionStorage.removeItem(REMEMBER_KEY + location.search);
148
+ saved = raw ? JSON.parse(raw) : null;
149
+ } catch { saved = null; }
150
+ if (!saved || typeof saved.sig !== 'object' || Date.now() - saved.at > REMEMBER_TTL_MS) return null;
151
+ const cur = signature();
152
+ const changed = Object.keys(cur).filter((id) => saved.sig[id] !== cur[id]);
153
+ return { changed, standingOn: typeof saved.standingOn === 'string' ? saved.standingOn : null };
154
+ }
155
+
156
+ // Visit members one hop at a time, nearest first from where Flo stands, then celebrate.
157
+ function startTour(ids, t) {
158
+ const left = ids.filter((id) => perchOf(id));
159
+ if (!left.length) return;
160
+ const order = [];
161
+ let at = flo.position.clone();
162
+ while (left.length && order.length < VISIT_MAX) {
163
+ let k = 0, d = Infinity;
164
+ left.forEach((id, i) => { const p = perchOf(id); const dd = p.distanceTo(at); if (dd < d) { d = dd; k = i; } });
165
+ const [id] = left.splice(k, 1); order.push(id); at = perchOf(id);
166
+ }
167
+ tour = { ids: order, i: 0, waitUntil: t };
168
+ }
169
+
170
+ function stepTour(t) {
171
+ if (!tour || flo.isBusy() || t < tour.waitUntil) return;
172
+ if (tour.i >= tour.ids.length) { tour = null; perch(null); successUntil = t + SUCCESS_S; flo.sayHello(t + SUCCESS_S - 0.9); return; }
173
+ const id = tour.ids[tour.i++];
174
+ if (!goTo(id, t, () => { if (tour) tour.waitUntil = now() + VISIT_DWELL_S; }, 'tour')) tour.waitUntil = t;
175
+ }
176
+
177
+ // After every rebuild: first time, arrive on the model; after a change, follow the member Flo stood on (or go
178
+ // home if it is gone) and visit whatever the change touched.
179
+ function modelChanged() {
180
+ sizeFromModel();
181
+ const t = now();
182
+ if (!placed) {
183
+ const was = takeRemembered();
184
+ const start = (was?.standingOn && perchOf(was.standingOn)) ? was.standingOn : home();
185
+ const p = start && perchOf(start);
186
+ if (!p) return;
187
+ placed = true; standingOn = start;
188
+ flo.setSize(modelR * sizeK);
189
+ if (was && was.changed.length) { flo.placeAt(p); startTour(was.changed, t + 0.4); }
190
+ else {
191
+ // drop in from above, so the first thing Flo does on the model is land on it
192
+ flo.placeAt(p.clone().add(new THREE.Vector3(0, 0, modelR * 7)));
193
+ flo.hopTo(p, null, t + 0.25, { drop: true });
194
+ }
195
+ return;
196
+ }
197
+ // the card says what the member is now (a new profile, a new length): ask the view to read it again
198
+ const p = standingOn && perchOf(standingOn);
199
+ if (p) {
200
+ const why = prevSel.has(standingOn) ? 'select' : null;
201
+ if (p.distanceTo(flo.position) > 1) goTo(standingOn, t, null, why);
202
+ else if (perched) onPerch(perched, 'refresh');
203
+ } else { const h = home(); if (h) goTo(h, t); }
204
+ }
205
+
206
+ function selectionChanged(set) {
207
+ const next = new Set(set);
208
+ const added = [...next].filter((id) => !prevSel.has(id) && !String(id).startsWith('det:'));
209
+ const prev = prevSel;
210
+ prevSel = next;
211
+ let target = added[added.length - 1];
212
+ // The member Flo stands on (or is hopping to) was deselected: its card goes, and Flo moves on to one still
213
+ // selected (the last), so it never stands over a member that is no longer part of the selection.
214
+ const on = perched || standingOn;
215
+ if (on && prev.has(on) && !next.has(on) && !tour) {
216
+ perch(null);
217
+ if (!target) target = [...next].filter((id) => !String(id).startsWith('det:')).pop();
218
+ }
219
+ if (!placed || !enabled || !target) return;
220
+ tour = null;
221
+ clearTimeout(settleTimer);
222
+ settleTimer = setTimeout(() => {
223
+ if (!prevSel.has(target)) return;
224
+ if (target === standingOn && !flo.isBusy()) perch(target, 'select'); // already standing on it: just say what it is
225
+ else goTo(target, now(), null, 'select');
226
+ }, SETTLE_MS);
227
+ }
228
+
229
+ function tick(cameraOverride) {
230
+ if ((!enabled && !leaving) || !placed) return;
231
+ const t = now();
232
+ stepTour(t);
233
+ flo.setMood(moodNow(t));
234
+ const camera = cameraOverride || getCamera();
235
+ let k = 1;
236
+ if (leaving) {
237
+ k = 1 - Math.min(1, (t - leaving.t0) / LEAVE_S);
238
+ if (k <= 0) { leaving = null; flo.object.visible = false; return; }
239
+ k = k * k;
240
+ }
241
+ flo.setSize(Math.max(modelR, pxToWorldAt(MIN_SCREEN_R_PX, flo.object.position)) * sizeK * k);
242
+ flo.tick(t, camera);
243
+ }
244
+
245
+ // Is the pointer on Flo? (The page shows its Minimize chip while it is.)
246
+ function hover(ndc, camera) {
247
+ if (!enabled || !placed || !flo.object.visible || leaving) return false;
248
+ ray.setFromCamera(ndc, camera);
249
+ return flo.hit(ray);
250
+ }
251
+
252
+ // Where the top of Flo's hat is on screen, in the canvas's own pixels (null when Flo is not drawn).
253
+ function hatScreen(camera, width, height) {
254
+ if (!enabled || !placed || !flo.object.visible) return null;
255
+ const p = flo.object.position.clone().add(new THREE.Vector3(0, 0, flo.r * 3.1)).project(camera);
256
+ if (p.z > 1) return null;
257
+ return { x: (p.x + 1) / 2 * width, y: (1 - p.y) / 2 * height };
258
+ }
259
+
260
+ // A press on Flo: true when it was Flo (the caller then leaves the selection alone). Any press in the view stops
261
+ // a tour of what changed: the person has started working, and Flo stays where it is.
262
+ function pointerDown(ndc, camera) {
263
+ if (!enabled || !placed || !flo.object.visible) return false;
264
+ if (tour) { tour = null; successUntil = 0; if (!prevSel.has(perched)) perch(null); }
265
+ ray.setFromCamera(ndc, camera);
266
+ if (!flo.hit(ray)) return false;
267
+ flo.sayHello(now());
268
+ return true;
269
+ }
270
+
271
+ // Minimize shrinks Flo away; bringing it back drops it onto the member it stood on, as on arrival.
272
+ function setEnabled(on, { animate = false } = {}) {
273
+ const was = enabled;
274
+ enabled = !!on;
275
+ if (enabled === was) return;
276
+ tour = null;
277
+ if (!enabled) {
278
+ perch(null);
279
+ if (animate && !reduced && placed && flo.object.visible) leaving = { t0: now() };
280
+ else { leaving = null; flo.object.visible = false; }
281
+ return;
282
+ }
283
+ leaving = null;
284
+ flo.object.visible = true;
285
+ const p = placed && standingOn && perchOf(standingOn);
286
+ if (!p) return;
287
+ // back on a member the person still has selected: its card comes back once Flo has landed
288
+ const land = prevSel.has(standingOn) ? () => perch(standingOn, 'select') : null;
289
+ if (animate && !reduced) {
290
+ flo.placeAt(p.clone().add(new THREE.Vector3(0, 0, modelR * 7)));
291
+ flo.hopTo(p, land, now(), { drop: true });
292
+ } else { flo.placeAt(p); if (land) land(); }
293
+ }
294
+
295
+ function setShellMood(m) { shellMood = ['idle', 'thinking', 'working', 'yourcall'].includes(m) ? m : 'idle'; }
296
+
297
+ function probe() {
298
+ const p = flo.object.position;
299
+ return { enabled, placed, standingOn, perched, mood: flo.mood, busy: flo.isBusy(), touring: !!tour, leaving: !!leaving, visible: flo.object.visible, r: flo.r, at: [p.x, p.y, p.z] };
300
+ }
301
+
302
+ return {
303
+ tick, modelChanged, selectionChanged, pointerDown, hover, hatScreen, remember, setEnabled, setShellMood, probe,
304
+ setScale(k) { sizeK = Number.isFinite(k) && k > 0 ? k : 1; },
305
+ setReducedMotion: (on) => { reduced = !!on; flo.setReducedMotion(on); },
306
+ get enabled() { return enabled; },
307
+ dispose: () => { clearTimeout(settleTimer); flo.dispose(); },
308
+ };
309
+ }
@@ -27,6 +27,7 @@ import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dom
27
27
  import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
28
28
  import { createEntityKeyRegistry, encodeCameraState } from './model-viewport-state.js';
29
29
  import { createModelViewportController } from './model-viewport.js';
30
+ import { createSteelFlo } from './steel-3d-flo.js';
30
31
  import { createSteelViewportAdapter } from './model-viewport-steel-adapter.js';
31
32
  import { MODEL_NAMED_VIEWS, createCadOrbitEventProxy, mountCadInputArbiter, modelCameraClipRange } from './model-navigation-controls.js';
32
33
  import { createModelCadToolController } from './model-cad-tools.js';
@@ -698,6 +699,37 @@ function init(canvas, theApi, options = {}) {
698
699
  // every stroke gets a dark halo so it reads on any background. depthTest off → always on top.
699
700
  marker = new THREE.Sprite(new THREE.SpriteMaterial({ map: reticleFor('dot'), transparent: true, depthTest: false, depthWrite: false }));
700
701
  marker.visible = false; marker.renderOrder = 999; scene.add(marker);
702
+ // Flo on the model (web/steel-3d-flo.js): decoration only. It is not in meshById, so it is never picked as a
703
+ // member, never in the Fit box and never a snap candidate. Needs flo.js (floPose), which the editor loads first.
704
+ if (typeof window.floPose === 'function') {
705
+ const reduce = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : null;
706
+ floView = createSteelFlo({ THREE, scene, meshById, getCamera: () => camera, getSceneBox: () => sceneBox, pxToWorldAt,
707
+ floPose: window.floPose, reducedMotion: !!reduce?.matches, enabled: floStartsShown(), onPerch: showFloCard });
708
+ floReduceOff?.();
709
+ const onReduce = () => floView?.setReducedMotion(reduce.matches);
710
+ reduce?.addEventListener?.('change', onReduce);
711
+ floReduceOff = () => { reduce?.removeEventListener?.('change', onReduce); floReduceOff = null; };
712
+ floView.setShellMood(floMoodWanted); // the shell may have said what AI Chat is doing before 3D was opened
713
+ // Hide, next to Flo while the pointer is on it (the Drawing Filter's "–" in Flo's bubble corner). The
714
+ // always-there control is Show Flo in the 3D Labels menu; this is the shortcut where Flo is.
715
+ // Flo's card: what the member Flo stands on is (web/flo-card.js decides what it says, the page supplies the
716
+ // values). Decorative and a copy of Properties, so it takes no pointer and is hidden from screen readers.
717
+ floCard = document.createElement('div');
718
+ floCard.id = 'm3dFloCard';
719
+ floCard.setAttribute('aria-hidden', 'true');
720
+ document.body.appendChild(floCard);
721
+ applyFloSize(floStoredSize()); // Flo and its card at the person's size (Labels → Flo size)
722
+ floMinChip = document.createElement('button');
723
+ floMinChip.id = 'm3dFloMin'; floMinChip.type = 'button';
724
+ floMinChip.setAttribute('aria-label', 'Hide Flo');
725
+ floMinChip.dataset.commandId = 'steel.flo-minimize';
726
+ floMinChip.dataset.tip = 'Hide Flo. Turn it back on in Labels.';
727
+ floMinChip.innerHTML = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 8h8"/></svg>';
728
+ floMinChip.addEventListener('pointerenter', () => clearTimeout(floMinTimer));
729
+ floMinChip.addEventListener('pointerleave', () => hideFloMinSoon());
730
+ floMinChip.addEventListener('click', (e) => { e.stopPropagation(); setFloShown(false, 'chip'); });
731
+ document.body.appendChild(floMinChip);
732
+ }
701
733
  // live dimension readout (toast-styled, follows the cursor during a drag — feet + snap type).
702
734
  // Two spans + textContent (never innerHTML) so it's XSS-proof; the type span is muted.
703
735
  readout = document.createElement('div');
@@ -893,6 +925,7 @@ let unframedFrames = 0, unframedWarned = false; // a gate that never opens loo
893
925
  // and left selLenLabelHost out, which this closes.
894
926
  function hideLabelHosts() {
895
927
  for (const host of [dimLabelHost, memberLabelHost, propLabelHost, selLenLabelHost]) if (host) host.style.display = 'none';
928
+ floCard?.classList.remove('show');
896
929
  if (propLabelNote) propLabelNote.style.display = 'none';
897
930
  }
898
931
  function renderSteelFrame() {
@@ -922,6 +955,8 @@ function renderSteelFrame() {
922
955
  positionMemberLabels();
923
956
  positionPropLabels();
924
957
  positionSelLenLabels();
958
+ floView?.tick();
959
+ placeFloMin(placeFloCard()); // after the card: with a card up, the chip sits on its corner
925
960
  renderer.render(scene, camera);
926
961
  if (overlayScene && overlayScene.children.length) { // 2nd pass with clipping OFF → the clip/work-area gizmos are never sectioned by any clip
927
962
  const saved = renderer.clippingPlanes;
@@ -1496,6 +1531,7 @@ function buildFromScene(sc) {
1496
1531
  if (hadVisibilityFilter !== hasVisibilityFilter()) notifyVisibilityChange({ intentional: false }); // keep the host's recovery control honest when an edit removes the last hidden/isolated mesh
1497
1532
  applyGroupVisibility(); applyDisplayMode();
1498
1533
  built = true;
1534
+ floView?.modelChanged(); // Flo arrives on the model, or follows the member it stood on
1499
1535
  // Fit only on entering 3D (rebuild(true)) — NOT on every edit. Frames whatever is on screen, so a
1500
1536
  // project whose references are already cached opens on the borrowed model rather than on nothing.
1501
1537
  // (A reference whose geometry is still streaming in arrives after this and is not re-framed; landing
@@ -5316,8 +5352,114 @@ function setSelection(ids) {
5316
5352
  if (reglow) applyDisplayMode(); // one re-sync after re-lighting the whole set, not one per part
5317
5353
  updateStatusChip();
5318
5354
  syncGizmoVisibility(); // the Profile Position gizmo follows the selection (single member only); (un)hides the frame gizmo to match
5355
+ floView?.selectionChanged(set); // Flo hops onto the member just selected
5356
+ if (floPerchId && set.has(floPerchId)) showFloCard(floPerchId); // with several selected, the card speaks for all of them
5319
5357
  }
5320
5358
  let selIds = new Set();
5359
+ let floView = null, floMoodWanted = 'idle', floMinChip = null, floMinTimer = 0, floReduceOff = null;
5360
+ let floCard = null, floCardId = null;
5361
+ // The member Flo stands on, kept even while its card has nothing to say (every field off): a field switched back on
5362
+ // (or Reset) brings the card back from it. floCardId is that member only while its card is showing.
5363
+ let floPerchId = null;
5364
+ // The card's size, measured only when its words or Flo size change (not every frame), and where it was last put.
5365
+ let floCardWH = null, floCardAt = null;
5366
+ const FLO_CARD_GAP = 12, FLO_CARD_EDGE = 8;
5367
+ // Flo's size as the page left it (Labels → Flo size, in percent); 1 when nothing valid is stored. The page's own
5368
+ // settings come first (api.floSettings): they hold even when the browser refuses to store them.
5369
+ function floStoredSize() {
5370
+ const pg = typeof api?.floSettings === 'function' ? api.floSettings() : null;
5371
+ if (pg) return pg.size >= 60 && pg.size <= 200 ? pg.size / 100 : 1;
5372
+ try { const v = Number(localStorage.getItem('steel:floSize:v2')); return v >= 60 && v <= 200 ? v / 100 : 1; } catch { return 1; }
5373
+ }
5374
+ function applyFloSize(k) { floView?.setScale(k); floCard?.style.setProperty('--fc-s', String(k)); measureFloCard(); }
5375
+ function measureFloCard() { floCardWH = floCard && floCardId ? { w: floCard.offsetWidth, h: floCard.offsetHeight } : null; }
5376
+ // Flo starts as the page left it: off until the person turns it on in the Labels menu.
5377
+ function floStartsShown() {
5378
+ const pg = typeof api?.floSettings === 'function' ? api.floSettings() : null;
5379
+ if (pg) return !!pg.on;
5380
+ try { return localStorage.getItem('steel:flo3d:v2') === 'on'; } catch { return false; }
5381
+ }
5382
+ // Flo landed on a member (or left it: id null). The card is filled once here, from the page's own formatted values,
5383
+ // and placed beside Flo on every frame by placeFloCard.
5384
+ function showFloCard(id) {
5385
+ if (!floCard) return;
5386
+ const card = id && typeof api?.floCardFor === 'function' ? api.floCardFor(id) : null;
5387
+ floPerchId = id || null;
5388
+ floCardId = card ? id : null;
5389
+ if (!card) { floCard.classList.remove('show'); floCardWH = floCardAt = null; return; }
5390
+ floCard.replaceChildren();
5391
+ const add = (cls, text, parent = floCard) => { const e = document.createElement('div'); e.className = cls; e.textContent = text; parent.appendChild(e); return e; };
5392
+ if (card.caption) add('fc-cap', card.caption);
5393
+ if (card.headline) add(card.headlineVaries ? 'fc-head fc-varies' : 'fc-head', card.headline);
5394
+ if (card.rows.length) {
5395
+ const grid = add('fc-rows', '');
5396
+ for (const r of card.rows) { add('fc-k', r.label, grid); add(r.varies ? 'fc-v fc-varies' : 'fc-v', r.value, grid); }
5397
+ }
5398
+ floCard.style.visibility = 'hidden'; // measured where it lands before it is seen
5399
+ floCard.classList.add('show');
5400
+ measureFloCard();
5401
+ placeFloCard();
5402
+ }
5403
+ // Beside Flo's head, on the right unless that runs off the stage or under the view cube (top right), then on the
5404
+ // left; always inside the stage. Hidden while Flo is off screen.
5405
+ // Returns the stage rect it read (or null), so the chip placed after it in the same frame need not read it again.
5406
+ function placeFloCard() {
5407
+ floCardAt = null;
5408
+ if (!floCard || !floCardId || !floView) return null;
5409
+ if (!canvasEl || canvasEl.style.display === 'none') { floCard.classList.remove('show'); return null; }
5410
+ const rect = canvasEl.getBoundingClientRect();
5411
+ const at = floView.hatScreen(camera, rect.width, rect.height);
5412
+ if (!at || at.x < 0 || at.y < 0 || at.x > rect.width || at.y > rect.height) { floCard.style.visibility = 'hidden'; return rect; }
5413
+ if (!floCardWH) measureFloCard();
5414
+ const { w, h } = floCardWH;
5415
+ const hx = rect.left + at.x, hy = rect.top + at.y;
5416
+ const cube = { left: rect.right - 110, bottom: rect.top + 110 }; // the view cube
5417
+ let left = hx + FLO_CARD_GAP, side = 'right';
5418
+ const top = Math.min(rect.bottom - FLO_CARD_EDGE - h, Math.max(rect.top + FLO_CARD_EDGE, hy - h * 0.35));
5419
+ if (left + w > rect.right - FLO_CARD_EDGE || (left + w > cube.left && top < cube.bottom)) { left = hx - FLO_CARD_GAP - w; side = 'left'; }
5420
+ left = Math.max(rect.left + FLO_CARD_EDGE, left);
5421
+ floCard.style.left = Math.round(left) + 'px';
5422
+ floCard.style.top = Math.round(top) + 'px';
5423
+ floCard.dataset.side = side;
5424
+ // the tail points at Flo's head wherever the card had to sit
5425
+ floCard.style.setProperty('--fc-tail', Math.round(Math.min(h - 14, Math.max(10, hy - top - 6))) + 'px');
5426
+ floCard.style.visibility = '';
5427
+ floCardAt = { left, top, w };
5428
+ return rect;
5429
+ }
5430
+ // The one way Flo is shown or hidden (the chip beside Flo and the Labels menu both come here), so the page hears
5431
+ // every change and keeps its switch in step.
5432
+ function setFloShown(on, via) {
5433
+ if (!floView) return;
5434
+ floView.setEnabled(on, { animate: true });
5435
+ hideFloMin();
5436
+ window.dispatchEvent(new CustomEvent('floless:flo3d-shown', { detail: { on: !!on, via } }));
5437
+ }
5438
+ function hideFloMin() { clearTimeout(floMinTimer); floMinChip?.classList.remove('show'); }
5439
+ function hideFloMinSoon() { clearTimeout(floMinTimer); floMinTimer = setTimeout(hideFloMin, 2000); }
5440
+ // Pointer on Flo: show the Hide chip just above-right of its hat; it rides along with Flo while shown (placeFloMin),
5441
+ // so a hop or a turn of the view never leaves it behind. Off Flo: it stays two seconds, longer while pointed at.
5442
+ function floHoverAt(e) {
5443
+ if (!floView || !floMinChip || !floView.enabled) return;
5444
+ const rect = canvasEl.getBoundingClientRect();
5445
+ const ndc = new THREE.Vector2(((e.clientX - rect.left) / rect.width) * 2 - 1, -((e.clientY - rect.top) / rect.height) * 2 + 1);
5446
+ if (!floView.hover(ndc, camera)) { if (floMinChip.classList.contains('show')) hideFloMinSoon(); return; }
5447
+ clearTimeout(floMinTimer);
5448
+ if (floMinChip.classList.contains('show')) return;
5449
+ floMinChip.classList.add('show');
5450
+ placeFloMin();
5451
+ }
5452
+ // Every frame while the chip shows: on the top-right corner of Flo's card when the card is up (half outside it, so it
5453
+ // covers none of what the card says), else just above-right of Flo's hat; gone when Flo is off screen or not drawn.
5454
+ function placeFloMin(stageRect) {
5455
+ if (!floMinChip || !floMinChip.classList.contains('show') || !floView) return;
5456
+ const rect = stageRect || canvasEl.getBoundingClientRect();
5457
+ const at = canvasEl.style.display === 'none' ? null : floView.hatScreen(camera, rect.width, rect.height);
5458
+ if (!at || at.x < 0 || at.y < 0 || at.x > rect.width || at.y > rect.height) { hideFloMin(); return; }
5459
+ const card = floCardAt; // set by placeFloCard when the card is up and on screen
5460
+ floMinChip.style.left = Math.round(card ? card.left + card.w - 12 : rect.left + at.x + 10) + 'px';
5461
+ floMinChip.style.top = Math.round(card ? card.top - 12 : rect.top + at.y - 12) + 'px';
5462
+ }
5321
5463
  // Material.clone() copies parameters but NOT instance-assigned callbacks, so a cloned highlight
5322
5464
  // material loses the triplanar patch and falls back to three's stock UV sampling — the highlighted
5323
5465
  // member's texture stretches and smears for as long as it stays selected or hovered.
@@ -8182,6 +8324,13 @@ function onDown(e) {
8182
8324
  let onAnchorDown = false; try { onAnchorDown = pickPositionAnchorHover(e.clientX, e.clientY); } catch (err) { console.error('steel-3d: position-anchor hit-test failed', err); onAnchorDown = false; }
8183
8325
  if (onAnchorDown) { e.stopPropagation(); controls.enabled = false; pending = { posAnchor: true }; return; }
8184
8326
  }
8327
+ // A press on Flo tips its hat and leaves the selection alone; dragging on from it still becomes a marquee. Flo stands
8328
+ // on the selected member, where its end dots, the position gizmo and Trim/Extend/Split clicks are, so those come first.
8329
+ if (floView?.enabled && !endpointHit && !geoMode()) {
8330
+ const rect = canvasEl.getBoundingClientRect();
8331
+ const ndc = new THREE.Vector2(((e.clientX - rect.left) / rect.width) * 2 - 1, -((e.clientY - rect.top) / rect.height) * 2 + 1);
8332
+ if (floView.pointerDown(ndc, camera)) { e.stopPropagation(); controls.enabled = false; pending = { posAnchor: true }; return; }
8333
+ }
8185
8334
  let id = null; try { id = pickAt(e.clientX, e.clientY); } catch { id = null; }
8186
8335
  // Geometry-edit mode (Trim/Extend or Split armed in the inspector): a click does the edit, no drag.
8187
8336
  const armedGeo = geoMode();
@@ -8479,6 +8628,7 @@ function onMoveEndpoint(e) {
8479
8628
  function onMove(e) {
8480
8629
  if (rightDownXY && Math.hypot(e.clientX - rightDownXY[0], e.clientY - rightDownXY[1]) > 5) rightMoved = true; // right-DRAG = orbit/pan, so no snap menu on the release
8481
8630
  if (!renderer || !canvasEl || canvasEl.style.display === 'none') return; // 3D inactive — ignore window pointer events
8631
+ if (!pending && !boxSel && !teklaDrag && e.target === canvasEl) floHoverAt(e);
8482
8632
  // Ctrl+Shift drag-out armed: this pointer stream is the gesture, so the move/copy path stands down.
8483
8633
  // Below the drag tolerance nothing has happened yet — the press can still turn out to be a click.
8484
8634
  if (teklaDrag) {
@@ -9198,6 +9348,7 @@ function setInputActive(on) { inputActive = on !== false; viewportController?.se
9198
9348
  function isReady() { return built; }
9199
9349
 
9200
9350
  function disposeSteel() {
9351
+ floReduceOff?.(); floView?.dispose(); floView = null; clearTimeout(floMinTimer); floMinChip?.remove(); floMinChip = null; floCard?.remove(); floCard = null; floCardId = null; floPerchId = null;
9201
9352
  if (aiMarkGroup) { scene?.remove(aiMarkGroup); aiMarkGroup = null; } disposeAiMarkMats(); // #2521 row 6 (the spec is kept: a re-init redraws it)
9202
9353
  clipGesture?.dispose(); clipGesture = null;
9203
9354
  sharedClipList?.destroy?.(); sharedClipList = null; releaseClipGestureInput?.(); releaseClipGestureInput = null; releaseClipOverlayInput?.(); releaseClipOverlayInput = null;
@@ -9492,6 +9643,14 @@ window.Steel3DView = {
9492
9643
  setConnReview,
9493
9644
  // #2521 row 6: the member ends and connections that rest on an AI decision (the editor's ⋯ Display switch).
9494
9645
  setAiMarks, aiMarksProbe,
9646
+ // Flo on the model: the Labels menu switch, the mood the shell pushes from AI Chat, the editor's note before
9647
+ // it reloads for a change made elsewhere (so Flo can visit what changed), and a test probe.
9648
+ setFlo: (on) => setFloShown(on, 'page'),
9649
+ setFloMood: (mood) => { floMoodWanted = mood; floView?.setShellMood(mood); },
9650
+ // The person changed what Flo's card shows (3D Labels → Flo): read the card again.
9651
+ refreshFloCard: () => { if (floPerchId) showFloCard(floPerchId); },
9652
+ // Labels → Flo size (a factor, 1 = as designed): Flo and its card together; the card is re-placed on the next frame.
9653
+ setFloSize: (k) => applyFloSize(Number.isFinite(k) && k > 0 ? k : 1), floRemember: () => floView?.remember(), floProbe: () => { if (!floView) return null; const r = canvasEl.getBoundingClientRect(), h = floView.hatScreen(camera, r.width, r.height); return { ...floView.probe(), hat: h && { x: r.left + h.x, y: r.top + h.y }, chip: !!floMinChip?.classList.contains('show'), card: floCardId && floCard?.classList.contains('show') && floCard.style.visibility !== 'hidden' ? { id: floCardId, rect: floCard.getBoundingClientRect().toJSON(), side: floCard.dataset.side, text: floCard.innerText } : null }; },
9495
9654
  // Reference models (#278) — an editor-only layer. `setReferences` takes the geometry the editor
9496
9655
  // fetched from the reference route; nothing here ever passes through contractToScene, which is what
9497
9656
  // keeps borrowed geometry out of every export by construction rather than by filtering.