@ifc-lite/clash 2.3.0 → 2.4.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/adapters/step.js +1 -0
- package/dist/adapters/step.js.map +1 -1
- package/dist/analysis.d.ts +6 -6
- package/dist/analysis.d.ts.map +1 -1
- package/dist/analysis.js +30 -29
- package/dist/analysis.js.map +1 -1
- package/dist/contact/narrow-phase.js +1 -1
- package/dist/engine-ts/broad.d.ts.map +1 -1
- package/dist/engine-ts/broad.js +11 -10
- package/dist/engine-ts/broad.js.map +1 -1
- package/dist/engine-ts/depth.d.ts +59 -10
- package/dist/engine-ts/depth.d.ts.map +1 -1
- package/dist/engine-ts/depth.js +101 -58
- package/dist/engine-ts/depth.js.map +1 -1
- package/dist/engine-ts/kernel.d.ts +2 -0
- package/dist/engine-ts/kernel.d.ts.map +1 -1
- package/dist/engine-ts/narrow.d.ts +8 -0
- package/dist/engine-ts/narrow.d.ts.map +1 -1
- package/dist/engine-ts/narrow.js +17 -13
- package/dist/engine-ts/narrow.js.map +1 -1
- package/dist/engine-ts/obb-detect.d.ts +19 -0
- package/dist/engine-ts/obb-detect.d.ts.map +1 -0
- package/dist/engine-ts/obb-detect.js +191 -0
- package/dist/engine-ts/obb-detect.js.map +1 -0
- package/dist/engine-ts/obb.d.ts +14 -23
- package/dist/engine-ts/obb.d.ts.map +1 -1
- package/dist/engine-ts/obb.js +35 -140
- package/dist/engine-ts/obb.js.map +1 -1
- package/dist/engine-ts/orchestrator.d.ts.map +1 -1
- package/dist/engine-ts/orchestrator.js +59 -15
- package/dist/engine-ts/orchestrator.js.map +1 -1
- package/dist/engine-ts/tri-mesh.d.ts +10 -5
- package/dist/engine-ts/tri-mesh.d.ts.map +1 -1
- package/dist/engine-ts/tri-mesh.js +35 -25
- package/dist/engine-ts/tri-mesh.js.map +1 -1
- package/dist/engine-ts/ts-kernel.d.ts.map +1 -1
- package/dist/engine-ts/ts-kernel.js +1 -0
- package/dist/engine-ts/ts-kernel.js.map +1 -1
- package/dist/engine-wasm/wasm-kernel.d.ts.map +1 -1
- package/dist/engine-wasm/wasm-kernel.js +10 -1
- package/dist/engine-wasm/wasm-kernel.js.map +1 -1
- package/dist/math/aabb.d.ts +9 -0
- package/dist/math/aabb.d.ts.map +1 -1
- package/dist/math/aabb.js +13 -0
- package/dist/math/aabb.js.map +1 -1
- package/dist/math/generated/plato.g.d.ts +11 -2
- package/dist/math/generated/plato.g.d.ts.map +1 -1
- package/dist/math/generated/plato.g.js +347 -190
- package/dist/math/generated/plato.g.js.map +1 -1
- package/dist/math/triangle-intersect.d.ts +12 -6
- package/dist/math/triangle-intersect.d.ts.map +1 -1
- package/dist/math/triangle-intersect.js +12 -6
- package/dist/math/triangle-intersect.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth.js","sourceRoot":"","sources":["../../src/engine-ts/depth.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D,OAAO,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"depth.js","sourceRoot":"","sources":["../../src/engine-ts/depth.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAgC5D,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,KAAc;IAC3D,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,GAAG,GAAG,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,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AC,CAAC,CAAC,QAAQ;KAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -16,6 +16,8 @@ export interface NarrowRecord {
|
|
|
16
16
|
distanceKind: ClashDistanceKind;
|
|
17
17
|
point: Vec3;
|
|
18
18
|
bounds: AABB;
|
|
19
|
+
/** See `Clash.depthFloor`. Absent for every non-`hard` record. */
|
|
20
|
+
depthFloor?: number;
|
|
19
21
|
}
|
|
20
22
|
export interface RuleDetection {
|
|
21
23
|
records: NarrowRecord[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../src/engine-ts/kernel.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEvG;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,CAAC,EAAE,MAAM,CAAC;IACV,uDAAuD;IACvD,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,YAAY,EAAE,iBAAiB,CAAC;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../src/engine-ts/kernel.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEvG;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,CAAC,EAAE,MAAM,CAAC;IACV,uDAAuD;IACvD,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,YAAY,EAAE,iBAAiB,CAAC;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,EAAE,IAAI,CAAC;IACb,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,mFAAmF;IACnF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wEAAwE;IACxE,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACxC;;;;OAIG;IACH,UAAU,CACR,QAAQ,EAAE,YAAY,EAAE,EACxB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EACvB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACjD,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1C,6DAA6D;IAC7D,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB"}
|
|
@@ -11,6 +11,14 @@ export interface NarrowResult {
|
|
|
11
11
|
distanceKind: ClashDistanceKind;
|
|
12
12
|
point: Vec3;
|
|
13
13
|
bounds: AABB;
|
|
14
|
+
/**
|
|
15
|
+
* For a `hard` result, the f32 noise floor of `distance` along the
|
|
16
|
+
* direction it was measured (`depthFloor` / `estimateFloor`): the depth at
|
|
17
|
+
* or below which this pair would have been `touch`. Absent otherwise.
|
|
18
|
+
* Carried out so the reported touching band is decided by the same rule as
|
|
19
|
+
* the verdict (#5639). Mirrors the Rust `NarrowResult::depth_floor`.
|
|
20
|
+
*/
|
|
21
|
+
depthFloor?: number;
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* Narrow-phase test for one candidate element pair.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"narrow.d.ts","sourceRoot":"","sources":["../../src/engine-ts/narrow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKvG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,iBAAiB,CAAC;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"narrow.d.ts","sourceRoot":"","sources":["../../src/engine-ts/narrow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKvG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,iBAAiB,CAAC;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,EAAE,IAAI,CAAC;IACb;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,GAChB,YAAY,GAAG,IAAI,CAgQrB"}
|
package/dist/engine-ts/narrow.js
CHANGED
|
@@ -5,7 +5,7 @@ import { aabbContains, boundsOfPoints, center, inflate, overlapBounds, signedGap
|
|
|
5
5
|
import { centroid, mid } from '../math/vec3.js';
|
|
6
6
|
import { triTriIntersect } from '../math/triangle-intersect.js';
|
|
7
7
|
import { triTriDistance } from '../math/triangle-distance.js';
|
|
8
|
-
import { boxPenetration, crossingVertexPenetration, depthClashResult } from './depth.js';
|
|
8
|
+
import { boxPenetration, containedSolidIsBuried, crossingVertexPenetration, depthClashResult } from './depth.js';
|
|
9
9
|
/**
|
|
10
10
|
* Narrow-phase test for one candidate element pair.
|
|
11
11
|
*
|
|
@@ -165,32 +165,36 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
|
|
|
165
165
|
// extent), so without it a flush contained pair — whose only measurable
|
|
166
166
|
// penetration is f32 noise — would be promoted to `hard` at a number
|
|
167
167
|
// that measures nothing (the eight Infra-Bridge pairs, see
|
|
168
|
-
// `depthClashResult`).
|
|
168
|
+
// `depthClashResult`). Since #5406 a pair flush to within the tri-tri
|
|
169
|
+
// predicate's own f32 noise band no longer crosses at all; this still
|
|
170
|
+
// decides a crossing above that band but at or below its precision floor.
|
|
171
|
+
// `null` means "no crossing vertex inside at all" (e.g. a thin member
|
|
172
|
+
// piercing straight through) — no evidence either way, not evidence of a
|
|
173
|
+
// sub-floor contact. The deeper side wins, the small side on a tie (the
|
|
174
|
+
// Rust kernel's order).
|
|
169
175
|
let meshEvidence = null;
|
|
170
176
|
if (crossSmall !== null && crossLarge !== null) {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
// of a sub-floor contact.
|
|
175
|
-
if (d > 0)
|
|
176
|
-
meshEvidence = d;
|
|
177
|
+
const s = crossingVertexPenetration(small, large, crossSmall);
|
|
178
|
+
const l = crossingVertexPenetration(large, small, crossLarge);
|
|
179
|
+
meshEvidence = s !== null && l !== null && l.depth > s.depth ? l : (s ?? l);
|
|
177
180
|
}
|
|
178
181
|
return depthClashResult(boxPenetration(small, large), Math.max(0, -signedGap(elA.bounds, elB.bounds)), meshEvidence, elA, elB, rule, point, contactBounds);
|
|
179
182
|
}
|
|
180
183
|
// Fully-enclosed solid: no surface crossing, but one element's AABB is wholly
|
|
181
184
|
// inside the other's, so it may be buried (e.g. equipment inside a slab). With
|
|
182
185
|
// no surface crossing the inner solid is entirely inside OR entirely outside
|
|
183
|
-
// the other, so ray-casting ONE
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
+
// the other, so ray-casting ONE probe point of the contained mesh against the
|
|
187
|
+
// other solid decides it — and ray casting (not an AABB test) correctly
|
|
188
|
+
// returns "outside" when the inner sits in a concave notch. The probe is
|
|
189
|
+
// chosen off the other's surface, see `containedSolidIsBuried` (#5473).
|
|
186
190
|
// Test B-contains-A first, then A-contains-B, so the inner pick is
|
|
187
191
|
// deterministic (and identical to the Rust kernel) on equal AABBs.
|
|
188
192
|
// Either way there is no surface crossing. When both elements are boxes the
|
|
189
193
|
// exact box-box depth is available (see `boxPenetration`) and is reported
|
|
190
194
|
// as measured; otherwise the AABB gap is an estimate, not a measured depth.
|
|
191
195
|
const enclosed = aabbContains(elB.bounds, elA.bounds)
|
|
192
|
-
? triA
|
|
193
|
-
: aabbContains(elA.bounds, elB.bounds) && triB
|
|
196
|
+
? containedSolidIsBuried(triA, triB)
|
|
197
|
+
: aabbContains(elA.bounds, elB.bounds) && containedSolidIsBuried(triB, triA);
|
|
194
198
|
if (enclosed) {
|
|
195
199
|
// `depthClashResult` may return `null` here (below the f32 floor and
|
|
196
200
|
// `!rule.reportTouch`) — that is a suppressed touch, not "no clash",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"narrow.js","sourceRoot":"","sources":["../../src/engine-ts/narrow.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAG/D,OAAO,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Q,EAAE,QAAQ,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,uEAAuE;IACvE,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QACnC,OAAO;YACL,MAAM,EAAE,OAAO;YACf,QAAQ,EAAE,OAAO;YACjB,YAAY,EAAE,MAAM;YACpB,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC;YAC9B,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MeshLike, type Obb } from './obb.js';
|
|
2
|
+
/**
|
|
3
|
+
* Detect whether `mesh` is a rectangular box: every (non-degenerate)
|
|
4
|
+
* triangle's normal falls into exactly 3 mutually orthogonal canonical
|
|
5
|
+
* directions, and every vertex of the triangles in a direction group lies on
|
|
6
|
+
* one of exactly two offset planes along that direction. That combination —
|
|
7
|
+
* 3 orthogonal face families, 2 planes each — forces the mesh to be a closed
|
|
8
|
+
* rectangular box (it rejects, for example, an axis-aligned L-shape, whose
|
|
9
|
+
* notch adds a third offset plane on two of the axes). Triangulation-
|
|
10
|
+
* independent: subdividing a box's faces adds triangles but never a new
|
|
11
|
+
* canonical direction or a third offset plane, so the detection (and the
|
|
12
|
+
* resulting `Obb`) is identical at any tessellation.
|
|
13
|
+
*
|
|
14
|
+
* Returns `null` — not a best-effort guess — when the check fails, so a
|
|
15
|
+
* caller that only trusts a non-null result never certifies a shape this
|
|
16
|
+
* function could not confirm.
|
|
17
|
+
*/
|
|
18
|
+
export declare function detectObb(mesh: MeshLike): Obb | null;
|
|
19
|
+
//# sourceMappingURL=obb-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obb-detect.d.ts","sourceRoot":"","sources":["../../src/engine-ts/obb-detect.ts"],"names":[],"mappings":"AAeA,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAwE5D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,GAAG,IAAI,CAwFpD"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { sub, cross, dot } from '../math/vec3.js';
|
|
5
|
+
import { OBB_EPS } from './obb.js';
|
|
6
|
+
function normalize(v) {
|
|
7
|
+
const len = Math.sqrt(dot(v, v));
|
|
8
|
+
if (!(len > OBB_EPS))
|
|
9
|
+
return null;
|
|
10
|
+
return [v[0] / len, v[1] / len, v[2] / len];
|
|
11
|
+
}
|
|
12
|
+
/** Flip `n` so its largest-magnitude component is positive, so a face and its
|
|
13
|
+
* antipodal opposite face collapse to the same canonical axis direction. Ties
|
|
14
|
+
* broken in x, y, z order — identical to the Rust `canonical`. */
|
|
15
|
+
function canonical(n) {
|
|
16
|
+
const ax = Math.abs(n[0]);
|
|
17
|
+
const ay = Math.abs(n[1]);
|
|
18
|
+
const az = Math.abs(n[2]);
|
|
19
|
+
let idx = 0;
|
|
20
|
+
if (ay > ax && ay >= az)
|
|
21
|
+
idx = 1;
|
|
22
|
+
else if (az > ax && az > ay)
|
|
23
|
+
idx = 2;
|
|
24
|
+
return n[idx] < 0 ? [-n[0], -n[1], -n[2]] : n;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* f32-ULP scale factor for a "worst-case" single-precision coordinate: for a
|
|
28
|
+
* value with magnitude in `[2, 4)` the true float32 ULP is `2^-22`, and for
|
|
29
|
+
* larger magnitudes the ULP only grows. Same constant (and reasoning) as
|
|
30
|
+
* `F32_ULP_SCALE` in `./depth.js`, and unlike the copies in `../contact/` it
|
|
31
|
+
* really is scaling the same quantity — the f32 quantisation of the same
|
|
32
|
+
* vertex buffer. It is still local because `./depth.js` imports THIS module
|
|
33
|
+
* (`obbPenetration`, `isThroughPenetration`), so importing the constant
|
|
34
|
+
* back out of it would close an import cycle for a one-line literal.
|
|
35
|
+
*/
|
|
36
|
+
const F32_ULP_SCALE = 1 / 4_194_304; // 2^-22
|
|
37
|
+
/**
|
|
38
|
+
* Bound, in radians, on the direction error of a face normal computed as
|
|
39
|
+
* `cross(b - a, c - a)` from vertices that arrived as f32.
|
|
40
|
+
*
|
|
41
|
+
* The vertices carry an absolute coordinate error of about
|
|
42
|
+
* `max|coord| * 2^-22` (`F32_ULP_SCALE`, the same f32-ULP bound the
|
|
43
|
+
* penetration floor uses), so each edge does too. `|cross| = |e1||e2|sin t`,
|
|
44
|
+
* and perturbing the edges by `d` tilts the normal by at most
|
|
45
|
+
* `d * (|e1| + |e2|) / |cross|`. The denominator makes this a property of the
|
|
46
|
+
* TRIANGLE's conditioning rather than a constant: a sliver, or a face with
|
|
47
|
+
* one very short edge, resolves its normal far less sharply than a
|
|
48
|
+
* well-shaped one at the same distance from the origin.
|
|
49
|
+
*
|
|
50
|
+
* This is the quantity an absolute `OBB_EPS` was standing in for, and a fixed
|
|
51
|
+
* bound is simultaneously too loose near the origin and far too tight away
|
|
52
|
+
* from it: a 0.05 m thick panel 1 km out resolves its normals to ~2.7e-4, so
|
|
53
|
+
* `|dot|` between two genuinely perpendicular faces exceeded `1e-6` and the
|
|
54
|
+
* box stopped being recognised as a box purely because it had been
|
|
55
|
+
* translated (#5355).
|
|
56
|
+
*/
|
|
57
|
+
function normalAngleError(a, b, c) {
|
|
58
|
+
const e1 = sub(b, a);
|
|
59
|
+
const e2 = sub(c, a);
|
|
60
|
+
let maxAbs = 0;
|
|
61
|
+
for (const v of [a, b, c]) {
|
|
62
|
+
for (const k of v) {
|
|
63
|
+
const m = Math.abs(k);
|
|
64
|
+
if (m > maxAbs)
|
|
65
|
+
maxAbs = m;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const coordErr = Math.max(maxAbs, 1) * F32_ULP_SCALE;
|
|
69
|
+
const n = cross(e1, e2);
|
|
70
|
+
const nLen = Math.sqrt(dot(n, n));
|
|
71
|
+
if (!(nLen > 0))
|
|
72
|
+
return Infinity;
|
|
73
|
+
const e1Len = Math.sqrt(dot(e1, e1));
|
|
74
|
+
const e2Len = Math.sqrt(dot(e2, e2));
|
|
75
|
+
return (coordErr * (e1Len + e2Len)) / nLen;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Detect whether `mesh` is a rectangular box: every (non-degenerate)
|
|
79
|
+
* triangle's normal falls into exactly 3 mutually orthogonal canonical
|
|
80
|
+
* directions, and every vertex of the triangles in a direction group lies on
|
|
81
|
+
* one of exactly two offset planes along that direction. That combination —
|
|
82
|
+
* 3 orthogonal face families, 2 planes each — forces the mesh to be a closed
|
|
83
|
+
* rectangular box (it rejects, for example, an axis-aligned L-shape, whose
|
|
84
|
+
* notch adds a third offset plane on two of the axes). Triangulation-
|
|
85
|
+
* independent: subdividing a box's faces adds triangles but never a new
|
|
86
|
+
* canonical direction or a third offset plane, so the detection (and the
|
|
87
|
+
* resulting `Obb`) is identical at any tessellation.
|
|
88
|
+
*
|
|
89
|
+
* Returns `null` — not a best-effort guess — when the check fails, so a
|
|
90
|
+
* caller that only trusts a non-null result never certifies a shape this
|
|
91
|
+
* function could not confirm.
|
|
92
|
+
*/
|
|
93
|
+
export function detectObb(mesh) {
|
|
94
|
+
if (mesh.count === 0)
|
|
95
|
+
return null;
|
|
96
|
+
const groups = [];
|
|
97
|
+
// Per-family bound on the representative normal's direction error.
|
|
98
|
+
const groupErr = [];
|
|
99
|
+
const groupOfTri = new Array(mesh.count).fill(-1);
|
|
100
|
+
for (let t = 0; t < mesh.count; t += 1) {
|
|
101
|
+
const [a, b, c] = mesh.tri(t);
|
|
102
|
+
const n = normalize(cross(sub(b, a), sub(c, a)));
|
|
103
|
+
if (!n)
|
|
104
|
+
continue; // degenerate triangle: contributes no face-normal evidence
|
|
105
|
+
const cn = canonical(n);
|
|
106
|
+
let gi = -1;
|
|
107
|
+
for (let g = 0; g < groups.length; g += 1) {
|
|
108
|
+
if (dot(groups[g], cn) > 1 - OBB_EPS) {
|
|
109
|
+
gi = g;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (gi === -1) {
|
|
114
|
+
if (groups.length >= 3)
|
|
115
|
+
return null; // a 4th face-normal family: not a box
|
|
116
|
+
groups.push(cn);
|
|
117
|
+
// The representative IS this triangle's normal, so the bound that
|
|
118
|
+
// applies to the orthogonality test below is this triangle's.
|
|
119
|
+
groupErr.push(normalAngleError(a, b, c));
|
|
120
|
+
gi = groups.length - 1;
|
|
121
|
+
}
|
|
122
|
+
groupOfTri[t] = gi;
|
|
123
|
+
}
|
|
124
|
+
if (groups.length !== 3)
|
|
125
|
+
return null;
|
|
126
|
+
for (let i = 0; i < 3; i += 1) {
|
|
127
|
+
for (let j = i + 1; j < 3; j += 1) {
|
|
128
|
+
// Two unit normals each uncertain in direction by `groupErr` can read
|
|
129
|
+
// as non-perpendicular by up to the sum of those angles
|
|
130
|
+
// (`|dot| = |cos(90deg +/- e)| <= sin e_i + sin e_j <= e_i + e_j`).
|
|
131
|
+
// `OBB_EPS` stays as a FLOOR so a mesh at the origin, where the derived
|
|
132
|
+
// bound collapses towards zero, is judged exactly as strictly as it was
|
|
133
|
+
// before #5355.
|
|
134
|
+
const tol = Math.max(groupErr[i] + groupErr[j], OBB_EPS);
|
|
135
|
+
if (Math.abs(dot(groups[i], groups[j])) > tol)
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const minOff = [Infinity, Infinity, Infinity];
|
|
140
|
+
const maxOff = [-Infinity, -Infinity, -Infinity];
|
|
141
|
+
for (let t = 0; t < mesh.count; t += 1) {
|
|
142
|
+
const gi = groupOfTri[t];
|
|
143
|
+
if (gi === -1)
|
|
144
|
+
continue;
|
|
145
|
+
const [a, b, c] = mesh.tri(t);
|
|
146
|
+
for (const v of [a, b, c]) {
|
|
147
|
+
const o = dot(v, groups[gi]);
|
|
148
|
+
if (o < minOff[gi])
|
|
149
|
+
minOff[gi] = o;
|
|
150
|
+
if (o > maxOff[gi])
|
|
151
|
+
maxOff[gi] = o;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Reject a 3rd offset plane on any axis (e.g. an L-shaped footprint).
|
|
155
|
+
for (let t = 0; t < mesh.count; t += 1) {
|
|
156
|
+
const gi = groupOfTri[t];
|
|
157
|
+
if (gi === -1)
|
|
158
|
+
continue;
|
|
159
|
+
const [a, b, c] = mesh.tri(t);
|
|
160
|
+
for (const v of [a, b, c]) {
|
|
161
|
+
const o = dot(v, groups[gi]);
|
|
162
|
+
const scale = Math.max(1, Math.abs(minOff[gi]), Math.abs(maxOff[gi]));
|
|
163
|
+
const nearMin = Math.abs(o - minOff[gi]) <= OBB_EPS * scale;
|
|
164
|
+
const nearMax = Math.abs(o - maxOff[gi]) <= OBB_EPS * scale;
|
|
165
|
+
if (!nearMin && !nearMax)
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const half = [0, 0, 0];
|
|
170
|
+
const c0 = [0, 0, 0];
|
|
171
|
+
for (let i = 0; i < 3; i += 1) {
|
|
172
|
+
half[i] = (maxOff[i] - minOff[i]) / 2;
|
|
173
|
+
c0[i] = (maxOff[i] + minOff[i]) / 2;
|
|
174
|
+
// Reject a zero-thickness "box": a face family whose triangles are all
|
|
175
|
+
// coplanar passes the 2-plane test above (minOff == maxOff, so both
|
|
176
|
+
// `nearMin` and `nearMax` hold for every vertex) with no positive
|
|
177
|
+
// extent along that axis. An open shell (a slab exported without its
|
|
178
|
+
// top face, or partial `IfcTriangulatedFaceSet` geometry) can produce
|
|
179
|
+
// exactly this — 3 orthogonal families, but one degenerate — and must
|
|
180
|
+
// not be certified as a box (review: #2536).
|
|
181
|
+
if (!(half[i] > OBB_EPS))
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const center = [
|
|
185
|
+
c0[0] * groups[0][0] + c0[1] * groups[1][0] + c0[2] * groups[2][0],
|
|
186
|
+
c0[0] * groups[0][1] + c0[1] * groups[1][1] + c0[2] * groups[2][1],
|
|
187
|
+
c0[0] * groups[0][2] + c0[1] * groups[1][2] + c0[2] * groups[2][2],
|
|
188
|
+
];
|
|
189
|
+
return { center, axes: [groups[0], groups[1], groups[2]], half };
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=obb-detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obb-detect.js","sourceRoot":"","sources":["../../src/engine-ts/obb-detect.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,EAA2B,MAAM,UAAU,CAAC;AAE5D,SAAS,SAAS,CAAC,CAAO;IACxB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED;;kEAEkE;AAClE,SAAS,SAAS,CAAC,CAAO;IACxB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC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,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AACnE,CAAC"}
|
package/dist/engine-ts/obb.d.ts
CHANGED
|
@@ -32,31 +32,21 @@ export interface MeshLike {
|
|
|
32
32
|
readonly count: number;
|
|
33
33
|
tri(t: number): [Vec3, Vec3, Vec3];
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Detect whether `mesh` is a rectangular box: every (non-degenerate)
|
|
37
|
-
* triangle's normal falls into exactly 3 mutually orthogonal canonical
|
|
38
|
-
* directions, and every vertex of the triangles in a direction group lies on
|
|
39
|
-
* one of exactly two offset planes along that direction. That combination —
|
|
40
|
-
* 3 orthogonal face families, 2 planes each — forces the mesh to be a closed
|
|
41
|
-
* rectangular box (it rejects, for example, an axis-aligned L-shape, whose
|
|
42
|
-
* notch adds a third offset plane on two of the axes). Triangulation-
|
|
43
|
-
* independent: subdividing a box's faces adds triangles but never a new
|
|
44
|
-
* canonical direction or a third offset plane, so the detection (and the
|
|
45
|
-
* resulting `Obb`) is identical at any tessellation.
|
|
46
|
-
*
|
|
47
|
-
* Returns `null` — not a best-effort guess — when the check fails, so a
|
|
48
|
-
* caller that only trusts a non-null result never certifies a shape this
|
|
49
|
-
* function could not confirm.
|
|
50
|
-
*/
|
|
51
|
-
export declare function detectObb(mesh: MeshLike): Obb | null;
|
|
52
35
|
/**
|
|
53
36
|
* Bound, in f64 ulps, on the absolute error of one component of the cross
|
|
54
37
|
* product of two UNIT vectors (each component is a product-difference of
|
|
55
38
|
* magnitude-<=1 terms: ~2 ulps), with headroom for the normalisation and the
|
|
56
39
|
* per-projection dot rounding it feeds. Shared by the axis noise bound in
|
|
57
|
-
* {@link
|
|
40
|
+
* {@link obbPenetration}; same literal in the Rust kernel.
|
|
58
41
|
*/
|
|
59
42
|
export declare const AXIS_NOISE_ULPS = 8;
|
|
43
|
+
/** An OBB-OBB minimum translation depth and the UNIT axis it was measured
|
|
44
|
+
* along: the depth's precision floor is the pair's f32 noise projected onto
|
|
45
|
+
* that axis (#5405). Mirrors the Rust `ObbPenetration`. */
|
|
46
|
+
export interface ObbPenetration {
|
|
47
|
+
depth: number;
|
|
48
|
+
axis: Vec3;
|
|
49
|
+
}
|
|
60
50
|
/**
|
|
61
51
|
* Exact penetration depth between two oriented boxes: the minimum overlap
|
|
62
52
|
* over the 15 canonical OBB-OBB separating-axis candidates (each box's 3 face
|
|
@@ -70,8 +60,9 @@ export declare const AXIS_NOISE_ULPS = 8;
|
|
|
70
60
|
* the ~ulp-level absolute error of the cross product into a direction error
|
|
71
61
|
* of up to `AXIS_NOISE_ULPS * EPS / |L|` radians. Each candidate's verdict
|
|
72
62
|
* therefore carries a SCALE-RELATIVE noise bound (see `testAxis`), and a
|
|
73
|
-
* verdict inside its own noise band is
|
|
74
|
-
*
|
|
63
|
+
* verdict inside its own noise band is never trusted to separate, and
|
|
64
|
+
* contributes a depth candidate of zero rather than being dropped from the
|
|
65
|
+
* minimum (#5355) (review: #2536; the same
|
|
75
66
|
* tolerance-from-the-wrong-quantity class as #2598/#2600/#2529 — an earlier
|
|
76
67
|
* ABSOLUTE `len > 1e-6` guard here both divided by lengths whose noise
|
|
77
68
|
* dwarfs a thin overlap at large operand scale, and hard-dropped axes that
|
|
@@ -86,7 +77,7 @@ export declare const AXIS_NOISE_ULPS = 8;
|
|
|
86
77
|
* `null` (caller falls back to the AABB estimate) rather than reporting a
|
|
87
78
|
* wrong depth.
|
|
88
79
|
*/
|
|
89
|
-
export declare function
|
|
80
|
+
export declare function obbPenetration(a: Obb, b: Obb): ObbPenetration | null;
|
|
90
81
|
/**
|
|
91
82
|
* Whether `a` and `b` are in a THROUGH-PENETRATION configuration: one box's
|
|
92
83
|
* cross-section, in the plane perpendicular to one of ITS OWN axes, is fully
|
|
@@ -96,7 +87,7 @@ export declare function obbPenetrationDepth(a: Obb, b: Obb): number | null;
|
|
|
96
87
|
* ways, so it also holds for the MUTUAL case: two walls crossing at an
|
|
97
88
|
* X-junction, each piercing the other clean through in thickness.
|
|
98
89
|
*
|
|
99
|
-
* This matters because {@link
|
|
90
|
+
* This matters because {@link obbPenetration} reports the minimum
|
|
100
91
|
* TRANSLATION distance to separate the pair, which for this shape is
|
|
101
92
|
* dominated by the piercing member's own extent along the piercing axis, not
|
|
102
93
|
* by how much material it actually crossed (review: #2536 — a 2 m duct
|
|
@@ -105,7 +96,7 @@ export declare function obbPenetrationDepth(a: Obb, b: Obb): number | null;
|
|
|
105
96
|
*
|
|
106
97
|
* Tests containment against EACH box's own axes independently (via
|
|
107
98
|
* {@link piercesAlong}'s general per-axis projection, the same projection
|
|
108
|
-
* {@link
|
|
99
|
+
* {@link obbPenetration} already computes for its 15 SAT candidates) —
|
|
109
100
|
* unlike an earlier version restricted to a frame shared by both boxes'
|
|
110
101
|
* axes up to sign, this also catches a member piercing through at a generic
|
|
111
102
|
* relative rotation (e.g. a duct crossing a wall at 15 degrees, review:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obb.d.ts","sourceRoot":"","sources":["../../src/engine-ts/obb.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxC;+DAC+D;AAC/D,eAAO,MAAM,OAAO,WAAO,CAAC;AAE5B,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,IAAI,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzB,6DAA6D;IAC7D,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;yDACyD;AACzD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;CACpC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