@ifc-lite/clash 1.7.0 → 1.8.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.
Files changed (62) hide show
  1. package/dist/analysis.d.ts +10 -1
  2. package/dist/analysis.d.ts.map +1 -1
  3. package/dist/analysis.js +20 -0
  4. package/dist/analysis.js.map +1 -1
  5. package/dist/contact/narrow-phase.d.ts +3 -2
  6. package/dist/contact/narrow-phase.d.ts.map +1 -1
  7. package/dist/contact/narrow-phase.js +32 -14
  8. package/dist/contact/narrow-phase.js.map +1 -1
  9. package/dist/contact/tri-tri.d.ts +33 -7
  10. package/dist/contact/tri-tri.d.ts.map +1 -1
  11. package/dist/contact/tri-tri.js +37 -14
  12. package/dist/contact/tri-tri.js.map +1 -1
  13. package/dist/duplicate-metric.d.ts +26 -8
  14. package/dist/duplicate-metric.d.ts.map +1 -1
  15. package/dist/duplicate-metric.js +26 -8
  16. package/dist/duplicate-metric.js.map +1 -1
  17. package/dist/duplicates.d.ts +9 -0
  18. package/dist/duplicates.d.ts.map +1 -1
  19. package/dist/duplicates.js +53 -18
  20. package/dist/duplicates.js.map +1 -1
  21. package/dist/engine-ts/depth.d.ts +99 -0
  22. package/dist/engine-ts/depth.d.ts.map +1 -0
  23. package/dist/engine-ts/depth.js +172 -0
  24. package/dist/engine-ts/depth.js.map +1 -0
  25. package/dist/engine-ts/kernel.d.ts +3 -1
  26. package/dist/engine-ts/kernel.d.ts.map +1 -1
  27. package/dist/engine-ts/narrow.d.ts +7 -1
  28. package/dist/engine-ts/narrow.d.ts.map +1 -1
  29. package/dist/engine-ts/narrow.js +53 -95
  30. package/dist/engine-ts/narrow.js.map +1 -1
  31. package/dist/engine-ts/obb.d.ts +116 -0
  32. package/dist/engine-ts/obb.d.ts.map +1 -0
  33. package/dist/engine-ts/obb.js +331 -0
  34. package/dist/engine-ts/obb.js.map +1 -0
  35. package/dist/engine-ts/orchestrator.d.ts.map +1 -1
  36. package/dist/engine-ts/orchestrator.js +3 -13
  37. package/dist/engine-ts/orchestrator.js.map +1 -1
  38. package/dist/engine-ts/tri-mesh.d.ts +84 -22
  39. package/dist/engine-ts/tri-mesh.d.ts.map +1 -1
  40. package/dist/engine-ts/tri-mesh.js +151 -48
  41. package/dist/engine-ts/tri-mesh.js.map +1 -1
  42. package/dist/engine-ts/ts-kernel.d.ts.map +1 -1
  43. package/dist/engine-ts/ts-kernel.js +1 -0
  44. package/dist/engine-ts/ts-kernel.js.map +1 -1
  45. package/dist/engine-wasm/wasm-kernel.d.ts.map +1 -1
  46. package/dist/engine-wasm/wasm-kernel.js +7 -0
  47. package/dist/engine-wasm/wasm-kernel.js.map +1 -1
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +2 -2
  51. package/dist/index.js.map +1 -1
  52. package/dist/math/aabb.d.ts +10 -1
  53. package/dist/math/aabb.d.ts.map +1 -1
  54. package/dist/math/aabb.js +33 -13
  55. package/dist/math/aabb.js.map +1 -1
  56. package/dist/triage.d.ts.map +1 -1
  57. package/dist/triage.js +11 -3
  58. package/dist/triage.js.map +1 -1
  59. package/dist/types.d.ts +39 -0
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/types.js.map +1 -1
  62. package/package.json +4 -3
@@ -5,57 +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
- /**
9
- * f32-ULP scale factor for a "worst-case" single-precision coordinate: for a
10
- * value with magnitude in `[2, 4)` the true float32 ULP is `2^-22`, and for
11
- * larger magnitudes the ULP only grows. Same `2^-22` term (and reasoning) as
12
- * `near_band_from_extent` in `rust/geometry/src/kernel/mesh_bridge.rs` — see
13
- * that function's doc for the derivation; kept here rather than shared
14
- * because the two live in different language runtimes.
15
- */
16
- const F32_ULP_SCALE = 1 / 4_194_304; // 2^-22
17
- /**
18
- * Penetration-depth floor below which a computed overlap cannot be
19
- * distinguished from float32 rounding noise, scaled to the pair's own
20
- * coordinate magnitude (not a fixed constant — infra models sit far from the
21
- * origin, where a fixed epsilon would be far too tight, and small models sit
22
- * near it, where a fixed epsilon would be far too loose).
23
- *
24
- * `rust/clash/src/tri_mesh.rs` ingests geometry from f32 buffers and stores/
25
- * queries it in f64, so f64 arithmetic cannot recover precision the source
26
- * data never had: two surfaces authored to be flush round to adjacent f32
27
- * values, and the resulting "penetration" is bit-noise at the ULP of
28
- * whichever operand coordinate is largest, not a measured overlap. Extent is
29
- * the max abs coordinate over both elements' AABBs (world space, matching
30
- * `near_band_from_extent`'s use of the actual compared coordinates) with a
31
- * floor of 1.0 so a model near the origin still gets the single-unit ULP,
32
- * not zero.
33
- *
34
- * The floor grows linearly with the pair's distance from the origin — that
35
- * is the point, since f32 precision itself degrades the same way. The
36
- * consequence: on a georeferenced model whose elements sit at real map
37
- * coordinates (hundreds of kilometres out, which real IFC files do), the
38
- * floor reaches decimetre scale, and a genuine clash below that threshold
39
- * reclassifies as `touch`. That is not a bug in this function — at those
40
- * magnitudes f32 genuinely cannot represent a finer distinction, so the
41
- * "penetration" is not reliably measurable either way — but it means the
42
- * floor tracks a limitation of the source data, not of clash detection.
43
- * The fix for a model in that position is ingesting geometry closer to the
44
- * origin (or in f64), not lowering this floor.
45
- */
46
- function precisionFloor(elA, elB) {
47
- let extent = 1.0;
48
- for (const b of [elA.bounds, elB.bounds]) {
49
- for (const v of [b.min, b.max]) {
50
- for (const c of v) {
51
- const a = Math.abs(c);
52
- if (a > extent)
53
- extent = a;
54
- }
55
- }
56
- }
57
- return extent * F32_ULP_SCALE;
58
- }
8
+ import { boxPenetration, crossingVertexPenetration, depthClashResult } from './depth.js';
59
9
  /**
60
10
  * Narrow-phase test for one candidate element pair.
61
11
  *
@@ -75,10 +25,14 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
75
25
  const aSmaller = triA.count <= triB.count;
76
26
  const small = aSmaller ? triA : triB;
77
27
  const large = aSmaller ? triB : triA;
78
- // One AABB containing the other flags the contained-contact case (#1866):
79
- // for such pairs the AABB signed gap measures how deep the small BOX sits in
80
- // the big one (its own extent), not how far the MESHES interpenetrate, so
81
- // collect the crossing triangles for a mesh-level depth measurement instead.
28
+ // A CONTAINED pair (one element's AABB wholly inside the other's) is the
29
+ // one class whose AABB estimate is fabricated the signed gap reads the
30
+ // small element's own extent, not anything about the overlap (#1866) so
31
+ // for such pairs collect the crossing triangles: their vertices are the
32
+ // mesh-level evidence `depthClashResult`'s f32 noise-floor gate needs (see
33
+ // `crossingVertexPenetration` — evidence for the floor test only, never a
34
+ // reported depth). Allocated only for contained pairs; every other pair
35
+ // has a genuine AABB overlap bound to floor-test instead.
82
36
  const contained = aabbContains(elB.bounds, elA.bounds) || aabbContains(elA.bounds, elB.bounds);
83
37
  const crossSmall = contained ? new Uint8Array(small.count) : null;
84
38
  const crossLarge = contained ? new Uint8Array(large.count) : null;
@@ -198,33 +152,30 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
198
152
  const point = contactN > 0
199
153
  ? [contactSumX / contactN, contactSumY / contactN, contactSumZ / contactN]
200
154
  : center(overlap);
201
- // Penetration estimate from the AABB overlap...
202
- let penetration = Math.max(0, -signedGap(elA.bounds, elB.bounds));
203
- // ...EXCEPT for a contained pair (#1866): there the AABB overlap equals the
204
- // small element's own extent, wildly overstating depth for designed face
205
- // contacts (e.g. opening fills inset in their host). Measure the real
206
- // mesh-level depth instead: the deepest crossing-triangle vertex of either
207
- // mesh inside the other solid. Falls back to the AABB estimate when no such
208
- // vertex lies inside (thin member piercing straight through).
155
+ // Exact box-box penetration depth when both elements are rectangular
156
+ // boxes (see `boxPenetration`); otherwise fall back to the AABB overlap,
157
+ // i.e. the smallest overlapping box dimension. That fallback is an
158
+ // estimate, not a measured depth for a non-box shape it can report a
159
+ // dimension of one of the elements rather than how far they interpenetrate.
160
+ // `depthClashResult` applies the f32 floor to EVERY candidate depth
161
+ // before any estimate-vs-mesh selection, so a pair below the floor
162
+ // reports `touch` regardless of which quantity would have been reported.
163
+ // For a contained pair the crossing-vertex penetration is that third
164
+ // candidate: the estimate is fabricated there (the small element's own
165
+ // extent), so without it a flush contained pair — whose only measurable
166
+ // penetration is f32 noise — would be promoted to `hard` at a number
167
+ // that measures nothing (the eight Infra-Bridge pairs, see
168
+ // `depthClashResult`).
169
+ let meshEvidence = null;
209
170
  if (crossSmall !== null && crossLarge !== null) {
210
- const meshDepth = Math.max(small.maxPenetrationInto(large, crossSmall), large.maxPenetrationInto(small, crossLarge));
211
- if (meshDepth > 0)
212
- penetration = meshDepth;
213
- }
214
- // A genuine triangle crossing was found, but the measured depth is at or
215
- // below the f32 precision floor for this pair's coordinate scale: it
216
- // cannot be distinguished from rounding noise (see `precisionFloor`),
217
- // so it is not a measured overlap. Reclassify as `touch` rather than
218
- // `hard` — the crossing still means the surfaces are in contact, which
219
- // is real information (and this codebase already distinguishes touching
220
- // from overlapping, e.g. the viewer's `clashHideTouching` toggle) —
221
- // rather than silently dropping the pair or reporting a fabricated depth.
222
- if (penetration <= precisionFloor(elA, elB)) {
223
- if (!rule.reportTouch)
224
- return null;
225
- return { status: 'touch', distance: 0, point, bounds: contactBounds };
171
+ const d = Math.max(crossingVertexPenetration(small, large, crossSmall), crossingVertexPenetration(large, small, crossLarge));
172
+ // 0 means "no crossing vertex inside at all" (e.g. a thin member
173
+ // piercing straight through) — no evidence either way, not evidence
174
+ // of a sub-floor contact.
175
+ if (d > 0)
176
+ meshEvidence = d;
226
177
  }
227
- return { status: 'hard', distance: -penetration, point, bounds: contactBounds };
178
+ return depthClashResult(boxPenetration(small, large), Math.max(0, -signedGap(elA.bounds, elB.bounds)), meshEvidence, elA, elB, rule, point, contactBounds);
228
179
  }
229
180
  // Fully-enclosed solid: no surface crossing, but one element's AABB is wholly
230
181
  // inside the other's, so it may be buried (e.g. equipment inside a slab). With
@@ -234,15 +185,18 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
234
185
  // correctly returns "outside" when the inner sits in a concave notch.
235
186
  // Test B-contains-A first, then A-contains-B, so the inner pick is
236
187
  // deterministic (and identical to the Rust kernel) on equal AABBs.
237
- if (aabbContains(elB.bounds, elA.bounds)) {
238
- if (triA.count > 0 && triB.containsPoint(triA.tri(0)[0])) {
239
- return { status: 'hard', distance: signedGap(elA.bounds, elB.bounds), point: center(overlap), bounds: overlap };
240
- }
241
- }
242
- else if (aabbContains(elA.bounds, elB.bounds)) {
243
- if (triB.count > 0 && triA.containsPoint(triB.tri(0)[0])) {
244
- return { status: 'hard', distance: signedGap(elA.bounds, elB.bounds), point: center(overlap), bounds: overlap };
245
- }
188
+ // Either way there is no surface crossing. When both elements are boxes the
189
+ // exact box-box depth is available (see `boxPenetration`) and is reported
190
+ // as measured; otherwise the AABB gap is an estimate, not a measured depth.
191
+ const enclosed = aabbContains(elB.bounds, elA.bounds)
192
+ ? triA.count > 0 && triB.containsPoint(triA.tri(0)[0])
193
+ : aabbContains(elA.bounds, elB.bounds) && triB.count > 0 && triA.containsPoint(triB.tri(0)[0]);
194
+ if (enclosed) {
195
+ // `depthClashResult` may return `null` here (below the f32 floor and
196
+ // `!rule.reportTouch`) — that is a suppressed touch, not "no clash",
197
+ // so return it as-is rather than falling through to the coincide check
198
+ // below.
199
+ return depthClashResult(boxPenetration(small, large), -signedGap(elA.bounds, elB.bounds), null, elA, elB, rule, center(overlap), overlap);
246
200
  }
247
201
  if (minDist === Infinity) {
248
202
  // Broad-phase candidate with no triangle-level proximity — not a clash.
@@ -270,12 +224,13 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
270
224
  // actually coincide), clamped to the element overlap — not the whole-
271
225
  // element AABB intersection, which for angled members spans nearly the
272
226
  // full member length and sits away from the real contact (#1362/#1402).
273
- return {
274
- status: 'hard',
275
- distance: gap,
276
- point: mid(closestA, closestB),
277
- bounds: contactBounds,
278
- };
227
+ // When both elements are boxes the exact box-box depth is available
228
+ // (see `boxPenetration`) and is reported as measured, not estimated.
229
+ // `depthClashResult` may return `null` (below the f32 floor and
230
+ // `!rule.reportTouch`) — a suppressed touch, not "no shared volume",
231
+ // so return it as-is rather than falling through to the face-touch
232
+ // handling meant for the "probes failed" case below.
233
+ return depthClashResult(boxPenetration(small, large), -gap, null, elA, elB, rule, mid(closestA, closestB), contactBounds);
279
234
  }
280
235
  // Only a face touch (no shared volume): fall through to the touch handling
281
236
  // below, which suppresses it unless reportTouch is set.
@@ -288,6 +243,8 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
288
243
  return {
289
244
  status: 'clearance',
290
245
  distance: minDist,
246
+ // `minDist` is an exact triangle-to-triangle distance.
247
+ distanceKind: 'mesh',
291
248
  point: mid(closestA, closestB),
292
249
  bounds: boundsOfPoints(closestA, closestB),
293
250
  };
@@ -300,6 +257,7 @@ export function testPair(elA, triA, elB, triB, rule, tolerance) {
300
257
  return {
301
258
  status: 'touch',
302
259
  distance: minDist,
260
+ distanceKind: 'mesh',
303
261
  point: mid(closestA, closestB),
304
262
  bounds: boundsOfPoints(closestA, closestB),
305
263
  };
@@ -1 +1 @@
1
- {"version":3,"file":"narrow.js","sourceRoot":"","sources":["../../src/engine-ts/narrow.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAG/D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAU9D;;;;;;;GAOG;AACH,MAAM,aAAa,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,QAAQ;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAS,cAAc,CAAC,GA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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,116 @@
1
+ /**
2
+ * Exact penetration depth for the one shape family it can be exact for:
3
+ * rectangular boxes. `maxPenetrationInto` (removed) measured the distance from
4
+ * the nearest crossing-triangle VERTEX to the other surface — an O(edge
5
+ * length) sampling artifact that converges to 0 as a mesh is retessellated,
6
+ * the opposite of what a depth metric should do (see the analytic-oracle
7
+ * fixtures in `obb.test.ts`).
8
+ *
9
+ * This module instead detects when both meshes ARE (within tolerance)
10
+ * axis-independent rectangular boxes and, only then, reports the minimum
11
+ * translation distance along a separating axis — the classical two-OBB
12
+ * penetration depth, which for boxes is provably exact and, because it is
13
+ * derived from the box's face-plane geometry rather than its triangulation,
14
+ * provably unchanged by retessellation. When either mesh is not confirmed to
15
+ * be a box, the caller falls back to the AABB estimate (never a wrong 'mesh'
16
+ * label) — a smaller true thing rather than a large wrong one.
17
+ */
18
+ import type { Vec3 } from '../types.js';
19
+ /** Tolerance for normal-direction dedup and offset-plane clustering. Same
20
+ * literal in the Rust kernel — see `rust/clash/src/obb.rs`. */
21
+ export declare const OBB_EPS = 0.000001;
22
+ export interface Obb {
23
+ center: Vec3;
24
+ /** Three mutually orthogonal unit axes. */
25
+ axes: [Vec3, Vec3, Vec3];
26
+ /** Half-extent along each axis, matching `axes` by index. */
27
+ half: [number, number, number];
28
+ }
29
+ /** Minimal structural view of `TriMesh` this module needs — avoids a
30
+ * circular import between `obb.ts` and `tri-mesh.ts`. */
31
+ export interface MeshLike {
32
+ readonly count: number;
33
+ tri(t: number): [Vec3, Vec3, Vec3];
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
+ /**
53
+ * Bound, in f64 ulps, on the absolute error of one component of the cross
54
+ * product of two UNIT vectors (each component is a product-difference of
55
+ * magnitude-<=1 terms: ~2 ulps), with headroom for the normalisation and the
56
+ * per-projection dot rounding it feeds. Shared by the axis noise bound in
57
+ * {@link obbPenetrationDepth}; same literal in the Rust kernel.
58
+ */
59
+ export declare const AXIS_NOISE_ULPS = 8;
60
+ /**
61
+ * Exact penetration depth between two oriented boxes: the minimum overlap
62
+ * over the 15 canonical OBB-OBB separating-axis candidates (each box's 3 face
63
+ * normals, plus the 9 pairwise cross products of one box's axes with the
64
+ * other's) — the standard result (Gottschalk, "Collision Queries using
65
+ * Oriented Bounding Boxes") that the minimum-translation-distance axis for two
66
+ * boxes is always among these 15.
67
+ *
68
+ * Cross-product candidates are conditioned by their length: both operands are
69
+ * unit axes, so `|L| = sin(angle between them)`, and normalising amplifies
70
+ * the ~ulp-level absolute error of the cross product into a direction error
71
+ * of up to `AXIS_NOISE_ULPS * EPS / |L|` radians. Each candidate's verdict
72
+ * therefore carries a SCALE-RELATIVE noise bound (see `testAxis`), and a
73
+ * verdict inside its own noise band is skipped — not trusted to separate,
74
+ * not trusted as a depth (review: #2536; the same
75
+ * tolerance-from-the-wrong-quantity class as #2598/#2600/#2529 — an earlier
76
+ * ABSOLUTE `len > 1e-6` guard here both divided by lengths whose noise
77
+ * dwarfs a thin overlap at large operand scale, and hard-dropped axes that
78
+ * were fine: for kilometre-scale near-parallel beams the dropped common
79
+ * normal IS the
80
+ * minimum-translation axis, and the min over the remaining axes over-reported
81
+ * a 0.02 m edge contact as a certified 0.45 m depth — see `obb.test.ts`).
82
+ *
83
+ * Returns `null` if any candidate axis reports, beyond its noise band, zero
84
+ * or negative overlap — the boxes would be separated along it, contradicting
85
+ * the caller's own crossing test — so a numerical edge case degrades to
86
+ * `null` (caller falls back to the AABB estimate) rather than reporting a
87
+ * wrong depth.
88
+ */
89
+ export declare function obbPenetrationDepth(a: Obb, b: Obb): number | null;
90
+ /**
91
+ * Whether `a` and `b` are in a THROUGH-PENETRATION configuration: one box's
92
+ * cross-section, in the plane perpendicular to one of ITS OWN axes, is fully
93
+ * inside the other's footprint there, while along that axis it extends
94
+ * beyond the other and out the far side — a thin member piercing clean
95
+ * through a wall/slab, not a partial overlap. The relation is checked BOTH
96
+ * ways, so it also holds for the MUTUAL case: two walls crossing at an
97
+ * X-junction, each piercing the other clean through in thickness.
98
+ *
99
+ * This matters because {@link obbPenetrationDepth} reports the minimum
100
+ * TRANSLATION distance to separate the pair, which for this shape is
101
+ * dominated by the piercing member's own extent along the piercing axis, not
102
+ * by how much material it actually crossed (review: #2536 — a 2 m duct
103
+ * through a 200 mm wall reported 1.1 m, not 0.2 m). Detecting the shape lets
104
+ * the caller decline to certify that number as a measured depth.
105
+ *
106
+ * Tests containment against EACH box's own axes independently (via
107
+ * {@link piercesAlong}'s general per-axis projection, the same projection
108
+ * {@link obbPenetrationDepth} already computes for its 15 SAT candidates) —
109
+ * unlike an earlier version restricted to a frame shared by both boxes'
110
+ * axes up to sign, this also catches a member piercing through at a generic
111
+ * relative rotation (e.g. a duct crossing a wall at 15 degrees, review:
112
+ * #2536 follow-up — the earlier version measured -1.1177 there, `'mesh'`-
113
+ * labelled, against a true ~0.207 m).
114
+ */
115
+ export declare function isThroughPenetration(a: Obb, b: Obb): boolean;
116
+ //# sourceMappingURL=obb.d.ts.map
@@ -0,0 +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;AAqBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,GAAG,IAAI,CA4EpD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAoEjE;AAkED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAK5D"}