@floless/app 0.169.0 → 0.171.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 +65531 -43728
- package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
- package/dist/schemas/steel.model.v2.schema.json +196 -4
- package/dist/skills/floless-app-bridge/SKILL.md +3 -3
- package/dist/skills/floless-app-knowledge/SKILL.md +46 -15
- package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
- package/dist/skills/floless-app-onboarding/SKILL.md +5 -4
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +0 -3
- package/dist/skills/floless-app-queue/SKILL.md +2 -3
- package/dist/skills/floless-app-report-issue/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
- package/dist/skills/floless-app-steel-model/SKILL.md +42 -39
- package/dist/skills/floless-app-steel-model/references/custom-connections.md +47 -0
- package/dist/skills/floless-app-steel-model/references/custom-sections.md +32 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
- package/dist/skills/floless-app-ui/SKILL.md +71 -126
- package/dist/skills/floless-app-workflows/SKILL.md +22 -3
- package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
- package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
- package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
- package/dist/web/add-ons.js +407 -0
- package/dist/web/agent-steps.js +89 -18
- package/dist/web/agents.js +32 -22
- package/dist/web/analytics.js +1 -1
- package/dist/web/app.css +331 -190
- package/dist/web/app.js +33 -13
- package/dist/web/aware.js +926 -218
- package/dist/web/chat.css +6 -1
- package/dist/web/chat.js +316 -112
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +479 -78
- package/dist/web/commands-steel.js +69 -2
- package/dist/web/commands-tekla-parser.js +23 -0
- package/dist/web/connections.js +14 -3
- package/dist/web/drawing-check-editor.js +352 -88
- package/dist/web/failure-copy.js +33 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +1 -1
- package/dist/web/guide.js +36 -29
- package/dist/web/index.html +98 -57
- package/dist/web/instructor.js +101 -17
- package/dist/web/kb-categories.js +64 -7
- package/dist/web/left-pane.js +4 -1
- package/dist/web/local-discovery.js +8 -7
- package/dist/web/missed-routines.js +239 -0
- package/dist/web/model-change-findings.js +430 -0
- package/dist/web/model-change-review.js +414 -0
- package/dist/web/model-editor-steel-adapter.js +2 -2
- package/dist/web/model-measure.js +6 -0
- package/dist/web/model-spatial-panel.js +19 -4
- package/dist/web/model-spatial-tools.js +3 -3
- package/dist/web/model-viewport-revit-adapter.js +3 -3
- package/dist/web/origin-rule.js +155 -0
- package/dist/web/project-access.js +1 -1
- package/dist/web/project-history.js +7 -1
- package/dist/web/project-modules.js +2 -2
- package/dist/web/project-rfis.js +6 -1
- package/dist/web/project-workflows.js +2 -2
- package/dist/web/revit-editor.css +85 -0
- package/dist/web/revit-editor.js +58 -9
- package/dist/web/run-history.js +12 -1
- package/dist/web/sha256-sync.js +62 -0
- package/dist/web/steel-3d-core.js +46 -9
- package/dist/web/steel-3d-flo.js +153 -7
- package/dist/web/steel-3d-view.js +33 -5
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-custom-connection.js +161 -0
- package/dist/web/steel-custom-sections.js +1796 -0
- package/dist/web/steel-editor.html +732 -161
- package/dist/web/steel-environments.js +297 -0
- package/dist/web/steel-filter-usage.js +299 -0
- package/dist/web/steel-filter.html +104 -6
- package/dist/web/steel-model-v2-client-validation.js +11 -1
- package/dist/web/steel-model-v2-commands.js +116 -13
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/steel-read-confidence.js +1 -56
- package/dist/web/step-rename.js +3 -2
- package/dist/web/tekla-editor.html +1 -0
- package/dist/web/terminal-requests.js +1 -1
- package/dist/web/tool-updates.js +7 -6
- package/dist/web/workspaces.js +1968 -138
- package/launch.mjs +87 -9
- package/package.json +4 -1
- package/dist/web/panels.js +0 -831
|
@@ -34,6 +34,10 @@ export { clipSegmentToPlanes } from './model-viewport-state.js';
|
|
|
34
34
|
// conversion in disguise — which is why it spells the constant rather than the number, and why this
|
|
35
35
|
// file leaves the geometry guard's literal ratchet at zero.
|
|
36
36
|
import { FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M } from './steel-units.js';
|
|
37
|
+
import {
|
|
38
|
+
COLUMN_BELOW_REACH_MM_IMPERIAL, COLUMN_BELOW_REACH_MM_METRIC as REGISTRY_BELOW_METRIC,
|
|
39
|
+
COLUMN_NEAR_CUT_MM_IMPERIAL, COLUMN_NEAR_CUT_MM_METRIC as REGISTRY_NEAR_CUT_METRIC, traitsFor,
|
|
40
|
+
} from './steel-environments.js';
|
|
37
41
|
export { FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M };
|
|
38
42
|
|
|
39
43
|
/** Atomic capability marker: storage, readers, authoring and shipped guidance advance together. */
|
|
@@ -186,7 +190,19 @@ export function reexpressMemberPlacement(member, refFrom, refTo, target, extents
|
|
|
186
190
|
* EHS carries no entry either: an ellipse has no member of the SectionKind union, so it stays BOX here
|
|
187
191
|
* and is refused as geometry upstream (`displaySectionForRow` → unsupported-custom), never drawn.
|
|
188
192
|
*
|
|
189
|
-
*
|
|
193
|
+
* THE EU FAMILIES (EU epic #3197, EU-2) are the entries carrying a third element, `'token'`: they match the
|
|
194
|
+
* designation's whole leading LETTER RUN, not a prefix. Their names are one to three letters, and a prefix
|
|
195
|
+
* would read `KKB…` or `KU…` (cold-formed channels the EU catalogue does not retain) as `KK`, `NOTCH…` as
|
|
196
|
+
* `N`, `HLB…` as `HL`. `KK200/100/5` has the run `KK`; `KKB100` has `KKB`, which no entry names. Each maps
|
|
197
|
+
* to an EXISTING kind only: the I and H families to 'I', the channels to 'C', `L` to 'L' (the prefix entry
|
|
198
|
+
* above already covers it), the hollow `KK` (cold-formed) and `KW` (hot-finished) to 'TUBE', and the
|
|
199
|
+
* circular `N` also to 'TUBE' — its roundness is the catalogue row's (`section.round`), exactly as a `CHS`
|
|
200
|
+
* or `HSS6.625X0.280` is, never the designation's. The tees `T` and `GT` ride to 'I' for the reason the
|
|
201
|
+
* UK tees do: a resolved tee draws from its displaySection, this is only the fallback.
|
|
202
|
+
* The families the Tekla default environment adds sizes under are whole tokens too: `HD` to 'I', `USP` to 'C', and
|
|
203
|
+
* `CFRHS`/`HFRHS`/`HFSHS`/`CFCHS`/`HFCHS` to 'TUBE' (as prefixes the first two would read as the channel `C`).
|
|
204
|
+
*
|
|
205
|
+
* @type {ReadonlyArray<readonly [string, SectionKind] | readonly [string, SectionKind, 'token']>}
|
|
190
206
|
*/
|
|
191
207
|
export const SECTION_FAMILIES = [
|
|
192
208
|
['W', 'I'], ['M', 'I'], ['S', 'I'], ['HP', 'I'], // US I-family
|
|
@@ -198,6 +214,18 @@ export const SECTION_FAMILIES = [
|
|
|
198
214
|
['L', 'L'], ['UKA', 'L'], ['RSA', 'L'], // angles (UK equal/unequal + legacy RSA)
|
|
199
215
|
['HSS', 'TUBE'], ['PIPE', 'TUBE'], ['TS', 'TUBE'], ['TUBE', 'TUBE'], ['HSQ', 'TUBE'],
|
|
200
216
|
['SHS', 'TUBE'], ['RHS', 'TUBE'], ['CHS', 'TUBE'], // hollow sections
|
|
217
|
+
// EU (EN) families, whole letter-run only. IPE and L are reached by the prefix entries above (an equal-length
|
|
218
|
+
// token entry could never win, so none is listed); HEA/HEB/HEM/HEAA are longer than their `HE` prefix and are listed.
|
|
219
|
+
['HEA', 'I', 'token'], ['HEB', 'I', 'token'], ['HEM', 'I', 'token'], ['HEAA', 'I', 'token'],
|
|
220
|
+
['INP', 'I', 'token'], ['HL', 'I', 'token'],
|
|
221
|
+
['UPE', 'C', 'token'], ['UNP', 'C', 'token'], ['UAP', 'C', 'token'],
|
|
222
|
+
['KK', 'TUBE', 'token'], ['KW', 'TUBE', 'token'], ['N', 'TUBE', 'token'],
|
|
223
|
+
['T', 'I', 'token'], ['GT', 'I', 'token'],
|
|
224
|
+
// EU sizes added from the Tekla default environment (#3197): its own family spellings. Whole token for the
|
|
225
|
+
// same reason — as prefixes `CFRHS`/`CFCHS` would read as the channel `C`, `USP` as the I `S`, `HD` as nothing.
|
|
226
|
+
['HD', 'I', 'token'], ['USP', 'C', 'token'],
|
|
227
|
+
['CFRHS', 'TUBE', 'token'], ['HFRHS', 'TUBE', 'token'], ['HFSHS', 'TUBE', 'token'],
|
|
228
|
+
['CFCHS', 'TUBE', 'token'], ['HFCHS', 'TUBE', 'token'],
|
|
201
229
|
];
|
|
202
230
|
|
|
203
231
|
/**
|
|
@@ -235,10 +263,12 @@ export function sectionKindOf(profile) {
|
|
|
235
263
|
/** @type {SectionKind} */
|
|
236
264
|
let kind = 'BOX';
|
|
237
265
|
let best = 0;
|
|
266
|
+
// The designation's leading letter run, for the whole-token (EU) entries: `KK200/100/5` -> `KK`.
|
|
267
|
+
const run = /^[A-Z]+/.exec(p)?.[0] ?? '';
|
|
238
268
|
// No cast on `familyKind`: the table is annotated, so a bad entry is a problem at the table (where
|
|
239
269
|
// section-kind.test.ts checks for it) rather than something an assertion here quietly waves through.
|
|
240
|
-
for (const [prefix, familyKind] of SECTION_FAMILIES) {
|
|
241
|
-
if (prefix.length > best && p.startsWith(prefix)) {
|
|
270
|
+
for (const [prefix, familyKind, match] of SECTION_FAMILIES) {
|
|
271
|
+
if (prefix.length > best && (match === 'token' ? run === prefix : p.startsWith(prefix))) {
|
|
242
272
|
best = prefix.length;
|
|
243
273
|
kind = familyKind;
|
|
244
274
|
}
|
|
@@ -607,6 +637,13 @@ export function sectionTopology(displaySection, w, d, fallbackKind = 'BOX') {
|
|
|
607
637
|
const radius = od / 2;
|
|
608
638
|
return [component(circle(radius), t > 0 && t < radius ? [circle(radius - t)] : [])];
|
|
609
639
|
}
|
|
640
|
+
if (xs?.shape === 'outline') {
|
|
641
|
+
// A custom section (add-ons S1a): its evaluated outline, already in mm, centred on its bounding box,
|
|
642
|
+
// counter-clockwise, x across the width and y up the depth. Drawn exactly as evaluated, never re-fitted.
|
|
643
|
+
const outer = Array.isArray(xs.outer) ? xs.outer.filter((p) => Array.isArray(p) && Number.isFinite(p[0]) && Number.isFinite(p[1])) : [];
|
|
644
|
+
if (outer.length >= 3) return [component(polygon(outer.map(([x, y]) => [x, y])))];
|
|
645
|
+
return [];
|
|
646
|
+
}
|
|
610
647
|
if (xs?.shape === 'solid-circle') {
|
|
611
648
|
const diameter = Number(xs.diameter) > 0 ? Number(xs.diameter) : Math.min(w, d);
|
|
612
649
|
return [component(circle(diameter / 2))];
|
|
@@ -1148,7 +1185,7 @@ export function sheetIncludesElevation(fromZ, toZ, elevMm, tol = MODEL_V2_TOL.CU
|
|
|
1148
1185
|
* the read binds it). Smaller means a missed column that "Add to this view" fixes; larger means dashed
|
|
1149
1186
|
* clutter that cannot be removed from the sheet.
|
|
1150
1187
|
*/
|
|
1151
|
-
export const COLUMN_BELOW_REACH_MM =
|
|
1188
|
+
export const COLUMN_BELOW_REACH_MM = COLUMN_BELOW_REACH_MM_IMPERIAL; // 12" = one foot; the figure lives in the trait registry (steel-environments.js), which takes it from the one definition of the foot
|
|
1152
1189
|
|
|
1153
1190
|
/**
|
|
1154
1191
|
* The same convention for a project built to a metric standard: a round 300 mm, not the 304.8 a
|
|
@@ -1167,11 +1204,11 @@ export const COLUMN_BELOW_REACH_MM = FT_TO_MM; // 12" = one foot, from the one
|
|
|
1167
1204
|
* immutable, is a property of the project rather than of the reader, and is exactly the question
|
|
1168
1205
|
* "which standard is this built to".
|
|
1169
1206
|
*/
|
|
1170
|
-
export const COLUMN_BELOW_REACH_MM_METRIC = 300
|
|
1207
|
+
export const COLUMN_BELOW_REACH_MM_METRIC = REGISTRY_BELOW_METRIC; // 300 — declared once, in the trait registry
|
|
1171
1208
|
|
|
1172
1209
|
/** The default reach for a project built to `environment` — metric standards get the round number. */
|
|
1173
1210
|
export function defaultColumnBelowReach(environment) {
|
|
1174
|
-
return environment
|
|
1211
|
+
return traitsFor(environment).columnBelowReachMm;
|
|
1175
1212
|
}
|
|
1176
1213
|
|
|
1177
1214
|
/**
|
|
@@ -1251,10 +1288,10 @@ export function columnCutRelation(fromZ, toZ, cutMm, reach = COLUMN_BELOW_REACH_
|
|
|
1251
1288
|
* show them anyway. Keyed on the project's environment for the reason `defaultColumnBelowReach` is. Not in
|
|
1252
1289
|
* the frozen `MODEL_V2_TOL`, which is merge/refusal semantics.
|
|
1253
1290
|
*/
|
|
1254
|
-
export const COLUMN_NEAR_CUT_MM_METRIC = 50
|
|
1255
|
-
export const COLUMN_NEAR_CUT_MM =
|
|
1291
|
+
export const COLUMN_NEAR_CUT_MM_METRIC = REGISTRY_NEAR_CUT_METRIC; // 50 — declared once, in the trait registry
|
|
1292
|
+
export const COLUMN_NEAR_CUT_MM = COLUMN_NEAR_CUT_MM_IMPERIAL;
|
|
1256
1293
|
export function defaultColumnNearCut(environment) {
|
|
1257
|
-
return environment
|
|
1294
|
+
return traitsFor(environment).columnNearCutMm;
|
|
1258
1295
|
}
|
|
1259
1296
|
|
|
1260
1297
|
/**
|
package/dist/web/steel-3d-flo.js
CHANGED
|
@@ -17,7 +17,6 @@ import { createFlo3D } from './flo-3d.js';
|
|
|
17
17
|
|
|
18
18
|
const MODEL_R_OF_DIAG = 0.011; // Flo's ring radius as a share of the model's diagonal...
|
|
19
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
20
|
const VISIT_MAX = 10; // a big change is shown by its first ten members, not all of them
|
|
22
21
|
const VISIT_DWELL_S = 1.2; // long enough on each changed member to read Flo's card about it
|
|
23
22
|
const SUCCESS_S = 2.4;
|
|
@@ -26,8 +25,41 @@ const REMEMBER_TTL_MS = 120_000;
|
|
|
26
25
|
const SETTLE_MS = 250; // a click-through of members moves Flo once, when it stops
|
|
27
26
|
const ALONG = 0.3; // a beam's perch: this far along it, clear of the label and the ends
|
|
28
27
|
const LEAVE_S = 0.2; // Minimize: Flo shrinks away this fast (instant under reduced motion)
|
|
28
|
+
const HALF_WIDTH_R = 1.5; // Flo's reach either side of its middle, in r: the hat's brim (1.25 r) widened by a hop's squash
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// How big Flo is on screen (#3380): its ring radius in screen pixels follows the zoom, the way a map pin does,
|
|
31
|
+
// and the person's Flo size multiplies it. The zoom is read as how many pixels the model's diagonal spans on
|
|
32
|
+
// screen at Flo's depth (the same px-per-world scale the labels and marks use, so it means the same in the
|
|
33
|
+
// perspective and the orthographic camera). Zoomed in close Flo gets smaller, so it never covers the members in
|
|
34
|
+
// focus; zoomed out it gets bigger, so it stays visible beside a small model. Continuous: a power curve, no steps.
|
|
35
|
+
export const FLO_SIZE = Object.freeze({
|
|
36
|
+
REF_MODEL_PX: 1200, // the model's diagonal on screen at which Flo is drawn at its designed size (about "Fit")
|
|
37
|
+
FIT_R_PX: 22, // Flo's ring radius there, at Flo size 100 % (Flo stands about 3.3 r tall: ~73 px)
|
|
38
|
+
CURVE: 0.3, // how strongly the zoom changes Flo: 10x closer draws Flo half as big
|
|
39
|
+
MIN_R_PX: 11, // the curve stops here when zoomed in close...
|
|
40
|
+
MAX_R_PX: 34, // ...and here when zoomed out; both scale with Flo size, so the slider always counts
|
|
41
|
+
FLOOR_R_PX: 8, // never smaller than this, whatever the slider says: Flo stays recognisable
|
|
42
|
+
HEIGHT_R: 3.3, // Flo's height, hat included, in r
|
|
43
|
+
VIEW_SHARE: 0.28, // never taller than this share of the view, whatever the slider says
|
|
44
|
+
MEMBER_SHARE: 3, // never wider (about 3 r) than the member as drawn, so it never hides it (the floor still holds).
|
|
45
|
+
// Half the member was tried: in a real zoom-out it stopped Flo growing as soon as the beam got small
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Flo's ring radius in screen pixels. modelPx: the model's diagonal on screen; viewH: the view's height in px;
|
|
49
|
+
// memberPx: how long the member Flo stands on is drawn, foreshortening included (both optional); sizeK: Flo size as a factor.
|
|
50
|
+
// Rounded to a quarter pixel, so a still camera never shimmers.
|
|
51
|
+
/** @param {{ sizeK?: number, modelPx?: number, viewH?: number, memberPx?: number }} [opts] */
|
|
52
|
+
export function floScreenRadiusPx({ sizeK = 1, modelPx, viewH, memberPx } = {}) {
|
|
53
|
+
const S = FLO_SIZE;
|
|
54
|
+
const k = Number.isFinite(sizeK) && sizeK > 0 ? sizeK : 1;
|
|
55
|
+
const zoom = Number.isFinite(modelPx) && modelPx > 0 ? Math.pow(S.REF_MODEL_PX / modelPx, S.CURVE) : 1;
|
|
56
|
+
let r = Math.min(k * S.MAX_R_PX, Math.max(k * S.MIN_R_PX, k * S.FIT_R_PX * zoom));
|
|
57
|
+
if (Number.isFinite(memberPx) && memberPx > 0) r = Math.min(r, memberPx / S.MEMBER_SHARE);
|
|
58
|
+
if (Number.isFinite(viewH) && viewH > 0) r = Math.min(r, viewH * S.VIEW_SHARE / S.HEIGHT_R);
|
|
59
|
+
return Math.round(Math.max(S.FLOOR_R_PX, r) * 4) / 4;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox, getViewSize = () => /** @type {{ w: number, h: number } | null} */ (null), floPose, reducedMotion, enabled: startEnabled = false, onPerch = () => {} }) {
|
|
31
63
|
const now = () => performance.now() / 1000;
|
|
32
64
|
const flo = createFlo3D(THREE, {
|
|
33
65
|
floPose, up: new THREE.Vector3(0, 0, 1), reducedMotion,
|
|
@@ -35,6 +67,9 @@ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox,
|
|
|
35
67
|
let enabled = !!startEnabled;
|
|
36
68
|
let perched = null; // the member whose card is showing (onPerch), or null
|
|
37
69
|
let placed = false, standingOn = null, modelR = 300, sizeK = 1; // sizeK: the person's Flo size (Labels menu), 1 = as designed
|
|
70
|
+
let modelDiag = 0; // the model's diagonal (mm): Flo's zoom reading (floScreenRadiusPx)
|
|
71
|
+
const spines = new Map(); // member id -> its spine (mm), read once per model
|
|
72
|
+
const pa = new THREE.Vector3(), pb = new THREE.Vector3();
|
|
38
73
|
let shellMood = 'idle';
|
|
39
74
|
let tour = null; // { ids, i, waitUntil }
|
|
40
75
|
let successUntil = 0;
|
|
@@ -95,6 +130,8 @@ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox,
|
|
|
95
130
|
const box = getSceneBox();
|
|
96
131
|
if (!box || box.isEmpty()) return;
|
|
97
132
|
const diag = box.getSize(new THREE.Vector3()).length();
|
|
133
|
+
modelDiag = diag;
|
|
134
|
+
spines.clear(); // a rebuilt model: read the members again
|
|
98
135
|
modelR = Math.min(MODEL_R_MAX, Math.max(MODEL_R_MIN, diag * MODEL_R_OF_DIAG));
|
|
99
136
|
}
|
|
100
137
|
|
|
@@ -238,8 +275,96 @@ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox,
|
|
|
238
275
|
if (k <= 0) { leaving = null; flo.object.visible = false; return; }
|
|
239
276
|
k = k * k;
|
|
240
277
|
}
|
|
241
|
-
|
|
278
|
+
// Flo moves first (a hop), then takes its size where it now is, so what is drawn this frame is the size worked out
|
|
279
|
+
// for this frame's position, not the last one's.
|
|
242
280
|
flo.tick(t, camera);
|
|
281
|
+
flo.setSize(worldRadius(camera) * k);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// A member's spine in the model (mm): the line it runs along, end to end, and how far its section reaches from that
|
|
285
|
+
// line, read from its own vertices once per model (a beam that runs diagonally in plan is a diagonal line, not the
|
|
286
|
+
// box around it). The direction is the vertices' main axis (power iteration on their spread). Null when not drawn.
|
|
287
|
+
function spineOf(id) {
|
|
288
|
+
if (!id) return null;
|
|
289
|
+
if (spines.has(id)) return spines.get(id);
|
|
290
|
+
const pts = [], v = new THREE.Vector3();
|
|
291
|
+
meshById.get(id)?.traverse?.((o) => {
|
|
292
|
+
const pos = o.isMesh && o.geometry?.attributes?.position;
|
|
293
|
+
if (!pos) return;
|
|
294
|
+
o.updateMatrixWorld(true);
|
|
295
|
+
const stride = Math.max(1, Math.floor(pos.count / 2000)); // a few thousand points say where a member runs
|
|
296
|
+
for (let i = 0; i < pos.count; i += stride) pts.push(v.fromBufferAttribute(pos, i).applyMatrix4(o.matrixWorld).clone());
|
|
297
|
+
});
|
|
298
|
+
let spine = null;
|
|
299
|
+
if (pts.length >= 2) {
|
|
300
|
+
const c = new THREE.Vector3();
|
|
301
|
+
for (const q of pts) c.add(q);
|
|
302
|
+
c.divideScalar(pts.length);
|
|
303
|
+
let xx = 0, xy = 0, xz = 0, yy = 0, yz = 0, zz = 0;
|
|
304
|
+
for (const q of pts) { const x = q.x - c.x, y = q.y - c.y, z = q.z - c.z; xx += x * x; xy += x * y; xz += x * z; yy += y * y; yz += y * z; zz += z * z; }
|
|
305
|
+
const box = new THREE.Box3().setFromPoints(pts), size = box.getSize(new THREE.Vector3());
|
|
306
|
+
const dir = size.x >= size.y && size.x >= size.z ? new THREE.Vector3(1, 0, 0) : size.y >= size.z ? new THREE.Vector3(0, 1, 0) : new THREE.Vector3(0, 0, 1);
|
|
307
|
+
for (let k = 0; k < 24; k++) {
|
|
308
|
+
const n = new THREE.Vector3(xx * dir.x + xy * dir.y + xz * dir.z, xy * dir.x + yy * dir.y + yz * dir.z, xz * dir.x + yz * dir.y + zz * dir.z);
|
|
309
|
+
if (!(n.lengthSq() > 0)) break;
|
|
310
|
+
dir.copy(n.normalize());
|
|
311
|
+
}
|
|
312
|
+
let t0 = Infinity, t1 = -Infinity, rad = 0;
|
|
313
|
+
for (const q of pts) {
|
|
314
|
+
const d = v.subVectors(q, c), t = d.dot(dir);
|
|
315
|
+
t0 = Math.min(t0, t); t1 = Math.max(t1, t);
|
|
316
|
+
rad = Math.max(rad, Math.sqrt(Math.max(0, d.lengthSq() - t * t)));
|
|
317
|
+
}
|
|
318
|
+
spine = { a: c.clone().addScaledVector(dir, t0), b: c.clone().addScaledVector(dir, t1), rad };
|
|
319
|
+
}
|
|
320
|
+
spines.set(id, spine);
|
|
321
|
+
return spine;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// How long a member is drawn, in px: its spine as projected plus its section either side (at Flo's scale), so a beam
|
|
325
|
+
// seen end-on, a diagonal one seen along its run, or a column seen from above counts as short. A spine running
|
|
326
|
+
// behind a perspective camera is cut at the near plane, never dropped, so passing the camera changes nothing in one
|
|
327
|
+
// step; nothing is cut at the far plane (an orthographic view's depth range has no bearing on how long it looks).
|
|
328
|
+
// 0 only when the whole member is behind the camera, or not drawn.
|
|
329
|
+
function memberPx(id, camera, w, h, scale) {
|
|
330
|
+
const sp = spineOf(id);
|
|
331
|
+
if (!sp) return 0;
|
|
332
|
+
pa.copy(sp.a).applyMatrix4(camera.matrixWorldInverse);
|
|
333
|
+
pb.copy(sp.b).applyMatrix4(camera.matrixWorldInverse);
|
|
334
|
+
if (!camera.isOrthographicCamera) {
|
|
335
|
+
const zn = -Math.max(1e-6, camera.near);
|
|
336
|
+
if (pa.z > zn && pb.z > zn) return 0;
|
|
337
|
+
if (pa.z > zn) pa.lerp(pb, (pa.z - zn) / (pa.z - pb.z));
|
|
338
|
+
else if (pb.z > zn) pb.lerp(pa, (pb.z - zn) / (pb.z - pa.z));
|
|
339
|
+
}
|
|
340
|
+
pa.applyMatrix4(camera.projectionMatrix); pb.applyMatrix4(camera.projectionMatrix);
|
|
341
|
+
const len = Math.hypot((pb.x - pa.x) * w / 2, (pb.y - pa.y) * h / 2);
|
|
342
|
+
return Number.isFinite(len) ? len + 2 * sp.rad * scale : 0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Screen pixels per mm at Flo, from the camera's own projection: in an orthographic view the same everywhere (depth
|
|
346
|
+
// plays no part, so a near or far plane passing Flo changes nothing); in perspective set by Flo's depth in front of
|
|
347
|
+
// the camera, which is also the scale off to the side of the view (the view's own px-per-mm helper reads the
|
|
348
|
+
// distance, not the depth, and so overstates Flo there). Null only with Flo behind a perspective camera, where it
|
|
349
|
+
// is not drawn.
|
|
350
|
+
function pxPerMm(camera, h) {
|
|
351
|
+
const m = camera.projectionMatrix.elements[5] * h / 2; // px per unit of view height, at unit depth or overall
|
|
352
|
+
if (camera.isOrthographicCamera) return m > 0 ? m : null;
|
|
353
|
+
const depth = -pa.copy(flo.object.position).applyMatrix4(camera.matrixWorldInverse).z;
|
|
354
|
+
const px = depth > 0 ? m / depth : NaN;
|
|
355
|
+
return Number.isFinite(px) && px > 0 ? px : null;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Flo's radius in the model (mm) for this frame: floScreenRadiusPx turned back into model units at Flo, measured
|
|
359
|
+
// live from this camera, so the zoom never lags and every limit holds every frame. Hopping to a member that is
|
|
360
|
+
// much shorter or longer on screen, Flo takes the new member's size as it takes off: a step, owned on purpose
|
|
361
|
+
// (route B, #3380), because a blend over the hop kept breaking the limits it was meant to respect.
|
|
362
|
+
function worldRadius(camera) {
|
|
363
|
+
const v = getViewSize(), w = v?.w, h = v?.h;
|
|
364
|
+
camera.updateMatrixWorld();
|
|
365
|
+
const scale = w > 0 && h > 0 ? pxPerMm(camera, h) : null;
|
|
366
|
+
if (!scale) return modelR * sizeK; // no view yet, or Flo is behind the camera and not drawn
|
|
367
|
+
return floScreenRadiusPx({ sizeK, modelPx: modelDiag * scale, viewH: h, memberPx: memberPx(standingOn, camera, w, h, scale) }) / scale;
|
|
243
368
|
}
|
|
244
369
|
|
|
245
370
|
// Is the pointer on Flo? (The page shows its Minimize chip while it is.)
|
|
@@ -249,12 +374,33 @@ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox,
|
|
|
249
374
|
return flo.hit(ray);
|
|
250
375
|
}
|
|
251
376
|
|
|
252
|
-
// Where the top of Flo's hat is on screen, in the canvas's own pixels
|
|
377
|
+
// Where the top of Flo's hat is on screen, in the canvas's own pixels, and how far Flo reaches either side of that
|
|
378
|
+
// point there (`half`), so a card beside Flo stands clear of it rather than over its brim (null when Flo is not drawn).
|
|
253
379
|
function hatScreen(camera, width, height) {
|
|
254
380
|
if (!enabled || !placed || !flo.object.visible) return null;
|
|
255
|
-
const
|
|
381
|
+
const top = flo.object.position.clone().add(new THREE.Vector3(0, 0, flo.r * 3.1));
|
|
382
|
+
const p = top.clone().project(camera);
|
|
256
383
|
if (p.z > 1) return null;
|
|
257
|
-
|
|
384
|
+
const edge = top.add(new THREE.Vector3().setFromMatrixColumn(camera.matrixWorld, 0).multiplyScalar(flo.r * HALF_WIDTH_R)).project(camera);
|
|
385
|
+
return { x: (p.x + 1) / 2 * width, y: (1 - p.y) / 2 * height, half: Math.abs(edge.x - p.x) / 2 * width };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Where Flo's body is drawn on screen, in the canvas's own pixels: the box around every projected vertex, so the outline
|
|
389
|
+
// Flo actually has (null when Flo is not drawn). For the test probe, which measures the card against it; too slow for a frame.
|
|
390
|
+
function screenBox(camera, width, height) {
|
|
391
|
+
if (!enabled || !placed || !flo.object.visible) return null;
|
|
392
|
+
flo.object.updateMatrixWorld(true);
|
|
393
|
+
const v = new THREE.Vector3(), box = { left: Infinity, right: -Infinity, top: Infinity, bottom: -Infinity };
|
|
394
|
+
flo.body.traverse((o) => {
|
|
395
|
+
const pos = o.isMesh && o.visible && o.geometry.attributes.position;
|
|
396
|
+
if (!pos) return;
|
|
397
|
+
for (let i = 0; i < pos.count; i++) {
|
|
398
|
+
v.fromBufferAttribute(pos, i).applyMatrix4(o.matrixWorld).project(camera);
|
|
399
|
+
const x = (v.x + 1) / 2 * width, y = (1 - v.y) / 2 * height;
|
|
400
|
+
box.left = Math.min(box.left, x); box.right = Math.max(box.right, x); box.top = Math.min(box.top, y); box.bottom = Math.max(box.bottom, y);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
return box.left <= box.right ? box : null;
|
|
258
404
|
}
|
|
259
405
|
|
|
260
406
|
// A press on Flo: true when it was Flo (the caller then leaves the selection alone). Any press in the view stops
|
|
@@ -300,7 +446,7 @@ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox,
|
|
|
300
446
|
}
|
|
301
447
|
|
|
302
448
|
return {
|
|
303
|
-
tick, modelChanged, selectionChanged, pointerDown, hover, hatScreen, remember, setEnabled, setShellMood, probe,
|
|
449
|
+
tick, modelChanged, selectionChanged, pointerDown, hover, hatScreen, screenBox, remember, setEnabled, setShellMood, probe,
|
|
304
450
|
setScale(k) { sizeK = Number.isFinite(k) && k > 0 ? k : 1; },
|
|
305
451
|
setReducedMotion: (on) => { reduced = !!on; flo.setReducedMotion(on); },
|
|
306
452
|
get enabled() { return enabled; },
|
|
@@ -703,7 +703,8 @@ function init(canvas, theApi, options = {}) {
|
|
|
703
703
|
// member, never in the Fit box and never a snap candidate. Needs flo.js (floPose), which the editor loads first.
|
|
704
704
|
if (typeof window.floPose === 'function') {
|
|
705
705
|
const reduce = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : null;
|
|
706
|
-
floView = createSteelFlo({ THREE, scene, meshById, getCamera: () => camera, getSceneBox: () => sceneBox,
|
|
706
|
+
floView = createSteelFlo({ THREE, scene, meshById, getCamera: () => camera, getSceneBox: () => sceneBox,
|
|
707
|
+
getViewSize: () => canvasEl && { w: canvasEl.clientWidth, h: canvasEl.clientHeight },
|
|
707
708
|
floPose: window.floPose, reducedMotion: !!reduce?.matches, enabled: floStartsShown(), onPerch: showFloCard });
|
|
708
709
|
floReduceOff?.();
|
|
709
710
|
const onReduce = () => floView?.setReducedMotion(reduce.matches);
|
|
@@ -1093,7 +1094,18 @@ function placePlate(mesh, el) {
|
|
|
1093
1094
|
const w = Math.max(el.width || 10, 1), d = Math.max(el.depth || 10, 1), t = Math.max(el.thickness || 5, 0.5);
|
|
1094
1095
|
const hw = w / 2, hd = d / 2;
|
|
1095
1096
|
const shape = new THREE.Shape();
|
|
1096
|
-
|
|
1097
|
+
// A custom connection's plate (#2303) is the polygon its definition drew — a tapered gusset, an L-shaped clip —
|
|
1098
|
+
// in plate-local (u, v) about `center`, the same outline the export sends. Every built-in plate has none and is
|
|
1099
|
+
// the centred width × depth rectangle. A degenerate outline (under 3 points, zero area, not finite) falls back to
|
|
1100
|
+
// the rectangle rather than drawing nothing.
|
|
1101
|
+
const outline = plateOutline(el.outline);
|
|
1102
|
+
if (outline) {
|
|
1103
|
+
shape.moveTo(outline[0][0], outline[0][1]);
|
|
1104
|
+
for (let i = 1; i < outline.length; i++) shape.lineTo(outline[i][0], outline[i][1]);
|
|
1105
|
+
shape.closePath();
|
|
1106
|
+
} else {
|
|
1107
|
+
shape.moveTo(-hw, -hd); shape.lineTo(hw, -hd); shape.lineTo(hw, hd); shape.lineTo(-hw, hd); shape.closePath();
|
|
1108
|
+
}
|
|
1097
1109
|
for (const h of el.holes || []) { // bolts own the holes — punch one per fastener
|
|
1098
1110
|
const r = Math.max((h.d || 0) / 2, 0.1);
|
|
1099
1111
|
const hole = new THREE.Path(); hole.absarc(h.u || 0, h.v || 0, r, 0, Math.PI * 2, true);
|
|
@@ -1109,6 +1121,17 @@ function placePlate(mesh, el) {
|
|
|
1109
1121
|
mesh.position.set(...(el.center || [0, 0, 0]));
|
|
1110
1122
|
}
|
|
1111
1123
|
|
|
1124
|
+
// A plate's polygon outline as finite [u, v] pairs with a real area, or null to draw the rectangle.
|
|
1125
|
+
function plateOutline(raw) {
|
|
1126
|
+
if (!Array.isArray(raw) || raw.length < 3) return null;
|
|
1127
|
+
const pts = [];
|
|
1128
|
+
for (const p of raw) {
|
|
1129
|
+
if (!Array.isArray(p) || p.length < 2 || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) return null;
|
|
1130
|
+
pts.push([p[0], p[1]]);
|
|
1131
|
+
}
|
|
1132
|
+
return Math.abs(shoelaceArea(pts)) > 1e-6 ? pts : null;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1112
1135
|
// Signed area of a closed 2D polygon (shoelace) — used to reject a zero-area/collinear footprint.
|
|
1113
1136
|
function shoelaceArea(pts) {
|
|
1114
1137
|
let a = 0;
|
|
@@ -5030,6 +5053,10 @@ function onKey(e) {
|
|
|
5030
5053
|
// Don't touch the dim tool while a member gesture (drag / box-select) owns the shared marker/readout —
|
|
5031
5054
|
// toggling would clear them mid-gesture. The gesture finishes on pointerup; the key is a no-op until then.
|
|
5032
5055
|
const midGesture = pending || dragging || boxSel;
|
|
5056
|
+
// #3145: D and the X/Y/Z/F locks are toggles, so a held key's auto-repeat would flip them on and off and leave
|
|
5057
|
+
// the tool or lock in whatever state the last repeat landed on. Only the first press counts; repeats are consumed.
|
|
5058
|
+
if (e.repeat && !e.ctrlKey && !e.metaKey && !e.altKey && !midGesture
|
|
5059
|
+
&& (k === 'd' || (dimMode3d && (k === 'f' || k === 'x' || k === 'y' || k === 'z')))) { e.preventDefault(); return; }
|
|
5033
5060
|
if (k === 'd' && !e.ctrlKey && !e.metaKey && !e.altKey && !midGesture) { e.preventDefault(); toggleMeasureTool(); return; } // D routes through the shared CAD lifecycle
|
|
5034
5061
|
if (dimMode3d && !midGesture) {
|
|
5035
5062
|
if (k === 'escape') { e.preventDefault(); if (snapOnly3d) setSnapOnly3d(null); else if (measureSession) { measureSession.cancelStep(); dimPreviewLine.visible = false; readout.style.display = 'none'; clearSharedSnapGuides(); } else if (dimDraft3d) { dimDraft3d = null; dimPreviewLine.visible = false; readout.style.display = 'none'; } else disarmMeasureTool(); return; } // Esc steps back through the common restriction → point 2 → point 1 → tool lifecycle
|
|
@@ -5413,10 +5440,11 @@ function placeFloCard() {
|
|
|
5413
5440
|
if (!floCardWH) measureFloCard();
|
|
5414
5441
|
const { w, h } = floCardWH;
|
|
5415
5442
|
const hx = rect.left + at.x, hy = rect.top + at.y;
|
|
5443
|
+
const clear = (at.half || 0) + FLO_CARD_GAP; // from Flo's middle to past its brim, at whatever size Flo is drawn
|
|
5416
5444
|
const cube = { left: rect.right - 110, bottom: rect.top + 110 }; // the view cube
|
|
5417
|
-
let left = hx +
|
|
5445
|
+
let left = hx + clear, side = 'right';
|
|
5418
5446
|
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 -
|
|
5447
|
+
if (left + w > rect.right - FLO_CARD_EDGE || (left + w > cube.left && top < cube.bottom)) { left = hx - clear - w; side = 'left'; }
|
|
5420
5448
|
left = Math.max(rect.left + FLO_CARD_EDGE, left);
|
|
5421
5449
|
floCard.style.left = Math.round(left) + 'px';
|
|
5422
5450
|
floCard.style.top = Math.round(top) + 'px';
|
|
@@ -9650,7 +9678,7 @@ window.Steel3DView = {
|
|
|
9650
9678
|
// The person changed what Flo's card shows (3D Labels → Flo): read the card again.
|
|
9651
9679
|
refreshFloCard: () => { if (floPerchId) showFloCard(floPerchId); },
|
|
9652
9680
|
// 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 }; },
|
|
9681
|
+
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), b = floView.screenBox(camera, r.width, r.height); return { ...floView.probe(), hat: h && { x: r.left + h.x, y: r.top + h.y, half: h.half }, box: b && { left: r.left + b.left, right: r.left + b.right, top: r.top + b.top, bottom: r.top + b.bottom }, 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 }; },
|
|
9654
9682
|
// Reference models (#278) — an editor-only layer. `setReferences` takes the geometry the editor
|
|
9655
9683
|
// fetched from the reference route; nothing here ever passes through contractToScene, which is what
|
|
9656
9684
|
// keeps borrowed geometry out of every export by construction rather than by filtering.
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* Pure, and read from the LIVE model the editor holds, so a mark sits on the member on screen.
|
|
30
30
|
*/
|
|
31
31
|
import { planViewId } from './steel-plan-view-id.js';
|
|
32
|
+
import { bottomLeftOrigin, originRuleNote } from './origin-rule.js';
|
|
32
33
|
import { createMemberPresenceIndex, memberPresence } from './steel-model-v2-projection.js';
|
|
33
34
|
import { FT_IN, formatElevation, normalizeDisplayUnits, parseElevationMm } from './display-units.js';
|
|
34
35
|
|
|
@@ -227,7 +228,8 @@ export function aiDecisionMarksOf(model) {
|
|
|
227
228
|
break;
|
|
228
229
|
}
|
|
229
230
|
case 'setup': {
|
|
230
|
-
|
|
231
|
+
// #2909: the note says how the AI's origin stands against FloLess's bottom-left default (never a block).
|
|
232
|
+
if (subject.row === 'origin') { note.push({ decisionId: id, channel: 'setup-origin', reason: 'model', rule: originRuleNote(bottomLeftOrigin(model), entry.value) }); break; }
|
|
231
233
|
const plan = plansByView.get(subject.viewId);
|
|
232
234
|
if (!plan) { note.push({ decisionId: id, channel: 'setup', reason: 'gone' }); break; }
|
|
233
235
|
if (!views.has(subject.viewId)) views.set(subject.viewId, []);
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* steel-custom-connection — what Inspect says about a custom connection built from standard parts (#2303 slice A).
|
|
3
|
+
*
|
|
4
|
+
* Pure: the editor hands it the joint, its definition row, the parts and fit facts the scene built, and the person's
|
|
5
|
+
* label switches; it returns the words and states to show. No DOM, so the server tests drive it directly.
|
|
6
|
+
*
|
|
7
|
+
* The rules it holds (owner rulings 2026-11-09, spec §4):
|
|
8
|
+
* - an AI-assisted connection says so ("AI-assisted"), unless the person turned the label off — then it still says
|
|
9
|
+
* the AI built it here, with "label off", because the switch hides the label on exports and names only;
|
|
10
|
+
* - a clean fit reads "Meets detailing rules · not strength-checked", never as checked: the AI never marks its own
|
|
11
|
+
* work, and green stays a person's sign-off;
|
|
12
|
+
* - a fit not met names the check; a person's acceptance is shown only while it still describes the connection
|
|
13
|
+
* (its identity matches what was built), and a stale one says the connection changed since.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Plain words for each fit measurement. Must equal `FIT_FACT_LABELS` in server/connection-readiness.ts (a test pins it). */
|
|
17
|
+
export const FIT_LABELS = Object.freeze({
|
|
18
|
+
'bearing-contact': 'Bearing faces meet',
|
|
19
|
+
'head-bearing': 'Bolt head bears on a ply',
|
|
20
|
+
'nut-bearing': 'Nut bears on a ply',
|
|
21
|
+
'clamped-grip': 'Clamped grip',
|
|
22
|
+
'bolt-length': 'Bolt length',
|
|
23
|
+
'clash-clearance': 'Clearance to other steel',
|
|
24
|
+
'support-reach': 'Reach to the supporting member',
|
|
25
|
+
'edge-distance': 'Edge distance',
|
|
26
|
+
'weld-line': 'Weld on the joint line',
|
|
27
|
+
'weld-size': 'Weld size against the rule minimum',
|
|
28
|
+
'bolt-pitch': 'Bolt spacing against the rule minimum',
|
|
29
|
+
clash: 'Parts clear of each other and of the members',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const finite = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
33
|
+
|
|
34
|
+
/** `fitFactVerdict` (server/steel-fit-rule.ts), exactly: 'within' | 'outside' | 'unmeasured'. */
|
|
35
|
+
export function fitVerdict(fact) {
|
|
36
|
+
if (!fact || !finite(fact.actualMm) || !finite(fact.limitMm) || !finite(fact.toleranceMm)) return 'unmeasured';
|
|
37
|
+
const within = fact.relation === 'equal'
|
|
38
|
+
? Math.abs(fact.actualMm - fact.limitMm) <= fact.toleranceMm
|
|
39
|
+
: fact.relation === 'at-least'
|
|
40
|
+
? fact.actualMm + fact.toleranceMm >= fact.limitMm
|
|
41
|
+
: fact.actualMm - fact.toleranceMm <= fact.limitMm;
|
|
42
|
+
if (within && fact.estimated === true) return 'unmeasured';
|
|
43
|
+
return within ? 'within' : 'outside';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Is the visible label shown for this connection? Mirrors `aiLabelShown` (server/connection-display-store.ts). */
|
|
47
|
+
export function labelShown(display, jointId) {
|
|
48
|
+
if (!display) return true;
|
|
49
|
+
if (display.model === 'hidden') return false;
|
|
50
|
+
return !(display.joints && Object.prototype.hasOwnProperty.call(display.joints, jointId));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const FACE_WORDS = {
|
|
54
|
+
'web+': 'web', 'web-': 'web', 'flange-top-outer': 'top flange', 'flange-top-inner': 'top flange (inside face)',
|
|
55
|
+
'flange-bot-outer': 'bottom flange', 'flange-bot-inner': 'bottom flange (inside face)',
|
|
56
|
+
'leg-a-outer': 'leg', 'leg-a-inner': 'leg (inside face)', 'leg-b-outer': 'other leg', 'leg-b-inner': 'other leg (inside face)', end: 'end',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The connection's features in plain English, with lengths in the project's units (`fmt(mm)`), read from what was
|
|
61
|
+
* built (`parts`, the scene elements of this joint) where it built and from the definition otherwise.
|
|
62
|
+
*/
|
|
63
|
+
export function describeFeatures(definition, parts, jointId, fmt) {
|
|
64
|
+
const features = Array.isArray(definition && definition.features) ? definition.features : [];
|
|
65
|
+
const list = Array.isArray(parts) ? parts : [];
|
|
66
|
+
const len = (mm) => (typeof fmt === 'function' ? fmt(mm) : `${Math.round(mm * 10) / 10} mm`);
|
|
67
|
+
const names = new Map(features.filter((f) => f && f.type === 'plate').map((f) => [f.id, f.name || 'plate']));
|
|
68
|
+
const ply = (p) => (p && p.role ? `the ${p.role}'s ${FACE_WORDS[p.face] || p.face}` : (names.get(p && p.feature) || (p && p.feature) || 'a part'));
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const f of features) {
|
|
71
|
+
if (!f) continue;
|
|
72
|
+
if (f.type === 'plate') {
|
|
73
|
+
const part = list.find((p) => p.id === `${jointId}:${f.id}`);
|
|
74
|
+
const welds = features.filter((w) => w && w.type === 'weld' && Array.isArray(w.between) && w.between.some((b) => b && b.feature === f.id))
|
|
75
|
+
.map((w) => w.between.find((b) => !(b && b.feature === f.id))).filter(Boolean);
|
|
76
|
+
const sides = part && Array.isArray(part.outline) ? `, ${part.outline.length}-sided outline` : '';
|
|
77
|
+
out.push(`${part ? `${len(part.thickness)} ` : ''}${f.name || 'plate'}${sides}${welds.length ? `, welded to ${welds.map(ply).join(' and ')}` : ''}`);
|
|
78
|
+
} else if (f.type === 'bolt-group') {
|
|
79
|
+
const shanks = list.filter((p) => p.kind === 'rod' && typeof p.id === 'string' && p.id.startsWith(`${jointId}:${f.id}:bolt`));
|
|
80
|
+
const dia = shanks[0] && finite(shanks[0].d) ? `${len(shanks[0].d)} ` : '';
|
|
81
|
+
out.push(`${shanks.length ? `${shanks.length} × ` : ''}${dia}${f.grade || ''} bolts (${f.boltType === 'shop' ? 'shop' : 'site'}) through ${(f.plies || []).map(ply).join(' and ')}`);
|
|
82
|
+
} else if (f.type === 'weld') {
|
|
83
|
+
const bead = list.find((p) => p.kind === 'weld' && typeof p.id === 'string' && (p.id === `${jointId}:${f.id}` || p.id.startsWith(`${jointId}:${f.id}:`)));
|
|
84
|
+
out.push(`Fillet weld${bead && finite(bead.leg) ? ` ${len(bead.leg)}` : ''} between ${(f.between || []).map(ply).join(' and ')}${f.sides === 'both' ? ', both sides' : ''}`);
|
|
85
|
+
} else if (f.type === 'cut') {
|
|
86
|
+
out.push(`The ${f.member} is cut (${f.tool && f.tool.kind === 'box' ? 'a cope' : 'a round hole'})`);
|
|
87
|
+
} else if (f.type === 'trim') {
|
|
88
|
+
out.push(`The ${f.member} is cut back clear of the connection`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Everything Inspect shows for one custom connection.
|
|
96
|
+
*
|
|
97
|
+
* @param {object} o
|
|
98
|
+
* @param {object} o.joint the `custom-parts` joint from the model
|
|
99
|
+
* @param {object|null} o.entry its `connection_definitions[]` row, or null when the model no longer has it
|
|
100
|
+
* @param {object|null} o.evidence the scene's fit evidence for this joint ({ facts, unresolved, identity }), or null
|
|
101
|
+
* @param {object[]} o.parts the scene elements of this joint
|
|
102
|
+
* @param {object|null} o.display the label switches ({ model, joints }), null = all shown
|
|
103
|
+
* @param {(mm:number)=>string} o.fmt project-unit length formatter
|
|
104
|
+
*/
|
|
105
|
+
export function customConnectionView({ joint, entry, evidence, parts, display, fmt }) {
|
|
106
|
+
const def = entry && entry.definition ? entry.definition : null;
|
|
107
|
+
const provenance = joint && joint.provenance ? joint.provenance : null;
|
|
108
|
+
const aiAssisted = !!provenance && provenance.assisted === 'ai';
|
|
109
|
+
const shown = labelShown(display, joint && joint.id);
|
|
110
|
+
const modelShown = !display || display.model !== 'hidden';
|
|
111
|
+
const facts = evidence && Array.isArray(evidence.facts) ? evidence.facts : [];
|
|
112
|
+
const rows = facts.map((f) => ({ id: f.id, label: FIT_LABELS[f.kind] || f.kind, verdict: fitVerdict(f), estimated: f.estimated === true, clause: f.clause || null }));
|
|
113
|
+
const unmeasured = evidence && Array.isArray(evidence.unresolved) ? evidence.unresolved : [];
|
|
114
|
+
// What the engine could not measure is listed with the checks that are not met: it is not a pass.
|
|
115
|
+
const notMet = [...rows.filter((r) => r.verdict !== 'within'),
|
|
116
|
+
...unmeasured.map((u) => ({ id: u, label: 'Not measured', verdict: 'unmeasured', estimated: false, clause: null, detail: u }))];
|
|
117
|
+
const passing = rows.filter((r) => r.verdict === 'within');
|
|
118
|
+
const accepted = Array.isArray(joint && joint.acceptedFailures) ? joint.acceptedFailures : [];
|
|
119
|
+
const identity = evidence && evidence.identity;
|
|
120
|
+
const current = accepted.filter((a) => a && a.identity === identity);
|
|
121
|
+
const keptAll = notMet.length > 0 && notMet.every((r) => current.some((a) => a.factId === r.id));
|
|
122
|
+
const stale = accepted.length > 0 && current.length < accepted.length;
|
|
123
|
+
|
|
124
|
+
let verdict;
|
|
125
|
+
if (!evidence) {
|
|
126
|
+
verdict = { tone: 'info', text: 'Fit not checked yet', tip: 'FloLess has not measured this connection in this view yet. It checks again when the model is rebuilt.' };
|
|
127
|
+
} else if (!notMet.length) {
|
|
128
|
+
verdict = { tone: 'neutral', text: 'Meets detailing rules · not strength-checked', tip: 'Every placement check FloLess measured is within its rule. That is not a strength check, and no one has signed it off.' };
|
|
129
|
+
} else if (keptAll) {
|
|
130
|
+
const when = current.map((a) => a.at).sort().pop();
|
|
131
|
+
verdict = { tone: 'neutral', text: 'Fit not met · kept by you', tip: `You chose to keep this connection built although these checks are not met: ${[...new Set(notMet.map((r) => r.label.toLowerCase()))].join('; ')}. The record and its exports say so.`,
|
|
132
|
+
hint: when ? `Kept built by you on ${String(when).slice(0, 10)}` : null };
|
|
133
|
+
} else if (stale) {
|
|
134
|
+
verdict = { tone: 'warn', text: 'Changed since you accepted it · fit not met', tip: 'The connection or its members changed after you kept it built, so your acceptance no longer describes it. Ask in AI Chat to check it again.' };
|
|
135
|
+
} else if (notMet.every((r) => r.label === 'Not measured')) {
|
|
136
|
+
verdict = { tone: 'warn', text: 'Some rule checks could not be measured', tip: 'FloLess could not measure every placement check on this connection, so it does not say it meets the rules. Ask in AI Chat what is missing.' };
|
|
137
|
+
} else {
|
|
138
|
+
verdict = { tone: 'warn', text: `Fit not met: ${[...new Set(notMet.filter((r) => r.label !== 'Not measured').map((r) => r.label))].join(', ')}`, tip: 'At least one placement check is outside its rule or could not be proved. Ask in AI Chat to rebuild it, or to keep it built anyway.' };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const assumptions = (def && def.provenance && Array.isArray(def.provenance.assumptions) ? def.provenance.assumptions : [])
|
|
142
|
+
.filter((a) => a && typeof a.param === 'string')
|
|
143
|
+
.map((a) => ({ param: a.param, value: finite(a.value) ? (typeof fmt === 'function' ? fmt(a.value) : `${a.value} mm`) : String(a.value), clause: a.clause || null,
|
|
144
|
+
basis: a.basis === 'rule-minimum' ? 'rule minimum' : a.basis === 'drawing' ? 'from the drawing' : 'set by a person' }));
|
|
145
|
+
const evidenceRef = def && def.provenance && def.provenance.evidence ? def.provenance.evidence.detailRef || def.provenance.evidence.sheetId || null : null;
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
name: def ? def.name : 'Custom connection',
|
|
149
|
+
definitionMissing: !def,
|
|
150
|
+
aiAssisted, labelShown: shown, modelShown,
|
|
151
|
+
chip: aiAssisted
|
|
152
|
+
? (shown
|
|
153
|
+
? { text: 'AI-assisted', tip: 'The AI composed this connection from standard parts (plates, bolts, welds) because no standard connection type models the drawn detail.' }
|
|
154
|
+
: { text: 'AI-assisted · label off', tip: 'The AI composed this connection. You turned its label off, so exports and part names do not show it; FloLess’s record still keeps that the AI built it.' })
|
|
155
|
+
: null,
|
|
156
|
+
source: evidenceRef,
|
|
157
|
+
verdict, notMet, passing, unmeasured,
|
|
158
|
+
features: def ? describeFeatures(def, parts, joint.id, fmt) : [],
|
|
159
|
+
assumptions,
|
|
160
|
+
};
|
|
161
|
+
}
|