@floless/app 0.104.2 → 0.106.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 +11505 -8050
- package/dist/schemas/steel.model.v2.schema.json +652 -0
- package/dist/schemas/steel.takeoff.v1.schema.json +54 -4
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +109 -5
- package/dist/skills/floless-app-tweak-contract/SKILL.md +23 -7
- package/dist/skills/floless-app-vectorize/SKILL.md +21 -5
- package/dist/templates/steel-model.flo +5 -1
- package/dist/templates/vectorize.flo +5 -1
- package/dist/web/app.css +119 -4
- package/dist/web/aware.js +526 -65
- package/dist/web/index.html +28 -1
- package/dist/web/steel-3d-core.js +242 -0
- package/dist/web/steel-3d-view.js +515 -50
- package/dist/web/steel-editor.html +1508 -175
- package/dist/web/steel-filter.html +67 -2
- package/dist/web/steel-materials.js +249 -0
- package/dist/web/steel-model-adapter.js +210 -0
- package/dist/web/steel-model-commands.js +691 -0
- package/dist/web/steel-view-generation.js +10 -1
- package/dist/web/vector-editor.html +118 -3
- package/dist/web/vendor/README.md +6 -1
- package/dist/web/vendor/RoomEnvironment.js +185 -0
- package/dist/web/workspaces.js +509 -79
- package/package.json +6 -1
package/dist/web/index.html
CHANGED
|
@@ -50,7 +50,11 @@
|
|
|
50
50
|
<div class="controls">
|
|
51
51
|
<label id="wf-label">workflow</label>
|
|
52
52
|
<div class="wf-combo" id="wf-combo">
|
|
53
|
-
|
|
53
|
+
<!-- Ships DISABLED to match the "loading…" label below it. loadApps() only runs after the
|
|
54
|
+
license check, the health probe and (when AWARE is not ready) the whole bootstrap, so an
|
|
55
|
+
enabled start state let a click in that window open the popover onto an empty list — the
|
|
56
|
+
symptom of #358. buildWorkflowCombo() enables it the moment there are real rows. -->
|
|
57
|
+
<button id="wf-trigger" class="wf-trigger" type="button" disabled aria-haspopup="listbox" aria-expanded="false" aria-controls="wf-popover" aria-labelledby="wf-label wf-trigger-label" data-tip="Pick a workflow — type to search; grouped by provider">
|
|
54
58
|
<span class="wf-trigger-label" id="wf-trigger-label">loading…</span>
|
|
55
59
|
<span class="wf-dirty-dot" id="wf-dirty-dot" data-tip="Unsaved input changes — Save (Ctrl+S) to keep them" hidden>●</span>
|
|
56
60
|
<svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
|
|
@@ -360,6 +364,29 @@
|
|
|
360
364
|
</div>
|
|
361
365
|
</div>
|
|
362
366
|
|
|
367
|
+
<!-- Import failed: `aware app install` refused the .flo. It says exactly what is wrong on stderr —
|
|
368
|
+
which agent isn't runnable, which node id is duplicated — and the plain "import failed …
|
|
369
|
+
(exit N)" toast this replaces could carry none of it (#314). Shows what happened in plain
|
|
370
|
+
English, the one-command fix when we can name it, and AWARE's own output (open only when
|
|
371
|
+
there is no fix to show instead). Filled by openImportFailedModal() in aware.js. -->
|
|
372
|
+
<div class="modal-backdrop" id="import-failed-modal">
|
|
373
|
+
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="import-failed-title" aria-describedby="import-failed-sub" tabindex="-1">
|
|
374
|
+
<div class="modal-title" id="import-failed-title">Import failed</div>
|
|
375
|
+
<div class="modal-sub" id="import-failed-sub"></div>
|
|
376
|
+
<div class="import-failed-remedy" id="import-failed-remedy" hidden>
|
|
377
|
+
<div class="import-failed-remedy-label">Try this in your terminal AI, then import again:</div>
|
|
378
|
+
<div id="import-failed-remedy-rows"></div>
|
|
379
|
+
</div>
|
|
380
|
+
<details class="import-failed-detail" id="import-failed-detail">
|
|
381
|
+
<summary class="import-failed-summary" id="import-failed-summary"><span class="import-failed-caret" aria-hidden="true">▸</span>What AWARE reported</summary>
|
|
382
|
+
<pre class="fm-note" id="import-failed-raw" tabindex="0" role="region" aria-labelledby="import-failed-summary"></pre>
|
|
383
|
+
</details>
|
|
384
|
+
<div class="modal-actions">
|
|
385
|
+
<button id="import-failed-close">Close</button>
|
|
386
|
+
</div>
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
|
|
363
390
|
<div class="menu" id="menu" role="menu">
|
|
364
391
|
<button class="menu-item" data-action="open" role="menuitem">
|
|
365
392
|
<span class="menu-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/></svg></span>
|
|
@@ -134,6 +134,78 @@ export function dispToMm(pt, ptPerFt) { const k = kOf(ptPerFt); return [nz(pt[0]
|
|
|
134
134
|
/** scene mm point [x,y,…] → display-space wp [px,py] (inverse of dispToMm). */
|
|
135
135
|
export function planPointToWp(p, ptPerFt) { const k = kOf(ptPerFt); return [nz(p[0] / k), nz(-p[1] / k)]; }
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* The px→ft scale and default T.O.S of the plan that OWNS a member, resolved from the SAME per-plan
|
|
139
|
+
* list that feeds 3D snap candidates (`api.membersByPlan()`).
|
|
140
|
+
*
|
|
141
|
+
* Why it reads that list rather than taking the active plane's scale: 3D snap targets are built from
|
|
142
|
+
* every sheet in each sheet's own scale, while a drag/endpoint commit used to invert through the
|
|
143
|
+
* ACTIVE sheet's scale. Editing an off-active-sheet member whose sheet has a different `pt_per_ft` (or
|
|
144
|
+
* a different `default_tos`) therefore wrote a mis-scaled `wp`. Sharing one source makes the target and
|
|
145
|
+
* the commit incapable of disagreeing.
|
|
146
|
+
*
|
|
147
|
+
* `fallback` is used when the id is unknown (a not-yet-loaded contract, or a member outside the plan
|
|
148
|
+
* list) so a lookup miss can never throw out of a pointer handler.
|
|
149
|
+
*/
|
|
150
|
+
export function planScaleIndex(byPlan, fallback) {
|
|
151
|
+
const ix = new Map();
|
|
152
|
+
for (const pl of byPlan || []) {
|
|
153
|
+
if (!pl || !Array.isArray(pl.members)) continue;
|
|
154
|
+
const scale = {
|
|
155
|
+
ptPerFt: pl.ptPerFt > 0 ? pl.ptPerFt : 1,
|
|
156
|
+
defaultTosMm: pl.defaultTosMm != null ? pl.defaultTosMm : (fallback ? fallback.defaultTosMm : 0),
|
|
157
|
+
};
|
|
158
|
+
for (const m of pl.members) if (m && typeof m === 'object' && !ix.has(m)) ix.set(m, scale);
|
|
159
|
+
}
|
|
160
|
+
return ix;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* O(1) lookup into a `planScaleIndex`, keyed by the member OBJECT. Unknown member → `fallback`
|
|
165
|
+
* (may be undefined; callers guard).
|
|
166
|
+
*
|
|
167
|
+
* Keyed by object, never by `m.id`: member ids are only SHEET-unique by contract — that is the whole
|
|
168
|
+
* reason `contractWithExportScopedMemberIds` namespaces them for export and the editor keeps a separate
|
|
169
|
+
* `planeOfMember` that resolves by identity. Keying this index by bare id would resolve the second of
|
|
170
|
+
* two same-id members through the FIRST sheet's scale, which is the very class of bug this seam exists
|
|
171
|
+
* to remove.
|
|
172
|
+
*/
|
|
173
|
+
export function planScaleOf(index, member, fallback) {
|
|
174
|
+
const s = index && typeof index.get === 'function' ? index.get(member) : null;
|
|
175
|
+
return s || fallback;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* A member's centreline resolved through the plan that OWNS it.
|
|
180
|
+
*
|
|
181
|
+
* This composition is exported (rather than left inline in the view) so the OWNING-PLAN wiring is
|
|
182
|
+
* unit-testable: asserting `planScaleOf`'s return value alone would still pass if a call site
|
|
183
|
+
* regressed to the active sheet's scale, because the bug was never in the pure lookup — it was in
|
|
184
|
+
* which scale got handed to `memberGeometry`.
|
|
185
|
+
*/
|
|
186
|
+
export function memberGeometryInOwnPlan(m, index, fallback) {
|
|
187
|
+
const s = planScaleOf(index, m, fallback) || { ptPerFt: 1, defaultTosMm: 0 };
|
|
188
|
+
return memberGeometry(m, s.ptPerFt, s.defaultTosMm);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Alt-drag T.O.S levels across EVERY sheet, each sheet resolved in its OWN default elevation.
|
|
193
|
+
* Taking the active sheet's member list with some other sheet's default would report unset-T.O.S
|
|
194
|
+
* members at an elevation they are not drawn at.
|
|
195
|
+
*/
|
|
196
|
+
export function elevationLevelsByPlan(byPlan, fallback, excludeMember) {
|
|
197
|
+
const set = new Set();
|
|
198
|
+
for (const pl of byPlan || []) {
|
|
199
|
+
if (!pl || !Array.isArray(pl.members)) continue;
|
|
200
|
+
const dtos = pl.defaultTosMm != null ? pl.defaultTosMm : (fallback ? fallback.defaultTosMm : 0);
|
|
201
|
+
// Exclude by OBJECT, not by id: ids are only sheet-unique, so excluding by id would silently drop
|
|
202
|
+
// every same-id member on every other sheet from the level set.
|
|
203
|
+
const members = excludeMember ? pl.members.filter((m) => m !== excludeMember) : pl.members;
|
|
204
|
+
for (const z of elevationLevels(members, pl.ptPerFt, dtos, undefined)) set.add(z);
|
|
205
|
+
}
|
|
206
|
+
return [...set].sort((a, b) => a - b);
|
|
207
|
+
}
|
|
208
|
+
|
|
137
209
|
/**
|
|
138
210
|
* member → its 3D centerline `{ kind, line:[[x,y,z],[x,y,z]] }` in mm, matching contractToScene's
|
|
139
211
|
* from/to. Beam: work-line at T.O.S. Column: vertical at the plan point, bos→tos.
|
|
@@ -539,6 +611,176 @@ export function dominantAxis3d(a, b, axesMap) {
|
|
|
539
611
|
return best;
|
|
540
612
|
}
|
|
541
613
|
|
|
614
|
+
// ---- steel.model/v2 foundation (model-level epic, unit 2) — INACTIVE ------------------------------
|
|
615
|
+
// Pure primitives for the model-level contract. Nothing below is wired into the editor or the 3D view:
|
|
616
|
+
// unit 2 ships the v2 contract inactive, so these exist to be unit-tested and consumed by unit 3's
|
|
617
|
+
// migration preview. Kept here because they are the same KIND of thing as the rest of this module
|
|
618
|
+
// (framework-free scene-space math, node-tested from server/steel-3d-core.test.ts) and server code
|
|
619
|
+
// already imports web/*-core.js (contract-to-scene.ts pulls in grid-core).
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* The pinned tolerances from epic §5.2b. These are CONTRACT SEMANTICS — they decide what displays,
|
|
623
|
+
* merges, or blocks a migration — not implementation tuning. Revisit with data; never widen one to
|
|
624
|
+
* make a demo pass.
|
|
625
|
+
*
|
|
626
|
+
* The cut-plane quantum is the existing authoring quantum (grid-core's gridLevelKey rounds to 1/16").
|
|
627
|
+
* The de-dup distance is 1/4": measured column coincidence after removing the registration offset was
|
|
628
|
+
* 0.7 mm median / 1.76 mm worst, so ~3.6x headroom, and it stays far below any real member spacing.
|
|
629
|
+
*/
|
|
630
|
+
export const MODEL_V2_TOL = Object.freeze({
|
|
631
|
+
CUT_PLANE_MM: 1.5875, // 1/16" — a member includes a sheet elevation within this
|
|
632
|
+
DEDUP_MM: 6.35, // 1/4" — geometric equivalence for a de-dup CANDIDATE (never proof)
|
|
633
|
+
RESIDUAL_REPORT_MM: 1.5875, // registration residual above this is reported
|
|
634
|
+
RESIDUAL_REFUSE_MM: 6.35, // ...and above this is refused: beyond drafting drift = a different grid
|
|
635
|
+
ROTATION_REFUSE_DEG: 0.05, // secondary ceiling (the binding gate is induced displacement)
|
|
636
|
+
SCALE_REFUSE_FRAC: 0.002, // secondary ceiling, 0.2%
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
/** The §5.2a elevation union: `{known:mm}` | `{unknown:true, rfiRef?}`. */
|
|
640
|
+
export function isUnknownElev(e) { return !!e && e.unknown === true; }
|
|
641
|
+
/** The known elevation in mm, or null when unknown/malformed. Never returns 0 for "unknown". */
|
|
642
|
+
export function knownZ(e) { return e && typeof e.known === 'number' && Number.isFinite(e.known) ? e.known : null; }
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Does a member spanning fromZ..toZ cross a sheet's cut elevation? (epic §5.3)
|
|
646
|
+
*
|
|
647
|
+
* Inclusive on BOTH sides within `tol`, and orientation-agnostic (a member is not required to be stored
|
|
648
|
+
* low-first except for columns). An UNKNOWN endpoint returns false: an unknown elevation is an RFI, not
|
|
649
|
+
* a position, and guessing which sheets an unplaced member appears on is exactly the "nearest sheet"
|
|
650
|
+
* heuristic §5.3 forbids — such a member is presented via `plan.memberRefs` instead.
|
|
651
|
+
*/
|
|
652
|
+
export function sheetIncludesElevation(fromZ, toZ, elevMm, tol = MODEL_V2_TOL.CUT_PLANE_MM) {
|
|
653
|
+
const a = knownZ(fromZ), b = knownZ(toZ);
|
|
654
|
+
if (a === null || b === null || !Number.isFinite(elevMm)) return false;
|
|
655
|
+
return elevMm >= Math.min(a, b) - tol && elevMm <= Math.max(a, b) + tol;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/** Apply a similarity transform (from registerSheet) to a local [x,y] → world mm. */
|
|
659
|
+
export function applySimilarity(t, p) {
|
|
660
|
+
if (!t || !Array.isArray(p)) return null;
|
|
661
|
+
const c = Math.cos(t.rotationRad) * t.scale, s = Math.sin(t.rotationRad) * t.scale;
|
|
662
|
+
return [nz(p[0] * c - p[1] * s + t.translation[0]), nz(p[0] * s + p[1] * c + t.translation[1])];
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// Similarity (rotation + uniform scale + translation) from two control PAIRS. Module-private on
|
|
666
|
+
// purpose: exporting it would hand callers a transform with no verdict attached, and the whole point of
|
|
667
|
+
// registerSheet is that a registration cannot be obtained without passing the gate. null when degenerate.
|
|
668
|
+
function similarityFromControls(c0, c1) {
|
|
669
|
+
const lx = c1.local[0] - c0.local[0], ly = c1.local[1] - c0.local[1];
|
|
670
|
+
const wx = c1.world[0] - c0.world[0], wy = c1.world[1] - c0.world[1];
|
|
671
|
+
const localLen = Math.hypot(lx, ly), worldLen = Math.hypot(wx, wy);
|
|
672
|
+
if (!(localLen > 1e-9) || !(worldLen > 1e-9)) return null; // coincident controls carry no direction
|
|
673
|
+
const scale = worldLen / localLen;
|
|
674
|
+
const rotationRad = Math.atan2(wy, wx) - Math.atan2(ly, lx);
|
|
675
|
+
const c = Math.cos(rotationRad) * scale, s = Math.sin(rotationRad) * scale;
|
|
676
|
+
return {
|
|
677
|
+
scale,
|
|
678
|
+
rotationRad: Math.atan2(Math.sin(rotationRad), Math.cos(rotationRad)), // wrap to (-pi, pi]
|
|
679
|
+
translation: [nz(c0.world[0] - (c0.local[0] * c - c0.local[1] * s)), nz(c0.world[1] - (c0.local[0] * s + c0.local[1] * c))],
|
|
680
|
+
baselineMm: worldLen,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const _finite2 = (p) => Array.isArray(p) && p.length >= 2 && Number.isFinite(p[0]) && Number.isFinite(p[1]);
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Register one sheet onto the model frame, and RULE ON IT. (epic §6.2 + §5.2b)
|
|
688
|
+
*
|
|
689
|
+
* This is the only exported registration entry point, and that is the design: everything the verdict
|
|
690
|
+
* depends on is DERIVED here from evidence the caller states as fact, never accepted as a conclusion the
|
|
691
|
+
* caller asserts. A signature taking `handedness` or `residualMm` would not be a gate — a caller could
|
|
692
|
+
* pass `'right'` and `0` and sail through the very checks that exist to refuse a bad sheet.
|
|
693
|
+
*
|
|
694
|
+
* controls ≥2 `{ local:[x,y], world:[x,y] }` pairs. The first two FIT the transform; every extra one
|
|
695
|
+
* is promoted to a residual sample, so supplying more evidence can never weaken the result.
|
|
696
|
+
* axes `{ localX, localY, worldX, worldY }` direction vectors from MATCHED LABELLED AXES. Two
|
|
697
|
+
* point-pairs cannot establish handedness — a reflection composed with a rotation is
|
|
698
|
+
* indistinguishable from a rotation on two points — so without axes handedness is
|
|
699
|
+
* UNESTABLISHED and the sheet is refused rather than presumed right-handed.
|
|
700
|
+
* samples extra `{local, world}` checks. A two-control fit is exact BY CONSTRUCTION, so zero
|
|
701
|
+
* residual from it is arithmetic, not agreement: with no sample the verdict is capped at
|
|
702
|
+
* 'report' and can never be 'ok'.
|
|
703
|
+
* bounds `{min:[x,y], max:[x,y]}` world bounds of the geometry this transform will move. Extent is
|
|
704
|
+
* derived from it (the farthest corner/sample from the pivot) because rotation and scale
|
|
705
|
+
* error grow with distance from the pivot — gating on the control baseline alone would pass
|
|
706
|
+
* a sheet that displaces distant members several times the de-dup tolerance.
|
|
707
|
+
*
|
|
708
|
+
* Returns `{ verdict:'ok'|'report'|'refuse', reasons:[…], transform }`, and `transform` is **null** on
|
|
709
|
+
* refuse so a refused registration cannot be applied by a caller that ignored the verdict.
|
|
710
|
+
*/
|
|
711
|
+
export function registerSheet(input) {
|
|
712
|
+
const reasons = [];
|
|
713
|
+
const refuse = (why) => ({ verdict: 'refuse', reasons: [...reasons, why], transform: null });
|
|
714
|
+
|
|
715
|
+
// The options object itself is untrusted — a null/array/scalar must REFUSE, never throw out of the gate.
|
|
716
|
+
if (input !== undefined && (typeof input !== 'object' || input === null || Array.isArray(input))) return refuse('bad-input');
|
|
717
|
+
const { controls, axes, samples, bounds } = input || {};
|
|
718
|
+
if ((controls !== undefined && !Array.isArray(controls)) || (samples !== undefined && !Array.isArray(samples))) return refuse('bad-input');
|
|
719
|
+
|
|
720
|
+
// A malformed control or sample REFUSES rather than being filtered away. Dropping it would silently
|
|
721
|
+
// shrink the evidence the verdict rests on — the opposite of "extra evidence is never ignored".
|
|
722
|
+
const wellFormed = (c) => !!c && typeof c === 'object' && _finite2(c.local) && _finite2(c.world);
|
|
723
|
+
const cs = controls || [];
|
|
724
|
+
if (cs.some((c) => !wellFormed(c))) return refuse('malformed-control');
|
|
725
|
+
const ss = samples || [];
|
|
726
|
+
if (ss.some((s) => !wellFormed(s))) return refuse('malformed-sample');
|
|
727
|
+
|
|
728
|
+
if (cs.length < 2) return refuse('needs-two-controls');
|
|
729
|
+
const transform = similarityFromControls(cs[0], cs[1]);
|
|
730
|
+
if (!transform || !Number.isFinite(transform.scale) || !Number.isFinite(transform.rotationRad)
|
|
731
|
+
|| !Number.isFinite(transform.baselineMm) || !transform.translation.every(Number.isFinite)) {
|
|
732
|
+
// Finite INPUTS can still overflow to a non-finite translation near ±1e308; checking only scale and
|
|
733
|
+
// rotation would let that escape with a verdict attached.
|
|
734
|
+
return refuse('degenerate-controls');
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// Handedness — from the matched axis pair only. Its absence is a refusal, not a default.
|
|
738
|
+
if (!axes || !_finite2(axes.localX) || !_finite2(axes.localY) || !_finite2(axes.worldX) || !_finite2(axes.worldY)) {
|
|
739
|
+
return refuse('handedness-unestablished');
|
|
740
|
+
}
|
|
741
|
+
const crossOf = (u, v) => u[0] * v[1] - u[1] * v[0];
|
|
742
|
+
const localHand = crossOf(axes.localX, axes.localY), worldHand = crossOf(axes.worldX, axes.worldY);
|
|
743
|
+
if (!(Math.abs(localHand) > 1e-12) || !(Math.abs(worldHand) > 1e-12)) return refuse('handedness-degenerate');
|
|
744
|
+
if ((localHand > 0) !== (worldHand > 0)) return refuse('mirrored');
|
|
745
|
+
|
|
746
|
+
// Extent — the farthest thing this transform will actually move, not the baseline between controls.
|
|
747
|
+
const pivot = cs[0].world;
|
|
748
|
+
const far = (p) => Math.hypot(p[0] - pivot[0], p[1] - pivot[1]);
|
|
749
|
+
if (!bounds || typeof bounds !== 'object' || !_finite2(bounds.min) || !_finite2(bounds.max)) return refuse('bounds-missing');
|
|
750
|
+
let extentMm = 0;
|
|
751
|
+
for (const x of [bounds.min[0], bounds.max[0]]) for (const y of [bounds.min[1], bounds.max[1]]) extentMm = Math.max(extentMm, far([x, y]));
|
|
752
|
+
// EVERY control counts toward the extent, including the second fitting one — a 100 m fitting baseline
|
|
753
|
+
// inside 1 m of bounds would otherwise report a 1 m extent and pass a gate it should fail.
|
|
754
|
+
for (const c of cs) extentMm = Math.max(extentMm, far(c.world));
|
|
755
|
+
const extraSamples = [...cs.slice(2), ...ss];
|
|
756
|
+
for (const s of extraSamples) extentMm = Math.max(extentMm, far(s.world));
|
|
757
|
+
if (!Number.isFinite(extentMm) || extentMm <= 0) return refuse('bounds-degenerate');
|
|
758
|
+
|
|
759
|
+
// Residual — max post-transform error over samples BEYOND the fitting pair. null = unestablished.
|
|
760
|
+
let residualMm = null;
|
|
761
|
+
for (const s of extraSamples) {
|
|
762
|
+
const q = applySimilarity(transform, s.local);
|
|
763
|
+
residualMm = Math.max(residualMm ?? 0, Math.hypot(q[0] - s.world[0], q[1] - s.world[1]));
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Induced displacement is the BINDING gate: §5.2b's own 0.05 deg over the measured 19.4 m baseline
|
|
767
|
+
// admits ~16.9 mm, against a 6.35 mm refusal in the same table. Angle and ratio are secondary ceilings.
|
|
768
|
+
const induced = (Math.abs(transform.rotationRad) + Math.abs(transform.scale - 1)) * extentMm;
|
|
769
|
+
let verdict = 'ok';
|
|
770
|
+
const report = (why) => { reasons.push(why); if (verdict === 'ok') verdict = 'report'; };
|
|
771
|
+
|
|
772
|
+
if (induced > MODEL_V2_TOL.RESIDUAL_REFUSE_MM) return refuse('induced-displacement');
|
|
773
|
+
if (Math.abs(transform.rotationRad) * 180 / Math.PI > MODEL_V2_TOL.ROTATION_REFUSE_DEG) return refuse('rotation');
|
|
774
|
+
if (Math.abs(transform.scale - 1) > MODEL_V2_TOL.SCALE_REFUSE_FRAC) return refuse('scale');
|
|
775
|
+
if (residualMm !== null && residualMm > MODEL_V2_TOL.RESIDUAL_REFUSE_MM) return refuse('residual');
|
|
776
|
+
|
|
777
|
+
if (induced > MODEL_V2_TOL.RESIDUAL_REPORT_MM) report('induced-displacement');
|
|
778
|
+
if (residualMm === null) report('residual-unverified');
|
|
779
|
+
else if (residualMm > MODEL_V2_TOL.RESIDUAL_REPORT_MM) report('residual');
|
|
780
|
+
|
|
781
|
+
return { verdict, reasons, transform: { ...transform, extentMm, residualMm } };
|
|
782
|
+
}
|
|
783
|
+
|
|
542
784
|
export function dim3dGeom(a, b, axis, axisDir) {
|
|
543
785
|
const p1 = [a[0], a[1], a[2]];
|
|
544
786
|
const u = (axis === 'x' || axis === 'y') ? unitOrNull(axisDir) : null; // z/free never project onto axisDir
|