@floless/app 0.158.0 → 0.159.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 +92620 -75445
- package/dist/schemas/drawing-check.profile.v1.schema.json +33 -1
- package/dist/skills/floless-app-actions/SKILL.md +23 -5
- package/dist/skills/floless-app-bridge/SKILL.md +5 -3
- package/dist/skills/floless-app-onboarding/SKILL.md +67 -4
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +7 -4
- package/dist/skills/floless-app-queue/SKILL.md +3 -1
- package/dist/skills/floless-app-steel-model/SKILL.md +11 -5
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +28 -8
- package/dist/skills/floless-app-workflows/SKILL.md +6 -3
- package/dist/web/agents.js +12 -5
- package/dist/web/app.css +87 -13
- package/dist/web/app.js +6 -0
- package/dist/web/aware.js +29 -4
- package/dist/web/chat.css +42 -22
- package/dist/web/chat.js +181 -30
- package/dist/web/commands-shell.js +305 -4
- package/dist/web/commands-steel.js +1 -0
- package/dist/web/drawing-check-editor.html +10 -0
- package/dist/web/drawing-check-editor.js +44 -0
- package/dist/web/guide.js +4 -2
- package/dist/web/index.html +41 -9
- package/dist/web/instructor.js +20 -8
- package/dist/web/pages.js +71 -13
- package/dist/web/project-access.js +67 -8
- package/dist/web/project-modules.js +474 -0
- package/dist/web/project-workflows.js +274 -0
- package/dist/web/steel-3d-core.js +46 -0
- package/dist/web/steel-3d-view.js +8 -38
- package/dist/web/steel-editor.html +192 -49
- package/dist/web/workspace-root-recovery.js +119 -0
- package/dist/web/workspaces.js +358 -114
- package/launch-starting-page.mjs +5 -2
- package/launch.mjs +136 -78
- package/package.json +5 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A project's Workflows step (#2470 R6.2): the workflows this project owns, each with its state and how its current
|
|
3
|
+
* version last ran; New workflow… with this project chosen; archived ones in a closed section.
|
|
4
|
+
*
|
|
5
|
+
* It renders what GET /api/workflows/owned?projectId= answers and opens what already exists — the workflow's canvas or
|
|
6
|
+
* draft view (flolessBridge.openOwnedWorkflow), an archived one's Restore card (openArchivedWorkflow), the New workflow
|
|
7
|
+
* dialog (flolessBridge.newWorkflow). It builds nothing and runs nothing. Spec:
|
|
8
|
+
* docs/superpowers/specs/2026-10-22-2470-r6-2-workflows-tab-PLAN.md.
|
|
9
|
+
*/
|
|
10
|
+
(() => {
|
|
11
|
+
const bridge = () => window.flolessBridge || {};
|
|
12
|
+
const api = (path) => {
|
|
13
|
+
if (typeof bridge().api === 'function') return bridge().api(path);
|
|
14
|
+
return fetch(path).then(async (res) => {
|
|
15
|
+
const body = await res.json().catch(() => ({}));
|
|
16
|
+
if (!res.ok || body.ok === false) { const err = new Error(body.error || `HTTP ${res.status}`); err.status = res.status; err.body = body; throw err; }
|
|
17
|
+
return body;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
21
|
+
const toast = (msg, kind) => { if (typeof window.showToast === 'function') window.showToast(msg, kind); };
|
|
22
|
+
|
|
23
|
+
function ago(iso, now = Date.now()) {
|
|
24
|
+
const t = Date.parse(iso);
|
|
25
|
+
if (!Number.isFinite(t)) return '';
|
|
26
|
+
const s = Math.max(0, Math.round((now - t) / 1000));
|
|
27
|
+
if (s < 60) return 'just now';
|
|
28
|
+
const m = Math.round(s / 60);
|
|
29
|
+
if (m < 60) return `${m} min ago`;
|
|
30
|
+
const h = Math.round(m / 60);
|
|
31
|
+
if (h < 24) return `${h} h ago`;
|
|
32
|
+
const d = Math.round(h / 24);
|
|
33
|
+
return d === 1 ? 'yesterday' : `${d} days ago`;
|
|
34
|
+
}
|
|
35
|
+
const exact = (iso) => { const t = Date.parse(iso); return Number.isFinite(t) ? new Date(t).toLocaleString() : ''; };
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The line under a row's name. Runs belong to the CURRENT published version (its runtime id changes on every
|
|
39
|
+
* publish), so it says "this version" and never "never run"; a row the server did not check says just that.
|
|
40
|
+
*/
|
|
41
|
+
function runLine(w, now) {
|
|
42
|
+
if (w.status === 'archived') return 'Archived. Restore it from the Workflows page to use it again.';
|
|
43
|
+
if (!w.activePublication) return 'Not compiled yet';
|
|
44
|
+
const f = w.runFacts;
|
|
45
|
+
if (!f || f.checked === false) return 'Last run not checked';
|
|
46
|
+
const when = f.lastRunAt ? ago(f.lastRunAt, now) : '';
|
|
47
|
+
switch (f.lastRun) {
|
|
48
|
+
case 'none': return 'This version hasn’t run yet';
|
|
49
|
+
case 'ok': return when ? `This version last ran ${when} and finished` : 'This version’s last run finished';
|
|
50
|
+
case 'failed': return when ? `This version last ran ${when} and failed` : 'This version’s last run failed';
|
|
51
|
+
default: return when ? `This version last ran ${when}; its result isn’t recorded` : 'This version’s last run couldn’t be read';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function chip(w) {
|
|
56
|
+
if (w.status === 'archived') return '<span class="pw-chip is-muted">Archived</span>';
|
|
57
|
+
if (!w.activePublication) return '<span class="pw-chip is-muted">Draft</span>';
|
|
58
|
+
return '<span class="pw-chip">Published</span>';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function rowHtml(w, now) {
|
|
62
|
+
const archived = w.status === 'archived';
|
|
63
|
+
const at = w.runFacts && w.runFacts.checked && w.runFacts.lastRunAt ? ` data-tip="${esc(exact(w.runFacts.lastRunAt))}"` : '';
|
|
64
|
+
const tip = archived ? 'Shows this workflow under Archived on the Workflows page, where you can restore it'
|
|
65
|
+
: w.activePublication ? 'Opens this workflow on the Workflows tab' : 'Opens this draft on the Workflows tab';
|
|
66
|
+
// Each command id is written whole; only the instance after "#" varies.
|
|
67
|
+
const carrier = archived
|
|
68
|
+
? `data-pw-archived="1" data-command-id="shell.project-workflow-open-archived#${esc(w.workflowId)}"`
|
|
69
|
+
: `data-command-id="shell.project-workflow-open#${esc(w.workflowId)}"`;
|
|
70
|
+
return `<div class="pg-row pw-row" role="listitem">
|
|
71
|
+
<button type="button" class="pw-row-open" data-pw-open="${esc(w.workflowId)}" ${carrier} data-command-instance-label="${esc(w.displayName)}" data-tip="${esc(tip)}">
|
|
72
|
+
<span class="pg-row-line"><span class="pg-row-title">${esc(w.displayName)}</span>${chip(w)}</span>
|
|
73
|
+
<span class="pg-row-meta"${at}>${esc(runLine(w, now))}</span>
|
|
74
|
+
</button>
|
|
75
|
+
</div>`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const LOAD_FAILED = 'FloLess couldn’t read the workflow list just now. Check that FloLess is still running, then try again.';
|
|
79
|
+
/**
|
|
80
|
+
* The sentence a failed read shows. FloLess's own "could not be reached" / "took too long" answers (no HTTP status) are
|
|
81
|
+
* written for people; anything the server answered with a status gets the fixed sentence, never its raw text.
|
|
82
|
+
*/
|
|
83
|
+
const loadFailure = (error) => (!error?.status && typeof error?.message === 'string' && /^FloLess /.test(error.message) ? error.message : LOAD_FAILED);
|
|
84
|
+
|
|
85
|
+
/** The step's markup for one answer. `view`: { status: 'loading' | 'ready' | 'failed', rows, error, archivedOpen, busyNew }. */
|
|
86
|
+
function html(view, now = Date.now()) {
|
|
87
|
+
const newBtn = (cls) => `<button type="button" class="ghost ${cls}" data-pw-new="1" data-command-id="shell.project-workflow-new"${view.busyNew ? ' disabled aria-busy="true"' : ''}
|
|
88
|
+
data-tip="Name a new workflow for this project. AI builds it with you; nothing is made until you confirm.">New workflow…</button>`;
|
|
89
|
+
const head = `<div class="step-head"><span tabindex="-1" data-pw-heading="1">Workflows</span>${view.status === 'ready' && view.rows.some((w) => w.status !== 'archived') ? newBtn('pw-new') : ''}</div>
|
|
90
|
+
<p class="pg-sub">Repeatable checks and reports that belong to this project. Agents, schedules and other workflows that
|
|
91
|
+
use this project are under <button type="button" class="pw-access" data-pw-access="1" aria-haspopup="dialog" data-command-id="shell.project-workflows-access"
|
|
92
|
+
data-tip="Shows every Agent, schedule and workflow that reaches into this project">Project access</button>.</p>`;
|
|
93
|
+
if (view.status === 'loading') return `${head}<p class="pg-loading-line">Loading this project’s workflows…</p>`;
|
|
94
|
+
if (view.status === 'gone') {
|
|
95
|
+
return `${head}<div class="pg-empty pw-failed"><p class="pg-empty-title">FloLess couldn’t find this project any more.</p>
|
|
96
|
+
<p>It may have been archived or removed. Go back to your projects to open it again.</p></div>`;
|
|
97
|
+
}
|
|
98
|
+
if (view.status === 'failed') {
|
|
99
|
+
return `${head}<div class="pg-empty pw-failed"><p class="pg-empty-title">FloLess couldn’t load this project’s workflows.</p>
|
|
100
|
+
<p>${esc(view.error || LOAD_FAILED)}</p>
|
|
101
|
+
<p><button type="button" class="ghost" data-pw-retry="1" data-command-id="shell.project-workflows-retry">Try again</button></p></div>`;
|
|
102
|
+
}
|
|
103
|
+
const active = view.rows.filter((w) => w.status !== 'archived');
|
|
104
|
+
const archived = view.rows.filter((w) => w.status === 'archived');
|
|
105
|
+
const list = active.length
|
|
106
|
+
? `<div class="pg-list" role="list" aria-label="Workflows in this project">${active.map((w) => rowHtml(w, now)).join('')}</div>`
|
|
107
|
+
: `<div class="pg-empty pw-empty"><p class="pg-empty-title">No workflows in this project yet</p>
|
|
108
|
+
<p>Build one with New workflow…, or ask AI Chat to build one for this project.</p><p>${newBtn('pw-new-empty')}</p></div>`;
|
|
109
|
+
const archivedHtml = archived.length
|
|
110
|
+
? `<details class="ws-archived pw-archived"${view.archivedOpen ? ' open' : ''}>
|
|
111
|
+
<summary class="ws-archived-summary" data-command-id="shell.project-workflows-archived"><span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span>Archived <span class="ws-archived-count">${archived.length}</span></summary>
|
|
112
|
+
<div class="pg-list" role="list" aria-label="Archived workflows">${archived.map((w) => rowHtml(w, now)).join('')}</div></details>`
|
|
113
|
+
: '';
|
|
114
|
+
return head + list + archivedHtml;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// One pane, one project at a time: a read that answers after the person left the project or the step is dropped.
|
|
118
|
+
let state = null; // { pane, project, generation, view, inflight, again }
|
|
119
|
+
let opening = false;
|
|
120
|
+
|
|
121
|
+
// The live region stays mounted across re-renders (a fresh one each time is often not announced); only the body below
|
|
122
|
+
// it is redrawn. Found by class among the pane's own children.
|
|
123
|
+
const ownChild = (pane, cls) => [...pane.children].find((el) => el.classList.contains(cls)) || null;
|
|
124
|
+
const announce = (pane, text) => { const live = ownChild(pane, 'pw-live'); if (live) live.textContent = text; };
|
|
125
|
+
|
|
126
|
+
function paint() {
|
|
127
|
+
const { pane, view } = state;
|
|
128
|
+
const active = pane.contains(document.activeElement) && document.activeElement !== document.body ? document.activeElement : null;
|
|
129
|
+
// The heading carries no Instructor id; it is where Project access's "Show on the Workflows step" sends the keyboard,
|
|
130
|
+
// often while the list is still loading, so it is kept across the redraw too.
|
|
131
|
+
const focused = active?.hasAttribute('data-pw-heading') ? 'heading' : active?.getAttribute('data-command-id') ?? null;
|
|
132
|
+
let body = ownChild(pane, 'pw-body');
|
|
133
|
+
if (!body) {
|
|
134
|
+
pane.innerHTML = '<span class="sr-only pw-live" role="status" aria-live="polite"></span><div class="pw-body"></div>';
|
|
135
|
+
body = ownChild(pane, 'pw-body');
|
|
136
|
+
}
|
|
137
|
+
body.innerHTML = html(view);
|
|
138
|
+
if (focused === 'heading') body.querySelector('[data-pw-heading]')?.focus({ preventScroll: true });
|
|
139
|
+
else if (focused) {
|
|
140
|
+
const again = [...body.querySelectorAll('[data-command-id]')].find((el) => el.getAttribute('data-command-id') === focused);
|
|
141
|
+
if (again) again.focus({ preventScroll: true });
|
|
142
|
+
// Try again is gone once the list is back: the keyboard lands on the step's heading, not on the page.
|
|
143
|
+
else if (focused === 'shell.project-workflows-retry') body.querySelector('[data-pw-heading]')?.focus({ preventScroll: true });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function load() {
|
|
148
|
+
if (!state) return;
|
|
149
|
+
if (state.inflight) { state.again = true; return; }
|
|
150
|
+
const mine = state;
|
|
151
|
+
const generation = mine.generation;
|
|
152
|
+
mine.inflight = true;
|
|
153
|
+
try {
|
|
154
|
+
const body = await api(`/api/workflows/owned?archived=1&projectId=${encodeURIComponent(mine.project.id)}`);
|
|
155
|
+
if (state !== mine || mine.generation !== generation) return;
|
|
156
|
+
mine.view = { ...mine.view, status: 'ready', rows: Array.isArray(body.workflows) ? body.workflows : [], error: null };
|
|
157
|
+
const n = mine.view.rows.filter((w) => w.status !== 'archived').length;
|
|
158
|
+
paint();
|
|
159
|
+
announce(mine.pane, n === 0 ? 'No workflows in this project yet' : `${n} workflow${n === 1 ? '' : 's'} in this project`);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (state !== mine || mine.generation !== generation) return;
|
|
162
|
+
const gone = error?.status === 404 && error?.body?.code === 'unknown-project';
|
|
163
|
+
mine.view = { ...mine.view, status: gone ? 'gone' : 'failed', error: gone ? null : loadFailure(error) };
|
|
164
|
+
paint();
|
|
165
|
+
announce(mine.pane, gone ? 'FloLess couldn’t find this project any more.' : 'FloLess couldn’t load this project’s workflows.');
|
|
166
|
+
} finally {
|
|
167
|
+
mine.inflight = false;
|
|
168
|
+
// A change that arrived meanwhile is read once more; a dialog in progress holds it until it settles.
|
|
169
|
+
if (state === mine && mine.again && !mine.view.busyNew) { mine.again = false; void load(); }
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function render(pane, project) {
|
|
174
|
+
if (!pane || !project) return;
|
|
175
|
+
const same = state && state.pane === pane && state.project.id === project.id;
|
|
176
|
+
const keepOpen = same ? state.view.archivedOpen : false;
|
|
177
|
+
state = { pane, project, generation: (state?.generation || 0) + 1, view: { status: 'loading', rows: [], archivedOpen: keepOpen, busyNew: false },
|
|
178
|
+
inflight: false, again: false, stale: false };
|
|
179
|
+
paint();
|
|
180
|
+
if (!same) watchVisibility(pane);
|
|
181
|
+
void load();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// On screen: the pane itself is shown AND the Workspaces view around it is (switching to the Workflows tab hides the
|
|
185
|
+
// whole view, not the pane). A DOM without layout (a test harness) counts as shown unless the pane is hidden.
|
|
186
|
+
const shown = (pane) => !pane.hidden
|
|
187
|
+
&& (typeof pane.checkVisibility === 'function' ? pane.checkVisibility() : pane.offsetParent !== null);
|
|
188
|
+
|
|
189
|
+
/** A workflow changed or a run ended: re-read while the step is on screen, otherwise when it is next shown. */
|
|
190
|
+
function refresh() {
|
|
191
|
+
if (!state) return;
|
|
192
|
+
if (!shown(state.pane)) { state.stale = true; return; }
|
|
193
|
+
if (state.view.busyNew) { state.again = true; return; }
|
|
194
|
+
void load();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Coming back to the step after it was out of view (the Workflows tab, where its workflows are run) always re-reads:
|
|
198
|
+
// a change message sent while the event stream was reconnecting is never seen, so being told is not relied on.
|
|
199
|
+
let observer = null;
|
|
200
|
+
function watchVisibility(pane) {
|
|
201
|
+
observer?.disconnect();
|
|
202
|
+
if (typeof IntersectionObserver !== 'function') return;
|
|
203
|
+
observer = new IntersectionObserver((entries) => {
|
|
204
|
+
if (state?.pane !== pane) return;
|
|
205
|
+
const inView = entries[entries.length - 1].isIntersecting;
|
|
206
|
+
if (!inView) { state.stale = true; return; }
|
|
207
|
+
if (state.stale) { state.stale = false; refresh(); }
|
|
208
|
+
});
|
|
209
|
+
observer.observe(pane);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function openRow(button) {
|
|
213
|
+
if (opening) return;
|
|
214
|
+
opening = true;
|
|
215
|
+
const id = button.getAttribute('data-pw-open');
|
|
216
|
+
try {
|
|
217
|
+
const b = bridge();
|
|
218
|
+
const fn = button.hasAttribute('data-pw-archived') ? b.openArchivedWorkflow : b.openOwnedWorkflow;
|
|
219
|
+
if (typeof fn !== 'function') throw new Error('this window cannot open workflows');
|
|
220
|
+
await fn.call(b, id);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
// Opening switches to the Workflows tab first, so the step may be hidden: a toast is seen wherever the person is.
|
|
223
|
+
console.warn('[project-workflows] a workflow could not be opened', error);
|
|
224
|
+
toast('FloLess couldn’t open that workflow. It may have been moved or archived meanwhile. Try again, or open it from the Workflows page.', 'warn');
|
|
225
|
+
refresh();
|
|
226
|
+
} finally { opening = false; }
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async function newWorkflow(button) {
|
|
230
|
+
const mine = state;
|
|
231
|
+
if (!mine || mine.view.busyNew) return;
|
|
232
|
+
mine.view = { ...mine.view, busyNew: true };
|
|
233
|
+
paint();
|
|
234
|
+
try {
|
|
235
|
+
if (typeof bridge().newWorkflow !== 'function') throw new Error('Use ≡ → New workflow and choose this project as its location.');
|
|
236
|
+
await bridge().newWorkflow({ ownerProjectId: mine.project.id });
|
|
237
|
+
} catch (error) {
|
|
238
|
+
toast(error?.message || 'FloLess couldn’t open New workflow.', 'warn');
|
|
239
|
+
} finally {
|
|
240
|
+
if (state === mine) {
|
|
241
|
+
mine.view = { ...mine.view, busyNew: false };
|
|
242
|
+
mine.again = false;
|
|
243
|
+
paint();
|
|
244
|
+
void load();
|
|
245
|
+
if (!mine.pane.hidden) mine.pane.querySelector('[data-pw-new]')?.focus({ preventScroll: true });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
document.addEventListener('click', (event) => {
|
|
251
|
+
if (!state || !state.pane.contains(event.target)) return;
|
|
252
|
+
const open = event.target.closest('[data-pw-open]');
|
|
253
|
+
if (open) { event.preventDefault(); void openRow(open); return; }
|
|
254
|
+
const create = event.target.closest('[data-pw-new]');
|
|
255
|
+
if (create) { event.preventDefault(); void newWorkflow(create); return; }
|
|
256
|
+
const access = event.target.closest('[data-pw-access]');
|
|
257
|
+
if (access) {
|
|
258
|
+
event.preventDefault();
|
|
259
|
+
if (typeof window.flolessProjectAccess?.open === 'function') window.flolessProjectAccess.open(access);
|
|
260
|
+
else toast('Use Project access in the project’s header to see what else reaches this project.', 'warn');
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (event.target.closest('[data-pw-retry]')) { event.preventDefault(); state.view = { ...state.view, status: 'loading' }; paint(); void load(); }
|
|
264
|
+
});
|
|
265
|
+
// The Archived section's open/closed state survives a re-read.
|
|
266
|
+
document.addEventListener('toggle', (event) => {
|
|
267
|
+
if (state && event.target?.matches?.('.pw-archived') && state.pane.contains(event.target)) {
|
|
268
|
+
state.view.archivedOpen = event.target.hasAttribute('open');
|
|
269
|
+
}
|
|
270
|
+
}, true);
|
|
271
|
+
window.addEventListener('floless:apps-changed', refresh);
|
|
272
|
+
|
|
273
|
+
window.flolessProjectWorkflows = { render, refresh, html, runLine };
|
|
274
|
+
})();
|
|
@@ -542,6 +542,52 @@ export function sectionOutlinePts(kind, w, d, thk) {
|
|
|
542
542
|
return { outer }; // BOX / unclassified → rectangle
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
+
/**
|
|
546
|
+
* The 3D section kind of one scene member: an explicit `section.shape` override wins, then the bake's
|
|
547
|
+
* `section.round` (a round HSS cannot be told from its designation — `sectionKindOf` answers TUBE for both
|
|
548
|
+
* `HSS6X6X3/8` and `HSS6.625X0.280`), then the designation through `sectionKindOf`. Shared by the 3D
|
|
549
|
+
* renderer (`steel-3d-view.js`) and the Page `.glb` exporter (`server/glb-export.ts`) so the two cannot
|
|
550
|
+
* draw the same member as different shapes.
|
|
551
|
+
*/
|
|
552
|
+
export function memberShapeKind(el) {
|
|
553
|
+
const explicit = (el && el.section && el.section.shape || '').toString().toUpperCase().trim();
|
|
554
|
+
if (/^(I|C|L|TUBE|BOX|ROUND)$/.test(explicit)) return explicit;
|
|
555
|
+
if (el && el.section && el.section.round === true) return 'ROUND';
|
|
556
|
+
return sectionKindOf((el && el.meta && el.meta.profile) || '');
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/** True when a member is drawn as an extruded section rather than a plain box. */
|
|
560
|
+
export function memberExtrudes(el) {
|
|
561
|
+
const display = el && el.meta && el.meta.displaySection;
|
|
562
|
+
const displayExtrudes = !!display && !/^(rect|joist|unsupported-custom)$/.test(String(display.shape));
|
|
563
|
+
return displayExtrudes || memberShapeKind(el) !== 'BOX';
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// A real thickness off the element's `xsection` (AISC table / designation) when there is one and it fits
|
|
567
|
+
// inside the section, else null so the caller keeps its estimate. The fit check matters: a metric
|
|
568
|
+
// designation's thickness token is parsed as inches, which would draw a leg thicker than the whole angle.
|
|
569
|
+
function xsectionThk(xs, key, half) {
|
|
570
|
+
const t = xs && typeof xs[key] === 'number' ? xs[key] : null;
|
|
571
|
+
return t != null && t > 0 && t < 2 * half ? t : null;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* The section topology a member is extruded from. `displaySection` (tee, double-angle, …) wins; without it
|
|
576
|
+
* the element's `xsection` supplies the real thicknesses. Without either every thickness is a GUESS off the
|
|
577
|
+
* envelope — an L4X4 leg came out 18.3mm against a real 9.5 — and the estimates in `sectionOutlinePts` are
|
|
578
|
+
* the fallback that lets a member be drawn at all.
|
|
579
|
+
*/
|
|
580
|
+
export function memberSectionTopology(kind, w, d, xs, displaySection) {
|
|
581
|
+
const fallback = xs ? {
|
|
582
|
+
...(xs.shape === 'i' ? { shape: 'i', d: xs.d, bf: xs.bf, tw: xsectionThk(xs, 'tw', w / 2), tf: xsectionThk(xs, 'tf', d / 2) } : {}),
|
|
583
|
+
...(xs.shape === 'channel' ? { shape: 'channel', d: xs.d, bf: xs.bf, tw: xsectionThk(xs, 'tw', w / 2), tf: xsectionThk(xs, 'tf', d / 2) } : {}),
|
|
584
|
+
...(xs.shape === 'angle' ? { shape: 'angle', d: xs.d, b: xs.b, t: xsectionThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
585
|
+
...(xs.shape === 'rhs' ? { shape: 'rhs', d: xs.d, b: xs.b, t: xsectionThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
586
|
+
...(xs.shape === 'chs' ? { shape: 'chs', od: xs.od, t: xsectionThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
587
|
+
} : null;
|
|
588
|
+
return sectionTopology(displaySection || fallback, w, d, kind);
|
|
589
|
+
}
|
|
590
|
+
|
|
545
591
|
/** How many segments approximate a circle for the consumers that need a polygon. */
|
|
546
592
|
export const ROUND_SEGMENTS = 48;
|
|
547
593
|
|
|
@@ -21,7 +21,7 @@ import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-m
|
|
|
21
21
|
import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
|
|
22
22
|
import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
|
|
23
23
|
import { FT_TO_MM as FT_MM } from './steel-units.js';
|
|
24
|
-
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, projectToPlane, snapGridPoint, projectPointOnSegment2d, projectPointOnSegment3d, selectedFrontmostHit, worldEndpointCommit, SEG_DEGENERACY, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, translateEndpoints, livePositionState, swingBasis, swingEndpoint, swingBarriers, clampSwingTheta, POSITION_SWING_MARGIN_RAD, POSITION_OFFSET_SNAP_MM, POSITION_ROT_SNAP_DEG, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
24
|
+
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, projectToPlane, snapGridPoint, projectPointOnSegment2d, projectPointOnSegment3d, selectedFrontmostHit, worldEndpointCommit, SEG_DEGENERACY, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberShapeKind, memberExtrudes, memberSectionTopology, memberMeshAxes, positionSwingDelta, snapToStep, rollCommitNorm, unwrapAngleStep, translateEndpoints, livePositionState, swingBasis, swingEndpoint, swingBarriers, clampSwingTheta, POSITION_SWING_MARGIN_RAD, POSITION_OFFSET_SNAP_MM, POSITION_ROT_SNAP_DEG, POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
25
25
|
// `gridGeometry`, `gridCandidates3d` and `sheetScaleMm` live behind the host's model read boundary
|
|
26
26
|
// because their display-scale argument is meaningless on a world-mm model grid.
|
|
27
27
|
import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
|
|
@@ -940,42 +940,13 @@ function lengthAxisOf(el) {
|
|
|
940
940
|
// finish across the nut's short axis instead of along its sweep.
|
|
941
941
|
if (kind === 'rod' || kind === 'bolt-shank' || kind === 'anchor' || kind === 'nut') return 'y'; // CylinderGeometry
|
|
942
942
|
if (kind === 'plate' || kind === 'washer' || kind === 'bolt-head') return 'z';
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
const explicit = (el.section && el.section.shape || '').toString().toUpperCase().trim();
|
|
949
|
-
if (/^(I|C|L|TUBE|BOX|ROUND)$/.test(explicit)) return explicit; // explicit section.shape override wins
|
|
950
|
-
// A ROUND section cannot be told from its designation here: `sectionKindOf` matches a literal prefix and
|
|
951
|
-
// answers TUBE for both `HSS6X6X3/8` (rectangular) and `HSS6.625X0.280` (round). The bake parses the
|
|
952
|
-
// numerics and says so on `section.round` — without it a pipe drew as a rectangle whose corner reaches
|
|
953
|
-
// 0.707·OD, putting a rolled pipe's flush face 23.7 mm off its reference line.
|
|
954
|
-
if (el.section && el.section.round === true) return 'ROUND';
|
|
955
|
-
// The designation itself goes to the shared classifier (steel-3d-core.js), which the 2D plan outline
|
|
956
|
-
// and the base-plate weld also use. The copy that lived here drew MC channels as I-sections (#647).
|
|
957
|
-
return sectionKindOf((el.meta && el.meta.profile) || '');
|
|
958
|
-
}
|
|
959
|
-
// A real thickness off the element's `xsection` (AISC table / designation) when there is one and it fits
|
|
960
|
-
// inside the section, else null so the caller keeps its estimate. The fit check matters: a metric
|
|
961
|
-
// designation's thickness token is parsed as inches, which would draw a leg thicker than the whole angle.
|
|
962
|
-
function realThk(xs, key, half) {
|
|
963
|
-
const t = xs && typeof xs[key] === 'number' ? xs[key] : null;
|
|
964
|
-
return t != null && t > 0 && t < 2 * half ? t : null;
|
|
965
|
-
}
|
|
966
|
-
// `xs` is the scene element's `xsection`. Without it every thickness here is a GUESS off the envelope —
|
|
967
|
-
// an L4X4 leg came out 18.3mm against a real 9.5, so a connection bearing on the real face rendered buried
|
|
968
|
-
// in a member that was drawn nearly twice too thick. The estimates remain as the fallback for sections we
|
|
969
|
-
// have no data for; they are the reason a member can still be drawn at all.
|
|
943
|
+
return !memberExtrudes(el) ? 'y' : 'z'; // Box vs Extrude
|
|
944
|
+
}
|
|
945
|
+
// The section kind and topology are steel-3d-core.js's (`memberShapeKind`, `memberSectionTopology`), shared
|
|
946
|
+
// with the Page .glb exporter so a shared 3D file draws every member as this view does.
|
|
947
|
+
const shapeOf = memberShapeKind;
|
|
970
948
|
function profileShape(kind, w, d, xs, displaySection) {
|
|
971
|
-
const
|
|
972
|
-
...(xs.shape === 'i' ? { shape: 'i', d: xs.d, bf: xs.bf, tw: realThk(xs, 'tw', w / 2), tf: realThk(xs, 'tf', d / 2) } : {}),
|
|
973
|
-
...(xs.shape === 'channel' ? { shape: 'channel', d: xs.d, bf: xs.bf, tw: realThk(xs, 'tw', w / 2), tf: realThk(xs, 'tf', d / 2) } : {}),
|
|
974
|
-
...(xs.shape === 'angle' ? { shape: 'angle', d: xs.d, b: xs.b, t: realThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
975
|
-
...(xs.shape === 'rhs' ? { shape: 'rhs', d: xs.d, b: xs.b, t: realThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
976
|
-
...(xs.shape === 'chs' ? { shape: 'chs', od: xs.od, t: realThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
977
|
-
} : null;
|
|
978
|
-
const topology = sectionTopology(displaySection || fallback, w, d, kind);
|
|
949
|
+
const topology = memberSectionTopology(kind, w, d, xs, displaySection);
|
|
979
950
|
const trace = (path, descriptor) => {
|
|
980
951
|
if (descriptor.kind === 'circle') { path.absarc(descriptor.cx, descriptor.cy, descriptor.radius, 0, Math.PI * 2, false); return; }
|
|
981
952
|
descriptor.points.forEach(([x, y], i) => (i ? path.lineTo(x, y) : path.moveTo(x, y))); path.closePath();
|
|
@@ -989,8 +960,7 @@ function profileShape(kind, w, d, xs, displaySection) {
|
|
|
989
960
|
function memberGeom(el, w, d, len) {
|
|
990
961
|
const kind = shapeOf(el);
|
|
991
962
|
const display = el?.meta?.displaySection;
|
|
992
|
-
|
|
993
|
-
if (kind === 'BOX' && !displayExtrudes) return new THREE.BoxGeometry(w, len, d); // length on local Y
|
|
963
|
+
if (!memberExtrudes(el)) return new THREE.BoxGeometry(w, len, d); // length on local Y
|
|
994
964
|
const shapes = profileShape(kind, w, d, el && el.xsection, display);
|
|
995
965
|
const g = new THREE.ExtrudeGeometry(shapes, { depth: len, bevelEnabled: false, curveSegments: 32 });
|
|
996
966
|
g.translate(0, 0, -len / 2); return g; // extruded +Z, centred
|