@floless/app 0.137.3 → 0.138.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 +47890 -27033
- package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
- package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
- package/dist/schemas/steel.model.v2.schema.json +218 -27
- package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
- package/dist/skills/floless-app-rfi/SKILL.md +410 -0
- package/dist/skills/floless-app-routines/SKILL.md +7 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
- package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
- package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
- package/dist/templates/floless-workspace-knowledge.flo +20 -4
- package/dist/templates/steel-model.flo +27 -15
- package/dist/web/app.css +559 -131
- package/dist/web/app.js +216 -54
- package/dist/web/aware.js +982 -128
- package/dist/web/checkpoint-standard.js +218 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +237 -5
- package/dist/web/commands-steel.js +172 -47
- package/dist/web/connection-review-client.js +2 -2
- package/dist/web/display-units.js +243 -0
- package/dist/web/grid-core.js +474 -58
- package/dist/web/grid-display.js +344 -0
- package/dist/web/index.html +106 -66
- package/dist/web/instructor-reporter.js +5 -0
- package/dist/web/instructor.js +175 -33
- package/dist/web/json-schema-subset.js +145 -25
- package/dist/web/steel-3d-core.js +237 -151
- package/dist/web/steel-3d-view.js +366 -113
- package/dist/web/steel-catalog-picker.js +98 -15
- package/dist/web/steel-detail-refs.js +1 -1
- package/dist/web/steel-editor.html +6479 -921
- package/dist/web/steel-filter.html +404 -57
- package/dist/web/steel-model-adapter.js +1 -1
- package/dist/web/steel-model-commands.js +72 -66
- package/dist/web/steel-model-v2-client-validation.js +10 -3
- package/dist/web/steel-model-v2-commands.js +269 -77
- package/dist/web/steel-model-v2-projection.js +18 -17
- package/dist/web/steel-plan-transform.js +52 -9
- package/dist/web/steel-plan-view-id.js +1 -7
- package/dist/web/steel-read-confidence.js +454 -5
- package/dist/web/steel-units.js +39 -0
- package/dist/web/steel-view-generation.js +21 -7
- package/dist/web/workspaces.js +2178 -497
- package/package.json +5 -1
|
@@ -5,15 +5,29 @@
|
|
|
5
5
|
* lift into AWARE viewer-3d, while the native model geometry remains Steel-specific.
|
|
6
6
|
*
|
|
7
7
|
* Coordinate map MUST match server/contract-to-scene.ts (the bake) so editing-space == render-space:
|
|
8
|
-
* scene is mm, Z-up. mmX = dispX·k, mmY = -dispY·k (k
|
|
9
|
-
* mmZ =
|
|
10
|
-
*
|
|
8
|
+
* scene is mm, Z-up. mmX = dispX·k, mmY = -dispY·k (k IS the view's `mm_per_px`, Y flipped),
|
|
9
|
+
* mmZ = the MEMBER's own T.O.S/B.O.S, ALREADY in millimetres, and NOT the plan's `elevation_mm` cut
|
|
10
|
+
* plane. It used to be inches times IN_TO_MM, back when the editor ran an inches-canonical sub-world;
|
|
11
|
+
* there is no conversion on this axis any more. planPointToWp is the inverse (editing-only; the bake
|
|
12
|
+
* never needs it).
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import { sheetScaleMm } from './grid-core.js';
|
|
16
|
+
|
|
17
|
+
// Defined once in the leaf `steel-units` module and re-exported here, because this file is the seam a
|
|
18
|
+
// dozen consumers already import them from and `grid-core` (which this file imports) needs them too.
|
|
19
|
+
// IMPORTED and then exported, NOT `export … from`: a pure re-export publishes the names without
|
|
20
|
+
// creating local bindings, and this module USES them (FT_TO_MM in the level helpers, IN_TO_MM in
|
|
21
|
+
// POSITION_OFFSET_SNAP_MM). The first cut wrote the re-export form and every consumer still resolved
|
|
22
|
+
// them perfectly — while memberGeometry threw `IN_TO_MM is not defined` at run time. The full suite
|
|
23
|
+
// found it; nothing smaller did.
|
|
24
|
+
//
|
|
25
|
+
// `memberGeometry` was IN_TO_MM's other local caller until the editor went metric and its elevations
|
|
26
|
+
// stopped needing conversion. The remaining one below is a real quarter-INCH drag quantum, not a unit
|
|
27
|
+
// conversion in disguise — which is why it spells the constant rather than the number, and why this
|
|
28
|
+
// file leaves the geometry guard's literal ratchet at zero.
|
|
29
|
+
import { FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M } from './steel-units.js';
|
|
30
|
+
export { FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M };
|
|
17
31
|
|
|
18
32
|
/** Atomic capability marker: storage, readers, authoring and shipped guidance advance together. */
|
|
19
33
|
export const POSITION_BASIS_CAPABILITY_VERSION = 1;
|
|
@@ -157,19 +171,24 @@ export function reexpressMemberPlacement(member, refFrom, refTo, target, extents
|
|
|
157
171
|
* `allowJs` without `checkJs`, so a typo'd entry (`['MC', 'c']`) or a malformed one still compiles —
|
|
158
172
|
* verified. `section-kind.test.ts` validates the table's shape for that reason.
|
|
159
173
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
174
|
+
* There is no 'T' kind: a tee's real outline is its catalogue-supplied `displaySection` (the `tee`
|
|
175
|
+
* branch of `sectionTopology`), never this fallback classifier. So US `WT`/`ST`/`MT` carry no entry and
|
|
176
|
+
* ride their parent letter to 'I'; the UK tees `UKT`/`TEE` have no I-parent-letter to ride, so they need
|
|
177
|
+
* an explicit entry — mapped to 'I' for the SAME reason, the nearest drawable fallback for a tee with no
|
|
178
|
+
* displaySection. This is the fallback kind only; a resolved tee always draws from its displaySection.
|
|
179
|
+
* EHS carries no entry either: an ellipse has no member of the SectionKind union, so it stays BOX here
|
|
180
|
+
* and is refused as geometry upstream (`displaySectionForRow` → unsupported-custom), never drawn.
|
|
165
181
|
*
|
|
166
182
|
* @type {ReadonlyArray<readonly [string, SectionKind]>}
|
|
167
183
|
*/
|
|
168
184
|
export const SECTION_FAMILIES = [
|
|
169
185
|
['W', 'I'], ['M', 'I'], ['S', 'I'], ['HP', 'I'], // US I-family
|
|
170
186
|
['UC', 'I'], ['UB', 'I'], ['UKC', 'I'], ['UKB', 'I'], ['IPE', 'I'], ['HE', 'I'], // UK/EU I-family
|
|
171
|
-
['
|
|
172
|
-
['
|
|
187
|
+
['UKBP', 'I'], // UK bearing pile (also rides UKB)
|
|
188
|
+
['RSJ', 'I'], ['JUMBO', 'I'], // UK: Rolled Steel JOIST is an I; JUMBO heavy column
|
|
189
|
+
['UKT', 'I'], ['TEE', 'I'], // UK tees ride to I like US WT/ST/MT — real tee outline is the displaySection's
|
|
190
|
+
['C', 'C'], ['MC', 'C'], ['PFC', 'C'], ['UKPFC', 'C'], ['RSC', 'C'], // channels (UKPFC does NOT start with PFC)
|
|
191
|
+
['L', 'L'], ['UKA', 'L'], ['RSA', 'L'], // angles (UK equal/unequal + legacy RSA)
|
|
173
192
|
['HSS', 'TUBE'], ['PIPE', 'TUBE'], ['TS', 'TUBE'], ['TUBE', 'TUBE'], ['HSQ', 'TUBE'],
|
|
174
193
|
['SHS', 'TUBE'], ['RHS', 'TUBE'], ['CHS', 'TUBE'], // hollow sections
|
|
175
194
|
];
|
|
@@ -250,12 +269,118 @@ export function clipSegmentToPlanes(a, b, planes = []) {
|
|
|
250
269
|
return [mix(lo), mix(hi)];
|
|
251
270
|
}
|
|
252
271
|
|
|
253
|
-
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
272
|
+
/**
|
|
273
|
+
* THE clamped projection of a point onto a segment — the single implementation, for every caller.
|
|
274
|
+
*
|
|
275
|
+
* Seven hand-kept copies of this used to exist across the editor, the 3D view and the server (#951),
|
|
276
|
+
* in two dimensionalities, with three return shapes and four different rules for what counts as a
|
|
277
|
+
* degenerate segment. Nothing kept them in agreement, and this repo's own history is the list of what
|
|
278
|
+
* that costs (#647, #770). There is one now.
|
|
279
|
+
*
|
|
280
|
+
* `p`, `a` and `b` are plain number arrays in ONE coordinate space — the CALLER's. This math is
|
|
281
|
+
* space-agnostic: world millimetres, screen pixels and sheet display points all project the same way.
|
|
282
|
+
* Returns `{ distance, t, closest }`: `t` is the parameter along a→b clamped into [0,1], `closest` the
|
|
283
|
+
* point that parameter names, `distance` the straight-line distance from `p` to it.
|
|
284
|
+
*
|
|
285
|
+
* `rule` is the caller's OWN degeneracy rule, built with `SEG_DEGENERACY` below. It is a required
|
|
286
|
+
* argument, deliberately: the right rule IS caller-specific — 1e-9 mm² is a meaningless threshold in
|
|
287
|
+
* screen pixels — so quietly picking one for all seven would be a silent geometry change, which is
|
|
288
|
+
* exactly the failure class this unification exists to end. Converging them is separate work, per call
|
|
289
|
+
* site, each with its own evidence.
|
|
290
|
+
*
|
|
291
|
+
* The rule is a RULE, not just a number, because the seven originals did not merely use different
|
|
292
|
+
* thresholds — they used different COMPARISONS, and the difference is observable. Two reviewers found
|
|
293
|
+
* this independently after the first cut collapsed all four into `len2 > tol`:
|
|
294
|
+
* · `spDistToSeg`'s `L2 < 1e-9` and `distPointSeg`'s `len2 > 1e-9` disagree at exactly `len2 === 1e-9`,
|
|
295
|
+
* a constructible double: measured 0.9999683772233983 against 1.
|
|
296
|
+
* · `|| 1` substitutes a DENOMINATOR rather than short-circuiting, so a segment with one non-finite
|
|
297
|
+
* component answers all-NaN where `len2 > tol` answers `t = 0` and a partly finite point: measured
|
|
298
|
+
* `[NaN, NaN]` against `[0, NaN]`.
|
|
299
|
+
* Neither is reachable from sane geometry. Both are exactly the "dimensionally plausible, physically
|
|
300
|
+
* wrong, invisible in a screenshot" class #951 was written about, so both are modelled rather than
|
|
301
|
+
* argued away. `server/geometry-primitive-parity.test.ts` runs all seven originals verbatim against
|
|
302
|
+
* this one, including both of those cases.
|
|
303
|
+
*/
|
|
304
|
+
function projectOnSegment(p, a, b, rule, dims) {
|
|
305
|
+
// The CONSUMER validates, not only the factories. Review wrote the object literal by hand instead of
|
|
306
|
+
// calling `atMost()`, and a bare `{mode:'atMost'}` (no `len2`) then compared `len2 > undefined`,
|
|
307
|
+
// which is false for every segment — silently degenerate, always. `{mode:'below'}` is the mirror
|
|
308
|
+
// image: never degenerate. A wrong rule that answers confidently is the exact failure this redesign
|
|
309
|
+
// exists to end, so an unusable rule cannot reach the arithmetic.
|
|
310
|
+
if (!rule || !DEGENERACY_MODES.has(rule.mode)
|
|
311
|
+
|| (rule.mode !== 'unitDenominator' && !(typeof rule.len2 === 'number' && rule.len2 >= 0))) {
|
|
312
|
+
throw new TypeError('projectPointOnSegment: pass a rule built with SEG_DEGENERACY');
|
|
313
|
+
}
|
|
314
|
+
let len2 = 0, dot = 0;
|
|
315
|
+
for (let i = 0; i < dims; i++) { const d = b[i] - a[i]; len2 += d * d; dot += (p[i] - a[i]) * d; }
|
|
316
|
+
const clamp = (v) => Math.max(0, Math.min(1, v));
|
|
317
|
+
let t;
|
|
318
|
+
if (rule.mode === 'unitDenominator') t = clamp(dot / (len2 || 1));
|
|
319
|
+
else if (rule.mode === 'below') t = len2 < rule.len2 ? 0 : clamp(dot / len2);
|
|
320
|
+
else t = len2 > rule.len2 ? clamp(dot / len2) : 0;
|
|
321
|
+
const closest = dims === 2
|
|
322
|
+
? [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t]
|
|
323
|
+
: [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
|
|
324
|
+
const distance = dims === 2
|
|
325
|
+
? Math.hypot(p[0] - closest[0], p[1] - closest[1])
|
|
326
|
+
: Math.hypot(p[0] - closest[0], p[1] - closest[1], p[2] - closest[2]);
|
|
327
|
+
return { distance, t, closest };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const DEGENERACY_MODES = new Set(['atMost', 'below', 'unitDenominator']);
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The degeneracy rules the seven originals actually used — named, so a call site states its own and a
|
|
334
|
+
* reader can see at a glance which sites differ and where.
|
|
335
|
+
*
|
|
336
|
+
* There is deliberately NO default and no "recommended" one. Picking a favourite here is the converged
|
|
337
|
+
* tolerance #951 forbids; making the four visible side by side is what lets someone later converge them
|
|
338
|
+
* with evidence, per call site, which is the follow-up work the issue asks for.
|
|
339
|
+
*/
|
|
340
|
+
export const SEG_DEGENERACY = {
|
|
341
|
+
/**
|
|
342
|
+
* Project only when the squared length is GREATER than `len2`; otherwise t = 0. A non-finite squared
|
|
343
|
+
* length fails that test and so lands on t = 0. Three originals: `distPointSeg` (`> 1e-9` mm²),
|
|
344
|
+
* `distToSeg` (`> 0` screen px²) and `pointSegmentDistance2d` (`d2 ? … : 0`, which is `> 0` exactly,
|
|
345
|
+
* NaN included, because NaN is falsy).
|
|
346
|
+
*/
|
|
347
|
+
atMost: (len2) => {
|
|
348
|
+
if (!(typeof len2 === 'number' && len2 >= 0)) throw new TypeError('SEG_DEGENERACY.atMost: needs a non-negative number');
|
|
349
|
+
return Object.freeze({ mode: 'atMost', len2 });
|
|
350
|
+
},
|
|
351
|
+
/**
|
|
352
|
+
* t = 0 only when the squared length is STRICTLY BELOW `len2`; everything else projects, a non-finite
|
|
353
|
+
* squared length included (`NaN < tol` is false, so it divides and propagates). One original:
|
|
354
|
+
* `spDistToSeg`'s `if (L2 < 1e-9) return spDist(p, a)`, in display points².
|
|
355
|
+
*/
|
|
356
|
+
below: (len2) => {
|
|
357
|
+
if (!(typeof len2 === 'number' && len2 >= 0)) throw new TypeError('SEG_DEGENERACY.below: needs a non-negative number');
|
|
358
|
+
return Object.freeze({ mode: 'below', len2 });
|
|
359
|
+
},
|
|
360
|
+
/**
|
|
361
|
+
* Substitute a DENOMINATOR of 1 for a falsy squared length rather than short-circuiting — the `len2
|
|
362
|
+
* || 1` idiom. For an exactly zero-length segment this gives the same answer as `atMost(0)` (the
|
|
363
|
+
* numerator is zero too), and for a non-finite one it does not: the whole point comes back NaN
|
|
364
|
+
* instead of only the components that were. Three originals: `closestOnSeg`, `closestOnSeg3`, `projPt`.
|
|
365
|
+
*/
|
|
366
|
+
unitDenominator: Object.freeze({ mode: 'unitDenominator' }),
|
|
367
|
+
};
|
|
368
|
+
Object.freeze(SEG_DEGENERACY);
|
|
369
|
+
|
|
370
|
+
/** Clamped projection of a 2D point onto segment a-b. See `projectOnSegment` and `SEG_DEGENERACY`. */
|
|
371
|
+
export function projectPointOnSegment2d(p, a, b, rule) {
|
|
372
|
+
return projectOnSegment(p, a, b, rule, 2);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Clamped projection of a 3D point onto segment a-b. See `projectOnSegment` and `SEG_DEGENERACY`. */
|
|
376
|
+
export function projectPointOnSegment3d(p, a, b, rule) {
|
|
377
|
+
return projectOnSegment(p, a, b, rule, 3);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** The visible frontmost solid is the only member a direct 3D command may act on. */
|
|
381
|
+
export function selectedFrontmostHit(hits, selectedId) {
|
|
382
|
+
const hit = Array.isArray(hits) ? hits[0] : null;
|
|
383
|
+
return hit?.object?.userData?.id === selectedId ? hit : null;
|
|
259
384
|
}
|
|
260
385
|
|
|
261
386
|
/**
|
|
@@ -337,10 +462,10 @@ const nz = (n) => n + 0; // normalize -0 → 0 (negating 0 yields -0, which surp
|
|
|
337
462
|
* server/contract-to-scene each used to carry their own copy of `[x·k, -y·k]`, with a comment on each
|
|
338
463
|
* naming the others as mirrors to keep by hand.
|
|
339
464
|
*/
|
|
340
|
-
export function dispToMm(pt,
|
|
465
|
+
export function dispToMm(pt, mmPerPx) { const k = sheetScaleMm(mmPerPx); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
|
|
341
466
|
|
|
342
467
|
/** scene mm point [x,y,…] → display-space wp [px,py] (inverse of dispToMm). */
|
|
343
|
-
export function planPointToWp(p,
|
|
468
|
+
export function planPointToWp(p, mmPerPx) { const k = sheetScaleMm(mmPerPx); return [nz(p[0] / k), nz(-p[1] / k)]; }
|
|
344
469
|
|
|
345
470
|
/**
|
|
346
471
|
* The section outline itself: local points centred on the origin, x = width, y = depth, closed, plus an
|
|
@@ -385,7 +510,7 @@ export function sectionOutlinePts(kind, w, d, thk) {
|
|
|
385
510
|
// The `Math.min(…*0.5, …)` clamps are not decoration — the floors (6, 5) are FLAT minimums so an
|
|
386
511
|
// ESTIMATED section still reads at small zoom, and on a small section at a coarse scale the floor
|
|
387
512
|
// exceeds the section itself. Unclamped, the inner corner runs past the outline and the drawn footprint
|
|
388
|
-
// comes out BIGGER than the member: an L4X4X3/8 at
|
|
513
|
+
// comes out BIGGER than the member: an L4X4X3/8 at 12 pt/ft measured 5"x5" instead of 4"x4".
|
|
389
514
|
const tf = real('tf', hd) ?? Math.min(d * 0.5, Math.max(d * 0.10, 6));
|
|
390
515
|
const tw = real('tw', hw) ?? Math.min(w * 0.5, Math.max(w * 0.10, 5));
|
|
391
516
|
return { outer: [[-hw, -hd], [hw, -hd], [hw, -hd + tf], [tw / 2, -hd + tf], [tw / 2, hd - tf], [hw, hd - tf],
|
|
@@ -418,7 +543,7 @@ export function sectionOutlinePts(kind, w, d, thk) {
|
|
|
418
543
|
// `r` is returned ALONGSIDE the points and is not redundant: the polygon is INSCRIBED, so its widest
|
|
419
544
|
// point between two vertices is `r·cos(π/ROUND_SEGMENTS)`. Measuring the points would put a pipe's flush
|
|
420
545
|
// face a fraction inside its own steel, silently, at exactly the rolls where no vertex lines up with the
|
|
421
|
-
// axis being measured. `sectionExtents`
|
|
546
|
+
// axis being measured. `sectionExtents` reads `r`; anything that DRAWS reads the points.
|
|
422
547
|
//
|
|
423
548
|
// `kind` cannot be derived from the designation: `sectionKindOf` matches a literal prefix and answers
|
|
424
549
|
// TUBE for `HSS6X6X3/8` (rectangular) and `HSS6.625X0.280` (round) alike — only the numerics separate
|
|
@@ -517,8 +642,8 @@ export function sectionTopology(displaySection, w, d, fallbackKind = 'BOX') {
|
|
|
517
642
|
*
|
|
518
643
|
* `fitScale` is the THIRD thing `worldToSheetPx` does and the easiest to forget, because it is 1 on every
|
|
519
644
|
* well-registered sheet: it is the ratio between the distance the sheet's two controls actually span in
|
|
520
|
-
* world and the distance their pixels imply at the sheet's stated `
|
|
521
|
-
* its declared scale carries every work point at half the pixels — and an outline sized from `
|
|
645
|
+
* world and the distance their pixels imply at the sheet's stated `mm_per_px`. A sheet registered at twice
|
|
646
|
+
* its declared scale carries every work point at half the pixels — and an outline sized from `mm_per_px`
|
|
522
647
|
* alone, as this one is, then draws the section at twice the size of the member it belongs to. (Found by
|
|
523
648
|
* adversarial review; the first cut of this function dismissed it as a pre-existing sizing question, which
|
|
524
649
|
* it was — right up until this became the one place that claims to map world into sheet px.)
|
|
@@ -530,92 +655,25 @@ export function sectionOutlinePx(pts, rotDeg, sheetRotRad = 0, fitScale = 1) {
|
|
|
530
655
|
return pts.map(([x, y]) => [nz(x * cs - y * sn), nz(-(x * sn + y * cs))]);
|
|
531
656
|
}
|
|
532
657
|
|
|
533
|
-
/**
|
|
534
|
-
* The px→ft scale and default T.O.S of the plan that OWNS a member, resolved from the SAME per-plan
|
|
535
|
-
* list that feeds 3D snap candidates (`api.membersByPlan()`).
|
|
536
|
-
*
|
|
537
|
-
* Why it reads that list rather than taking the active plane's scale: 3D snap targets are built from
|
|
538
|
-
* every sheet in each sheet's own scale, while a drag/endpoint commit used to invert through the
|
|
539
|
-
* ACTIVE sheet's scale. Editing an off-active-sheet member whose sheet has a different `pt_per_ft` (or
|
|
540
|
-
* a different `default_tos`) therefore wrote a mis-scaled `wp`. Sharing one source makes the target and
|
|
541
|
-
* the commit incapable of disagreeing.
|
|
542
|
-
*
|
|
543
|
-
* `fallback` is used when the id is unknown (a not-yet-loaded contract, or a member outside the plan
|
|
544
|
-
* list) so a lookup miss can never throw out of a pointer handler.
|
|
545
|
-
*/
|
|
546
|
-
export function planScaleIndex(byPlan, fallback) {
|
|
547
|
-
const ix = new Map();
|
|
548
|
-
for (const pl of byPlan || []) {
|
|
549
|
-
if (!pl || !Array.isArray(pl.members)) continue;
|
|
550
|
-
const scale = {
|
|
551
|
-
ptPerFt: pl.ptPerFt > 0 ? pl.ptPerFt : 1,
|
|
552
|
-
defaultTosMm: pl.defaultTosMm != null ? pl.defaultTosMm : (fallback ? fallback.defaultTosMm : 0),
|
|
553
|
-
};
|
|
554
|
-
for (const m of pl.members) if (m && typeof m === 'object' && !ix.has(m)) ix.set(m, scale);
|
|
555
|
-
}
|
|
556
|
-
return ix;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* O(1) lookup into a `planScaleIndex`, keyed by the member OBJECT. Unknown member → `fallback`
|
|
561
|
-
* (may be undefined; callers guard).
|
|
562
|
-
*
|
|
563
|
-
* Keyed by object, never by `m.id`: member ids are only SHEET-unique by contract — that is the whole
|
|
564
|
-
* reason `contractWithExportScopedMemberIds` namespaces them for export and the editor keeps a separate
|
|
565
|
-
* `planeOfMember` that resolves by identity. Keying this index by bare id would resolve the second of
|
|
566
|
-
* two same-id members through the FIRST sheet's scale, which is the very class of bug this seam exists
|
|
567
|
-
* to remove.
|
|
568
|
-
*/
|
|
569
|
-
export function planScaleOf(index, member, fallback) {
|
|
570
|
-
const s = index && typeof index.get === 'function' ? index.get(member) : null;
|
|
571
|
-
return s || fallback;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* A member's centreline resolved through the plan that OWNS it.
|
|
576
|
-
*
|
|
577
|
-
* This composition is exported (rather than left inline in the view) so the OWNING-PLAN wiring is
|
|
578
|
-
* unit-testable: asserting `planScaleOf`'s return value alone would still pass if a call site
|
|
579
|
-
* regressed to the active sheet's scale, because the bug was never in the pure lookup — it was in
|
|
580
|
-
* which scale got handed to `memberGeometry`.
|
|
581
|
-
*/
|
|
582
|
-
export function memberGeometryInOwnPlan(m, index, fallback) {
|
|
583
|
-
const s = planScaleOf(index, m, fallback) || { ptPerFt: 1, defaultTosMm: 0 };
|
|
584
|
-
return memberGeometry(m, s.ptPerFt, s.defaultTosMm);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Alt-drag T.O.S levels across EVERY sheet, each sheet resolved in its OWN default elevation.
|
|
589
|
-
* Taking the active sheet's member list with some other sheet's default would report unset-T.O.S
|
|
590
|
-
* members at an elevation they are not drawn at.
|
|
591
|
-
*/
|
|
592
|
-
export function elevationLevelsByPlan(byPlan, fallback, excludeMember) {
|
|
593
|
-
const set = new Set();
|
|
594
|
-
for (const pl of byPlan || []) {
|
|
595
|
-
if (!pl || !Array.isArray(pl.members)) continue;
|
|
596
|
-
const dtos = pl.defaultTosMm != null ? pl.defaultTosMm : (fallback ? fallback.defaultTosMm : 0);
|
|
597
|
-
// Exclude by OBJECT, not by id: ids are only sheet-unique, so excluding by id would silently drop
|
|
598
|
-
// every same-id member on every other sheet from the level set.
|
|
599
|
-
const members = excludeMember ? pl.members.filter((m) => m !== excludeMember) : pl.members;
|
|
600
|
-
for (const z of elevationLevels(members, pl.ptPerFt, dtos, undefined)) set.add(z);
|
|
601
|
-
}
|
|
602
|
-
return [...set].sort((a, b) => a - b);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
658
|
/**
|
|
606
659
|
* member → its 3D centerline `{ kind, line:[[x,y,z],[x,y,z]] }` in mm, matching contractToScene's
|
|
607
660
|
* from/to. Beam: work-line at T.O.S. Column: vertical at the plan point, bos→tos.
|
|
608
661
|
*/
|
|
609
|
-
export function memberGeometry(m,
|
|
610
|
-
const a = dispToMm(m.wp[0],
|
|
662
|
+
export function memberGeometry(m, mmPerPx, defaultTosMm = 0) {
|
|
663
|
+
const a = dispToMm(m.wp[0], mmPerPx), b = dispToMm(m.wp[1], mmPerPx);
|
|
611
664
|
if (m.role === 'column') {
|
|
612
|
-
|
|
613
|
-
|
|
665
|
+
// NO CONVERSION. These arrive in world millimetres now; they used to be the projection's inches and
|
|
666
|
+
// this was the multiplication back. It is the single most dangerous line in the metric change: a
|
|
667
|
+
// stale `* IN_TO_MM` here puts every column 25.4x too high in 3D while the contract stays correct,
|
|
668
|
+
// so nothing on screen looks like a unit bug — it looks like a modelling one. The projection's
|
|
669
|
+
// fields were RENAMED (`tos` -> `tosMm`) precisely so this site could not keep compiling unchanged.
|
|
670
|
+
const bos = m.col && m.col.bosMm != null ? m.col.bosMm : 0;
|
|
671
|
+
const tos = m.col && m.col.tosMm != null ? m.col.tosMm : defaultTosMm;
|
|
614
672
|
return { kind: 'column', line: [[a[0], a[1], bos], [a[0], a[1], tos]] };
|
|
615
673
|
}
|
|
616
674
|
const e = m.ends || [];
|
|
617
|
-
const z0 = e[0] && e[0].
|
|
618
|
-
const z1 = e[1] && e[1].
|
|
675
|
+
const z0 = e[0] && e[0].tosMm != null ? e[0].tosMm : defaultTosMm;
|
|
676
|
+
const z1 = e[1] && e[1].tosMm != null ? e[1].tosMm : defaultTosMm;
|
|
619
677
|
return { kind: 'beam', line: [[a[0], a[1], z0], [b[0], b[1], z1]] };
|
|
620
678
|
}
|
|
621
679
|
|
|
@@ -647,13 +705,9 @@ export function snapElevation(z, levels, tol) {
|
|
|
647
705
|
// intersections (columns land on them); grid lines below member centerlines.
|
|
648
706
|
const PRECEDENCE = { origin: 0, vertex: 0, intersection: 1, 'grid-int': 1, midpoint: 2, centerline: 3, 'vertical-axis': 4, 'grid-line': 5, level: 1 }; // origin = the local UCS origin, ties with a vertex (a deliberate reference point)
|
|
649
707
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
let t = ((p[0] - a[0]) * ab[0] + (p[1] - a[1]) * ab[1] + (p[2] - a[2]) * ab[2]) / len2;
|
|
654
|
-
t = Math.max(0, Math.min(1, t));
|
|
655
|
-
return [a[0] + ab[0] * t, a[1] + ab[1] * t, a[2] + ab[2] * t];
|
|
656
|
-
}
|
|
708
|
+
// Snap candidates are world mm, and this caller's historic rule is `len2 || 1` — NOT the millimetre
|
|
709
|
+
// threshold `distPointSeg` uses: a near-degenerate stub member should still snap to its own point here.
|
|
710
|
+
function closestOnSeg(p, a, b) { return projectPointOnSegment3d(p, a, b, SEG_DEGENERACY.unitDenominator).closest; }
|
|
657
711
|
|
|
658
712
|
// Once per candidate TYPE, not once per session: a single global latch meant the first malformed kind
|
|
659
713
|
// silenced every later one, so a second, unrelated breakage would arrive with no trace at all. Keyed by
|
|
@@ -991,9 +1045,13 @@ export function dominantAxis3d(a, b, axesMap) {
|
|
|
991
1045
|
* merges, or refuses inconsistent registration — not implementation tuning. Revisit with data; never widen one to
|
|
992
1046
|
* make a demo pass.
|
|
993
1047
|
*
|
|
994
|
-
* The cut-plane quantum is
|
|
995
|
-
*
|
|
996
|
-
*
|
|
1048
|
+
* The cut-plane quantum is 1/16" and it is JUSTIFIED BY THE MEASUREMENT, not by the authoring lattice:
|
|
1049
|
+
* column coincidence after removing the registration offset was 0.7 mm median / 1.76 mm worst, so
|
|
1050
|
+
* 1.5875 mm is the distance below which two elevations are the same drafted plane. This comment used to
|
|
1051
|
+
* say it WAS grid-core's `gridLevelKey` quantum; the two were the same number by coincidence and are
|
|
1052
|
+
* separate rules now. `gridLevelKey` is a millimetre-based identity handle (grid-core's `LEVEL_SAME_MM`
|
|
1053
|
+
* decides level identity, at 0.5 mm); this is a physical drafting-drift tolerance and is unchanged.
|
|
1054
|
+
* The de-dup distance is 1/4": same measurement, ~3.6x headroom, far below any real member spacing.
|
|
997
1055
|
*/
|
|
998
1056
|
export const MODEL_V2_TOL = Object.freeze({
|
|
999
1057
|
CUT_PLANE_MM: 1.5875, // 1/16" — a member includes a sheet elevation within this
|
|
@@ -1012,7 +1070,7 @@ export const MODEL_V2_TOL = Object.freeze({
|
|
|
1012
1070
|
//
|
|
1013
1071
|
// They bound the pick, NOT the registration: the transform is fitted from the grid, so a pick within
|
|
1014
1072
|
// tolerance moves nothing. What they bound is the evidence — the picks are the only measurement that
|
|
1015
|
-
// sees the drawing at all, and so the only check on `grid.origin` and `
|
|
1073
|
+
// sees the drawing at all, and so the only check on `grid.origin` and `mm_per_px`. Two picks a
|
|
1016
1074
|
// baseline apart therefore bound a scale error to ±(REFUSE_PT / baselinePt), which is why the reader
|
|
1017
1075
|
// skill tells the AI to choose the FURTHEST intersection: a longer baseline is a better measurement.
|
|
1018
1076
|
CONTROL_CHECK_REPORT_PT: 2, // 1/36" on the printed sheet — past ordinary reading error, worth saying
|
|
@@ -1021,6 +1079,18 @@ export const MODEL_V2_TOL = Object.freeze({
|
|
|
1021
1079
|
|
|
1022
1080
|
/** The §5.2a elevation union: `{known:mm}` | `{unknown:true, rfiRef?}`. */
|
|
1023
1081
|
export function isUnknownElev(e) { return !!e && e.unknown === true; }
|
|
1082
|
+
/**
|
|
1083
|
+
* PLACED, BUT NOT PROVEN (#1155) — the server put this member somewhere so it would be built, and
|
|
1084
|
+
* said out loud that the drawings did not settle it.
|
|
1085
|
+
*
|
|
1086
|
+
* It carries a real `known`, so anything that only asks "is there a number?" builds it, which is the
|
|
1087
|
+
* whole point. Anything that asks "is this height EVIDENCE?" has to ask this too — pricing it,
|
|
1088
|
+
* scoring it, aligning another member to it, or hanging a connection off it are all decisions that
|
|
1089
|
+
* must not be made from a guess.
|
|
1090
|
+
*/
|
|
1091
|
+
export function isAssumedElev(e) { return !!e && e.assumed === true; }
|
|
1092
|
+
/** Either spelling of "nobody has confirmed this height". */
|
|
1093
|
+
export function isUnresolvedElev(e) { return isUnknownElev(e) || isAssumedElev(e); }
|
|
1024
1094
|
/** The known elevation in mm, or null when unknown/malformed. Never returns 0 for "unknown". */
|
|
1025
1095
|
export function knownZ(e) { return e && typeof e.known === 'number' && Number.isFinite(e.known) ? e.known : null; }
|
|
1026
1096
|
|
|
@@ -1410,41 +1480,6 @@ export function sectionExtents(outline) {
|
|
|
1410
1480
|
return { lo: [loX, loY], hi: [hiX, hiY] };
|
|
1411
1481
|
}
|
|
1412
1482
|
|
|
1413
|
-
/**
|
|
1414
|
-
* How far the ROLLED section reaches along one world axis — the outline's support function at `rotDeg`.
|
|
1415
|
-
*
|
|
1416
|
-
* This is what a flush face needs while the composition still measures against the WORLD axes (slice 1a):
|
|
1417
|
-
* the section is rolled about the reference line, so `top` has to hold the rolled steel's topmost fibre
|
|
1418
|
-
* on the line, and the topmost fibre moves with the angle. Slice 1b replaces the whole question with
|
|
1419
|
-
* `positionOffsetVector`, which measures on the section's own axes and needs no angle at all.
|
|
1420
|
-
*
|
|
1421
|
-
* `axis` picks which world direction to measure: 'depth' is the one the section's local +y rolls into
|
|
1422
|
-
* (world up for a beam), 'width' the one local +x rolls into.
|
|
1423
|
-
*
|
|
1424
|
-
* A ROUND section is pinned to its exact radius at every roll — its support function genuinely is `r` in
|
|
1425
|
-
* every direction, and measuring the inscribed polygon instead would report `r·cos(π/48)`.
|
|
1426
|
-
*
|
|
1427
|
-
* @param {{outer:[number,number][], round?:boolean, r?:number}} outline
|
|
1428
|
-
* @param {number|undefined} rotDeg
|
|
1429
|
-
* @param {'depth'|'width'} axis
|
|
1430
|
-
* @returns {{lo:number, hi:number}} signed extremes along that axis
|
|
1431
|
-
*/
|
|
1432
|
-
export function rolledExtent(outline, rotDeg, axis) {
|
|
1433
|
-
if (outline.round) return { lo: -outline.r, hi: outline.r };
|
|
1434
|
-
// A non-finite rot reads as 0. This value moves a member's COORDINATES, not just its facing, so an
|
|
1435
|
-
// Infinity would reach Math.cos → NaN → NaN endpoints — which the degeneracy guard cannot catch
|
|
1436
|
-
// (`NaN < 1` is false) and which serialize to `null` for the viewer and both native writers alike.
|
|
1437
|
-
const th = ((typeof rotDeg === 'number' && isFinite(rotDeg) ? rotDeg : 0) * Math.PI) / 180;
|
|
1438
|
-
const c = Math.cos(th), s = Math.sin(th);
|
|
1439
|
-
let lo = Infinity, hi = -Infinity;
|
|
1440
|
-
for (const [x, y] of outline.outer) {
|
|
1441
|
-
const v = axis === 'width' ? x * c - y * s : x * s + y * c;
|
|
1442
|
-
if (v < lo) lo = v;
|
|
1443
|
-
if (v > hi) hi = v;
|
|
1444
|
-
}
|
|
1445
|
-
return { lo, hi };
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
1483
|
/**
|
|
1449
1484
|
* Where a named face puts the section relative to the reference line, on ONE axis, in section
|
|
1450
1485
|
* coordinates. `top`/`left` put that face ON the line, so the steel hangs off the other side — the
|
|
@@ -1652,7 +1687,10 @@ export function positionOffsetVector(frame, ex, depthFace, widthFace, rotDeg, wi
|
|
|
1652
1687
|
}
|
|
1653
1688
|
|
|
1654
1689
|
// The ¼" / 5° snaps the 3D Profile Position gizmo applies to a dragged offset / roll (Shift = free).
|
|
1655
|
-
|
|
1690
|
+
// `IN_TO_MM / 4`, not `25.4 / 4`: the quantum IS a quarter of an inch, so it should say so in the one
|
|
1691
|
+
// vocabulary the repo has for that fact. Writing the number spelled the same digits as a unit
|
|
1692
|
+
// conversion while meaning something else, which is exactly what the geometry guard is watching for.
|
|
1693
|
+
export const POSITION_OFFSET_SNAP_MM = IN_TO_MM / 4;
|
|
1656
1694
|
export const POSITION_ROT_SNAP_DEG = 5;
|
|
1657
1695
|
|
|
1658
1696
|
/** Round `value` to the nearest multiple of `step` (the gizmo's ¼"/5° drag snap); `step<=0` = free. */
|
|
@@ -1769,6 +1807,54 @@ export function quantizeMm(v) {
|
|
|
1769
1807
|
return typeof v === 'number' && isFinite(v) ? Math.round(v * 1e9) / 1e9 : NaN;
|
|
1770
1808
|
}
|
|
1771
1809
|
|
|
1810
|
+
/**
|
|
1811
|
+
* Turn an endpoint preview into the immutable host commit payload. Returning null means the gesture is
|
|
1812
|
+
* incomplete or quantises back to its drag-start point, so the caller restores the canonical overlay.
|
|
1813
|
+
*/
|
|
1814
|
+
export function worldEndpointCommit(pending) {
|
|
1815
|
+
if (!pending || pending.world !== true || typeof pending.id !== 'string'
|
|
1816
|
+
|| (pending.end !== 0 && pending.end !== 1)
|
|
1817
|
+
|| !Array.isArray(pending.orig) || pending.orig.length !== 3
|
|
1818
|
+
|| !Array.isArray(pending.newPt) || pending.newPt.length !== 3
|
|
1819
|
+
|| !pending.orig.every(Number.isFinite) || !pending.newPt.every(Number.isFinite)
|
|
1820
|
+
|| pending.state?.available !== true || pending.state.id !== pending.id
|
|
1821
|
+
|| !Number.isSafeInteger(pending.state.generation)
|
|
1822
|
+
|| !pending.state.fingerprint || typeof pending.state.fingerprint !== 'object'
|
|
1823
|
+
|| Array.isArray(pending.state.fingerprint)
|
|
1824
|
+
|| !pending.state.fingerprint.from || !pending.state.fingerprint.to) return null;
|
|
1825
|
+
if (!pending.newPt.some((v, i) => quantizeMm(v) !== quantizeMm(pending.orig[i]))) return null;
|
|
1826
|
+
return {
|
|
1827
|
+
id: pending.id,
|
|
1828
|
+
end: pending.end,
|
|
1829
|
+
point: pending.newPt.slice(),
|
|
1830
|
+
state: pending.state,
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
/** Resolve an endpoint drag without discarding the elevation of a 3D snap. */
|
|
1835
|
+
export function endpointDragPoint(origin, planeHit, verticalHit, vertical, candidates, toScreen, tolPx, free3d = true) {
|
|
1836
|
+
if (vertical) {
|
|
1837
|
+
if (!verticalHit) return null;
|
|
1838
|
+
const point = [origin[0], origin[1], verticalHit[2]];
|
|
1839
|
+
const levels = [...new Set(candidates.flatMap((c) => [c.p, c.a, c.b])
|
|
1840
|
+
.filter(finiteVec3).map((p) => p[2]))];
|
|
1841
|
+
const r = snapPoint(point, levels.map((z) => ({ type: 'level', p: [origin[0], origin[1], z] })), toScreen, tolPx);
|
|
1842
|
+
return { point: r.snapped, type: r.candidate?.type || null };
|
|
1843
|
+
}
|
|
1844
|
+
// An edge-on horizontal plane has no ray hit, but an existing endpoint is still pickable.
|
|
1845
|
+
const query = planeHit || verticalHit;
|
|
1846
|
+
if (!query) return null;
|
|
1847
|
+
const allowed = candidates.filter((c) => {
|
|
1848
|
+
// An axis or grid steers XY at the cursor's Z; without a plane hit that Z is not an elevation pick.
|
|
1849
|
+
if (!planeHit && (!finiteVec3(c.p) || c.type === 'vertical-axis' || c.type === 'grid-int')) return false;
|
|
1850
|
+
const point = candidatePoint(c, query);
|
|
1851
|
+
return finiteVec3(point) && (free3d || candidateOnPlane(c, query, origin, [0, 0, 1]));
|
|
1852
|
+
});
|
|
1853
|
+
const r = snapPoint(query, allowed, toScreen, tolPx);
|
|
1854
|
+
if (r.candidate) return { point: free3d ? r.snapped : [r.snapped[0], r.snapped[1], origin[2]], type: r.candidate.type };
|
|
1855
|
+
return planeHit ? { point: planeHit, type: null } : null;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1772
1858
|
/**
|
|
1773
1859
|
* ONE canonical "is this a vertical brace", matching the durable scene reader's normalisation
|
|
1774
1860
|
* (`contract-to-scene.ts` `memberIsBrace`, which trims and lowercases). The repo had THREE spellings of
|