@floless/app 0.132.2 → 0.133.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 +5948 -3270
- package/dist/schemas/steel.model.v2.schema.json +216 -3
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +66 -5
- package/dist/templates/steel-model.flo +6 -2
- package/dist/web/app.css +41 -1
- package/dist/web/app.js +3 -2
- package/dist/web/aware.js +291 -12
- package/dist/web/commands-shell.js +40 -2
- package/dist/web/commands-steel.js +130 -3
- package/dist/web/index.html +16 -3
- package/dist/web/instructor.js +108 -25
- package/dist/web/steel-3d-core.js +128 -0
- package/dist/web/steel-3d-view.js +38 -13
- package/dist/web/steel-editor.html +361 -158
- package/dist/web/steel-model-v2-client-validation.js +6 -0
- package/dist/web/steel-model-v2-commands.js +127 -50
- package/dist/web/steel-model-v2-projection.js +3 -2
- package/package.json +4 -1
package/dist/web/index.html
CHANGED
|
@@ -126,7 +126,10 @@
|
|
|
126
126
|
|
|
127
127
|
<aside class="chat" id="chat-panel" data-group="In the Narrative panel">
|
|
128
128
|
<div class="panel-label">
|
|
129
|
-
<span>
|
|
129
|
+
<span class="narrative-tabs" role="tablist" aria-label="Left panel content">
|
|
130
|
+
<button data-command-id="shell.narrative-tab" type="button" class="narrative-tab active" id="narrative-tab" role="tab" aria-selected="true" aria-controls="messages">Narrative</button>
|
|
131
|
+
<button data-command-id="shell.ai-answers-tab" type="button" class="narrative-tab" id="ai-answers-tab" role="tab" aria-selected="false" aria-controls="ai-answers" tabindex="-1">AI answers <span class="answer-unread" id="answer-unread" hidden></span></button>
|
|
132
|
+
</span>
|
|
130
133
|
<span class="label-end">
|
|
131
134
|
<span class="role">curated · full chat in your terminal</span>
|
|
132
135
|
<button data-command-id="shell.narrative-panel" type="button" class="panel-toggle" data-side="left" aria-label="Collapse Narrative panel" aria-controls="chat-panel" aria-expanded="true" data-tip="Collapse Narrative panel">‹</button>
|
|
@@ -140,7 +143,9 @@
|
|
|
140
143
|
<div class="host-banner">
|
|
141
144
|
<div class="host-line host-ok">✓ plugin: floless-aeco · <span id="agent-count-narr">—</span> agents available</div>
|
|
142
145
|
</div>
|
|
143
|
-
<div class="messages" id="messages"></div>
|
|
146
|
+
<div class="messages" id="messages" role="tabpanel" aria-labelledby="narrative-tab"></div>
|
|
147
|
+
<div class="messages ai-answers" id="ai-answers" role="tabpanel" aria-labelledby="ai-answers-tab" hidden></div>
|
|
148
|
+
<span class="sr-only" id="narrative-answer-status" role="status" aria-live="polite"></span>
|
|
144
149
|
<div class="resize-handle resize-handle-right" data-resize="left" data-tip="Drag to resize · double-click to reset"></div>
|
|
145
150
|
</aside>
|
|
146
151
|
|
|
@@ -325,7 +330,15 @@
|
|
|
325
330
|
data-tip="Every command FloLess knows, with what it acts on and how to reach it">
|
|
326
331
|
press <kbd>?</kbd> to explain a control<span class="ix-hint-sep">·</span><span class="ix-hint-link">see all</span>
|
|
327
332
|
</button>
|
|
328
|
-
<
|
|
333
|
+
<span class="ix-ask-split" id="ix-ask-split" role="group" aria-label="Ask terminal AI" hidden>
|
|
334
|
+
<button data-command-id="shell.instructor-ask" type="button" class="ix-ask ix-ask-main" data-tip="Start a read-only answer in your terminal AI; it will appear in AI answers">Ask AI now</button>
|
|
335
|
+
<button data-command-id="shell.instructor-ask-options" type="button" class="ix-ask ix-ask-caret" id="ix-ask-options" aria-label="More ways to ask" aria-haspopup="menu" aria-expanded="false" aria-controls="ix-ask-menu" data-tip="More ways to ask">▾</button>
|
|
336
|
+
</span>
|
|
337
|
+
<button data-command-id="shell.instructor-ask-queue" type="button" class="ix-ask ix-ask-queue" data-tip="Queue and copy this context for your terminal AI">Queue & copy</button>
|
|
338
|
+
</div>
|
|
339
|
+
<div class="ix-ask-menu" id="ix-ask-menu" role="menu" hidden>
|
|
340
|
+
<button data-command-id="shell.instructor-ask-runtime" type="button" role="menuitem">Choose terminal AI…</button>
|
|
341
|
+
<button data-command-id="shell.instructor-ask-queue" type="button" role="menuitem">Queue & copy for terminal</button>
|
|
329
342
|
</div>
|
|
330
343
|
|
|
331
344
|
|
package/dist/web/instructor.js
CHANGED
|
@@ -279,10 +279,11 @@
|
|
|
279
279
|
The only place that touches the DOM. Paints exactly what the producer
|
|
280
280
|
returned; authors nothing. */
|
|
281
281
|
|
|
282
|
-
var $band, $chip, $parts, $ask, $toggle;
|
|
282
|
+
var $band, $chip, $parts, $ask, $askQueue, $askSplit, $askOptions, $askMenu, $toggle;
|
|
283
283
|
var snapshot = { surface: 'shell', workflow: null, workspace: null, focus: null, child: null };
|
|
284
284
|
var collapsed = false;
|
|
285
285
|
var enabled = true;
|
|
286
|
+
var directAskAvailable = false;
|
|
286
287
|
|
|
287
288
|
function seg(cls, text) {
|
|
288
289
|
var el = document.createElement('span');
|
|
@@ -309,8 +310,12 @@
|
|
|
309
310
|
$parts.appendChild(seg(i === 0 ? 'ix-val' : 'ix-seg', part));
|
|
310
311
|
});
|
|
311
312
|
|
|
312
|
-
$
|
|
313
|
-
|
|
313
|
+
$askSplit.hidden = !g.ask || !directAskAvailable;
|
|
314
|
+
$askQueue.hidden = !g.ask || directAskAvailable;
|
|
315
|
+
if (g.ask) {
|
|
316
|
+
$ask.dataset.subject = g.ask;
|
|
317
|
+
$askQueue.dataset.subject = g.ask;
|
|
318
|
+
}
|
|
314
319
|
}
|
|
315
320
|
|
|
316
321
|
function setCollapsed(next) {
|
|
@@ -531,7 +536,7 @@
|
|
|
531
536
|
'In the Narrative panel', 'In the node Inspect panel', 'In the Instructor strip',
|
|
532
537
|
'In the ≡ menu', 'In the footer',
|
|
533
538
|
'In the contract editor', 'In the report viewer', 'In the guide',
|
|
534
|
-
'In the agent library', 'In the requests list', 'In the Routines dialog',
|
|
539
|
+
'In the agent library', 'In the requests list', 'In the run request dialog', 'In the Routines dialog',
|
|
535
540
|
'In the Report an issue dialog', 'In the Build an agent dialog', 'In the Bake dialog',
|
|
536
541
|
'In the FloLess dialogs',
|
|
537
542
|
/* the steel editor — read top-left down, then the menus, then the dialogs.
|
|
@@ -1078,7 +1083,11 @@
|
|
|
1078
1083
|
if (!$band) return;
|
|
1079
1084
|
$chip = $band.querySelector('.ix-chip');
|
|
1080
1085
|
$parts = $band.querySelector('.ix-parts');
|
|
1081
|
-
$ask = $band.querySelector('.ix-ask');
|
|
1086
|
+
$ask = $band.querySelector('.ix-ask-main');
|
|
1087
|
+
$askQueue = $band.querySelector('.ix-ask-queue');
|
|
1088
|
+
$askSplit = $band.querySelector('.ix-ask-split');
|
|
1089
|
+
$askOptions = document.getElementById('ix-ask-options');
|
|
1090
|
+
$askMenu = document.getElementById('ix-ask-menu');
|
|
1082
1091
|
$toggle = $band.querySelector('.ix-toggle');
|
|
1083
1092
|
|
|
1084
1093
|
// Default ON: only the literal '0' turns it off, so a brand-new user (no key
|
|
@@ -1091,39 +1100,113 @@
|
|
|
1091
1100
|
|
|
1092
1101
|
$toggle.addEventListener('click', function () { setCollapsed(!collapsed); });
|
|
1093
1102
|
|
|
1094
|
-
|
|
1095
|
-
if ($ask.getAttribute('aria-busy') === 'true') return;
|
|
1096
|
-
var bridge = window.flolessBridge;
|
|
1097
|
-
if (!bridge || typeof bridge.requestInstructorHelp !== 'function') return;
|
|
1098
|
-
|
|
1099
|
-
// Capture the producer's complete answer at click time. Duplicate labels are common, so the
|
|
1100
|
-
// terminal AI gets the resolved command/instance and every visible fact, not a label-only ask.
|
|
1103
|
+
function currentAskContext(subjectButton) {
|
|
1101
1104
|
var g = guidanceFor(snapshot);
|
|
1102
1105
|
if (g.tone === 'silent' && g.fallback) g = g.fallback;
|
|
1103
|
-
|
|
1104
|
-
subject: g.ask || g.chip ||
|
|
1106
|
+
return {
|
|
1107
|
+
subject: g.ask || g.chip || subjectButton.dataset.subject || 'this FloLess context',
|
|
1105
1108
|
commandId: g.commandId || undefined,
|
|
1106
1109
|
instance: g.instance || undefined,
|
|
1107
1110
|
tone: g.tone,
|
|
1108
1111
|
facts: g.parts.slice(),
|
|
1109
1112
|
surface: g.surface || snapshot.surface || 'shell',
|
|
1110
1113
|
};
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
var askBusy = false;
|
|
1117
|
+
async function withAskBusy(button, label, action) {
|
|
1118
|
+
if (askBusy) return;
|
|
1119
|
+
var bridge = window.flolessBridge;
|
|
1120
|
+
if (!bridge || typeof bridge.requestInstructorHelp !== 'function') return;
|
|
1121
|
+
var context = currentAskContext(button);
|
|
1122
|
+
var idleLabel = button.textContent;
|
|
1123
|
+
var askControls = [$ask, $askQueue, $askOptions].concat(Array.from($askMenu.querySelectorAll('button')));
|
|
1124
|
+
var priorDisabled = askControls.map(function (control) { return !!control.disabled; });
|
|
1125
|
+
askBusy = true;
|
|
1126
|
+
askControls.forEach(function (control) { control.disabled = true; });
|
|
1127
|
+
button.setAttribute('aria-busy', 'true');
|
|
1128
|
+
button.setAttribute('data-blocked-reason', 'Starting this request…');
|
|
1129
|
+
button.disabled = true;
|
|
1130
|
+
button.textContent = label;
|
|
1116
1131
|
try {
|
|
1117
|
-
await bridge
|
|
1132
|
+
await action(bridge, context);
|
|
1118
1133
|
} finally {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1134
|
+
askControls.forEach(function (control, index) { control.disabled = priorDisabled[index]; });
|
|
1135
|
+
askBusy = false;
|
|
1136
|
+
button.removeAttribute('aria-busy');
|
|
1137
|
+
button.removeAttribute('data-blocked-reason');
|
|
1138
|
+
button.textContent = idleLabel;
|
|
1139
|
+
try { button.focus(); } catch (e) { /* focus restoration is best-effort */ }
|
|
1124
1140
|
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
$ask.addEventListener('click', function () {
|
|
1144
|
+
return withAskBusy($ask, 'Starting…', function (bridge, context) {
|
|
1145
|
+
return bridge.requestInstructorHelp(context, { mode: 'direct' });
|
|
1146
|
+
});
|
|
1147
|
+
});
|
|
1148
|
+
$askQueue.addEventListener('click', function () {
|
|
1149
|
+
return withAskBusy($askQueue, 'Sending…', function (bridge, context) {
|
|
1150
|
+
return bridge.requestInstructorHelp(context, { mode: 'queue' });
|
|
1151
|
+
});
|
|
1125
1152
|
});
|
|
1126
1153
|
|
|
1154
|
+
function closeAskMenu(restore) {
|
|
1155
|
+
$askMenu.hidden = true;
|
|
1156
|
+
$askOptions.setAttribute('aria-expanded', 'false');
|
|
1157
|
+
if (restore) $askOptions.focus();
|
|
1158
|
+
}
|
|
1159
|
+
function openAskMenu() {
|
|
1160
|
+
if (askBusy) return;
|
|
1161
|
+
var rect = $askOptions.getBoundingClientRect();
|
|
1162
|
+
$askMenu.hidden = false;
|
|
1163
|
+
$askMenu.style.left = Math.max(8, rect.right - $askMenu.offsetWidth) + 'px';
|
|
1164
|
+
$askMenu.style.top = Math.max(8, rect.top - $askMenu.offsetHeight - 5) + 'px';
|
|
1165
|
+
$askOptions.setAttribute('aria-expanded', 'true');
|
|
1166
|
+
$askMenu.querySelector('button').focus();
|
|
1167
|
+
}
|
|
1168
|
+
$askOptions.addEventListener('click', function () { $askMenu.hidden ? openAskMenu() : closeAskMenu(true); });
|
|
1169
|
+
$askOptions.addEventListener('keydown', function (e) {
|
|
1170
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); openAskMenu(); }
|
|
1171
|
+
});
|
|
1172
|
+
$askMenu.addEventListener('keydown', function (e) {
|
|
1173
|
+
var items = Array.from($askMenu.querySelectorAll('button'));
|
|
1174
|
+
var at = items.indexOf(document.activeElement);
|
|
1175
|
+
if (e.key === 'Escape') { e.preventDefault(); closeAskMenu(true); }
|
|
1176
|
+
else if (e.key === 'Tab') closeAskMenu(false);
|
|
1177
|
+
else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
1178
|
+
e.preventDefault();
|
|
1179
|
+
items[(at + (e.key === 'ArrowDown' ? 1 : -1) + items.length) % items.length].focus();
|
|
1180
|
+
} else if (e.key === 'Home' || e.key === 'End') {
|
|
1181
|
+
e.preventDefault(); items[e.key === 'Home' ? 0 : items.length - 1].focus();
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
document.addEventListener('pointerdown', function (e) {
|
|
1185
|
+
if (!$askMenu.hidden && !$askMenu.contains(e.target) && e.target !== $askOptions) closeAskMenu(false);
|
|
1186
|
+
}, true);
|
|
1187
|
+
$askMenu.querySelector('[data-command-id="shell.instructor-ask-runtime"]').addEventListener('click', function () {
|
|
1188
|
+
var context = currentAskContext($ask);
|
|
1189
|
+
closeAskMenu(true);
|
|
1190
|
+
var bridge = window.flolessBridge;
|
|
1191
|
+
if (bridge && typeof bridge.chooseInstructorRuntime === 'function') bridge.chooseInstructorRuntime(context);
|
|
1192
|
+
});
|
|
1193
|
+
$askMenu.querySelector('[data-command-id="shell.instructor-ask-queue"]').addEventListener('click', function (event) {
|
|
1194
|
+
var item = event.currentTarget;
|
|
1195
|
+
closeAskMenu(false);
|
|
1196
|
+
return Promise.resolve(withAskBusy(item, 'Sending…', function (bridge, context) {
|
|
1197
|
+
return bridge.requestInstructorHelp(context, { mode: 'queue' });
|
|
1198
|
+
})).finally(function () { try { $askOptions.focus(); } catch (e) { /* best-effort */ } });
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
var askBridge = window.flolessBridge;
|
|
1202
|
+
if (askBridge && typeof askBridge.instructorAskOptions === 'function') {
|
|
1203
|
+
askBridge.instructorAskOptions().then(function (options) {
|
|
1204
|
+
var enhance = function () { directAskAvailable = !!(options && options.found && options.found.length); paint(); };
|
|
1205
|
+
if (document.activeElement === $askQueue) $askQueue.addEventListener('blur', enhance, { once: true });
|
|
1206
|
+
else enhance();
|
|
1207
|
+
}).catch(function () { directAskAvailable = false; paint(); });
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1127
1210
|
document.addEventListener('mouseover', function (e) {
|
|
1128
1211
|
var t = e.target instanceof Element ? e.target : null;
|
|
1129
1212
|
if (t) { lastHovered = t; lastHoveredAt = Date.now(); }
|
|
@@ -15,6 +15,134 @@ import { mmPerPx } from './grid-core.js';
|
|
|
15
15
|
export const FT_TO_MM = 304.8;
|
|
16
16
|
export const IN_TO_MM = 25.4;
|
|
17
17
|
|
|
18
|
+
/** Atomic capability marker: storage, readers, authoring and shipped guidance advance together. */
|
|
19
|
+
export const POSITION_BASIS_CAPABILITY_VERSION = 1;
|
|
20
|
+
/** Storage integrity is deliberately much stricter than the geometric near-plumb threshold. */
|
|
21
|
+
export const BASIS_ORTHONORMAL_TOL = 1e-10;
|
|
22
|
+
|
|
23
|
+
const finiteVec3 = (v) => Array.isArray(v) && v.length === 3 && v.every((n) => typeof n === 'number' && Number.isFinite(n));
|
|
24
|
+
const dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
25
|
+
const len3 = (v) => Math.sqrt(dot3(v, v));
|
|
26
|
+
|
|
27
|
+
/** Return the stable semantic diagnostic for a stored position basis, or null when it is valid. */
|
|
28
|
+
export function positionBasisIssue(x, y) {
|
|
29
|
+
if (!finiteVec3(x) || !finiteVec3(y)) return 'position-basis-not-unit';
|
|
30
|
+
if (Math.abs(len3(x) - 1) > BASIS_ORTHONORMAL_TOL || Math.abs(len3(y) - 1) > BASIS_ORTHONORMAL_TOL) {
|
|
31
|
+
return 'position-basis-not-unit';
|
|
32
|
+
}
|
|
33
|
+
if (Math.abs(dot3(x, y)) > BASIS_ORTHONORMAL_TOL) return 'position-basis-not-orthogonal';
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Strict reader: derive the right-handed normal without normalising or repairing stored axes. */
|
|
38
|
+
export function basisFromAxes(x, y) {
|
|
39
|
+
if (positionBasisIssue(x, y)) return null;
|
|
40
|
+
return { x: [...x], y: [...y], z: cross3(x, y) };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Writer-only canonicalisation for authoritative view axes. Stored readers never call this helper. */
|
|
44
|
+
export function canonicalPositionBasis(x, y) {
|
|
45
|
+
if (!finiteVec3(x) || !finiteVec3(y)) return null;
|
|
46
|
+
const lx = len3(x);
|
|
47
|
+
if (!(lx > 0)) return null;
|
|
48
|
+
const nx = x.map((n) => n / lx);
|
|
49
|
+
const xy = dot3(y, nx);
|
|
50
|
+
const py = y.map((n, i) => n - xy * nx[i]);
|
|
51
|
+
const ly = len3(py);
|
|
52
|
+
if (!(ly > 0)) return null;
|
|
53
|
+
const ny = py.map((n) => n / ly);
|
|
54
|
+
return Object.freeze({ x: Object.freeze(nx), y: Object.freeze(ny) });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** One production folding rule shared by scene reading, editor display and basis re-expression. */
|
|
58
|
+
export function effectiveDepthPosition(explicit, role, dzMm, horizMm, isVerticalBrace = false) {
|
|
59
|
+
if (explicit === 'top' || explicit === 'middle' || explicit === 'bottom') return explicit;
|
|
60
|
+
if (role === 'column' || isVerticalBrace) return 'middle';
|
|
61
|
+
return dzMm > horizMm * 0.5774 ? 'middle' : 'top';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function effectiveWidthPosition(explicit) {
|
|
65
|
+
return explicit === 'left' || explicit === 'right' ? explicit : 'middle';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const addScaled3 = (a, sa, b, sb) => [a[0] * sa + b[0] * sb, a[1] * sa + b[1] * sb, a[2] * sa + b[2] * sb];
|
|
69
|
+
const sub3 = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
70
|
+
const dist3 = (a, b) => len3(sub3(a, b));
|
|
71
|
+
const finiteNumber = (v, fallback = 0) => typeof v === 'number' && Number.isFinite(v) ? v : fallback;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Re-express one stored Profile Position against a captured authoring basis without moving any steel.
|
|
75
|
+
* The returned patch deliberately preserves named faces and numeric offsets byte-for-byte: right-handed
|
|
76
|
+
* transverse rebasing changes only the roll spelling and stored basis. A caller applies the user's edit
|
|
77
|
+
* after this preflight succeeds.
|
|
78
|
+
*/
|
|
79
|
+
export function reexpressMemberPlacement(member, refFrom, refTo, target, extents = /** @type {{lo:number[],hi:number[]}|null} */ (null)) {
|
|
80
|
+
if (!member || !finiteVec3(refFrom) || !finiteVec3(refTo) || !target) {
|
|
81
|
+
return { ok: false, code: 'position-rebase-invalid', message: 'Profile Position could not be decoded.' };
|
|
82
|
+
}
|
|
83
|
+
const oldBasis = member.positionBasis
|
|
84
|
+
? basisFromAxes(member.positionBasis.x, member.positionBasis.y)
|
|
85
|
+
: { x: [1, 0, 0], y: [0, 1, 0], z: [0, 0, 1] };
|
|
86
|
+
if (!oldBasis) return { ok: false, code: positionBasisIssue(member.positionBasis?.x, member.positionBasis?.y) || 'position-rebase-invalid' };
|
|
87
|
+
let targetBasis;
|
|
88
|
+
let storedTarget;
|
|
89
|
+
if (target.kind === 'global') {
|
|
90
|
+
targetBasis = { x: [1, 0, 0], y: [0, 1, 0], z: [0, 0, 1] };
|
|
91
|
+
storedTarget = undefined;
|
|
92
|
+
} else {
|
|
93
|
+
storedTarget = canonicalPositionBasis(target.x, target.y);
|
|
94
|
+
targetBasis = storedTarget && basisFromAxes(storedTarget.x, storedTarget.y);
|
|
95
|
+
if (!targetBasis) return { ok: false, code: 'position-authoring-basis-unavailable', message: 'The active edit frame is not a valid orthonormal basis.' };
|
|
96
|
+
}
|
|
97
|
+
const a0 = partFrame(refFrom, refTo, oldBasis.z, oldBasis.x);
|
|
98
|
+
const a1 = partFrame(refFrom, refTo, targetBasis.z, targetBasis.x);
|
|
99
|
+
if (!a0 || !a1) return { ok: false, code: 'position-rebase-degenerate', message: 'A zero-length member has no Profile Position frame.' };
|
|
100
|
+
const dz = Math.abs(refTo[2] - refFrom[2]), horiz = Math.hypot(refTo[0] - refFrom[0], refTo[1] - refFrom[1]);
|
|
101
|
+
const depthFace = effectiveDepthPosition(member.position, member.role === 'column' ? 'column' : 'beam', dz, horiz,
|
|
102
|
+
member.memberType === 'brace' && member.brace?.type === 'vertical');
|
|
103
|
+
const widthFace = effectiveWidthPosition(member.positionH);
|
|
104
|
+
let oy0, oz0;
|
|
105
|
+
if (extents && extents.lo && extents.hi) {
|
|
106
|
+
oy0 = faceOffset(widthFace, extents.lo[0], extents.hi[0]) + finiteNumber(member.positionHOffset);
|
|
107
|
+
oz0 = faceOffset(depthFace, extents.lo[1], extents.hi[1]) + finiteNumber(member.positionOffset);
|
|
108
|
+
} else {
|
|
109
|
+
if (depthFace !== 'middle' || widthFace !== 'middle') {
|
|
110
|
+
return { ok: false, code: 'position-rebase-section-unresolved', message: 'A named section face cannot be re-expressed until the section resolves.' };
|
|
111
|
+
}
|
|
112
|
+
oy0 = finiteNumber(member.positionHOffset);
|
|
113
|
+
oz0 = finiteNumber(member.positionOffset);
|
|
114
|
+
}
|
|
115
|
+
const theta0 = finiteNumber(member.rot) * Math.PI / 180;
|
|
116
|
+
const c0 = Math.cos(theta0), s0 = Math.sin(theta0);
|
|
117
|
+
const width = addScaled3(a0.y, c0, a0.z, s0);
|
|
118
|
+
const depth = addScaled3(a0.y, -s0, a0.z, c0);
|
|
119
|
+
const offset = addScaled3(width, oy0, depth, oz0);
|
|
120
|
+
const theta1 = Math.atan2(dot3(width, a1.z), dot3(width, a1.y));
|
|
121
|
+
const c1 = Math.cos(theta1), s1 = Math.sin(theta1);
|
|
122
|
+
const qY = dot3(offset, a1.y), qZ = dot3(offset, a1.z);
|
|
123
|
+
const oy1 = qY * c1 + qZ * s1, oz1 = -qY * s1 + qZ * c1;
|
|
124
|
+
const width1 = addScaled3(a1.y, c1, a1.z, s1);
|
|
125
|
+
const depth1 = addScaled3(a1.y, -s1, a1.z, c1);
|
|
126
|
+
const offset1 = addScaled3(width1, oy1, depth1, oz1);
|
|
127
|
+
const axial = Math.abs(dot3(offset, a1.x));
|
|
128
|
+
const orth = Math.abs(dot3(width, depth));
|
|
129
|
+
const axisError = Math.max(Math.abs(len3(width) - 1), Math.abs(len3(depth) - 1));
|
|
130
|
+
const offsetError = dist3(offset, offset1);
|
|
131
|
+
const physicalTol = extents ? 0.001 : 1e-9;
|
|
132
|
+
const radius = extents ? Math.max(Math.abs(extents.lo[0]), Math.abs(extents.hi[0]), Math.abs(extents.lo[1]), Math.abs(extents.hi[1])) : 1;
|
|
133
|
+
if (axial > 0.001 || axisError > BASIS_ORTHONORMAL_TOL || orth * radius > physicalTol || offsetError > physicalTol) {
|
|
134
|
+
return { ok: false, code: 'position-rebase-residual', message: 'Re-expression would move the member beyond the 0.001 mm placement tolerance.' };
|
|
135
|
+
}
|
|
136
|
+
let degrees = (theta1 * 180 / Math.PI) % 360;
|
|
137
|
+
if (degrees < 0) degrees += 360;
|
|
138
|
+
if (Object.is(degrees, -0) || Math.abs(degrees) < 1e-12 || Math.abs(degrees - 360) < 1e-12) degrees = 0;
|
|
139
|
+
return {
|
|
140
|
+
ok: true,
|
|
141
|
+
patch: { positionBasis: storedTarget ? { x: [...storedTarget.x], y: [...storedTarget.y] } : undefined, rot: degrees },
|
|
142
|
+
residual: { axial, orthogonal: orth, offset: offsetError },
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
18
146
|
/** @typedef {'I'|'C'|'L'|'TUBE'|'BOX'} SectionKind */
|
|
19
147
|
|
|
20
148
|
/**
|
|
@@ -20,7 +20,7 @@ import { RoomEnvironment } from 'three/addons/RoomEnvironment.js';
|
|
|
20
20
|
import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-materials.js';
|
|
21
21
|
import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
|
|
22
22
|
import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
|
|
23
|
-
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes } from './steel-3d-core.js';
|
|
23
|
+
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
24
24
|
// `gridGeometry`, `gridCandidates3d` and `mmPerPx` live behind the host's model read boundary because
|
|
25
25
|
// their display-scale argument is meaningless on a world-mm model grid.
|
|
26
26
|
import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
|
|
@@ -5491,9 +5491,27 @@ function pointEntryFrame() {
|
|
|
5491
5491
|
if (frame3d) return { kind: 'local', frame: frame3d }; // full basis already; token deep-clones it
|
|
5492
5492
|
return { kind: 'global', frame: RO_IDENT }; // identity([0,0,0]) — reused, no per-call alloc
|
|
5493
5493
|
}
|
|
5494
|
+
function positionAuthoringBasisSnapshot() {
|
|
5495
|
+
const p = pointEntryFrame(), f = p.frame;
|
|
5496
|
+
return Object.freeze({
|
|
5497
|
+
ok: true, kind: p.kind,
|
|
5498
|
+
x: Object.freeze([...f.xAxis]), y: Object.freeze([...f.yAxis]),
|
|
5499
|
+
generation: pointEntryGen, capabilityVersion: POSITION_BASIS_CAPABILITY_VERSION,
|
|
5500
|
+
});
|
|
5501
|
+
}
|
|
5494
5502
|
// A monotonic generation: any mutation that could change the entry frame, anchor, or scene bumps it, so a
|
|
5495
5503
|
// token whose gen still matches at commit is proven un-drifted (frame/anchor snapshot stays valid).
|
|
5496
5504
|
let pointEntryGen = 0;
|
|
5505
|
+
const positionBasisListeners = new Set();
|
|
5506
|
+
function bumpPointEntryGen() {
|
|
5507
|
+
pointEntryGen++;
|
|
5508
|
+
for (const listener of positionBasisListeners) { try { listener(positionAuthoringBasisSnapshot()); } catch (_) {} }
|
|
5509
|
+
}
|
|
5510
|
+
function onPositionAuthoringBasisChange(listener) {
|
|
5511
|
+
if (typeof listener !== 'function') return () => {};
|
|
5512
|
+
positionBasisListeners.add(listener);
|
|
5513
|
+
return () => positionBasisListeners.delete(listener);
|
|
5514
|
+
}
|
|
5497
5515
|
let pointEntryTok = null; // { consumer:'movecopy'|'add', gen, frame, kind, anchorWorld, aimWorld|null, addPhase } | null
|
|
5498
5516
|
// Open: capture the frame/anchor/aim snapshot for one operation. Returns the initial HUD UI state, or null-ok.
|
|
5499
5517
|
function pointEntryBegin(consumer) {
|
|
@@ -5512,12 +5530,12 @@ function pointEntryBegin(consumer) {
|
|
|
5512
5530
|
return { ok: true, mode, locked, kind: pef.kind, primed: pef.kind !== 'global' };
|
|
5513
5531
|
}
|
|
5514
5532
|
function pointEntryEnd() { pointEntryTok = null; } // editor closed the HUD (not a commit) → drop the token, no gen bump
|
|
5515
|
-
function pointEntryCommit() { pointEntryTok = null;
|
|
5533
|
+
function pointEntryCommit() { pointEntryTok = null; bumpPointEntryGen(); } // a successful commit: clear token + bump gen BEFORE the geometry callback (silent — no drift toast on the reentrant rebuild)
|
|
5516
5534
|
// Any mutation that could change the entry frame/anchor/scene. hard = the scene/tool changed → also drop the
|
|
5517
5535
|
// base/start so a stale anchor can't revalidate; soft (frame/workplane drift) keeps the world base.
|
|
5518
5536
|
function invalidatePointEntry(reason) {
|
|
5519
5537
|
const hadLive = !!pointEntryTok, hadStaged = !!(tfDraft && tfDraft.vA);
|
|
5520
|
-
|
|
5538
|
+
bumpPointEntryGen(); pointEntryTok = null;
|
|
5521
5539
|
tfLast = null; tfLastClient = null; // drop the captured aim so a reopened {dist} demands a fresh hover under the new frame (Codex R5 #1)
|
|
5522
5540
|
const hard = reason === 'rebuild' || reason === 'undo' || reason === 'view' || reason === 'hide';
|
|
5523
5541
|
if (hard) { cmClear3d(); drClear3d(); }
|
|
@@ -5527,7 +5545,7 @@ function invalidatePointEntry(reason) {
|
|
|
5527
5545
|
}
|
|
5528
5546
|
// A pointer base/start pick invalidates any open typed-entry token (silent — no toast): the anchor changed,
|
|
5529
5547
|
// so a stale HUD from a prior phase/operation must not commit against the new draft.
|
|
5530
|
-
function notePointerPick() { if (pointEntryTok && api && api.closeCmHud) api.closeCmHud(); pointEntryTok = null;
|
|
5548
|
+
function notePointerPick() { if (pointEntryTok && api && api.closeCmHud) api.closeCmHud(); pointEntryTok = null; bumpPointEntryGen(); }
|
|
5531
5549
|
// What the tools ACTUALLY follow — a set ◇ Plane shadows the local frame, so the chip never claims Local
|
|
5532
5550
|
// while a plane overrides it. Editor's Axes chip reads this in 3D. A horizontal frame reports its in-plane
|
|
5533
5551
|
// angle; a tilted frame reports its tilt (normal off-vertical) — a single angle can't describe a 3D orientation.
|
|
@@ -6091,12 +6109,11 @@ function drHudApply(pv, abs) {
|
|
|
6091
6109
|
if (r.error) return { err: r.error === 'empty' ? 'Type a coordinate (X, Y)' : 'Enter a valid value' };
|
|
6092
6110
|
const p = r.point;
|
|
6093
6111
|
if (t.addPhase === 'start') { // set the start; the tool stays armed for the 2nd point
|
|
6094
|
-
pointEntryCommit(); drDraft = p; tfCandidates = null;
|
|
6112
|
+
pointEntryCommit(); drDraft = p; drBasisTok = positionAuthoringBasisSnapshot(); tfCandidates = null;
|
|
6095
6113
|
if (readout) readout.style.display = 'none';
|
|
6096
6114
|
return { ok: true };
|
|
6097
6115
|
}
|
|
6098
6116
|
if (!drDraft || Math.hypot(p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]) < 0.5) return { err: 'Zero length — type a non-zero value' }; // sub-mm epsilon (typed; NOT the 50 mm pointer double-click guard)
|
|
6099
|
-
pointEntryCommit();
|
|
6100
6117
|
commitDrawPoint(p);
|
|
6101
6118
|
return { ok: true };
|
|
6102
6119
|
}
|
|
@@ -6104,19 +6121,26 @@ function drHudApply(pv, abs) {
|
|
|
6104
6121
|
// ---- draw a new member on the working plane (spec §7): two plane picks → api.onAddMember3d (scene
|
|
6105
6122
|
// mm); the editor maps them to wp + per-end TOS and materializes a beam or (near-vertical) column. ----
|
|
6106
6123
|
let drDraft = null; // first pick, scene mm
|
|
6124
|
+
let drBasisTok = null; // immutable authoring-basis snapshot captured with the first point
|
|
6107
6125
|
let drRubber = null;
|
|
6108
6126
|
const addActive = () => !!(api && api.addModeActive && api.addModeActive());
|
|
6109
|
-
function drClear3d() { drDraft = null; tfLock.clear(); if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; } // callable pre-init (all handles guarded); clears the shared axis lock on Add disarm (mirrors cmClear3d)
|
|
6127
|
+
function drClear3d() { drDraft = null; drBasisTok = null; tfLock.clear(); if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; } // callable pre-init (all handles guarded); clears the shared axis lock on Add disarm (mirrors cmClear3d)
|
|
6110
6128
|
// The shared "commit the 2nd draw point" transition — used by both the pointer (drClick) and typed entry
|
|
6111
6129
|
// (drHudApply). Clears local draw state BEFORE the geometry callback so the reentrant rebuild is safe.
|
|
6112
6130
|
function commitDrawPoint(p2) {
|
|
6113
|
-
const start = drDraft;
|
|
6114
|
-
|
|
6131
|
+
const start = drDraft, basis = drBasisTok;
|
|
6132
|
+
if (!basis || basis.generation !== pointEntryGen) {
|
|
6133
|
+
drDraft = null; drBasisTok = null; if (api && api.toast) api.toast('Frame changed — pick both member points again');
|
|
6134
|
+
return false;
|
|
6135
|
+
}
|
|
6136
|
+
drDraft = null; drBasisTok = null; tfCandidates = null; // the new member is a snap target for the NEXT one — invalidate the shared snap cache
|
|
6115
6137
|
if (drRubber) drRubber.visible = false; if (readout) readout.style.display = 'none'; // stays armed for the next member
|
|
6116
|
-
|
|
6138
|
+
pointEntryCommit(); // invalidate the captured generation before the re-entrant model rebuild
|
|
6139
|
+
if (start && api && api.onAddMember3d) api.onAddMember3d(start, p2, basis);
|
|
6140
|
+
return true;
|
|
6117
6141
|
}
|
|
6118
6142
|
function drClick(e) {
|
|
6119
|
-
if (!drDraft) { const r0 = wpPointAt(e); if (!r0) return; notePointerPick(); drDraft = r0.p; return; } // start pick = free (bumps the gen so an open first-point typed token can't survive)
|
|
6143
|
+
if (!drDraft) { const r0 = wpPointAt(e); if (!r0) return; notePointerPick(); drDraft = r0.p; drBasisTok = positionAuthoringBasisSnapshot(); return; } // start pick = free (bumps the gen so an open first-point typed token can't survive)
|
|
6120
6144
|
const r = drDestPoint(e); if (!r) return; // 2nd pick: X/Y/Z line-lock (or Alt normal) if locked, else free snap
|
|
6121
6145
|
const p = r.p;
|
|
6122
6146
|
if (Math.hypot(p[0] - drDraft[0], p[1] - drDraft[1], p[2] - drDraft[2]) < 50) return; // ~<2in — ignore a doubled click (pointer only; typed uses a sub-mm epsilon)
|
|
@@ -7187,6 +7211,7 @@ function setInputActive(on) { inputActive = on !== false; }
|
|
|
7187
7211
|
function isReady() { return built; }
|
|
7188
7212
|
|
|
7189
7213
|
function dispose() {
|
|
7214
|
+
positionBasisListeners.clear();
|
|
7190
7215
|
// Stage D, torn down like every sibling overlay above. Without it a re-init() mints a fresh line and
|
|
7191
7216
|
// label while refMeasure3d still reports armed:true against a reference id from the previous
|
|
7192
7217
|
// session — a chip asking for a first point over a scene where every click is a no-op.
|
|
@@ -7502,11 +7527,11 @@ window.Steel3DView = {
|
|
|
7502
7527
|
cameraState, setCameraState, sectionViewState, sceneBounds, objectsPaneState, applyObjectsPaneState, // saved-view snapshot surface (Views Organizer + F11 generated cuts)
|
|
7503
7528
|
workAreaSetAll, workAreaFromSelection, workAreaToggle, workAreaSetWhole, clearWorkArea, workAreaState,
|
|
7504
7529
|
armWorkPlanePick, setWorkPlanePrincipal, clearWorkPlane, toggleWorkPlaneVisible, workPlaneInfo,
|
|
7505
|
-
armFrame3d, disarmFrame3d, repickFrame3d, setFrame3d, setFrameBasis, setFrameAngle, setFrameOrigin, clearFrame3d, frameInfo, frameArmed: () => frameMode, framePicking, framePickStep, frameHandlesScreen, // 3D local drawing frame (UCS stage 1)
|
|
7530
|
+
armFrame3d, disarmFrame3d, repickFrame3d, setFrame3d, setFrameBasis, setFrameAngle, setFrameOrigin, clearFrame3d, frameInfo, positionAuthoringBasis: positionAuthoringBasisSnapshot, onPositionAuthoringBasisChange, frameArmed: () => frameMode, framePicking, framePickStep, frameHandlesScreen, // 3D local drawing frame (UCS stage 1)
|
|
7506
7531
|
coordReadout: () => { if (!readout || !readout._coord || readout.style.display === 'none' || readout._coord.style.display === 'none') return null; return { local: readout._coord.classList.contains('ro-local'), values: readout._coordV.map((v) => v.textContent), labels: readout._coordL.map((l) => l.textContent.trim()), text: readout._coord.textContent }; }, // UCS stage 2 test probe: the live local-coordinate row (null when hidden)
|
|
7507
7532
|
cmEscape, cmHasBase, cmClear3d, setCmAxis, cmLastClient, cmHudApply,
|
|
7508
7533
|
drHudApply, pointEntryBegin, pointEntryEnd, drHasStart: () => !!drDraft, // UCS stage 3: shared typed point-entry HUD (Move/Copy + Add)
|
|
7509
|
-
drClear3d, drEscape: () => { if (drDraft) { drDraft = null; if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; return true; } return false; }, // Esc drops the START only — KEEP the axis lock (tfLock) so the next member reuses it (matches the chip + Move/Copy step-back); full disarm (drClear3d) clears the lock
|
|
7534
|
+
drClear3d, drEscape: () => { if (drDraft) { drDraft = null; drBasisTok = null; if (drRubber) drRubber.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; return true; } return false; }, // Esc drops the START only — KEEP the axis lock (tfLock) so the next member reuses it (matches the chip + Move/Copy step-back); full disarm (drClear3d) clears the lock
|
|
7510
7535
|
toggleDimTool, setDimAxis, dimAxis, setDims3dVisible, dims3dVisible, refreshDims,
|
|
7511
7536
|
setSnapOnly: setSnapOnly3d, snapOnly: () => snapOnly3d, dimToolOn: () => dimMode3d, rightDragged: () => rightMoved, // Tekla-style snap override (right-click menu lives in steel-editor.html)
|
|
7512
7537
|
teklaDragging: () => !!(teklaDrag && teklaDrag.active), // a drag-out to Tekla is in flight — the editor's global Escape must leave it (and the selection) alone
|