@perplexdotgg/bounce 1.3.1 → 1.5.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/README.md +4 -3
- package/build/bounce.d.ts +2449 -2199
- package/build/bounce.js +568 -625
- package/docs/documentation.md +0 -30
- package/package.json +6 -6
package/build/bounce.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createClass, ChildType, NumberType, LazyReferenceListType, BooleanType, LazyReferenceType, ReferenceListType, ReferenceType } from "monomorph";
|
|
1
|
+
import { props, createClass, ChildType, NumberType, LazyReferenceListType, BooleanType, LazyReferenceType, ReferenceListType, ReferenceType } from "monomorph";
|
|
2
2
|
const mat3Keys = ["e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8"];
|
|
3
|
-
const mat3Props = {
|
|
3
|
+
const mat3Props = props({
|
|
4
4
|
e0: 0,
|
|
5
5
|
e1: 0,
|
|
6
6
|
e2: 0,
|
|
@@ -10,8 +10,8 @@ const mat3Props = {
|
|
|
10
10
|
e6: 0,
|
|
11
11
|
e7: 0,
|
|
12
12
|
e8: 0
|
|
13
|
-
};
|
|
14
|
-
class Mat3 extends createClass(mat3Props) {
|
|
13
|
+
});
|
|
14
|
+
class Mat3 extends createClass()(mat3Props) {
|
|
15
15
|
adjointMatrix(a3) {
|
|
16
16
|
let a00 = a3.e0, a01 = a3.e1, a02 = a3.e2;
|
|
17
17
|
let a10 = a3.e3, a11 = a3.e4, a12 = a3.e5;
|
|
@@ -420,12 +420,12 @@ function squaredDistance(a3, b3) {
|
|
|
420
420
|
let z = b3.z - a3.z;
|
|
421
421
|
return x2 * x2 + y4 * y4 + z * z;
|
|
422
422
|
}
|
|
423
|
-
const vec3Props = {
|
|
423
|
+
const vec3Props = props({
|
|
424
424
|
x: 0,
|
|
425
425
|
y: 0,
|
|
426
426
|
z: 0
|
|
427
|
-
};
|
|
428
|
-
class Vec3 extends createClass(vec3Props) {
|
|
427
|
+
});
|
|
428
|
+
class Vec3 extends createClass()(vec3Props) {
|
|
429
429
|
constructor(data, index, pool) {
|
|
430
430
|
if (Array.isArray(data)) {
|
|
431
431
|
data = {
|
|
@@ -923,24 +923,24 @@ const rb = /* @__PURE__ */ Vec3.create();
|
|
|
923
923
|
const temp = /* @__PURE__ */ Vec3.create();
|
|
924
924
|
const rotatedVector = /* @__PURE__ */ Vec3.create();
|
|
925
925
|
const rotationMatrix$3 = /* @__PURE__ */ Mat3.create();
|
|
926
|
-
const lineProps = {
|
|
926
|
+
const lineProps = props({
|
|
927
927
|
a: Vec3,
|
|
928
928
|
b: Vec3
|
|
929
|
-
};
|
|
930
|
-
class Line extends createClass(lineProps) {
|
|
929
|
+
});
|
|
930
|
+
class Line extends createClass()(lineProps) {
|
|
931
931
|
setFromPointAndDirection(point2, direction2, length) {
|
|
932
932
|
this.a.copy(point2);
|
|
933
933
|
this.b.addScaledToVector(point2, direction2, length);
|
|
934
934
|
}
|
|
935
935
|
}
|
|
936
936
|
const quatKeys = ["x", "y", "z", "w"];
|
|
937
|
-
const quatProps = {
|
|
937
|
+
const quatProps = props({
|
|
938
938
|
x: 0,
|
|
939
939
|
y: 0,
|
|
940
940
|
z: 0,
|
|
941
941
|
w: 1
|
|
942
|
-
};
|
|
943
|
-
class Quat extends createClass(quatProps) {
|
|
942
|
+
});
|
|
943
|
+
class Quat extends createClass()(quatProps) {
|
|
944
944
|
constructor(data, index, pool) {
|
|
945
945
|
if (Array.isArray(data)) {
|
|
946
946
|
if (data.length && data.length < 4) {
|
|
@@ -1160,7 +1160,7 @@ const rotationMatrix$2 = /* @__PURE__ */ Mat3.create();
|
|
|
1160
1160
|
const scaling = /* @__PURE__ */ Vec3.create();
|
|
1161
1161
|
const conjugatedRotation = /* @__PURE__ */ Quat.create();
|
|
1162
1162
|
const rotatedTranslation = /* @__PURE__ */ Vec3.create();
|
|
1163
|
-
const mat4Props = {
|
|
1163
|
+
const mat4Props = props({
|
|
1164
1164
|
e0: 0,
|
|
1165
1165
|
e1: 0,
|
|
1166
1166
|
e2: 0,
|
|
@@ -1177,8 +1177,8 @@ const mat4Props = {
|
|
|
1177
1177
|
e13: 0,
|
|
1178
1178
|
e14: 0,
|
|
1179
1179
|
e15: 0
|
|
1180
|
-
};
|
|
1181
|
-
class Mat4 extends createClass(mat4Props) {
|
|
1180
|
+
});
|
|
1181
|
+
class Mat4 extends createClass()(mat4Props) {
|
|
1182
1182
|
multiply3x3(out, a3) {
|
|
1183
1183
|
const x2 = a3.x;
|
|
1184
1184
|
const y4 = a3.y;
|
|
@@ -1730,11 +1730,11 @@ class Mat4 extends createClass(mat4Props) {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
const rotation$3 = /* @__PURE__ */ Quat.create();
|
|
1732
1732
|
const cross_bn_cn = /* @__PURE__ */ Vec3.create();
|
|
1733
|
-
const planeProps = {
|
|
1733
|
+
const planeProps = props({
|
|
1734
1734
|
normal: Vec3,
|
|
1735
1735
|
constant: 0
|
|
1736
|
-
};
|
|
1737
|
-
class Plane extends createClass(planeProps) {
|
|
1736
|
+
});
|
|
1737
|
+
class Plane extends createClass()(planeProps) {
|
|
1738
1738
|
toObject() {
|
|
1739
1739
|
return {
|
|
1740
1740
|
normal: this.normal.toObject(),
|
|
@@ -1802,11 +1802,11 @@ class Plane extends createClass(planeProps) {
|
|
|
1802
1802
|
return fraction;
|
|
1803
1803
|
}
|
|
1804
1804
|
}
|
|
1805
|
-
const segmentProps = {
|
|
1805
|
+
const segmentProps = props({
|
|
1806
1806
|
pointA: Vec3,
|
|
1807
1807
|
pointB: Vec3
|
|
1808
|
-
};
|
|
1809
|
-
class Segment extends createClass(segmentProps) {
|
|
1808
|
+
});
|
|
1809
|
+
class Segment extends createClass()(segmentProps) {
|
|
1810
1810
|
computeCenter(out) {
|
|
1811
1811
|
out.addVectors(this.pointA, this.pointB);
|
|
1812
1812
|
out.scaleVector(out, 0.5);
|
|
@@ -1826,12 +1826,12 @@ const newMax = /* @__PURE__ */ Vec3.create();
|
|
|
1826
1826
|
const col = /* @__PURE__ */ Vec3.create();
|
|
1827
1827
|
const a$2 = /* @__PURE__ */ Vec3.create();
|
|
1828
1828
|
const b$1 = /* @__PURE__ */ Vec3.create();
|
|
1829
|
-
const aabbProps = {
|
|
1829
|
+
const aabbProps = props({
|
|
1830
1830
|
min: Vec3,
|
|
1831
1831
|
max: Vec3,
|
|
1832
1832
|
centroid: ChildType(Vec3, void 0, true)
|
|
1833
|
-
};
|
|
1834
|
-
class Aabb extends createClass(aabbProps) {
|
|
1833
|
+
});
|
|
1834
|
+
class Aabb extends createClass()(aabbProps) {
|
|
1835
1835
|
computeSupport(out, direction2) {
|
|
1836
1836
|
out.x = direction2.x < 0 ? this.min.x : this.max.x;
|
|
1837
1837
|
out.y = direction2.y < 0 ? this.min.y : this.max.y;
|
|
@@ -1959,6 +1959,7 @@ class Aabb extends createClass(aabbProps) {
|
|
|
1959
1959
|
this.min.minVectors(boxA.min, boxB.min);
|
|
1960
1960
|
this.max.maxVectors(boxA.max, boxB.max);
|
|
1961
1961
|
this.computeCentroid(this.centroid);
|
|
1962
|
+
return this;
|
|
1962
1963
|
}
|
|
1963
1964
|
expand(value) {
|
|
1964
1965
|
this.min.x -= value;
|
|
@@ -2104,7 +2105,7 @@ const aabbCenter = /* @__PURE__ */ Vec3.create();
|
|
|
2104
2105
|
const aabbHalfExtents = /* @__PURE__ */ Vec3.create();
|
|
2105
2106
|
const segmentCenter = /* @__PURE__ */ Vec3.create();
|
|
2106
2107
|
const segmentHalfExtents = /* @__PURE__ */ Vec3.create();
|
|
2107
|
-
const triangleProps$1 = {
|
|
2108
|
+
const triangleProps$1 = props({
|
|
2108
2109
|
computedBounds: ChildType(Aabb, void 0, true),
|
|
2109
2110
|
normal: ChildType(Vec3, void 0, true),
|
|
2110
2111
|
a: Vec3,
|
|
@@ -2115,10 +2116,10 @@ const triangleProps$1 = {
|
|
|
2115
2116
|
// aabb: { struct: Aabb, readOnly: true },
|
|
2116
2117
|
// activeEdges: { struct: Uint32, optional: true },
|
|
2117
2118
|
// translation: { struct: Vec3, optional: true },
|
|
2118
|
-
};
|
|
2119
|
+
});
|
|
2119
2120
|
const ab$5 = /* @__PURE__ */ Vec3.create();
|
|
2120
2121
|
const ac$3 = /* @__PURE__ */ Vec3.create();
|
|
2121
|
-
let Triangle$1 = class Triangle extends createClass(triangleProps$1) {
|
|
2122
|
+
let Triangle$1 = class Triangle extends createClass()(triangleProps$1) {
|
|
2122
2123
|
// type: ShapeType.triangle = ShapeType.triangle;
|
|
2123
2124
|
computeNormal(out) {
|
|
2124
2125
|
ab$5.subtractVectors(this.b, this.a);
|
|
@@ -2191,13 +2192,13 @@ let Triangle$1 = class Triangle extends createClass(triangleProps$1) {
|
|
|
2191
2192
|
out.transform(centerOfMassTransform2);
|
|
2192
2193
|
}
|
|
2193
2194
|
};
|
|
2194
|
-
const faceProps = {
|
|
2195
|
+
const faceProps = props({
|
|
2195
2196
|
numVertices: 0,
|
|
2196
2197
|
buffer: LazyReferenceListType(() => Vec3)
|
|
2197
|
-
};
|
|
2198
|
+
});
|
|
2198
2199
|
const triangle$1 = /* @__PURE__ */ Triangle$1.create();
|
|
2199
2200
|
const tempVertex = /* @__PURE__ */ Vec3.create();
|
|
2200
|
-
class Face extends createClass(faceProps) {
|
|
2201
|
+
class Face extends createClass()(faceProps) {
|
|
2201
2202
|
clear() {
|
|
2202
2203
|
this.numVertices = 0;
|
|
2203
2204
|
}
|
|
@@ -2293,7 +2294,7 @@ var ConstraintType = /* @__PURE__ */ ((ConstraintType2) => {
|
|
|
2293
2294
|
ConstraintType2[ConstraintType2["hingeConstraint"] = 3] = "hingeConstraint";
|
|
2294
2295
|
return ConstraintType2;
|
|
2295
2296
|
})(ConstraintType || {});
|
|
2296
|
-
const baseConstraintProps = {
|
|
2297
|
+
const baseConstraintProps = props({
|
|
2297
2298
|
// unless we use require here, this file will be imported after it is needed
|
|
2298
2299
|
bodyA: LazyReferenceType((() => Body)),
|
|
2299
2300
|
bodyB: LazyReferenceType((() => Body)),
|
|
@@ -2303,10 +2304,10 @@ const baseConstraintProps = {
|
|
|
2303
2304
|
/* local */
|
|
2304
2305
|
),
|
|
2305
2306
|
isEnabled: BooleanType(true)
|
|
2306
|
-
};
|
|
2307
|
+
});
|
|
2307
2308
|
const localToWorldTransformA$1 = /* @__PURE__ */ Mat4.create();
|
|
2308
2309
|
const point$1 = /* @__PURE__ */ Vec3.create();
|
|
2309
|
-
const contactManifoldProps = {
|
|
2310
|
+
const contactManifoldProps = props({
|
|
2310
2311
|
// meta data
|
|
2311
2312
|
bodyA: LazyReferenceType((() => Body)),
|
|
2312
2313
|
bodyB: LazyReferenceType((() => Body)),
|
|
@@ -2322,8 +2323,8 @@ const contactManifoldProps = {
|
|
|
2322
2323
|
contactPointsA: ReferenceListType(Vec3),
|
|
2323
2324
|
contactPointsB: ReferenceListType(Vec3),
|
|
2324
2325
|
lambdas: ReferenceListType(Vec3)
|
|
2325
|
-
};
|
|
2326
|
-
class ContactManifold extends createClass(contactManifoldProps) {
|
|
2326
|
+
});
|
|
2327
|
+
class ContactManifold extends createClass()(contactManifoldProps) {
|
|
2327
2328
|
get maxContacts() {
|
|
2328
2329
|
return this.contactPointsA.maxLength;
|
|
2329
2330
|
}
|
|
@@ -2443,14 +2444,14 @@ class ContactManifoldPool {
|
|
|
2443
2444
|
return manifold;
|
|
2444
2445
|
}
|
|
2445
2446
|
}
|
|
2446
|
-
const contactPairProps = {
|
|
2447
|
+
const contactPairProps = props({
|
|
2447
2448
|
bodyA: LazyReferenceType((() => Body)),
|
|
2448
2449
|
bodyB: LazyReferenceType((() => Body)),
|
|
2449
2450
|
firstContactManifold: ReferenceType(ContactManifold),
|
|
2450
2451
|
translationAB: Vec3,
|
|
2451
2452
|
rotationAB: Quat
|
|
2452
|
-
};
|
|
2453
|
-
class ContactPair extends createClass(contactPairProps) {
|
|
2453
|
+
});
|
|
2454
|
+
class ContactPair extends createClass()(contactPairProps) {
|
|
2454
2455
|
get key() {
|
|
2455
2456
|
return createContactPairKey(this.bodyA, this.bodyB);
|
|
2456
2457
|
}
|
|
@@ -2467,7 +2468,7 @@ const angularVelocityA = /* @__PURE__ */ Vec3.create();
|
|
|
2467
2468
|
const angularVelocityB = /* @__PURE__ */ Vec3.create();
|
|
2468
2469
|
const inverseInertiaA$2 = /* @__PURE__ */ Mat3.create();
|
|
2469
2470
|
const inverseInertiaB$2 = /* @__PURE__ */ Mat3.create();
|
|
2470
|
-
const directionalConstraintProps = {
|
|
2471
|
+
const directionalConstraintProps = props({
|
|
2471
2472
|
mR1PlusUxAxis: Vec3,
|
|
2472
2473
|
mR2xAxis: Vec3,
|
|
2473
2474
|
mInvI1_R1PlusUxAxis: Vec3,
|
|
@@ -2476,10 +2477,8 @@ const directionalConstraintProps = {
|
|
|
2476
2477
|
bias: 0,
|
|
2477
2478
|
softness: 0,
|
|
2478
2479
|
totalLambda: 0
|
|
2479
|
-
};
|
|
2480
|
-
class DirectionalConstraint extends createClass(
|
|
2481
|
-
directionalConstraintProps
|
|
2482
|
-
) {
|
|
2480
|
+
});
|
|
2481
|
+
class DirectionalConstraint extends createClass()(directionalConstraintProps) {
|
|
2483
2482
|
isSpringActive() {
|
|
2484
2483
|
return this.softness !== 0;
|
|
2485
2484
|
}
|
|
@@ -2609,16 +2608,14 @@ class DirectionalConstraint extends createClass(
|
|
|
2609
2608
|
}
|
|
2610
2609
|
}
|
|
2611
2610
|
}
|
|
2612
|
-
const contactConstraintProps = {
|
|
2611
|
+
const contactConstraintProps = props({
|
|
2613
2612
|
normalConstraint: DirectionalConstraint,
|
|
2614
2613
|
tangentConstraint: DirectionalConstraint,
|
|
2615
2614
|
bitangentConstraint: DirectionalConstraint,
|
|
2616
2615
|
localPositionA: Vec3,
|
|
2617
2616
|
localPositionB: Vec3
|
|
2618
|
-
};
|
|
2619
|
-
class ContactConstraint extends createClass(
|
|
2620
|
-
contactConstraintProps
|
|
2621
|
-
) {
|
|
2617
|
+
});
|
|
2618
|
+
class ContactConstraint extends createClass()(contactConstraintProps) {
|
|
2622
2619
|
getLambda(out, index) {
|
|
2623
2620
|
out.x = this.normalConstraint.totalLambda;
|
|
2624
2621
|
out.y = this.tangentConstraint.totalLambda;
|
|
@@ -2640,7 +2637,7 @@ class ContactConstraint extends createClass(
|
|
|
2640
2637
|
this.normalConstraint.warmStart(bodyA, bodyB, inverseMassA, inverseMassB, normal4);
|
|
2641
2638
|
}
|
|
2642
2639
|
}
|
|
2643
|
-
const manifoldConstraintProps = {
|
|
2640
|
+
const manifoldConstraintProps = props({
|
|
2644
2641
|
bodyA: LazyReferenceType((() => Body)),
|
|
2645
2642
|
bodyB: LazyReferenceType((() => Body)),
|
|
2646
2643
|
subShapeIdA: 0,
|
|
@@ -2654,10 +2651,8 @@ const manifoldConstraintProps = {
|
|
|
2654
2651
|
inverseMassB: 0,
|
|
2655
2652
|
contactConstraints: ReferenceListType(ContactConstraint),
|
|
2656
2653
|
numContacts: 0
|
|
2657
|
-
};
|
|
2658
|
-
class ManifoldConstraint extends createClass(
|
|
2659
|
-
manifoldConstraintProps
|
|
2660
|
-
) {
|
|
2654
|
+
});
|
|
2655
|
+
class ManifoldConstraint extends createClass()(manifoldConstraintProps) {
|
|
2661
2656
|
updateTangentDirections() {
|
|
2662
2657
|
this.worldSpaceTangent.computeNormalizedPerpendicular(this.worldSpaceNormal);
|
|
2663
2658
|
this.worldSpaceBitangent.crossVectors(this.worldSpaceNormal, this.worldSpaceTangent);
|
|
@@ -2757,14 +2752,14 @@ function computeClosestPowersOfTwo(n2) {
|
|
|
2757
2752
|
const next = 1 << Math.ceil(Math.log2(n2));
|
|
2758
2753
|
return { previous, next };
|
|
2759
2754
|
}
|
|
2760
|
-
const isometryProps = {
|
|
2755
|
+
const isometryProps = props({
|
|
2761
2756
|
matrix: Mat4
|
|
2762
|
-
};
|
|
2757
|
+
});
|
|
2763
2758
|
const tempTranslation = /* @__PURE__ */ Vec3.create();
|
|
2764
2759
|
const tempRotation = /* @__PURE__ */ Quat.create();
|
|
2765
2760
|
const rotation$2 = /* @__PURE__ */ Mat3.create();
|
|
2766
2761
|
const inverseMatrix = /* @__PURE__ */ Mat4.create();
|
|
2767
|
-
class Isometry extends createClass(isometryProps) {
|
|
2762
|
+
class Isometry extends createClass()(isometryProps) {
|
|
2768
2763
|
fromRotationAndTranslation(rotation2, translation) {
|
|
2769
2764
|
if (rotation2) {
|
|
2770
2765
|
tempRotation.copy(rotation2);
|
|
@@ -3312,11 +3307,11 @@ class TransformedConvexObject {
|
|
|
3312
3307
|
out.transformFromMat4(this.transform.matrix);
|
|
3313
3308
|
}
|
|
3314
3309
|
}
|
|
3315
|
-
const transformedConvexShapeProps = {
|
|
3310
|
+
const transformedConvexShapeProps = props({
|
|
3316
3311
|
transform: Isometry
|
|
3317
|
-
};
|
|
3312
|
+
});
|
|
3318
3313
|
const direction = /* @__PURE__ */ Vec3.create();
|
|
3319
|
-
class TransformedConvexShape extends createClass(
|
|
3314
|
+
class TransformedConvexShape extends createClass()(
|
|
3320
3315
|
transformedConvexShapeProps
|
|
3321
3316
|
) {
|
|
3322
3317
|
constructor() {
|
|
@@ -3330,12 +3325,10 @@ class TransformedConvexShape extends createClass(
|
|
|
3330
3325
|
out.transformByMat4(this.transform.matrix);
|
|
3331
3326
|
}
|
|
3332
3327
|
}
|
|
3333
|
-
const convexRadiusObjectProps = {
|
|
3328
|
+
const convexRadiusObjectProps = props({
|
|
3334
3329
|
radius: 0
|
|
3335
|
-
};
|
|
3336
|
-
class ConvexRadiusObject extends createClass(
|
|
3337
|
-
convexRadiusObjectProps
|
|
3338
|
-
) {
|
|
3330
|
+
});
|
|
3331
|
+
class ConvexRadiusObject extends createClass()(convexRadiusObjectProps) {
|
|
3339
3332
|
constructor() {
|
|
3340
3333
|
super();
|
|
3341
3334
|
this.convexShape = null;
|
|
@@ -3382,10 +3375,10 @@ var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
|
|
|
3382
3375
|
ShapeType2[ShapeType2["triangleMesh"] = 7] = "triangleMesh";
|
|
3383
3376
|
return ShapeType2;
|
|
3384
3377
|
})(ShapeType || {});
|
|
3385
|
-
const sphereNoConvexProps = {
|
|
3378
|
+
const sphereNoConvexProps = props({
|
|
3386
3379
|
radius: 0
|
|
3387
|
-
};
|
|
3388
|
-
class SphereNoConvex extends createClass(sphereNoConvexProps) {
|
|
3380
|
+
});
|
|
3381
|
+
class SphereNoConvex extends createClass()(sphereNoConvexProps) {
|
|
3389
3382
|
getConvexRadius() {
|
|
3390
3383
|
return this.radius;
|
|
3391
3384
|
}
|
|
@@ -3393,10 +3386,10 @@ class SphereNoConvex extends createClass(sphereNoConvexProps) {
|
|
|
3393
3386
|
out.zero();
|
|
3394
3387
|
}
|
|
3395
3388
|
}
|
|
3396
|
-
const sphereWithConvexProps = {
|
|
3389
|
+
const sphereWithConvexProps = props({
|
|
3397
3390
|
radius: 0
|
|
3398
|
-
};
|
|
3399
|
-
class SphereWithConvex extends createClass(sphereWithConvexProps) {
|
|
3391
|
+
});
|
|
3392
|
+
class SphereWithConvex extends createClass()(sphereWithConvexProps) {
|
|
3400
3393
|
getConvexRadius() {
|
|
3401
3394
|
return 0;
|
|
3402
3395
|
}
|
|
@@ -3409,7 +3402,7 @@ class SphereWithConvex extends createClass(sphereWithConvexProps) {
|
|
|
3409
3402
|
}
|
|
3410
3403
|
}
|
|
3411
3404
|
}
|
|
3412
|
-
const sphereProps = {
|
|
3405
|
+
const sphereProps = props({
|
|
3413
3406
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
3414
3407
|
computedVolume: NumberType(0, true),
|
|
3415
3408
|
computedAabb: ChildType(Aabb, void 0, true),
|
|
@@ -3417,11 +3410,11 @@ const sphereProps = {
|
|
|
3417
3410
|
copyForDiff: LazyReferenceType((() => Sphere)),
|
|
3418
3411
|
sphereNoConvex: ChildType(SphereNoConvex, void 0, true),
|
|
3419
3412
|
sphereWithConvex: ChildType(SphereWithConvex, void 0, true)
|
|
3420
|
-
};
|
|
3413
|
+
});
|
|
3421
3414
|
const afterConstructorCode$a = `
|
|
3422
3415
|
this.world = null;
|
|
3423
3416
|
`;
|
|
3424
|
-
class Sphere extends createClass(
|
|
3417
|
+
class Sphere extends createClass({ afterConstructorCode: afterConstructorCode$a })(sphereProps) {
|
|
3425
3418
|
constructor() {
|
|
3426
3419
|
super(...arguments);
|
|
3427
3420
|
this.type = ShapeType.sphere;
|
|
@@ -3517,12 +3510,12 @@ const isometry$8 = /* @__PURE__ */ Isometry.create();
|
|
|
3517
3510
|
const absLocalSurfacePosition = /* @__PURE__ */ Vec3.create();
|
|
3518
3511
|
const tempVector$4 = /* @__PURE__ */ Vec3.create();
|
|
3519
3512
|
const defaultConvexRadius = 0.05;
|
|
3520
|
-
const boxSupportProps = {
|
|
3513
|
+
const boxSupportProps = props({
|
|
3521
3514
|
convexRadius: 0,
|
|
3522
3515
|
// TODO: cannot used undefined default for this, possibly due to it being used as a deeply nested prop
|
|
3523
3516
|
computedAabb: ChildType(Aabb, {}, true)
|
|
3524
|
-
};
|
|
3525
|
-
class BoxSupport extends createClass(boxSupportProps) {
|
|
3517
|
+
});
|
|
3518
|
+
class BoxSupport extends createClass()(boxSupportProps) {
|
|
3526
3519
|
computeSupport(out, direction2) {
|
|
3527
3520
|
this.computedAabb.computeSupport(out, direction2);
|
|
3528
3521
|
}
|
|
@@ -3530,7 +3523,7 @@ class BoxSupport extends createClass(boxSupportProps) {
|
|
|
3530
3523
|
return this.convexRadius;
|
|
3531
3524
|
}
|
|
3532
3525
|
}
|
|
3533
|
-
const boxProps = {
|
|
3526
|
+
const boxProps = props({
|
|
3534
3527
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
3535
3528
|
computedVolume: NumberType(0, true),
|
|
3536
3529
|
computedAabb: ChildType(Aabb, void 0, true),
|
|
@@ -3540,11 +3533,11 @@ const boxProps = {
|
|
|
3540
3533
|
depth: 0,
|
|
3541
3534
|
boxSupport: ChildType(BoxSupport, void 0, true),
|
|
3542
3535
|
copyForDiff: LazyReferenceType((() => Box))
|
|
3543
|
-
};
|
|
3536
|
+
});
|
|
3544
3537
|
const afterConstructorCode$9 = `
|
|
3545
3538
|
this.world = null;
|
|
3546
3539
|
`;
|
|
3547
|
-
class Box extends createClass(
|
|
3540
|
+
class Box extends createClass({ afterConstructorCode: afterConstructorCode$9 })(boxProps) {
|
|
3548
3541
|
constructor() {
|
|
3549
3542
|
super(...arguments);
|
|
3550
3543
|
this.type = ShapeType.box;
|
|
@@ -3661,23 +3654,23 @@ function updateShape$6(shape) {
|
|
|
3661
3654
|
updateVolume$4(shape);
|
|
3662
3655
|
updateLocalBounds$6(shape);
|
|
3663
3656
|
}
|
|
3664
|
-
const bodyPairNodeProps = {
|
|
3657
|
+
const bodyPairNodeProps = props({
|
|
3665
3658
|
bodyA: LazyReferenceType((() => Body)),
|
|
3666
3659
|
bodyB: LazyReferenceType((() => Body)),
|
|
3667
3660
|
edgeA: LazyReferenceType((() => BodyPairEdge)),
|
|
3668
3661
|
edgeB: LazyReferenceType((() => BodyPairEdge))
|
|
3669
|
-
};
|
|
3670
|
-
class BodyPairNode extends createClass(bodyPairNodeProps) {
|
|
3662
|
+
});
|
|
3663
|
+
class BodyPairNode extends createClass()(bodyPairNodeProps) {
|
|
3671
3664
|
containsStaticBody() {
|
|
3672
3665
|
return this.bodyA.type === BodyType.static || this.bodyB.type === BodyType.static;
|
|
3673
3666
|
}
|
|
3674
3667
|
}
|
|
3675
|
-
const bodyPairEdgeProps = {
|
|
3668
|
+
const bodyPairEdgeProps = props({
|
|
3676
3669
|
node: LazyReferenceType((() => BodyPairNode)),
|
|
3677
3670
|
next: LazyReferenceType((() => BodyPairEdge)),
|
|
3678
3671
|
prev: LazyReferenceType((() => BodyPairEdge))
|
|
3679
|
-
};
|
|
3680
|
-
class BodyPairEdge extends createClass(bodyPairEdgeProps) {
|
|
3672
|
+
});
|
|
3673
|
+
class BodyPairEdge extends createClass()(bodyPairEdgeProps) {
|
|
3681
3674
|
}
|
|
3682
3675
|
class BodyPairsModule {
|
|
3683
3676
|
constructor(bodyPool, nodesPool, edgesPool) {
|
|
@@ -3916,12 +3909,12 @@ class BodyPairsModule {
|
|
|
3916
3909
|
}
|
|
3917
3910
|
}
|
|
3918
3911
|
}
|
|
3919
|
-
const rayProps = {
|
|
3912
|
+
const rayProps = props({
|
|
3920
3913
|
origin: Vec3,
|
|
3921
3914
|
direction: Vec3,
|
|
3922
3915
|
length: 0
|
|
3923
|
-
};
|
|
3924
|
-
class Ray extends createClass(rayProps) {
|
|
3916
|
+
});
|
|
3917
|
+
class Ray extends createClass()(rayProps) {
|
|
3925
3918
|
intersectsAabb(aabb) {
|
|
3926
3919
|
return aabb.intersectsRay(this);
|
|
3927
3920
|
}
|
|
@@ -4027,7 +4020,6 @@ const CollisionFilter = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.def
|
|
|
4027
4020
|
shouldPairCollide,
|
|
4028
4021
|
toggleFlag
|
|
4029
4022
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4030
|
-
const expandedObjectBounds = /* @__PURE__ */ Aabb.create();
|
|
4031
4023
|
const leftAabb = /* @__PURE__ */ Aabb.create();
|
|
4032
4024
|
const rightAabb = /* @__PURE__ */ Aabb.create();
|
|
4033
4025
|
const centroidBounds$1 = /* @__PURE__ */ Aabb.create();
|
|
@@ -4036,15 +4028,15 @@ const ray$4 = /* @__PURE__ */ Ray.create();
|
|
|
4036
4028
|
const halfExtents$2 = /* @__PURE__ */ Vec3.create();
|
|
4037
4029
|
const nodeBounds$1 = /* @__PURE__ */ Aabb.create();
|
|
4038
4030
|
const bodyBounds$1 = /* @__PURE__ */ Aabb.create();
|
|
4039
|
-
const bvhNodeProps$1 = {
|
|
4031
|
+
const bvhNodeProps$1 = props({
|
|
4040
4032
|
parent: LazyReferenceType((() => BvhNode)),
|
|
4041
4033
|
left: LazyReferenceType((() => BvhNode)),
|
|
4042
4034
|
right: LazyReferenceType((() => BvhNode)),
|
|
4043
4035
|
computedBounds: ChildType(Aabb, void 0, true),
|
|
4044
4036
|
height: 0,
|
|
4045
4037
|
objects: LazyReferenceListType((() => Body))
|
|
4046
|
-
};
|
|
4047
|
-
class BvhNode extends createClass(bvhNodeProps$1) {
|
|
4038
|
+
});
|
|
4039
|
+
class BvhNode extends createClass()(bvhNodeProps$1) {
|
|
4048
4040
|
// objects: Body[] = [];
|
|
4049
4041
|
isLeaf() {
|
|
4050
4042
|
return this.left === null && this.right === null;
|
|
@@ -4086,7 +4078,7 @@ class BvhTree {
|
|
|
4086
4078
|
}
|
|
4087
4079
|
updateDirtyObjects() {
|
|
4088
4080
|
for (const object of this.dirtyObjects) {
|
|
4089
|
-
|
|
4081
|
+
this.update(object, false);
|
|
4090
4082
|
}
|
|
4091
4083
|
this.dirtyObjects.clear();
|
|
4092
4084
|
}
|
|
@@ -4175,7 +4167,7 @@ class BvhTree {
|
|
|
4175
4167
|
node.computedBounds.min.fromArray([Infinity, Infinity, Infinity]);
|
|
4176
4168
|
node.computedBounds.max.fromArray([-Infinity, -Infinity, -Infinity]);
|
|
4177
4169
|
for (const object of node.objects) {
|
|
4178
|
-
node.computedBounds.unionAabb(object.
|
|
4170
|
+
node.computedBounds.unionAabb(object.computedExpandedBounds);
|
|
4179
4171
|
}
|
|
4180
4172
|
node.height = 0;
|
|
4181
4173
|
} else {
|
|
@@ -4265,11 +4257,11 @@ class BvhTree {
|
|
|
4265
4257
|
destroyBvhNode(node) {
|
|
4266
4258
|
node.destroy();
|
|
4267
4259
|
}
|
|
4268
|
-
insert(object
|
|
4269
|
-
|
|
4260
|
+
insert(object) {
|
|
4261
|
+
object.computedExpandedBounds.expandAabb(object.computedBounds, this.options.expansionMargin);
|
|
4270
4262
|
if (!this.root) {
|
|
4271
4263
|
const root = this.createBvhNode();
|
|
4272
|
-
root.computedBounds.copy(
|
|
4264
|
+
root.computedBounds.copy(object.computedExpandedBounds);
|
|
4273
4265
|
root.objects.push(object);
|
|
4274
4266
|
root.height = 0;
|
|
4275
4267
|
this.root = root;
|
|
@@ -4288,7 +4280,7 @@ class BvhTree {
|
|
|
4288
4280
|
}
|
|
4289
4281
|
if (best.objects.length < this.options.maxObjectsPerLeaf || best.height >= this.options.maxDepth) {
|
|
4290
4282
|
best.objects.push(object);
|
|
4291
|
-
best.computedBounds.unionAabb(
|
|
4283
|
+
best.computedBounds.unionAabb(object.computedExpandedBounds);
|
|
4292
4284
|
object.node = best;
|
|
4293
4285
|
return this.refit(best);
|
|
4294
4286
|
}
|
|
@@ -4297,15 +4289,15 @@ class BvhTree {
|
|
|
4297
4289
|
best.objects.push(object);
|
|
4298
4290
|
this.splitObjects(left, right, best);
|
|
4299
4291
|
best.objects.length = 0;
|
|
4300
|
-
left.computedBounds.copy(left.objects.getAtIndex(0).
|
|
4292
|
+
left.computedBounds.copy(left.objects.getAtIndex(0).computedExpandedBounds);
|
|
4301
4293
|
for (let i = 1; i < left.objects.length; i++) {
|
|
4302
|
-
left.computedBounds.unionAabb(left.objects.getAtIndex(i).
|
|
4294
|
+
left.computedBounds.unionAabb(left.objects.getAtIndex(i).computedExpandedBounds);
|
|
4303
4295
|
}
|
|
4304
4296
|
left.parent = best;
|
|
4305
4297
|
left.height = 0;
|
|
4306
|
-
right.computedBounds.copy(right.objects.getAtIndex(0).
|
|
4298
|
+
right.computedBounds.copy(right.objects.getAtIndex(0).computedExpandedBounds);
|
|
4307
4299
|
for (let i = 1; i < right.objects.length; i++) {
|
|
4308
|
-
right.computedBounds.unionAabb(right.objects.getAtIndex(i).
|
|
4300
|
+
right.computedBounds.unionAabb(right.objects.getAtIndex(i).computedExpandedBounds);
|
|
4309
4301
|
}
|
|
4310
4302
|
right.parent = best;
|
|
4311
4303
|
right.height = 0;
|
|
@@ -4365,7 +4357,7 @@ class BvhTree {
|
|
|
4365
4357
|
this.remove(object);
|
|
4366
4358
|
return this.insert(object);
|
|
4367
4359
|
}
|
|
4368
|
-
intersectBody(onHit2,
|
|
4360
|
+
intersectBody(onHit2, bodyToIntersect, shouldUpdateDirtyObjects = true) {
|
|
4369
4361
|
if (!this.root) {
|
|
4370
4362
|
return;
|
|
4371
4363
|
}
|
|
@@ -4380,7 +4372,7 @@ class BvhTree {
|
|
|
4380
4372
|
if (!node) {
|
|
4381
4373
|
continue;
|
|
4382
4374
|
}
|
|
4383
|
-
if (!node.computedBounds.intersectsAabb(
|
|
4375
|
+
if (!node.computedBounds.intersectsAabb(bodyToIntersect.computedBounds)) {
|
|
4384
4376
|
continue;
|
|
4385
4377
|
}
|
|
4386
4378
|
if (!node.isLeaf()) {
|
|
@@ -4389,21 +4381,40 @@ class BvhTree {
|
|
|
4389
4381
|
continue;
|
|
4390
4382
|
}
|
|
4391
4383
|
for (const otherBody of node.objects) {
|
|
4392
|
-
if (
|
|
4384
|
+
if (bodyToIntersect === otherBody || !shouldPairCollide(bodyToIntersect.belongsToGroups, bodyToIntersect.collidesWithGroups, otherBody.belongsToGroups, otherBody.collidesWithGroups) || !bodyToIntersect.computedBounds.intersectsAabb(otherBody.computedBounds)) {
|
|
4393
4385
|
continue;
|
|
4394
4386
|
}
|
|
4395
|
-
if (
|
|
4396
|
-
|
|
4397
|
-
body2.collidesWithGroups,
|
|
4398
|
-
otherBody.belongsToGroups,
|
|
4399
|
-
otherBody.collidesWithGroups
|
|
4400
|
-
) === false) {
|
|
4401
|
-
continue;
|
|
4387
|
+
if (onHit2(otherBody)) {
|
|
4388
|
+
return;
|
|
4402
4389
|
}
|
|
4403
|
-
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
intersectAabb(onHit2, bounds, shouldUpdateDirtyObjects = true) {
|
|
4394
|
+
if (!this.root) {
|
|
4395
|
+
return;
|
|
4396
|
+
}
|
|
4397
|
+
if (shouldUpdateDirtyObjects) {
|
|
4398
|
+
this.updateDirtyObjects();
|
|
4399
|
+
}
|
|
4400
|
+
const stack2 = this.intersectStack;
|
|
4401
|
+
stack2.length = 0;
|
|
4402
|
+
stack2.push(this.root);
|
|
4403
|
+
while (stack2.length > 0) {
|
|
4404
|
+
const node = stack2.pop();
|
|
4405
|
+
if (!node.computedBounds.intersectsAabb(bounds)) {
|
|
4406
|
+
continue;
|
|
4407
|
+
}
|
|
4408
|
+
if (!node.isLeaf()) {
|
|
4409
|
+
stack2.push(node.left);
|
|
4410
|
+
stack2.push(node.right);
|
|
4411
|
+
continue;
|
|
4412
|
+
}
|
|
4413
|
+
for (const object of node.objects) {
|
|
4414
|
+
if (!bounds.intersectsAabb(object.computedBounds)) {
|
|
4404
4415
|
continue;
|
|
4405
4416
|
}
|
|
4406
|
-
if (onHit2(
|
|
4417
|
+
if (onHit2(object)) {
|
|
4407
4418
|
return;
|
|
4408
4419
|
}
|
|
4409
4420
|
}
|
|
@@ -4445,10 +4456,7 @@ class BvhTree {
|
|
|
4445
4456
|
stack2.push(this.root);
|
|
4446
4457
|
while (stack2.length > 0) {
|
|
4447
4458
|
const node = stack2.pop();
|
|
4448
|
-
if (!node) {
|
|
4449
|
-
continue;
|
|
4450
|
-
}
|
|
4451
|
-
if (node.computedBounds.intersectsAabb(bounds) === false) {
|
|
4459
|
+
if (!node || !node.computedBounds.intersectsAabb(bounds)) {
|
|
4452
4460
|
continue;
|
|
4453
4461
|
}
|
|
4454
4462
|
if (!node.isLeaf()) {
|
|
@@ -4457,10 +4465,7 @@ class BvhTree {
|
|
|
4457
4465
|
continue;
|
|
4458
4466
|
}
|
|
4459
4467
|
for (const body2 of node.objects) {
|
|
4460
|
-
if (shouldPairCollide(body2.belongsToGroups, body2.collidesWithGroups, belongsToGroups, collidesWithGroups)
|
|
4461
|
-
continue;
|
|
4462
|
-
}
|
|
4463
|
-
if (!body2.computedBounds.intersectsAabb(bounds)) {
|
|
4468
|
+
if (!shouldPairCollide(body2.belongsToGroups, body2.collidesWithGroups, belongsToGroups, collidesWithGroups) || !body2.computedBounds.intersectsAabb(bounds)) {
|
|
4464
4469
|
continue;
|
|
4465
4470
|
}
|
|
4466
4471
|
bodyVisitor.visit(body2);
|
|
@@ -4486,7 +4491,7 @@ class BvhTree {
|
|
|
4486
4491
|
continue;
|
|
4487
4492
|
}
|
|
4488
4493
|
nodeBounds$1.copy(node.computedBounds);
|
|
4489
|
-
if (ray2.intersectsAabb(nodeBounds$1)
|
|
4494
|
+
if (!ray2.intersectsAabb(nodeBounds$1)) {
|
|
4490
4495
|
continue;
|
|
4491
4496
|
}
|
|
4492
4497
|
if (!node.isLeaf()) {
|
|
@@ -4495,11 +4500,11 @@ class BvhTree {
|
|
|
4495
4500
|
continue;
|
|
4496
4501
|
}
|
|
4497
4502
|
for (const body2 of node.objects) {
|
|
4498
|
-
if (shouldPairCollide(body2.belongsToGroups, body2.collidesWithGroups, belongsToGroups, collidesWithGroups)
|
|
4503
|
+
if (!shouldPairCollide(body2.belongsToGroups, body2.collidesWithGroups, belongsToGroups, collidesWithGroups)) {
|
|
4499
4504
|
continue;
|
|
4500
4505
|
}
|
|
4501
4506
|
bodyBounds$1.copy(body2.computedBounds);
|
|
4502
|
-
if (ray2.intersectsAabb(bodyBounds$1)
|
|
4507
|
+
if (!ray2.intersectsAabb(bodyBounds$1)) {
|
|
4503
4508
|
continue;
|
|
4504
4509
|
}
|
|
4505
4510
|
bodyVisitor.visit(body2);
|
|
@@ -4530,7 +4535,7 @@ class BvhTree {
|
|
|
4530
4535
|
}
|
|
4531
4536
|
nodeBounds$1.copy(node.computedBounds);
|
|
4532
4537
|
nodeBounds$1.expandByVector(halfExtents$2);
|
|
4533
|
-
if (ray$4.intersectsAabb(nodeBounds$1)
|
|
4538
|
+
if (!ray$4.intersectsAabb(nodeBounds$1)) {
|
|
4534
4539
|
continue;
|
|
4535
4540
|
}
|
|
4536
4541
|
if (!node.isLeaf()) {
|
|
@@ -4539,12 +4544,12 @@ class BvhTree {
|
|
|
4539
4544
|
continue;
|
|
4540
4545
|
}
|
|
4541
4546
|
for (const body2 of node.objects) {
|
|
4542
|
-
if (shouldPairCollide(body2.belongsToGroups, body2.collidesWithGroups, belongsToGroups, collidesWithGroups)
|
|
4547
|
+
if (!shouldPairCollide(body2.belongsToGroups, body2.collidesWithGroups, belongsToGroups, collidesWithGroups)) {
|
|
4543
4548
|
continue;
|
|
4544
4549
|
}
|
|
4545
4550
|
bodyBounds$1.copy(body2.computedBounds);
|
|
4546
4551
|
bodyBounds$1.expandByVector(halfExtents$2);
|
|
4547
|
-
if (ray$4.intersectsAabb(bodyBounds$1)
|
|
4552
|
+
if (!ray$4.intersectsAabb(bodyBounds$1)) {
|
|
4548
4553
|
continue;
|
|
4549
4554
|
}
|
|
4550
4555
|
bodyVisitor.visit(body2);
|
|
@@ -4555,20 +4560,20 @@ class BvhTree {
|
|
|
4555
4560
|
}
|
|
4556
4561
|
}
|
|
4557
4562
|
}
|
|
4558
|
-
const basicTransformProps = {
|
|
4563
|
+
const basicTransformProps = props({
|
|
4559
4564
|
position: Vec3,
|
|
4560
4565
|
rotation: Quat,
|
|
4561
4566
|
scale: 1
|
|
4562
|
-
};
|
|
4563
|
-
class BasicTransform extends createClass(basicTransformProps) {
|
|
4567
|
+
});
|
|
4568
|
+
class BasicTransform extends createClass()(basicTransformProps) {
|
|
4564
4569
|
equals(other, tolerance = 1e-6) {
|
|
4565
4570
|
return this.position.equals(other.position, tolerance) && this.rotation.equals(other.rotation, tolerance) && Math.abs(this.scale - other.scale) < tolerance;
|
|
4566
4571
|
}
|
|
4567
4572
|
}
|
|
4568
|
-
const numberValueProps = {
|
|
4573
|
+
const numberValueProps = props({
|
|
4569
4574
|
value: 0
|
|
4570
|
-
};
|
|
4571
|
-
class NumberValue extends createClass(numberValueProps) {
|
|
4575
|
+
});
|
|
4576
|
+
class NumberValue extends createClass()(numberValueProps) {
|
|
4572
4577
|
toObject() {
|
|
4573
4578
|
return {
|
|
4574
4579
|
value: this.value
|
|
@@ -4630,12 +4635,12 @@ class ConvexHullWithConvex {
|
|
|
4630
4635
|
throw new Error("Method not implemented.");
|
|
4631
4636
|
}
|
|
4632
4637
|
}
|
|
4633
|
-
const convexHullPointProps = {
|
|
4638
|
+
const convexHullPointProps = props({
|
|
4634
4639
|
position: Vec3,
|
|
4635
4640
|
numFaces: 0,
|
|
4636
4641
|
faces: Vec3
|
|
4637
|
-
};
|
|
4638
|
-
class ConvexHullPoint extends createClass(convexHullPointProps) {
|
|
4642
|
+
});
|
|
4643
|
+
class ConvexHullPoint extends createClass()(convexHullPointProps) {
|
|
4639
4644
|
toObject() {
|
|
4640
4645
|
return {
|
|
4641
4646
|
position: this.position.toObject(),
|
|
@@ -4644,11 +4649,11 @@ class ConvexHullPoint extends createClass(convexHullPointProps) {
|
|
|
4644
4649
|
};
|
|
4645
4650
|
}
|
|
4646
4651
|
}
|
|
4647
|
-
const convexHullFaceProps = {
|
|
4652
|
+
const convexHullFaceProps = props({
|
|
4648
4653
|
firstVertex: 0,
|
|
4649
4654
|
numVertices: 0
|
|
4650
|
-
};
|
|
4651
|
-
class ConvexHullFace extends createClass(convexHullFaceProps) {
|
|
4655
|
+
});
|
|
4656
|
+
class ConvexHullFace extends createClass()(convexHullFaceProps) {
|
|
4652
4657
|
toObject() {
|
|
4653
4658
|
return {
|
|
4654
4659
|
firstVertex: this.firstVertex,
|
|
@@ -4656,7 +4661,7 @@ class ConvexHullFace extends createClass(convexHullFaceProps) {
|
|
|
4656
4661
|
};
|
|
4657
4662
|
}
|
|
4658
4663
|
}
|
|
4659
|
-
const convexHullProps = {
|
|
4664
|
+
const convexHullProps = props({
|
|
4660
4665
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
4661
4666
|
computedVolume: NumberType(0, true),
|
|
4662
4667
|
computedAabb: ChildType(Aabb, void 0, true),
|
|
@@ -4675,14 +4680,14 @@ const convexHullProps = {
|
|
|
4675
4680
|
// { array: Float64Array(f), itemMaxCount: f / 3, itemSize: 3 } [Vec3], transformed points used by ConvexHullNoConvex
|
|
4676
4681
|
translation: ChildType(Vec3, { x: 0, y: 0, z: 0 }),
|
|
4677
4682
|
copyForDiff: LazyReferenceType((() => ConvexHull))
|
|
4678
|
-
};
|
|
4683
|
+
});
|
|
4679
4684
|
const afterConstructorCode$8 = `
|
|
4680
|
-
this.world = null;
|
|
4681
|
-
this.shapeNoConvex = null;
|
|
4682
|
-
this.shapeWithConvex = null;
|
|
4683
|
-
this.type = ${ShapeType.convexHull};
|
|
4685
|
+
this.world = null;
|
|
4686
|
+
this.shapeNoConvex = null;
|
|
4687
|
+
this.shapeWithConvex = null;
|
|
4688
|
+
this.type = ${ShapeType.convexHull};
|
|
4684
4689
|
`;
|
|
4685
|
-
class ConvexHull extends createClass(
|
|
4690
|
+
class ConvexHull extends createClass({ afterConstructorCode: afterConstructorCode$8 })(convexHullProps) {
|
|
4686
4691
|
computeSupportShape(inMode, inScale) {
|
|
4687
4692
|
if (this.convexRadius === 0) {
|
|
4688
4693
|
this.shapeWithConvex.shape = this;
|
|
@@ -4867,14 +4872,12 @@ const vertex = /* @__PURE__ */ Vec3.create();
|
|
|
4867
4872
|
const multiplier = /* @__PURE__ */ Vec3.create();
|
|
4868
4873
|
const transform$1 = /* @__PURE__ */ Mat4.create();
|
|
4869
4874
|
const isometry$6 = /* @__PURE__ */ Isometry.create();
|
|
4870
|
-
const cylinderSupportShapeProps = {
|
|
4875
|
+
const cylinderSupportShapeProps = props({
|
|
4871
4876
|
halfHeight: 0,
|
|
4872
4877
|
radius: 0,
|
|
4873
4878
|
convexRadius: 0
|
|
4874
|
-
};
|
|
4875
|
-
class CylinderSupportShape extends createClass(
|
|
4876
|
-
cylinderSupportShapeProps
|
|
4877
|
-
) {
|
|
4879
|
+
});
|
|
4880
|
+
class CylinderSupportShape extends createClass()(cylinderSupportShapeProps) {
|
|
4878
4881
|
getConvexRadius() {
|
|
4879
4882
|
return this.convexRadius;
|
|
4880
4883
|
}
|
|
@@ -4897,7 +4900,7 @@ class CylinderSupportShape extends createClass(
|
|
|
4897
4900
|
throw new Error("Method not implemented.");
|
|
4898
4901
|
}
|
|
4899
4902
|
}
|
|
4900
|
-
const cylinderProps = {
|
|
4903
|
+
const cylinderProps = props({
|
|
4901
4904
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
4902
4905
|
computedVolume: NumberType(0, true),
|
|
4903
4906
|
computedAabb: ChildType(Aabb, void 0, true),
|
|
@@ -4907,11 +4910,11 @@ const cylinderProps = {
|
|
|
4907
4910
|
translation: ChildType(Vec3, void 0, true),
|
|
4908
4911
|
supportShape: ChildType(CylinderSupportShape, void 0, true),
|
|
4909
4912
|
copyForDiff: LazyReferenceType((() => Cylinder))
|
|
4910
|
-
};
|
|
4913
|
+
});
|
|
4911
4914
|
const afterConstructorCode$7 = `
|
|
4912
4915
|
this.world = null;
|
|
4913
4916
|
`;
|
|
4914
|
-
class Cylinder extends createClass(
|
|
4917
|
+
class Cylinder extends createClass({ afterConstructorCode: afterConstructorCode$7 })(cylinderProps) {
|
|
4915
4918
|
constructor() {
|
|
4916
4919
|
super(...arguments);
|
|
4917
4920
|
this.type = ShapeType.cylinder;
|
|
@@ -5067,11 +5070,11 @@ const support = /* @__PURE__ */ Vec3.create();
|
|
|
5067
5070
|
const supportTop = /* @__PURE__ */ Vec3.create();
|
|
5068
5071
|
const negatedScaledHalfHeightOfCylinder = /* @__PURE__ */ Vec3.create();
|
|
5069
5072
|
const supportBottom = /* @__PURE__ */ Vec3.create();
|
|
5070
|
-
const capsuleNoConvexProps = {
|
|
5073
|
+
const capsuleNoConvexProps = props({
|
|
5071
5074
|
halfHeightOfCylinder: Vec3,
|
|
5072
5075
|
convexRadius: 0
|
|
5073
|
-
};
|
|
5074
|
-
class CapsuleNoConvex extends createClass(capsuleNoConvexProps) {
|
|
5076
|
+
});
|
|
5077
|
+
class CapsuleNoConvex extends createClass()(capsuleNoConvexProps) {
|
|
5075
5078
|
computeSupport(out, direction2) {
|
|
5076
5079
|
if (direction2.y > 0) {
|
|
5077
5080
|
out.copy(this.halfHeightOfCylinder);
|
|
@@ -5086,13 +5089,11 @@ class CapsuleNoConvex extends createClass(capsuleNoConvexProps) {
|
|
|
5086
5089
|
throw new Error("Method not implemented.");
|
|
5087
5090
|
}
|
|
5088
5091
|
}
|
|
5089
|
-
const capsuleWithConvexProps = {
|
|
5092
|
+
const capsuleWithConvexProps = props({
|
|
5090
5093
|
halfHeightOfCylinder: Vec3,
|
|
5091
5094
|
radius: 0
|
|
5092
|
-
};
|
|
5093
|
-
class CapsuleWithConvex extends createClass(
|
|
5094
|
-
capsuleWithConvexProps
|
|
5095
|
-
) {
|
|
5095
|
+
});
|
|
5096
|
+
class CapsuleWithConvex extends createClass()(capsuleWithConvexProps) {
|
|
5096
5097
|
computeSupport(out, direction2) {
|
|
5097
5098
|
const len = direction2.length();
|
|
5098
5099
|
if (len > 0) {
|
|
@@ -5113,7 +5114,7 @@ class CapsuleWithConvex extends createClass(
|
|
|
5113
5114
|
throw new Error("Method not implemented.");
|
|
5114
5115
|
}
|
|
5115
5116
|
}
|
|
5116
|
-
const capsuleProps = {
|
|
5117
|
+
const capsuleProps = props({
|
|
5117
5118
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
5118
5119
|
computedVolume: NumberType(0, true),
|
|
5119
5120
|
computedAabb: ChildType(Aabb, void 0, true),
|
|
@@ -5122,11 +5123,11 @@ const capsuleProps = {
|
|
|
5122
5123
|
copyForDiff: LazyReferenceType((() => Capsule)),
|
|
5123
5124
|
capsuleNoConvex: ChildType(CapsuleNoConvex, void 0, true),
|
|
5124
5125
|
capsuleWithConvex: ChildType(CapsuleWithConvex, void 0, true)
|
|
5125
|
-
};
|
|
5126
|
+
});
|
|
5126
5127
|
const afterConstructorCode$6 = `
|
|
5127
5128
|
this.world = null;
|
|
5128
5129
|
`;
|
|
5129
|
-
class Capsule extends createClass(
|
|
5130
|
+
class Capsule extends createClass({ afterConstructorCode: afterConstructorCode$6 })(capsuleProps) {
|
|
5130
5131
|
constructor() {
|
|
5131
5132
|
super(...arguments);
|
|
5132
5133
|
this.type = ShapeType.capsule;
|
|
@@ -5271,7 +5272,7 @@ function updateShape$3(shape) {
|
|
|
5271
5272
|
updateVolume$2(shape);
|
|
5272
5273
|
updateLocalBounds$3(shape);
|
|
5273
5274
|
}
|
|
5274
|
-
const transformedShapeProps = {
|
|
5275
|
+
const transformedShapeProps = props({
|
|
5275
5276
|
shapeType: NumberType(ShapeType.box),
|
|
5276
5277
|
// we need to do "as 'shape' ..." otherwise they are just 'string' and not the actual specific keys
|
|
5277
5278
|
["shape" + ShapeType.box]: ReferenceType(Box, void 0, true),
|
|
@@ -5283,14 +5284,11 @@ const transformedShapeProps = {
|
|
|
5283
5284
|
["shape" + ShapeType.sphere]: ReferenceType(Sphere, void 0, true),
|
|
5284
5285
|
// triangleMesh not supported
|
|
5285
5286
|
transform: BasicTransform
|
|
5286
|
-
};
|
|
5287
|
+
});
|
|
5287
5288
|
const afterConstructorCode$5 = `
|
|
5288
5289
|
this.world = null;
|
|
5289
5290
|
`;
|
|
5290
|
-
class TransformedShape extends createClass(
|
|
5291
|
-
transformedShapeProps,
|
|
5292
|
-
{ afterConstructorCode: afterConstructorCode$5 }
|
|
5293
|
-
) {
|
|
5291
|
+
class TransformedShape extends createClass({ afterConstructorCode: afterConstructorCode$5 })(transformedShapeProps) {
|
|
5294
5292
|
get shape() {
|
|
5295
5293
|
return this["shape" + this.shapeType];
|
|
5296
5294
|
}
|
|
@@ -5312,18 +5310,18 @@ const transformedCenterOfMass = /* @__PURE__ */ Vec3.create();
|
|
|
5312
5310
|
const transformSubshapeToCompound = /* @__PURE__ */ Isometry.create();
|
|
5313
5311
|
const subShapeDirection = /* @__PURE__ */ Vec3.create();
|
|
5314
5312
|
const subShapeToWorld = /* @__PURE__ */ Isometry.create();
|
|
5315
|
-
const compoundShapeProps = {
|
|
5313
|
+
const compoundShapeProps = props({
|
|
5316
5314
|
computedCenterOfMass: ChildType(Vec3, {}, true),
|
|
5317
5315
|
computedVolume: NumberType(0, true),
|
|
5318
5316
|
computedAabb: ChildType(Aabb, {}, true),
|
|
5319
5317
|
copyForDiff: LazyReferenceType((() => CompoundShape)),
|
|
5320
5318
|
shapes: ReferenceListType(TransformedShape)
|
|
5321
|
-
};
|
|
5319
|
+
});
|
|
5322
5320
|
const afterConstructorCode$4 = `
|
|
5323
5321
|
this.world = null;
|
|
5324
5322
|
`;
|
|
5325
5323
|
const tempTransform = /* @__PURE__ */ BasicTransform.create();
|
|
5326
|
-
class CompoundShape extends createClass(
|
|
5324
|
+
class CompoundShape extends createClass({ afterConstructorCode: afterConstructorCode$4 })(compoundShapeProps) {
|
|
5327
5325
|
constructor() {
|
|
5328
5326
|
super(...arguments);
|
|
5329
5327
|
this.type = ShapeType.compoundShape;
|
|
@@ -5527,7 +5525,7 @@ const d = /* @__PURE__ */ Vec3.create();
|
|
|
5527
5525
|
const scale$1 = /* @__PURE__ */ Vec3.create();
|
|
5528
5526
|
const blockAabb = /* @__PURE__ */ Aabb.create();
|
|
5529
5527
|
const normal$1 = /* @__PURE__ */ Vec3.create();
|
|
5530
|
-
const heightMapProps = {
|
|
5528
|
+
const heightMapProps = props({
|
|
5531
5529
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
5532
5530
|
computedVolume: NumberType(0, true),
|
|
5533
5531
|
computedAabb: ChildType(Aabb, {}, true),
|
|
@@ -5540,18 +5538,18 @@ const heightMapProps = {
|
|
|
5540
5538
|
// maxHeights: PoolReferenceType(Vec1),
|
|
5541
5539
|
// levels: PoolReferenceType(Vec1),
|
|
5542
5540
|
// activeEdges: PoolReferenceType(Vec1),
|
|
5543
|
-
};
|
|
5541
|
+
});
|
|
5544
5542
|
const afterConstructorCode$3 = `
|
|
5545
|
-
this.world = null;
|
|
5546
|
-
this.heights = [];
|
|
5547
|
-
this.minHeights = [];
|
|
5548
|
-
this.maxHeights = [];
|
|
5549
|
-
this.levels = [];
|
|
5550
|
-
this.activeEdges = [];
|
|
5551
|
-
this.stack = [];
|
|
5552
|
-
this.children = [0, 0, 0, 0];
|
|
5543
|
+
this.world = null;
|
|
5544
|
+
this.heights = [];
|
|
5545
|
+
this.minHeights = [];
|
|
5546
|
+
this.maxHeights = [];
|
|
5547
|
+
this.levels = [];
|
|
5548
|
+
this.activeEdges = [];
|
|
5549
|
+
this.stack = [];
|
|
5550
|
+
this.children = [0, 0, 0, 0];
|
|
5553
5551
|
`;
|
|
5554
|
-
class HeightMap extends createClass(
|
|
5552
|
+
class HeightMap extends createClass({ afterConstructorCode: afterConstructorCode$3 })(heightMapProps) {
|
|
5555
5553
|
constructor() {
|
|
5556
5554
|
super(...arguments);
|
|
5557
5555
|
this.type = ShapeType.heightMap;
|
|
@@ -5678,8 +5676,8 @@ class HeightMap extends createClass(heightMapProps, { afterConstructorCode: afte
|
|
|
5678
5676
|
}
|
|
5679
5677
|
}
|
|
5680
5678
|
/**
|
|
5681
|
-
|
|
5682
|
-
|
|
5679
|
+
* this function visits every block and triangle of the heightMap. take care when using it on high resolution heightMaps. it is intended to generate a debug visualization of the heightMap.
|
|
5680
|
+
*/
|
|
5683
5681
|
createTriangulatedVerticesAndNormalsArray() {
|
|
5684
5682
|
const vertices = [];
|
|
5685
5683
|
const normals = [];
|
|
@@ -5782,15 +5780,15 @@ function updateShape$1(shape) {
|
|
|
5782
5780
|
updateVolume(shape);
|
|
5783
5781
|
updateLocalBounds$1(shape);
|
|
5784
5782
|
}
|
|
5785
|
-
const bvhNodeProps = {
|
|
5783
|
+
const bvhNodeProps = props({
|
|
5786
5784
|
parent: LazyReferenceType((() => TriangleMeshBvhNode)),
|
|
5787
5785
|
left: LazyReferenceType((() => TriangleMeshBvhNode)),
|
|
5788
5786
|
right: LazyReferenceType((() => TriangleMeshBvhNode)),
|
|
5789
5787
|
computedBounds: ChildType(Aabb, void 0, true),
|
|
5790
5788
|
depth: NumberType(0, true),
|
|
5791
5789
|
objects: LazyReferenceListType((() => Triangle$1))
|
|
5792
|
-
};
|
|
5793
|
-
class TriangleMeshBvhNode extends createClass(bvhNodeProps) {
|
|
5790
|
+
});
|
|
5791
|
+
class TriangleMeshBvhNode extends createClass()(bvhNodeProps) {
|
|
5794
5792
|
/**
|
|
5795
5793
|
* if bvh node is an internal node, this will be an empty list
|
|
5796
5794
|
* if bvh node is a leaf node, this will contain refs to the objects in the leaf
|
|
@@ -5845,12 +5843,10 @@ function splitObjects(objects) {
|
|
|
5845
5843
|
const rightObjects = objects.slice(mid);
|
|
5846
5844
|
return [leftObjects, rightObjects];
|
|
5847
5845
|
}
|
|
5848
|
-
const triangleMeshBvhTreeProps = {
|
|
5846
|
+
const triangleMeshBvhTreeProps = props({
|
|
5849
5847
|
nodes: ReferenceListType(TriangleMeshBvhNode)
|
|
5850
|
-
};
|
|
5851
|
-
class TriangleMeshBvhTree extends createClass(
|
|
5852
|
-
triangleMeshBvhTreeProps
|
|
5853
|
-
) {
|
|
5848
|
+
});
|
|
5849
|
+
class TriangleMeshBvhTree extends createClass()(triangleMeshBvhTreeProps) {
|
|
5854
5850
|
constructor() {
|
|
5855
5851
|
super(...arguments);
|
|
5856
5852
|
this.intersectStack = [];
|
|
@@ -6045,7 +6041,7 @@ const halfExtents$1 = /* @__PURE__ */ Vec3.create();
|
|
|
6045
6041
|
const nodeBounds = /* @__PURE__ */ Aabb.create();
|
|
6046
6042
|
const bodyBounds = /* @__PURE__ */ Aabb.create();
|
|
6047
6043
|
const isometry$2 = /* @__PURE__ */ Isometry.create();
|
|
6048
|
-
const triangleMeshProps = {
|
|
6044
|
+
const triangleMeshProps = props({
|
|
6049
6045
|
computedCenterOfMass: ChildType(Vec3, void 0, true),
|
|
6050
6046
|
computedVolume: NumberType(0, true),
|
|
6051
6047
|
computedAabb: ChildType(Aabb, void 0, true),
|
|
@@ -6056,11 +6052,11 @@ const triangleMeshProps = {
|
|
|
6056
6052
|
triangles: ReferenceListType(Triangle$1),
|
|
6057
6053
|
copyForDiff: LazyReferenceType((() => TriangleMesh)),
|
|
6058
6054
|
bvh: LazyReferenceType((() => TriangleMeshBvhTree))
|
|
6059
|
-
};
|
|
6055
|
+
});
|
|
6060
6056
|
const afterConstructorCode$2 = `
|
|
6061
6057
|
this.world = null;
|
|
6062
6058
|
`;
|
|
6063
|
-
class TriangleMesh extends createClass(
|
|
6059
|
+
class TriangleMesh extends createClass({ afterConstructorCode: afterConstructorCode$2 })(triangleMeshProps) {
|
|
6064
6060
|
constructor() {
|
|
6065
6061
|
super(...arguments);
|
|
6066
6062
|
this.type = ShapeType.triangleMesh;
|
|
@@ -6148,7 +6144,7 @@ function updateShape(shape) {
|
|
|
6148
6144
|
updateCopyForDiff(shape);
|
|
6149
6145
|
updateLocalBounds(shape);
|
|
6150
6146
|
}
|
|
6151
|
-
const constraintOptionsProps = {
|
|
6147
|
+
const constraintOptionsProps = props({
|
|
6152
6148
|
/**
|
|
6153
6149
|
* Value used to scale the amount of position error to correct per solve iteration. Expected to be in the interval [0, 1]
|
|
6154
6150
|
*/
|
|
@@ -6161,12 +6157,10 @@ const constraintOptionsProps = {
|
|
|
6161
6157
|
* Value used to scale the strength of the constraint. recommend to tune in the interval of [0, 1], with 0 being no correction, 1 being full correction
|
|
6162
6158
|
*/
|
|
6163
6159
|
strength: 1
|
|
6164
|
-
};
|
|
6165
|
-
class ConstraintOptions extends createClass(
|
|
6166
|
-
constraintOptionsProps
|
|
6167
|
-
) {
|
|
6160
|
+
});
|
|
6161
|
+
class ConstraintOptions extends createClass()(constraintOptionsProps) {
|
|
6168
6162
|
}
|
|
6169
|
-
const pointConstraintComponentProps = {
|
|
6163
|
+
const pointConstraintComponentProps = props({
|
|
6170
6164
|
bodyA: LazyReferenceType((() => Body)),
|
|
6171
6165
|
bodyB: LazyReferenceType((() => Body)),
|
|
6172
6166
|
options: ChildType(ConstraintOptions, {
|
|
@@ -6180,8 +6174,8 @@ const pointConstraintComponentProps = {
|
|
|
6180
6174
|
effectiveInverseInertiaA: ChildType(Mat3, void 0, true),
|
|
6181
6175
|
effectiveInverseInertiaB: ChildType(Mat3, void 0, true),
|
|
6182
6176
|
totalLambda: ChildType(Vec3, void 0, true)
|
|
6183
|
-
};
|
|
6184
|
-
class PointConstraintComponent extends createClass(pointConstraintComponentProps) {
|
|
6177
|
+
});
|
|
6178
|
+
class PointConstraintComponent extends createClass()(pointConstraintComponentProps) {
|
|
6185
6179
|
deactivate() {
|
|
6186
6180
|
this.effectiveMass.zero();
|
|
6187
6181
|
this.totalLambda.zero();
|
|
@@ -6290,15 +6284,15 @@ const lambda$2 = /* @__PURE__ */ Vec3.create();
|
|
|
6290
6284
|
const transformWorldToLocalA$2 = /* @__PURE__ */ Isometry.create();
|
|
6291
6285
|
const transformWorldToLocalB$2 = /* @__PURE__ */ Isometry.create();
|
|
6292
6286
|
const transformLocalToWorld$3 = /* @__PURE__ */ Mat4.create();
|
|
6293
|
-
const pointConstraintProps = {
|
|
6287
|
+
const pointConstraintProps = props({
|
|
6294
6288
|
...baseConstraintProps,
|
|
6295
6289
|
positionA: Vec3,
|
|
6296
6290
|
positionB: Vec3,
|
|
6297
6291
|
localPositionA: ChildType(Vec3, void 0, true),
|
|
6298
6292
|
localPositionB: ChildType(Vec3, void 0, true),
|
|
6299
6293
|
translationComponent: PointConstraintComponent
|
|
6300
|
-
};
|
|
6301
|
-
class PointConstraint extends createClass(pointConstraintProps) {
|
|
6294
|
+
});
|
|
6295
|
+
class PointConstraint extends createClass()(pointConstraintProps) {
|
|
6302
6296
|
constructor() {
|
|
6303
6297
|
super(...arguments);
|
|
6304
6298
|
this.type = ConstraintType.pointConstraint;
|
|
@@ -6367,7 +6361,7 @@ PointConstraint.create = function() {
|
|
|
6367
6361
|
constraint.world.sleepModule.wakeBodyUp(constraint.bodyB);
|
|
6368
6362
|
return constraint;
|
|
6369
6363
|
};
|
|
6370
|
-
const rotationEulerComponentProps = {
|
|
6364
|
+
const rotationEulerComponentProps = props({
|
|
6371
6365
|
bodyA: LazyReferenceType((() => Body)),
|
|
6372
6366
|
bodyB: LazyReferenceType((() => Body)),
|
|
6373
6367
|
options: ChildType(ConstraintOptions, {
|
|
@@ -6379,10 +6373,8 @@ const rotationEulerComponentProps = {
|
|
|
6379
6373
|
mInvI2: ChildType(Mat3, void 0, true),
|
|
6380
6374
|
effectiveMassRotationComponent: ChildType(Mat3, void 0, true),
|
|
6381
6375
|
totalLambdaRotationComponent: ChildType(Vec3, void 0, true)
|
|
6382
|
-
};
|
|
6383
|
-
class RotationEulerComponent extends createClass(
|
|
6384
|
-
rotationEulerComponentProps
|
|
6385
|
-
) {
|
|
6376
|
+
});
|
|
6377
|
+
class RotationEulerComponent extends createClass()(rotationEulerComponentProps) {
|
|
6386
6378
|
deactivate() {
|
|
6387
6379
|
this.effectiveMassRotationComponent.zero();
|
|
6388
6380
|
this.totalLambdaRotationComponent.zero();
|
|
@@ -6474,7 +6466,7 @@ const anchor = /* @__PURE__ */ Vec3.create();
|
|
|
6474
6466
|
const transformWorldToLocalA$1 = /* @__PURE__ */ Mat4.create();
|
|
6475
6467
|
const transformWorldToLocalB$1 = /* @__PURE__ */ Mat4.create();
|
|
6476
6468
|
const inverseRotationB = /* @__PURE__ */ Quat.create();
|
|
6477
|
-
const fixedConstraintProps = {
|
|
6469
|
+
const fixedConstraintProps = props({
|
|
6478
6470
|
...baseConstraintProps,
|
|
6479
6471
|
positionA: ChildType(Vec3),
|
|
6480
6472
|
positionB: ChildType(Vec3),
|
|
@@ -6493,8 +6485,8 @@ const fixedConstraintProps = {
|
|
|
6493
6485
|
inverseInitialRotationAToB: ChildType(Quat, void 0, true),
|
|
6494
6486
|
translationComponent: PointConstraintComponent,
|
|
6495
6487
|
rotationComponent: RotationEulerComponent
|
|
6496
|
-
};
|
|
6497
|
-
class FixedConstraint extends createClass(fixedConstraintProps) {
|
|
6488
|
+
});
|
|
6489
|
+
class FixedConstraint extends createClass()(fixedConstraintProps) {
|
|
6498
6490
|
constructor() {
|
|
6499
6491
|
super(...arguments);
|
|
6500
6492
|
this.type = ConstraintType.fixedConstraint;
|
|
@@ -6627,7 +6619,7 @@ var SpringMode = /* @__PURE__ */ ((SpringMode2) => {
|
|
|
6627
6619
|
SpringMode2[SpringMode2["UseStiffness"] = 1] = "UseStiffness";
|
|
6628
6620
|
return SpringMode2;
|
|
6629
6621
|
})(SpringMode || {});
|
|
6630
|
-
const springProps = {
|
|
6622
|
+
const springProps = props({
|
|
6631
6623
|
mode: NumberType(
|
|
6632
6624
|
0
|
|
6633
6625
|
/* UseFrequency */
|
|
@@ -6635,8 +6627,8 @@ const springProps = {
|
|
|
6635
6627
|
damping: 0,
|
|
6636
6628
|
frequency: 0,
|
|
6637
6629
|
stiffness: 0
|
|
6638
|
-
};
|
|
6639
|
-
class Spring extends createClass(springProps) {
|
|
6630
|
+
});
|
|
6631
|
+
class Spring extends createClass()(springProps) {
|
|
6640
6632
|
hasStiffness() {
|
|
6641
6633
|
return this.frequency > 0;
|
|
6642
6634
|
}
|
|
@@ -6644,11 +6636,11 @@ class Spring extends createClass(springProps) {
|
|
|
6644
6636
|
return this.frequency >= 0 && this.damping >= 0 && this.stiffness >= 0;
|
|
6645
6637
|
}
|
|
6646
6638
|
}
|
|
6647
|
-
const springComponentProps = {
|
|
6639
|
+
const springComponentProps = props({
|
|
6648
6640
|
bias: 0,
|
|
6649
6641
|
softness: 0
|
|
6650
|
-
};
|
|
6651
|
-
class SpringComponent extends createClass(springComponentProps) {
|
|
6642
|
+
});
|
|
6643
|
+
class SpringComponent extends createClass()(springComponentProps) {
|
|
6652
6644
|
getBias(lambda2) {
|
|
6653
6645
|
return this.softness * lambda2 + this.bias;
|
|
6654
6646
|
}
|
|
@@ -6690,7 +6682,7 @@ const inverseInertiaA$1 = /* @__PURE__ */ Mat3.create();
|
|
|
6690
6682
|
const inverseInertiaB$1 = /* @__PURE__ */ Mat3.create();
|
|
6691
6683
|
const linearImpulse = /* @__PURE__ */ Vec3.create();
|
|
6692
6684
|
const angularImpulse = /* @__PURE__ */ Vec3.create();
|
|
6693
|
-
const axisComponentProps = {
|
|
6685
|
+
const axisComponentProps = props({
|
|
6694
6686
|
bodyA: LazyReferenceType((() => Body)),
|
|
6695
6687
|
bodyB: LazyReferenceType((() => Body)),
|
|
6696
6688
|
options: ChildType(ConstraintOptions, {
|
|
@@ -6705,8 +6697,8 @@ const axisComponentProps = {
|
|
|
6705
6697
|
effectiveMass: 0,
|
|
6706
6698
|
totalLambda: 0,
|
|
6707
6699
|
springComponent: SpringComponent
|
|
6708
|
-
};
|
|
6709
|
-
class AxisComponent extends createClass(axisComponentProps) {
|
|
6700
|
+
});
|
|
6701
|
+
class AxisComponent extends createClass()(axisComponentProps) {
|
|
6710
6702
|
deactivate() {
|
|
6711
6703
|
this.effectiveMass = 0;
|
|
6712
6704
|
this.totalLambda = 0;
|
|
@@ -6861,7 +6853,7 @@ const localToWorldTransformB = /* @__PURE__ */ Mat4.create();
|
|
|
6861
6853
|
const armA = /* @__PURE__ */ Vec3.create();
|
|
6862
6854
|
const armB = /* @__PURE__ */ Vec3.create();
|
|
6863
6855
|
const vectorAB$5 = /* @__PURE__ */ Vec3.create();
|
|
6864
|
-
const distanceConstraintProps = {
|
|
6856
|
+
const distanceConstraintProps = props({
|
|
6865
6857
|
...baseConstraintProps,
|
|
6866
6858
|
positionA: ChildType(Vec3, { x: 0, y: 0, z: 0 }),
|
|
6867
6859
|
positionB: ChildType(Vec3, { x: 0, y: 0, z: 0 }),
|
|
@@ -6876,8 +6868,8 @@ const distanceConstraintProps = {
|
|
|
6876
6868
|
worldNormal: ChildType(Vec3, void 0, true),
|
|
6877
6869
|
minLambda: NumberType(0, true),
|
|
6878
6870
|
maxLambda: NumberType(0, true)
|
|
6879
|
-
};
|
|
6880
|
-
class DistanceConstraint extends createClass(distanceConstraintProps) {
|
|
6871
|
+
});
|
|
6872
|
+
class DistanceConstraint extends createClass()(distanceConstraintProps) {
|
|
6881
6873
|
constructor() {
|
|
6882
6874
|
super(...arguments);
|
|
6883
6875
|
this.type = ConstraintType.distanceConstraint;
|
|
@@ -7024,7 +7016,7 @@ var MotorMode = /* @__PURE__ */ ((MotorMode2) => {
|
|
|
7024
7016
|
MotorMode2[MotorMode2["Velocity"] = 2] = "Velocity";
|
|
7025
7017
|
return MotorMode2;
|
|
7026
7018
|
})(MotorMode || {});
|
|
7027
|
-
const motorProps = {
|
|
7019
|
+
const motorProps = props({
|
|
7028
7020
|
spring: ChildType(Spring, { mode: SpringMode.UseFrequency, damping: 1, frequency: 2, stiffness: 2 }),
|
|
7029
7021
|
minForce: NumberType(-Infinity),
|
|
7030
7022
|
maxForce: NumberType(Infinity),
|
|
@@ -7034,8 +7026,8 @@ const motorProps = {
|
|
|
7034
7026
|
0
|
|
7035
7027
|
/* Off */
|
|
7036
7028
|
)
|
|
7037
|
-
};
|
|
7038
|
-
class Motor extends createClass(motorProps) {
|
|
7029
|
+
});
|
|
7030
|
+
class Motor extends createClass()(motorProps) {
|
|
7039
7031
|
isValid() {
|
|
7040
7032
|
return this.spring.isValid() && this.minForce <= this.maxForce && this.minTorque <= this.maxTorque;
|
|
7041
7033
|
}
|
|
@@ -7047,7 +7039,7 @@ const perpendicular$1 = /* @__PURE__ */ Vec3.create();
|
|
|
7047
7039
|
const summedInverseInertia = /* @__PURE__ */ Mat3.create();
|
|
7048
7040
|
const massBA = /* @__PURE__ */ Vec3.create();
|
|
7049
7041
|
const massCA = /* @__PURE__ */ Vec3.create();
|
|
7050
|
-
const hingeComponentProps = {
|
|
7042
|
+
const hingeComponentProps = props({
|
|
7051
7043
|
bodyA: LazyReferenceType((() => Body)),
|
|
7052
7044
|
bodyB: LazyReferenceType((() => Body)),
|
|
7053
7045
|
options: ChildType(ConstraintOptions, {
|
|
@@ -7068,7 +7060,7 @@ const hingeComponentProps = {
|
|
|
7068
7060
|
inverseInertiaB: ChildType(Mat3, void 0, true),
|
|
7069
7061
|
totalLambdaA: NumberType(0, true),
|
|
7070
7062
|
totalLambdaB: NumberType(0, true)
|
|
7071
|
-
};
|
|
7063
|
+
});
|
|
7072
7064
|
function getOrthogonalVector(out, a3) {
|
|
7073
7065
|
if (Math.abs(a3.x) > Math.abs(a3.y)) {
|
|
7074
7066
|
out.fromArray([a3.z, 0, -a3.x]);
|
|
@@ -7076,7 +7068,7 @@ function getOrthogonalVector(out, a3) {
|
|
|
7076
7068
|
out.fromArray([0, a3.z, -a3.y]);
|
|
7077
7069
|
}
|
|
7078
7070
|
}
|
|
7079
|
-
class HingeComponent extends createClass(hingeComponentProps) {
|
|
7071
|
+
class HingeComponent extends createClass()(hingeComponentProps) {
|
|
7080
7072
|
deactivate() {
|
|
7081
7073
|
this.effectiveMass00 = 0;
|
|
7082
7074
|
this.effectiveMass01 = 0;
|
|
@@ -7194,7 +7186,7 @@ class HingeComponent extends createClass(hingeComponentProps) {
|
|
|
7194
7186
|
const spinBA = /* @__PURE__ */ Vec3.create();
|
|
7195
7187
|
const deltaSpin$1 = /* @__PURE__ */ Vec3.create();
|
|
7196
7188
|
const inverseEffectiveMass = /* @__PURE__ */ Vec3.create();
|
|
7197
|
-
const angleComponentProps = {
|
|
7189
|
+
const angleComponentProps = props({
|
|
7198
7190
|
bodyA: LazyReferenceType((() => Body)),
|
|
7199
7191
|
bodyB: LazyReferenceType((() => Body)),
|
|
7200
7192
|
options: ChildType(ConstraintOptions, {
|
|
@@ -7207,8 +7199,8 @@ const angleComponentProps = {
|
|
|
7207
7199
|
effectiveInverseInertiaA: ChildType(Vec3, void 0, true),
|
|
7208
7200
|
effectiveInverseInertiaB: ChildType(Vec3, void 0, true),
|
|
7209
7201
|
totalLambda: NumberType(0, true)
|
|
7210
|
-
};
|
|
7211
|
-
class AngleComponent extends createClass(angleComponentProps) {
|
|
7202
|
+
});
|
|
7203
|
+
class AngleComponent extends createClass()(angleComponentProps) {
|
|
7212
7204
|
deactivate() {
|
|
7213
7205
|
this.effectiveMass = 0;
|
|
7214
7206
|
this.totalLambda = 0;
|
|
@@ -7361,7 +7353,7 @@ const rotateLocalToWorldB = /* @__PURE__ */ Mat3.create();
|
|
|
7361
7353
|
const worldHingeA = /* @__PURE__ */ Vec3.create();
|
|
7362
7354
|
const worldHingeB = /* @__PURE__ */ Vec3.create();
|
|
7363
7355
|
const transformLocalToWorld = /* @__PURE__ */ Mat4.create();
|
|
7364
|
-
const hingeConstraintProps = {
|
|
7356
|
+
const hingeConstraintProps = props({
|
|
7365
7357
|
...baseConstraintProps,
|
|
7366
7358
|
// init data
|
|
7367
7359
|
pointA: ChildType(Vec3, { x: 0, y: 0, z: 0 }),
|
|
@@ -7393,8 +7385,8 @@ const hingeConstraintProps = {
|
|
|
7393
7385
|
rotationConstraintPart: HingeComponent,
|
|
7394
7386
|
rotationLimitsConstraintPart: AngleComponent,
|
|
7395
7387
|
motorConstraintPart: AngleComponent
|
|
7396
|
-
};
|
|
7397
|
-
class HingeConstraint extends createClass(hingeConstraintProps) {
|
|
7388
|
+
});
|
|
7389
|
+
class HingeConstraint extends createClass()(hingeConstraintProps) {
|
|
7398
7390
|
constructor() {
|
|
7399
7391
|
super(...arguments);
|
|
7400
7392
|
this.type = ConstraintType.hingeConstraint;
|
|
@@ -7697,7 +7689,7 @@ HingeConstraint.create = function() {
|
|
|
7697
7689
|
constraint.world.sleepModule.wakeBodyUp(constraint.bodyB);
|
|
7698
7690
|
return constraint;
|
|
7699
7691
|
};
|
|
7700
|
-
const constraintPairNodeProps = {
|
|
7692
|
+
const constraintPairNodeProps = props({
|
|
7701
7693
|
bodyA: LazyReferenceType((() => Body)),
|
|
7702
7694
|
bodyB: LazyReferenceType((() => Body)),
|
|
7703
7695
|
edgeA: LazyReferenceType((() => ConstraintPairEdge)),
|
|
@@ -7707,14 +7699,13 @@ const constraintPairNodeProps = {
|
|
|
7707
7699
|
constraintFixed: LazyReferenceType((() => FixedConstraint)),
|
|
7708
7700
|
constraintDistance: LazyReferenceType((() => DistanceConstraint)),
|
|
7709
7701
|
constraintHinge: LazyReferenceType((() => HingeConstraint))
|
|
7710
|
-
};
|
|
7702
|
+
});
|
|
7711
7703
|
const afterConstructorCode$1 = `
|
|
7712
7704
|
this.world = null;
|
|
7713
7705
|
this.constraints = [null, null, null, null];
|
|
7714
7706
|
`;
|
|
7715
|
-
class ConstraintPairNode extends createClass(
|
|
7716
|
-
constraintPairNodeProps
|
|
7717
|
-
{ afterConstructorCode: afterConstructorCode$1 }
|
|
7707
|
+
class ConstraintPairNode extends createClass({ afterConstructorCode: afterConstructorCode$1 })(
|
|
7708
|
+
constraintPairNodeProps
|
|
7718
7709
|
) {
|
|
7719
7710
|
containsStaticBody() {
|
|
7720
7711
|
return this.bodyA.type === BodyType.static || this.bodyB.type === BodyType.static;
|
|
@@ -7732,14 +7723,12 @@ class ConstraintPairNode extends createClass(
|
|
|
7732
7723
|
this.constraintType = value.type;
|
|
7733
7724
|
}
|
|
7734
7725
|
}
|
|
7735
|
-
const constraintPairEdgeProps = {
|
|
7726
|
+
const constraintPairEdgeProps = props({
|
|
7736
7727
|
node: LazyReferenceType((() => ConstraintPairNode)),
|
|
7737
7728
|
next: LazyReferenceType((() => ConstraintPairEdge)),
|
|
7738
7729
|
prev: LazyReferenceType((() => ConstraintPairEdge))
|
|
7739
|
-
};
|
|
7740
|
-
class ConstraintPairEdge extends createClass(
|
|
7741
|
-
constraintPairEdgeProps
|
|
7742
|
-
) {
|
|
7730
|
+
});
|
|
7731
|
+
class ConstraintPairEdge extends createClass()(constraintPairEdgeProps) {
|
|
7743
7732
|
}
|
|
7744
7733
|
class ConstraintPairsModule {
|
|
7745
7734
|
constructor(constraintPairNodePool, constraintPairEdgePool) {
|
|
@@ -7980,7 +7969,7 @@ var ColliderType = /* @__PURE__ */ ((ColliderType2) => {
|
|
|
7980
7969
|
ColliderType2[ColliderType2["attractor"] = 3] = "attractor";
|
|
7981
7970
|
return ColliderType2;
|
|
7982
7971
|
})(ColliderType || {});
|
|
7983
|
-
const bodyProps = {
|
|
7972
|
+
const bodyProps = props({
|
|
7984
7973
|
type: NumberType(
|
|
7985
7974
|
0
|
|
7986
7975
|
/* dynamic */
|
|
@@ -7991,6 +7980,7 @@ const bodyProps = {
|
|
|
7991
7980
|
angularVelocity: Vec3,
|
|
7992
7981
|
computedCenterOfMassPosition: ChildType(Vec3, void 0, true),
|
|
7993
7982
|
computedBounds: ChildType(Aabb, void 0, true),
|
|
7983
|
+
computedExpandedBounds: ChildType(Aabb, void 0, true),
|
|
7994
7984
|
previousPosition: ChildType(Vec3, void 0, true),
|
|
7995
7985
|
previousOrientation: ChildType(Quat, void 0, true),
|
|
7996
7986
|
isSleeping: BooleanType(false, true),
|
|
@@ -8033,15 +8023,18 @@ const bodyProps = {
|
|
|
8033
8023
|
(() => ConstraintPairEdge)
|
|
8034
8024
|
),
|
|
8035
8025
|
visitGeneration: NumberType(0, true)
|
|
8036
|
-
};
|
|
8026
|
+
});
|
|
8037
8027
|
const afterConstructorCode = `
|
|
8038
8028
|
this.world = null;
|
|
8039
8029
|
`;
|
|
8040
|
-
class Body extends createClass(
|
|
8030
|
+
class Body extends createClass({ afterConstructorCode })(bodyProps) {
|
|
8041
8031
|
get shape() {
|
|
8042
8032
|
return this["shape" + this.shapeType];
|
|
8043
8033
|
}
|
|
8044
8034
|
set shape(newShape) {
|
|
8035
|
+
this.setShape(newShape);
|
|
8036
|
+
}
|
|
8037
|
+
setShape(newShape, updateBroadphase = true) {
|
|
8045
8038
|
this["shape" + this.shapeType] = null;
|
|
8046
8039
|
this["shape" + newShape.type] = newShape;
|
|
8047
8040
|
this.shapeType = newShape.type;
|
|
@@ -8063,7 +8056,9 @@ class Body extends createClass(bodyProps, { afterConstructorCode }) {
|
|
|
8063
8056
|
newShape.computedVolume = hull.computedVolume;
|
|
8064
8057
|
newShape.inertia.copy(hull.inertia);
|
|
8065
8058
|
}
|
|
8066
|
-
|
|
8059
|
+
if (updateBroadphase) {
|
|
8060
|
+
updateBody(this);
|
|
8061
|
+
}
|
|
8067
8062
|
}
|
|
8068
8063
|
// physics integration functions
|
|
8069
8064
|
/**
|
|
@@ -8379,114 +8374,15 @@ function updateMassProperties(body2) {
|
|
|
8379
8374
|
body2.shape.computeInverseInertiaTensor(body2.computedLocalInverseInertia, body2.mass);
|
|
8380
8375
|
transformTensor(body2.computedWorldInverseInertia, body2.computedLocalInverseInertia, body2.orientation);
|
|
8381
8376
|
}
|
|
8382
|
-
function updateBody(body2) {
|
|
8377
|
+
function updateBody(body2, updateBroadphase = true) {
|
|
8383
8378
|
updateMassProperties(body2);
|
|
8384
8379
|
updateCenterOfMassPosition(body2);
|
|
8385
8380
|
updateWorldBounds(body2);
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
CollisionStatus2[CollisionStatus2["NotColliding"] = 0] = "NotColliding";
|
|
8389
|
-
CollisionStatus2[CollisionStatus2["Colliding"] = 1] = "Colliding";
|
|
8390
|
-
CollisionStatus2[CollisionStatus2["Indeterminate"] = 2] = "Indeterminate";
|
|
8391
|
-
return CollisionStatus2;
|
|
8392
|
-
})(CollisionStatus || {});
|
|
8393
|
-
const collisionResultProps = {
|
|
8394
|
-
status: NumberType(
|
|
8395
|
-
2
|
|
8396
|
-
/* Indeterminate */
|
|
8397
|
-
),
|
|
8398
|
-
hasContact: BooleanType(false),
|
|
8399
|
-
penetration: 0,
|
|
8400
|
-
contactPointA: Vec3,
|
|
8401
|
-
contactPointB: Vec3,
|
|
8402
|
-
normalA: Vec3,
|
|
8403
|
-
normalB: Vec3,
|
|
8404
|
-
momentArmA: Vec3,
|
|
8405
|
-
momentArmB: Vec3,
|
|
8406
|
-
surfaceNormalA: Vec3,
|
|
8407
|
-
surfaceNormalB: Vec3,
|
|
8408
|
-
bodyA: LazyReferenceType((() => Body)),
|
|
8409
|
-
bodyB: LazyReferenceType((() => Body)),
|
|
8410
|
-
subShapeIdA: 0,
|
|
8411
|
-
subShapeIdB: 0,
|
|
8412
|
-
isBackFace: BooleanType(false),
|
|
8413
|
-
faceA: Face,
|
|
8414
|
-
faceB: Face
|
|
8415
|
-
};
|
|
8416
|
-
class CollisionResult extends createClass(collisionResultProps) {
|
|
8417
|
-
/**
|
|
8418
|
-
* swaps the A and B data
|
|
8419
|
-
*/
|
|
8420
|
-
swap() {
|
|
8421
|
-
this.contactPointA.swap(this.contactPointB);
|
|
8422
|
-
this.normalA.swap(this.normalB);
|
|
8423
|
-
this.momentArmA.swap(this.momentArmB);
|
|
8424
|
-
this.surfaceNormalA.swap(this.surfaceNormalB);
|
|
8425
|
-
const tempBody = this.bodyA;
|
|
8426
|
-
this.bodyA = this.bodyB;
|
|
8427
|
-
this.bodyB = tempBody;
|
|
8428
|
-
const tempSubShapeId = this.subShapeIdA;
|
|
8429
|
-
this.subShapeIdA = this.subShapeIdB;
|
|
8430
|
-
this.subShapeIdB = tempSubShapeId;
|
|
8431
|
-
const tempFace = this.faceA;
|
|
8432
|
-
this.faceA = this.faceB;
|
|
8433
|
-
this.faceB = tempFace;
|
|
8381
|
+
if (updateBroadphase) {
|
|
8382
|
+
body2.markBodyAsDirty();
|
|
8434
8383
|
}
|
|
8435
8384
|
}
|
|
8436
|
-
const
|
|
8437
|
-
constructor() {
|
|
8438
|
-
this.earlyOutFraction = _CollisionCollector.initialEarlyOutFraction;
|
|
8439
|
-
this.body2 = null;
|
|
8440
|
-
}
|
|
8441
|
-
getEarlyOutFraction() {
|
|
8442
|
-
return _CollisionCollector.initialEarlyOutFraction;
|
|
8443
|
-
}
|
|
8444
|
-
getPositiveEarlyOutFraction() {
|
|
8445
|
-
return Math.max(Number.MIN_VALUE, this.earlyOutFraction);
|
|
8446
|
-
}
|
|
8447
|
-
reset() {
|
|
8448
|
-
this.earlyOutFraction = _CollisionCollector.initialEarlyOutFraction;
|
|
8449
|
-
this.body2 = null;
|
|
8450
|
-
return this;
|
|
8451
|
-
}
|
|
8452
|
-
addHit(result2) {
|
|
8453
|
-
}
|
|
8454
|
-
addMiss() {
|
|
8455
|
-
}
|
|
8456
|
-
};
|
|
8457
|
-
_CollisionCollector.initialEarlyOutFraction = Infinity;
|
|
8458
|
-
_CollisionCollector.shouldEarlyOutFraction = -Infinity;
|
|
8459
|
-
let CollisionCollector = _CollisionCollector;
|
|
8460
|
-
var CollectFacesMode = /* @__PURE__ */ ((CollectFacesMode2) => {
|
|
8461
|
-
CollectFacesMode2[CollectFacesMode2["CollectFaces"] = 0] = "CollectFaces";
|
|
8462
|
-
CollectFacesMode2[CollectFacesMode2["NoFaces"] = 1] = "NoFaces";
|
|
8463
|
-
return CollectFacesMode2;
|
|
8464
|
-
})(CollectFacesMode || {});
|
|
8465
|
-
var ActiveEdgeMode = /* @__PURE__ */ ((ActiveEdgeMode2) => {
|
|
8466
|
-
ActiveEdgeMode2[ActiveEdgeMode2["CollideOnlyWithActive"] = 0] = "CollideOnlyWithActive";
|
|
8467
|
-
ActiveEdgeMode2[ActiveEdgeMode2["CollideWithAll"] = 1] = "CollideWithAll";
|
|
8468
|
-
return ActiveEdgeMode2;
|
|
8469
|
-
})(ActiveEdgeMode || {});
|
|
8470
|
-
var BackFaceMode = /* @__PURE__ */ ((BackFaceMode2) => {
|
|
8471
|
-
BackFaceMode2[BackFaceMode2["IgnoreBackFaces"] = 0] = "IgnoreBackFaces";
|
|
8472
|
-
BackFaceMode2[BackFaceMode2["CollideWithBackFaces"] = 1] = "CollideWithBackFaces";
|
|
8473
|
-
return BackFaceMode2;
|
|
8474
|
-
})(BackFaceMode || {});
|
|
8475
|
-
function createDefaultCollisionSettings() {
|
|
8476
|
-
return {
|
|
8477
|
-
maxSeparation: 0,
|
|
8478
|
-
collisionTolerance: 1e-4,
|
|
8479
|
-
activeEdgeMode: 0,
|
|
8480
|
-
collectFacesMode: 1,
|
|
8481
|
-
penetrationTolerance: 1e-4,
|
|
8482
|
-
activeEdgeMovementDirectionX: 0,
|
|
8483
|
-
activeEdgeMovementDirectionY: 0,
|
|
8484
|
-
activeEdgeMovementDirectionZ: 0,
|
|
8485
|
-
backFaceMode: 0
|
|
8486
|
-
/* IgnoreBackFaces */
|
|
8487
|
-
};
|
|
8488
|
-
}
|
|
8489
|
-
const castResultProps = {
|
|
8385
|
+
const castResultProps = props({
|
|
8490
8386
|
status: NumberType(
|
|
8491
8387
|
2
|
|
8492
8388
|
/* Indeterminate */
|
|
@@ -8510,8 +8406,8 @@ const castResultProps = {
|
|
|
8510
8406
|
faceB: Face,
|
|
8511
8407
|
fraction: 0,
|
|
8512
8408
|
isBackFaceHit: BooleanType(false)
|
|
8513
|
-
};
|
|
8514
|
-
class CastResult extends createClass(castResultProps) {
|
|
8409
|
+
});
|
|
8410
|
+
class CastResult extends createClass()(castResultProps) {
|
|
8515
8411
|
/**
|
|
8516
8412
|
* swaps the A and B data
|
|
8517
8413
|
*/
|
|
@@ -8567,15 +8463,6 @@ var QueryPrecision = /* @__PURE__ */ ((QueryPrecision2) => {
|
|
|
8567
8463
|
QueryPrecision2[QueryPrecision2["preciseWithContacts"] = 2] = "preciseWithContacts";
|
|
8568
8464
|
return QueryPrecision2;
|
|
8569
8465
|
})(QueryPrecision || {});
|
|
8570
|
-
function createDefaultCastSettings() {
|
|
8571
|
-
return {
|
|
8572
|
-
...createDefaultCollisionSettings(),
|
|
8573
|
-
backFaceModeConvex: BackFaceMode.IgnoreBackFaces,
|
|
8574
|
-
backFaceModeTriangles: BackFaceMode.IgnoreBackFaces,
|
|
8575
|
-
useShrunkenShapeAndConvexRadius: false,
|
|
8576
|
-
returnDeepestPoint: false
|
|
8577
|
-
};
|
|
8578
|
-
}
|
|
8579
8466
|
const ab$4 = /* @__PURE__ */ Vec3.create();
|
|
8580
8467
|
function computeBarycentricCoordinates2d(outBarycentric, a3, b3, squaredTolerance = 1e-10) {
|
|
8581
8468
|
ab$4.subtractVectors(b3, a3);
|
|
@@ -8596,21 +8483,21 @@ function computeBarycentricCoordinates2d(outBarycentric, a3, b3, squaredToleranc
|
|
|
8596
8483
|
}
|
|
8597
8484
|
outBarycentric.isValid = true;
|
|
8598
8485
|
}
|
|
8599
|
-
const closestPointResultProps = {
|
|
8486
|
+
const closestPointResultProps = props({
|
|
8600
8487
|
point: Vec3,
|
|
8601
8488
|
pointSet: 0
|
|
8602
|
-
};
|
|
8603
|
-
class ClosestPointResult extends createClass(
|
|
8604
|
-
closestPointResultProps
|
|
8605
|
-
) {
|
|
8489
|
+
});
|
|
8490
|
+
class ClosestPointResult extends createClass()(closestPointResultProps) {
|
|
8606
8491
|
}
|
|
8607
|
-
const barycentricCoordinatesResultProps = {
|
|
8492
|
+
const barycentricCoordinatesResultProps = props({
|
|
8608
8493
|
u: 0,
|
|
8609
8494
|
v: 0,
|
|
8610
8495
|
w: 0,
|
|
8611
8496
|
isValid: BooleanType(false)
|
|
8612
|
-
};
|
|
8613
|
-
class BarycentricCoordinatesResult extends createClass(
|
|
8497
|
+
});
|
|
8498
|
+
class BarycentricCoordinatesResult extends createClass()(
|
|
8499
|
+
barycentricCoordinatesResultProps
|
|
8500
|
+
) {
|
|
8614
8501
|
}
|
|
8615
8502
|
const ab$3 = /* @__PURE__ */ Vec3.create();
|
|
8616
8503
|
const ac$2 = /* @__PURE__ */ Vec3.create();
|
|
@@ -8821,13 +8708,13 @@ function computeClosestPointOnTriangle(outClosestPoint, inA, inB, inC, mustInclu
|
|
|
8821
8708
|
tempVector$2.addVectors(tempVector$2, c);
|
|
8822
8709
|
outClosestPoint.point.scaleVector(n$1, tempVector$2.dot(n$1) / (3 * normalLengthSquared));
|
|
8823
8710
|
}
|
|
8824
|
-
const vec4Props = {
|
|
8711
|
+
const vec4Props = props({
|
|
8825
8712
|
x: 0,
|
|
8826
8713
|
y: 0,
|
|
8827
8714
|
z: 0,
|
|
8828
8715
|
w: 0
|
|
8829
|
-
};
|
|
8830
|
-
class Vec4 extends createClass(vec4Props) {
|
|
8716
|
+
});
|
|
8717
|
+
class Vec4 extends createClass()(vec4Props) {
|
|
8831
8718
|
}
|
|
8832
8719
|
const ab$1 = /* @__PURE__ */ Vec3.create();
|
|
8833
8720
|
const ac = /* @__PURE__ */ Vec3.create();
|
|
@@ -8929,32 +8816,30 @@ function computeClosestPointOnTetrahedron(result2, inA, inB, inC, inD, mustInclu
|
|
|
8929
8816
|
}
|
|
8930
8817
|
}
|
|
8931
8818
|
}
|
|
8932
|
-
const closestPointToSimplexProps = {
|
|
8819
|
+
const closestPointToSimplexProps = props({
|
|
8933
8820
|
point: Vec3,
|
|
8934
8821
|
squaredDistance: 0,
|
|
8935
8822
|
pointSet: 0,
|
|
8936
8823
|
closestPointFound: BooleanType(false)
|
|
8937
|
-
};
|
|
8938
|
-
class ClosestPointToSimplex extends createClass(
|
|
8939
|
-
closestPointToSimplexProps
|
|
8940
|
-
) {
|
|
8824
|
+
});
|
|
8825
|
+
class ClosestPointToSimplex extends createClass()(closestPointToSimplexProps) {
|
|
8941
8826
|
}
|
|
8942
|
-
const gjkClosestPointsProps = {
|
|
8827
|
+
const gjkClosestPointsProps = props({
|
|
8943
8828
|
squaredDistance: 0,
|
|
8944
8829
|
penetrationAxis: Vec3,
|
|
8945
8830
|
pointA: Vec3,
|
|
8946
8831
|
pointB: Vec3
|
|
8947
|
-
};
|
|
8948
|
-
class GjkClosestPoints extends createClass(gjkClosestPointsProps) {
|
|
8832
|
+
});
|
|
8833
|
+
class GjkClosestPoints extends createClass()(gjkClosestPointsProps) {
|
|
8949
8834
|
}
|
|
8950
|
-
const gjkCastShapeResultProps = {
|
|
8835
|
+
const gjkCastShapeResultProps = props({
|
|
8951
8836
|
isHitFound: false,
|
|
8952
8837
|
lambda: 1,
|
|
8953
8838
|
separatingAxis: Vec3,
|
|
8954
8839
|
pointA: Vec3,
|
|
8955
8840
|
pointB: Vec3
|
|
8956
|
-
};
|
|
8957
|
-
class GjkCastShapeResult extends createClass(gjkCastShapeResultProps) {
|
|
8841
|
+
});
|
|
8842
|
+
class GjkCastShapeResult extends createClass()(gjkCastShapeResultProps) {
|
|
8958
8843
|
}
|
|
8959
8844
|
const transformedConvexObject = /* @__PURE__ */ new TransformedConvexObject();
|
|
8960
8845
|
const y0 = /* @__PURE__ */ Vec3.create();
|
|
@@ -9437,15 +9322,103 @@ class GjkModule {
|
|
|
9437
9322
|
}
|
|
9438
9323
|
}
|
|
9439
9324
|
const v = /* @__PURE__ */ Vec3.create();
|
|
9440
|
-
|
|
9325
|
+
var CollisionStatus = /* @__PURE__ */ ((CollisionStatus2) => {
|
|
9326
|
+
CollisionStatus2[CollisionStatus2["NotColliding"] = 0] = "NotColliding";
|
|
9327
|
+
CollisionStatus2[CollisionStatus2["Colliding"] = 1] = "Colliding";
|
|
9328
|
+
CollisionStatus2[CollisionStatus2["Indeterminate"] = 2] = "Indeterminate";
|
|
9329
|
+
return CollisionStatus2;
|
|
9330
|
+
})(CollisionStatus || {});
|
|
9331
|
+
const collisionResultProps = props({
|
|
9332
|
+
status: NumberType(
|
|
9333
|
+
2
|
|
9334
|
+
/* Indeterminate */
|
|
9335
|
+
),
|
|
9336
|
+
hasContact: BooleanType(false),
|
|
9337
|
+
penetration: 0,
|
|
9338
|
+
contactPointA: Vec3,
|
|
9339
|
+
contactPointB: Vec3,
|
|
9340
|
+
normalA: Vec3,
|
|
9341
|
+
normalB: Vec3,
|
|
9342
|
+
momentArmA: Vec3,
|
|
9343
|
+
momentArmB: Vec3,
|
|
9344
|
+
surfaceNormalA: Vec3,
|
|
9345
|
+
surfaceNormalB: Vec3,
|
|
9346
|
+
bodyA: LazyReferenceType((() => Body)),
|
|
9347
|
+
bodyB: LazyReferenceType((() => Body)),
|
|
9348
|
+
subShapeIdA: 0,
|
|
9349
|
+
subShapeIdB: 0,
|
|
9350
|
+
isBackFace: BooleanType(false),
|
|
9351
|
+
faceA: Face,
|
|
9352
|
+
faceB: Face
|
|
9353
|
+
});
|
|
9354
|
+
class CollisionResult extends createClass()(collisionResultProps) {
|
|
9355
|
+
/**
|
|
9356
|
+
* swaps the A and B data
|
|
9357
|
+
*/
|
|
9358
|
+
swap() {
|
|
9359
|
+
this.contactPointA.swap(this.contactPointB);
|
|
9360
|
+
this.normalA.swap(this.normalB);
|
|
9361
|
+
this.momentArmA.swap(this.momentArmB);
|
|
9362
|
+
this.surfaceNormalA.swap(this.surfaceNormalB);
|
|
9363
|
+
const tempBody = this.bodyA;
|
|
9364
|
+
this.bodyA = this.bodyB;
|
|
9365
|
+
this.bodyB = tempBody;
|
|
9366
|
+
const tempSubShapeId = this.subShapeIdA;
|
|
9367
|
+
this.subShapeIdA = this.subShapeIdB;
|
|
9368
|
+
this.subShapeIdB = tempSubShapeId;
|
|
9369
|
+
const tempFace = this.faceA;
|
|
9370
|
+
this.faceA = this.faceB;
|
|
9371
|
+
this.faceB = tempFace;
|
|
9372
|
+
}
|
|
9373
|
+
}
|
|
9374
|
+
const _CollisionCollector = class _CollisionCollector {
|
|
9375
|
+
constructor() {
|
|
9376
|
+
this.earlyOutFraction = _CollisionCollector.initialEarlyOutFraction;
|
|
9377
|
+
this.body2 = null;
|
|
9378
|
+
}
|
|
9379
|
+
getEarlyOutFraction() {
|
|
9380
|
+
return _CollisionCollector.initialEarlyOutFraction;
|
|
9381
|
+
}
|
|
9382
|
+
getPositiveEarlyOutFraction() {
|
|
9383
|
+
return Math.max(Number.MIN_VALUE, this.earlyOutFraction);
|
|
9384
|
+
}
|
|
9385
|
+
reset() {
|
|
9386
|
+
this.earlyOutFraction = _CollisionCollector.initialEarlyOutFraction;
|
|
9387
|
+
this.body2 = null;
|
|
9388
|
+
return this;
|
|
9389
|
+
}
|
|
9390
|
+
addHit(result2) {
|
|
9391
|
+
}
|
|
9392
|
+
addMiss() {
|
|
9393
|
+
}
|
|
9394
|
+
};
|
|
9395
|
+
_CollisionCollector.initialEarlyOutFraction = Infinity;
|
|
9396
|
+
_CollisionCollector.shouldEarlyOutFraction = -Infinity;
|
|
9397
|
+
let CollisionCollector = _CollisionCollector;
|
|
9398
|
+
var CollectFacesMode = /* @__PURE__ */ ((CollectFacesMode2) => {
|
|
9399
|
+
CollectFacesMode2[CollectFacesMode2["CollectFaces"] = 0] = "CollectFaces";
|
|
9400
|
+
CollectFacesMode2[CollectFacesMode2["NoFaces"] = 1] = "NoFaces";
|
|
9401
|
+
return CollectFacesMode2;
|
|
9402
|
+
})(CollectFacesMode || {});
|
|
9403
|
+
var ActiveEdgeMode = /* @__PURE__ */ ((ActiveEdgeMode2) => {
|
|
9404
|
+
ActiveEdgeMode2[ActiveEdgeMode2["CollideOnlyWithActive"] = 0] = "CollideOnlyWithActive";
|
|
9405
|
+
ActiveEdgeMode2[ActiveEdgeMode2["CollideWithAll"] = 1] = "CollideWithAll";
|
|
9406
|
+
return ActiveEdgeMode2;
|
|
9407
|
+
})(ActiveEdgeMode || {});
|
|
9408
|
+
var BackFaceMode = /* @__PURE__ */ ((BackFaceMode2) => {
|
|
9409
|
+
BackFaceMode2[BackFaceMode2["IgnoreBackFaces"] = 0] = "IgnoreBackFaces";
|
|
9410
|
+
BackFaceMode2[BackFaceMode2["CollideWithBackFaces"] = 1] = "CollideWithBackFaces";
|
|
9411
|
+
return BackFaceMode2;
|
|
9412
|
+
})(BackFaceMode || {});
|
|
9413
|
+
const edgeProps = props({
|
|
9441
9414
|
neighbourTriangle: LazyReferenceType((() => Triangle2)),
|
|
9442
9415
|
neighbourEdge: 0,
|
|
9443
9416
|
startIndex: 0
|
|
9444
|
-
};
|
|
9445
|
-
class Edge extends createClass(edgeProps) {
|
|
9417
|
+
});
|
|
9418
|
+
class Edge extends createClass()(edgeProps) {
|
|
9446
9419
|
//
|
|
9447
9420
|
}
|
|
9448
|
-
const triangleProps = {
|
|
9421
|
+
const triangleProps = props({
|
|
9449
9422
|
edge0: Edge,
|
|
9450
9423
|
edge1: Edge,
|
|
9451
9424
|
edge2: Edge,
|
|
@@ -9459,7 +9432,7 @@ const triangleProps = {
|
|
|
9459
9432
|
removed: BooleanType(false),
|
|
9460
9433
|
inQueue: BooleanType(false),
|
|
9461
9434
|
iteration: 0
|
|
9462
|
-
};
|
|
9435
|
+
});
|
|
9463
9436
|
const vectorAB$4 = /* @__PURE__ */ Vec3.create();
|
|
9464
9437
|
const y10 = /* @__PURE__ */ Vec3.create();
|
|
9465
9438
|
const y20 = /* @__PURE__ */ Vec3.create();
|
|
@@ -9538,7 +9511,7 @@ function initTriangle(m, inIdx0, inIdx1, inIdx2, inPositions, minTriangleArea, b
|
|
|
9538
9511
|
}
|
|
9539
9512
|
}
|
|
9540
9513
|
}
|
|
9541
|
-
class Triangle2 extends createClass(triangleProps) {
|
|
9514
|
+
class Triangle2 extends createClass()(triangleProps) {
|
|
9542
9515
|
isFacing(inPosition) {
|
|
9543
9516
|
vectorAB$4.subtractVectors(inPosition, this.centroid);
|
|
9544
9517
|
return this.normal.dot(vectorAB$4) > 0;
|
|
@@ -10048,15 +10021,13 @@ const p10 = /* @__PURE__ */ Vec3.create();
|
|
|
10048
10021
|
const p12 = /* @__PURE__ */ Vec3.create();
|
|
10049
10022
|
const q10 = /* @__PURE__ */ Vec3.create();
|
|
10050
10023
|
const q12 = /* @__PURE__ */ Vec3.create();
|
|
10051
|
-
const penetrationDepthProps = {
|
|
10024
|
+
const penetrationDepthProps = props({
|
|
10052
10025
|
status: 0,
|
|
10053
10026
|
penetrationAxis: Vec3,
|
|
10054
10027
|
pointA: Vec3,
|
|
10055
10028
|
pointB: Vec3
|
|
10056
|
-
};
|
|
10057
|
-
class PenetrationDepth extends createClass(
|
|
10058
|
-
penetrationDepthProps
|
|
10059
|
-
) {
|
|
10029
|
+
});
|
|
10030
|
+
class PenetrationDepth extends createClass()(penetrationDepthProps) {
|
|
10060
10031
|
}
|
|
10061
10032
|
const transformed_a = /* @__PURE__ */ new TransformedConvexObject();
|
|
10062
10033
|
const closest = /* @__PURE__ */ GjkClosestPoints.create();
|
|
@@ -11218,88 +11189,79 @@ function collideCompoundVsTriangleMesh(penetrationDepthModule2, collector2, shap
|
|
|
11218
11189
|
function noOp() {
|
|
11219
11190
|
return;
|
|
11220
11191
|
}
|
|
11221
|
-
const collideShapesFns =
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
[ShapeType.capsule]: collideTriangleMeshVsConvex,
|
|
11295
|
-
[ShapeType.compoundShape]: collideTriangleMeshVsCompound,
|
|
11296
|
-
[ShapeType.convexHull]: collideTriangleMeshVsConvex,
|
|
11297
|
-
[ShapeType.cylinder]: collideTriangleMeshVsConvex,
|
|
11298
|
-
[ShapeType.heightMap]: noOp,
|
|
11299
|
-
[ShapeType.sphere]: collideTriangleMeshVsConvex,
|
|
11300
|
-
[ShapeType.triangleMesh]: noOp
|
|
11301
|
-
}
|
|
11302
|
-
};
|
|
11192
|
+
const collideShapesFns = [];
|
|
11193
|
+
collideShapesFns[ShapeType.box] = [];
|
|
11194
|
+
collideShapesFns[ShapeType.capsule] = [];
|
|
11195
|
+
collideShapesFns[ShapeType.compoundShape] = [];
|
|
11196
|
+
collideShapesFns[ShapeType.convexHull] = [];
|
|
11197
|
+
collideShapesFns[ShapeType.cylinder] = [];
|
|
11198
|
+
collideShapesFns[ShapeType.heightMap] = [];
|
|
11199
|
+
collideShapesFns[ShapeType.sphere] = [];
|
|
11200
|
+
collideShapesFns[ShapeType.triangleMesh] = [];
|
|
11201
|
+
collideShapesFns[ShapeType.box][ShapeType.box] = collideConvexVsConvex;
|
|
11202
|
+
collideShapesFns[ShapeType.box][ShapeType.capsule] = collideConvexVsConvex;
|
|
11203
|
+
collideShapesFns[ShapeType.box][ShapeType.compoundShape] = collideConvexVsCompound;
|
|
11204
|
+
collideShapesFns[ShapeType.box][ShapeType.convexHull] = collideConvexVsConvex;
|
|
11205
|
+
collideShapesFns[ShapeType.box][ShapeType.cylinder] = collideConvexVsConvex;
|
|
11206
|
+
collideShapesFns[ShapeType.box][ShapeType.heightMap] = collideConvexVsHeightMap;
|
|
11207
|
+
collideShapesFns[ShapeType.box][ShapeType.sphere] = collideConvexVsConvex;
|
|
11208
|
+
collideShapesFns[ShapeType.box][ShapeType.triangleMesh] = collideConvexVsTriangleMesh;
|
|
11209
|
+
collideShapesFns[ShapeType.capsule][ShapeType.box] = collideConvexVsConvex;
|
|
11210
|
+
collideShapesFns[ShapeType.capsule][ShapeType.capsule] = collideConvexVsConvex;
|
|
11211
|
+
collideShapesFns[ShapeType.capsule][ShapeType.compoundShape] = collideConvexVsCompound;
|
|
11212
|
+
collideShapesFns[ShapeType.capsule][ShapeType.convexHull] = collideConvexVsConvex;
|
|
11213
|
+
collideShapesFns[ShapeType.capsule][ShapeType.cylinder] = collideConvexVsConvex;
|
|
11214
|
+
collideShapesFns[ShapeType.capsule][ShapeType.heightMap] = collideConvexVsHeightMap;
|
|
11215
|
+
collideShapesFns[ShapeType.capsule][ShapeType.sphere] = collideConvexVsConvex;
|
|
11216
|
+
collideShapesFns[ShapeType.capsule][ShapeType.triangleMesh] = collideConvexVsTriangleMesh;
|
|
11217
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.box] = collideCompoundVsConvex;
|
|
11218
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.capsule] = collideCompoundVsConvex;
|
|
11219
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.compoundShape] = collideCompoundVsCompound;
|
|
11220
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.convexHull] = collideCompoundVsConvex;
|
|
11221
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.cylinder] = collideCompoundVsConvex;
|
|
11222
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.heightMap] = collideCompoundVsHeightMap;
|
|
11223
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.sphere] = collideCompoundVsConvex;
|
|
11224
|
+
collideShapesFns[ShapeType.compoundShape][ShapeType.triangleMesh] = collideCompoundVsTriangleMesh;
|
|
11225
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.box] = collideConvexVsConvex;
|
|
11226
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.capsule] = collideConvexVsConvex;
|
|
11227
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.compoundShape] = collideConvexVsCompound;
|
|
11228
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.convexHull] = collideConvexVsConvex;
|
|
11229
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.cylinder] = collideConvexVsConvex;
|
|
11230
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.heightMap] = collideConvexVsHeightMap;
|
|
11231
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.sphere] = collideConvexVsConvex;
|
|
11232
|
+
collideShapesFns[ShapeType.convexHull][ShapeType.triangleMesh] = collideConvexVsTriangleMesh;
|
|
11233
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.box] = collideConvexVsConvex;
|
|
11234
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.capsule] = collideConvexVsConvex;
|
|
11235
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.compoundShape] = collideConvexVsCompound;
|
|
11236
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.convexHull] = collideConvexVsConvex;
|
|
11237
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.cylinder] = collideConvexVsConvex;
|
|
11238
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.heightMap] = collideConvexVsHeightMap;
|
|
11239
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.sphere] = collideConvexVsConvex;
|
|
11240
|
+
collideShapesFns[ShapeType.cylinder][ShapeType.triangleMesh] = collideConvexVsTriangleMesh;
|
|
11241
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.box] = collideHeightMapVsConvex;
|
|
11242
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.capsule] = collideHeightMapVsConvex;
|
|
11243
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.compoundShape] = collideHeightMapVsCompound;
|
|
11244
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.convexHull] = collideHeightMapVsConvex;
|
|
11245
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.cylinder] = collideHeightMapVsConvex;
|
|
11246
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.heightMap] = noOp;
|
|
11247
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.sphere] = collideHeightMapVsConvex;
|
|
11248
|
+
collideShapesFns[ShapeType.heightMap][ShapeType.triangleMesh] = noOp;
|
|
11249
|
+
collideShapesFns[ShapeType.sphere][ShapeType.box] = collideConvexVsConvex;
|
|
11250
|
+
collideShapesFns[ShapeType.sphere][ShapeType.capsule] = collideConvexVsConvex;
|
|
11251
|
+
collideShapesFns[ShapeType.sphere][ShapeType.compoundShape] = collideConvexVsCompound;
|
|
11252
|
+
collideShapesFns[ShapeType.sphere][ShapeType.convexHull] = collideConvexVsConvex;
|
|
11253
|
+
collideShapesFns[ShapeType.sphere][ShapeType.cylinder] = collideConvexVsConvex;
|
|
11254
|
+
collideShapesFns[ShapeType.sphere][ShapeType.heightMap] = collideConvexVsHeightMap;
|
|
11255
|
+
collideShapesFns[ShapeType.sphere][ShapeType.sphere] = collideSphereVsSphere;
|
|
11256
|
+
collideShapesFns[ShapeType.sphere][ShapeType.triangleMesh] = collideConvexVsTriangleMesh;
|
|
11257
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.box] = collideTriangleMeshVsConvex;
|
|
11258
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.capsule] = collideTriangleMeshVsConvex;
|
|
11259
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.compoundShape] = collideTriangleMeshVsCompound;
|
|
11260
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.convexHull] = collideTriangleMeshVsConvex;
|
|
11261
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.cylinder] = collideTriangleMeshVsConvex;
|
|
11262
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.heightMap] = noOp;
|
|
11263
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.sphere] = collideTriangleMeshVsConvex;
|
|
11264
|
+
collideShapesFns[ShapeType.triangleMesh][ShapeType.triangleMesh] = noOp;
|
|
11303
11265
|
class CollideShapesModule {
|
|
11304
11266
|
constructor(penetrationDepthModule2) {
|
|
11305
11267
|
this.penetrationDepthModule = penetrationDepthModule2;
|
|
@@ -11309,11 +11271,9 @@ class CollideShapesModule {
|
|
|
11309
11271
|
// the isometries must transform the shapes into world space
|
|
11310
11272
|
// the results are in world space
|
|
11311
11273
|
collideShapes(collector2, shapeA, isometryA2, shapeB2, isometryB2, settings, bodyA, bodyB, subShapeIdA = 0, subShapeIdB = 0) {
|
|
11312
|
-
const
|
|
11313
|
-
const keyB = shapeB2.type;
|
|
11314
|
-
const collisionFunction = collideShapesFns[keyA][keyB];
|
|
11274
|
+
const collisionFunction = collideShapesFns[shapeA.type][shapeB2.type];
|
|
11315
11275
|
if (!collisionFunction) {
|
|
11316
|
-
throw new Error(`no collision function found for shapes with type ${
|
|
11276
|
+
throw new Error(`no collision function found for shapes with type ${shapeA.type} and ${shapeB2.type}`);
|
|
11317
11277
|
}
|
|
11318
11278
|
return collisionFunction(
|
|
11319
11279
|
this.penetrationDepthModule,
|
|
@@ -11332,13 +11292,15 @@ class CollideShapesModule {
|
|
|
11332
11292
|
);
|
|
11333
11293
|
}
|
|
11334
11294
|
}
|
|
11335
|
-
const estimateCollisionResponseResultProps = {
|
|
11295
|
+
const estimateCollisionResponseResultProps = props({
|
|
11336
11296
|
deltaLinearVelocityA: Vec3,
|
|
11337
11297
|
deltaAngularVelocityA: Vec3,
|
|
11338
11298
|
deltaLinearVelocityB: Vec3,
|
|
11339
11299
|
deltaAngularVelocityB: Vec3
|
|
11340
|
-
};
|
|
11341
|
-
class EstimateCollisionResponseResult extends createClass(
|
|
11300
|
+
});
|
|
11301
|
+
class EstimateCollisionResponseResult extends createClass()(
|
|
11302
|
+
estimateCollisionResponseResultProps
|
|
11303
|
+
) {
|
|
11342
11304
|
}
|
|
11343
11305
|
function estimateCollisionResponse(result2, manifold, timeStepSizeSeconds) {
|
|
11344
11306
|
result2.reset();
|
|
@@ -11628,7 +11590,7 @@ class CollideBodiesModule {
|
|
|
11628
11590
|
}
|
|
11629
11591
|
isometryA.matrix.postTranslatedMatrix(inCenterOfMassTransform.matrix, offset);
|
|
11630
11592
|
boundsA$1.copy(inShape.computedAabb);
|
|
11631
|
-
boundsA$1.expand(inCollideShapeSettings
|
|
11593
|
+
boundsA$1.expand(inCollideShapeSettings?.maxSeparation ?? 0);
|
|
11632
11594
|
boundsA$1.transform(inCenterOfMassTransform);
|
|
11633
11595
|
collideShapeVisitor.initialize(
|
|
11634
11596
|
isometryA,
|
|
@@ -11735,7 +11697,7 @@ class CastRayBodyVisitor {
|
|
|
11735
11697
|
}
|
|
11736
11698
|
visit(body2) {
|
|
11737
11699
|
isometryB.fromRotationAndTranslation(body2.orientation, body2.computedCenterOfMassPosition);
|
|
11738
|
-
this.castModule.castRay(this.collector, this.ray, body2.shape, isometryB, 1, zeroVector$1,
|
|
11700
|
+
this.castModule.castRay(this.collector, this.ray, body2.shape, isometryB, 1, zeroVector$1, body2);
|
|
11739
11701
|
}
|
|
11740
11702
|
}
|
|
11741
11703
|
const castRayVisitor = /* @__PURE__ */ new CastRayBodyVisitor();
|
|
@@ -12005,11 +11967,11 @@ class ManifoldCache {
|
|
|
12005
11967
|
const contactPairCacheMaxDeltaPositionSquared = squared(1e-3);
|
|
12006
11968
|
const contactPairCacheCosMaxDeltaRotationDiv2 = Math.cos(degreesToRadians(2) / 2);
|
|
12007
11969
|
const negatedPenetrationAxis = /* @__PURE__ */ Vec3.create();
|
|
12008
|
-
const vec3BufferProps = {
|
|
11970
|
+
const vec3BufferProps = props({
|
|
12009
11971
|
numItems: 0,
|
|
12010
11972
|
vec3List: ReferenceListType(Vec3)
|
|
12011
|
-
};
|
|
12012
|
-
class Vec3Buffer extends createClass(vec3BufferProps) {
|
|
11973
|
+
});
|
|
11974
|
+
class Vec3Buffer extends createClass()(vec3BufferProps) {
|
|
12013
11975
|
getVec3(out, index) {
|
|
12014
11976
|
out.copy(this.vec3List.getAtIndex(index));
|
|
12015
11977
|
}
|
|
@@ -12615,19 +12577,9 @@ class BvhModule {
|
|
|
12615
12577
|
for (const node of this.pairs.iteratePairs()) {
|
|
12616
12578
|
const bodyA = node.bodyA;
|
|
12617
12579
|
const bodyB = node.bodyB;
|
|
12618
|
-
if (bodyA.type
|
|
12580
|
+
if (bodyA.type !== BodyType.dynamic && bodyB.type !== BodyType.dynamic || bodyB.type === BodyType.static && bodyA.isSleeping) {
|
|
12619
12581
|
continue;
|
|
12620
12582
|
}
|
|
12621
|
-
if (bodyA.type === BodyType.static && bodyB.type === BodyType.dynamic) {
|
|
12622
|
-
if (bodyB.isSleeping) {
|
|
12623
|
-
continue;
|
|
12624
|
-
}
|
|
12625
|
-
}
|
|
12626
|
-
if (bodyA.type === BodyType.dynamic && bodyB.type === BodyType.static) {
|
|
12627
|
-
if (bodyA.isSleeping) {
|
|
12628
|
-
continue;
|
|
12629
|
-
}
|
|
12630
|
-
}
|
|
12631
12583
|
yield node;
|
|
12632
12584
|
}
|
|
12633
12585
|
}
|
|
@@ -13069,7 +13021,7 @@ function castConvexVsTriangleMesh(penetrationDepthModule2, ioCollector, inShapeA
|
|
|
13069
13021
|
isometryWorldToB$2.matrix.multiply3x3(transformedDisplacement, displacement2);
|
|
13070
13022
|
inShapeB.bvh.castAabb(onHit$2, boundsA, transformedDisplacement);
|
|
13071
13023
|
}
|
|
13072
|
-
function castRayVsConvex(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2,
|
|
13024
|
+
function castRayVsConvex(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2, bodyB = null) {
|
|
13073
13025
|
const convexB2 = inShapeB.computeSupportShape(SupportMode.IncludeConvexRadius, 1);
|
|
13074
13026
|
raycast.fraction = ioCollector.getEarlyOutFraction();
|
|
13075
13027
|
worldToB.matrix.invertMatrix(isometryB2.matrix);
|
|
@@ -13095,7 +13047,7 @@ const result$2 = /* @__PURE__ */ CastResult.create();
|
|
|
13095
13047
|
const raycast = { fraction: 0 };
|
|
13096
13048
|
const transformedRay$2 = /* @__PURE__ */ Ray.create();
|
|
13097
13049
|
const worldToB = /* @__PURE__ */ Isometry.create();
|
|
13098
|
-
function castRayVsCompound(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2,
|
|
13050
|
+
function castRayVsCompound(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2, bodyB = null) {
|
|
13099
13051
|
for (const shapeObj of inShapeB.shapes) {
|
|
13100
13052
|
const shape = shapeObj.shape;
|
|
13101
13053
|
const transform2 = shapeObj.transform;
|
|
@@ -13109,7 +13061,6 @@ function castRayVsCompound(penetrationDepthModule2, ioCollector, inRay, inShapeB
|
|
|
13109
13061
|
transformSubShapeBToWorld,
|
|
13110
13062
|
inScaleB,
|
|
13111
13063
|
offset2,
|
|
13112
|
-
inSettings,
|
|
13113
13064
|
bodyB
|
|
13114
13065
|
);
|
|
13115
13066
|
}
|
|
@@ -13136,7 +13087,7 @@ function onHit$1(triangle2) {
|
|
|
13136
13087
|
collector$1.addHit(result$1);
|
|
13137
13088
|
return false;
|
|
13138
13089
|
}
|
|
13139
|
-
function castRayVsTriangleMesh(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2,
|
|
13090
|
+
function castRayVsTriangleMesh(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2, bodyB = null) {
|
|
13140
13091
|
ioCollector.reset();
|
|
13141
13092
|
isometryWorldToB$1.matrix.invertMatrix(isometryB2.matrix);
|
|
13142
13093
|
transformedRay$1.copy(inRay).transform(isometryWorldToB$1);
|
|
@@ -13169,7 +13120,7 @@ function onHit(triangle2) {
|
|
|
13169
13120
|
collector.addHit(result);
|
|
13170
13121
|
return false;
|
|
13171
13122
|
}
|
|
13172
|
-
function castRayVsHeightMap(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2,
|
|
13123
|
+
function castRayVsHeightMap(penetrationDepthModule2, ioCollector, inRay, inShapeB, isometryB2, inScaleB, offset2, bodyB = null) {
|
|
13173
13124
|
ioCollector.reset();
|
|
13174
13125
|
isometryWorldToB.matrix.invertMatrix(isometryB2.matrix);
|
|
13175
13126
|
transformedRay.copy(inRay).transform(isometryWorldToB);
|
|
@@ -13182,100 +13133,76 @@ const result = /* @__PURE__ */ CastResult.create();
|
|
|
13182
13133
|
const raycasterResult = { fraction: 1, hit: false };
|
|
13183
13134
|
const isometryWorldToB = /* @__PURE__ */ Isometry.create();
|
|
13184
13135
|
const transformedRay = /* @__PURE__ */ Ray.create();
|
|
13185
|
-
const castShapesFns =
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
// [ShapeType.convexHull]: castTriangleMeshVsConvex,
|
|
13251
|
-
// [ShapeType.cylinder]: castTriangleMeshVsConvex,
|
|
13252
|
-
// [ShapeType.heightMap]: castTriangleMeshVsHeightMap,
|
|
13253
|
-
// [ShapeType.sphere]: castTriangleMeshVsConvex,
|
|
13254
|
-
// [ShapeType.triangleMesh]: castTriangleMeshVsTriangleMesh,
|
|
13255
|
-
// },
|
|
13256
|
-
// [ShapeType.triangle]: {
|
|
13257
|
-
// [ShapeType.box]: castTriangleVsConvex,
|
|
13258
|
-
// [ShapeType.sphere]: castTriangleVsConvex,
|
|
13259
|
-
// },
|
|
13260
|
-
};
|
|
13261
|
-
const raycastFns = {
|
|
13262
|
-
[ShapeType.sphere]: castRayVsConvex,
|
|
13263
|
-
[ShapeType.box]: castRayVsConvex,
|
|
13264
|
-
[ShapeType.capsule]: castRayVsConvex,
|
|
13265
|
-
[ShapeType.cylinder]: castRayVsConvex,
|
|
13266
|
-
[ShapeType.compoundShape]: castRayVsCompound,
|
|
13267
|
-
// castRayVsCompound,
|
|
13268
|
-
[ShapeType.convexHull]: castRayVsConvex,
|
|
13269
|
-
[ShapeType.heightMap]: castRayVsHeightMap,
|
|
13270
|
-
// castRayVsHeightMap,
|
|
13271
|
-
[ShapeType.triangleMesh]: castRayVsTriangleMesh
|
|
13272
|
-
// castRayVsTriangleMesh,
|
|
13273
|
-
};
|
|
13136
|
+
const castShapesFns = [];
|
|
13137
|
+
castShapesFns[ShapeType.box] = [];
|
|
13138
|
+
castShapesFns[ShapeType.capsule] = [];
|
|
13139
|
+
castShapesFns[ShapeType.compoundShape] = [];
|
|
13140
|
+
castShapesFns[ShapeType.convexHull] = [];
|
|
13141
|
+
castShapesFns[ShapeType.cylinder] = [];
|
|
13142
|
+
castShapesFns[ShapeType.heightMap] = [];
|
|
13143
|
+
castShapesFns[ShapeType.sphere] = [];
|
|
13144
|
+
castShapesFns[ShapeType.triangleMesh] = [];
|
|
13145
|
+
castShapesFns[ShapeType.box][ShapeType.box] = castConvexVsConvex;
|
|
13146
|
+
castShapesFns[ShapeType.box][ShapeType.capsule] = castConvexVsConvex;
|
|
13147
|
+
castShapesFns[ShapeType.box][ShapeType.compoundShape] = castConvexVsCompound;
|
|
13148
|
+
castShapesFns[ShapeType.box][ShapeType.convexHull] = castConvexVsConvex;
|
|
13149
|
+
castShapesFns[ShapeType.box][ShapeType.cylinder] = castConvexVsConvex;
|
|
13150
|
+
castShapesFns[ShapeType.box][ShapeType.heightMap] = castConvexVsHeightMap;
|
|
13151
|
+
castShapesFns[ShapeType.box][ShapeType.sphere] = castConvexVsConvex;
|
|
13152
|
+
castShapesFns[ShapeType.box][ShapeType.triangleMesh] = castConvexVsTriangleMesh;
|
|
13153
|
+
castShapesFns[ShapeType.capsule][ShapeType.box] = castConvexVsConvex;
|
|
13154
|
+
castShapesFns[ShapeType.capsule][ShapeType.capsule] = castConvexVsConvex;
|
|
13155
|
+
castShapesFns[ShapeType.capsule][ShapeType.compoundShape] = castConvexVsCompound;
|
|
13156
|
+
castShapesFns[ShapeType.capsule][ShapeType.convexHull] = castConvexVsConvex;
|
|
13157
|
+
castShapesFns[ShapeType.capsule][ShapeType.cylinder] = castConvexVsConvex;
|
|
13158
|
+
castShapesFns[ShapeType.capsule][ShapeType.heightMap] = castConvexVsHeightMap;
|
|
13159
|
+
castShapesFns[ShapeType.capsule][ShapeType.sphere] = castConvexVsConvex;
|
|
13160
|
+
castShapesFns[ShapeType.capsule][ShapeType.triangleMesh] = castConvexVsTriangleMesh;
|
|
13161
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.box] = castCompoundVsConvex;
|
|
13162
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.capsule] = castCompoundVsConvex;
|
|
13163
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.convexHull] = castCompoundVsConvex;
|
|
13164
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.cylinder] = castCompoundVsConvex;
|
|
13165
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.heightMap] = castConvexVsHeightMap;
|
|
13166
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.sphere] = castCompoundVsConvex;
|
|
13167
|
+
castShapesFns[ShapeType.compoundShape][ShapeType.triangleMesh] = castConvexVsTriangleMesh;
|
|
13168
|
+
castShapesFns[ShapeType.convexHull][ShapeType.box] = castConvexVsConvex;
|
|
13169
|
+
castShapesFns[ShapeType.convexHull][ShapeType.capsule] = castConvexVsConvex;
|
|
13170
|
+
castShapesFns[ShapeType.convexHull][ShapeType.compoundShape] = castConvexVsCompound;
|
|
13171
|
+
castShapesFns[ShapeType.convexHull][ShapeType.convexHull] = castConvexVsConvex;
|
|
13172
|
+
castShapesFns[ShapeType.convexHull][ShapeType.cylinder] = castConvexVsConvex;
|
|
13173
|
+
castShapesFns[ShapeType.convexHull][ShapeType.heightMap] = castConvexVsHeightMap;
|
|
13174
|
+
castShapesFns[ShapeType.convexHull][ShapeType.sphere] = castConvexVsConvex;
|
|
13175
|
+
castShapesFns[ShapeType.convexHull][ShapeType.triangleMesh] = castConvexVsTriangleMesh;
|
|
13176
|
+
castShapesFns[ShapeType.cylinder][ShapeType.box] = castConvexVsConvex;
|
|
13177
|
+
castShapesFns[ShapeType.cylinder][ShapeType.capsule] = castConvexVsConvex;
|
|
13178
|
+
castShapesFns[ShapeType.cylinder][ShapeType.compoundShape] = castConvexVsCompound;
|
|
13179
|
+
castShapesFns[ShapeType.cylinder][ShapeType.convexHull] = castConvexVsConvex;
|
|
13180
|
+
castShapesFns[ShapeType.cylinder][ShapeType.cylinder] = castConvexVsConvex;
|
|
13181
|
+
castShapesFns[ShapeType.cylinder][ShapeType.heightMap] = castConvexVsHeightMap;
|
|
13182
|
+
castShapesFns[ShapeType.cylinder][ShapeType.sphere] = castConvexVsConvex;
|
|
13183
|
+
castShapesFns[ShapeType.cylinder][ShapeType.triangleMesh] = castConvexVsTriangleMesh;
|
|
13184
|
+
castShapesFns[ShapeType.sphere][ShapeType.box] = castConvexVsConvex;
|
|
13185
|
+
castShapesFns[ShapeType.sphere][ShapeType.capsule] = castConvexVsConvex;
|
|
13186
|
+
castShapesFns[ShapeType.sphere][ShapeType.compoundShape] = castConvexVsCompound;
|
|
13187
|
+
castShapesFns[ShapeType.sphere][ShapeType.convexHull] = castConvexVsConvex;
|
|
13188
|
+
castShapesFns[ShapeType.sphere][ShapeType.cylinder] = castConvexVsConvex;
|
|
13189
|
+
castShapesFns[ShapeType.sphere][ShapeType.heightMap] = castConvexVsHeightMap;
|
|
13190
|
+
castShapesFns[ShapeType.sphere][ShapeType.sphere] = castConvexVsConvex;
|
|
13191
|
+
castShapesFns[ShapeType.sphere][ShapeType.triangleMesh] = castConvexVsTriangleMesh;
|
|
13192
|
+
const raycastFns = [];
|
|
13193
|
+
raycastFns[ShapeType.box] = castRayVsConvex;
|
|
13194
|
+
raycastFns[ShapeType.capsule] = castRayVsConvex;
|
|
13195
|
+
raycastFns[ShapeType.compoundShape] = castRayVsCompound;
|
|
13196
|
+
raycastFns[ShapeType.convexHull] = castRayVsConvex;
|
|
13197
|
+
raycastFns[ShapeType.cylinder] = castRayVsConvex;
|
|
13198
|
+
raycastFns[ShapeType.heightMap] = castRayVsHeightMap;
|
|
13199
|
+
raycastFns[ShapeType.sphere] = castRayVsConvex;
|
|
13200
|
+
raycastFns[ShapeType.triangleMesh] = castRayVsTriangleMesh;
|
|
13274
13201
|
class CastShapesModule {
|
|
13275
13202
|
constructor(penetrationDepthModule2) {
|
|
13276
13203
|
this.penetrationDepthModule = penetrationDepthModule2;
|
|
13277
13204
|
}
|
|
13278
|
-
castRay(collector2, ray2, shapeB2, isometryB2, scaleB, offset2,
|
|
13205
|
+
castRay(collector2, ray2, shapeB2, isometryB2, scaleB, offset2, bodyB = null) {
|
|
13279
13206
|
const fn = raycastFns[shapeB2.type];
|
|
13280
13207
|
if (!fn) {
|
|
13281
13208
|
return;
|
|
@@ -13289,7 +13216,6 @@ class CastShapesModule {
|
|
|
13289
13216
|
isometryB2,
|
|
13290
13217
|
scaleB,
|
|
13291
13218
|
offset2,
|
|
13292
|
-
settings,
|
|
13293
13219
|
bodyB
|
|
13294
13220
|
);
|
|
13295
13221
|
}
|
|
@@ -13298,11 +13224,9 @@ class CastShapesModule {
|
|
|
13298
13224
|
// the isometries must transform the shapes into world space
|
|
13299
13225
|
// the results are in world space
|
|
13300
13226
|
castShapes(collector2, shapeA, isometryA2, scaleA, shapeB2, isometryB2, scaleB, displacement2, offset2, settings, bodyA = null, bodyB = null) {
|
|
13301
|
-
const
|
|
13302
|
-
const keyB = shapeB2.type;
|
|
13303
|
-
const castFunction = castShapesFns[keyA][keyB];
|
|
13227
|
+
const castFunction = castShapesFns[shapeA.type][shapeB2.type];
|
|
13304
13228
|
if (!castFunction) {
|
|
13305
|
-
throw new Error(`no cast function found for shapes with type ${
|
|
13229
|
+
throw new Error(`no cast function found for shapes with type ${shapeA.type} and ${shapeB2.type}`);
|
|
13306
13230
|
}
|
|
13307
13231
|
return castFunction(
|
|
13308
13232
|
this.penetrationDepthModule,
|
|
@@ -15458,11 +15382,6 @@ class World {
|
|
|
15458
15382
|
updateWorldBounds(body2);
|
|
15459
15383
|
}
|
|
15460
15384
|
}
|
|
15461
|
-
// updateBodyProperties() {
|
|
15462
|
-
// for (const body of this.bodies()) {
|
|
15463
|
-
// // updateBody(body);
|
|
15464
|
-
// }
|
|
15465
|
-
// }
|
|
15466
15385
|
clearForcesOnBodies() {
|
|
15467
15386
|
for (const body2 of this.dynamicBodies) {
|
|
15468
15387
|
body2.clearForces();
|
|
@@ -15666,10 +15585,13 @@ class World {
|
|
|
15666
15585
|
options.type = BodyType.static;
|
|
15667
15586
|
options.world = this;
|
|
15668
15587
|
const body2 = this.staticBodies.create(options);
|
|
15588
|
+
const originalShape = options.shape;
|
|
15589
|
+
options.shape = null;
|
|
15669
15590
|
const bodyCopy = this.staticBodyCopies.create(options);
|
|
15670
15591
|
bodyCopy.copy(body2);
|
|
15671
15592
|
body2.copyForDiff = bodyCopy;
|
|
15672
|
-
|
|
15593
|
+
bodyCopy.setShape(body2.shape, false);
|
|
15594
|
+
options.shape = originalShape;
|
|
15673
15595
|
return body2;
|
|
15674
15596
|
}
|
|
15675
15597
|
createDynamicBody(options) {
|
|
@@ -15677,10 +15599,13 @@ class World {
|
|
|
15677
15599
|
options.type = BodyType.dynamic;
|
|
15678
15600
|
options.world = this;
|
|
15679
15601
|
const body2 = this.dynamicBodies.create(options);
|
|
15602
|
+
const originalShape = options.shape;
|
|
15603
|
+
options.shape = null;
|
|
15680
15604
|
const bodyCopy = this.dynamicBodyCopies.create(options);
|
|
15681
15605
|
bodyCopy.copy(body2);
|
|
15682
15606
|
body2.copyForDiff = bodyCopy;
|
|
15683
|
-
|
|
15607
|
+
bodyCopy.setShape(body2.shape, false);
|
|
15608
|
+
options.shape = originalShape;
|
|
15684
15609
|
return body2;
|
|
15685
15610
|
}
|
|
15686
15611
|
createKinematicBody(options) {
|
|
@@ -15688,10 +15613,13 @@ class World {
|
|
|
15688
15613
|
options.type = BodyType.kinematic;
|
|
15689
15614
|
options.world = this;
|
|
15690
15615
|
const body2 = this.kinematicBodies.create(options);
|
|
15616
|
+
const originalShape = options.shape;
|
|
15617
|
+
options.shape = null;
|
|
15691
15618
|
const bodyCopy = this.kinematicBodyCopies.create(options);
|
|
15692
15619
|
bodyCopy.copy(body2);
|
|
15693
15620
|
body2.copyForDiff = bodyCopy;
|
|
15694
|
-
|
|
15621
|
+
bodyCopy.setShape(body2.shape, false);
|
|
15622
|
+
options.shape = originalShape;
|
|
15695
15623
|
return body2;
|
|
15696
15624
|
}
|
|
15697
15625
|
createBody(options) {
|
|
@@ -15775,6 +15703,10 @@ class World {
|
|
|
15775
15703
|
}
|
|
15776
15704
|
// scene query API
|
|
15777
15705
|
intersectShape(onHit2, shape, transform2, settings) {
|
|
15706
|
+
if (!(transform2 instanceof BasicTransform)) {
|
|
15707
|
+
tempBasicTransform.reset(transform2);
|
|
15708
|
+
transform2 = tempBasicTransform;
|
|
15709
|
+
}
|
|
15778
15710
|
isometry.fromRotationAndTranslation(transform2.rotation, transform2.position);
|
|
15779
15711
|
intersectShapeCollector.initialize(onHit2);
|
|
15780
15712
|
this.collideBodiesModule.collideShape(
|
|
@@ -15784,7 +15716,7 @@ class World {
|
|
|
15784
15716
|
intersectShapeCollector,
|
|
15785
15717
|
collideShapeSettings,
|
|
15786
15718
|
zeroVector,
|
|
15787
|
-
AllFlag
|
|
15719
|
+
settings?.collisionMask ?? AllFlag
|
|
15788
15720
|
);
|
|
15789
15721
|
}
|
|
15790
15722
|
castRay(onHit2, ray2, settings) {
|
|
@@ -15793,12 +15725,8 @@ class World {
|
|
|
15793
15725
|
}
|
|
15794
15726
|
castShape(onHit2, shape, transform2, displacementOrEndPosition, settings) {
|
|
15795
15727
|
isometry.fromRotationAndTranslation(transform2.rotation, transform2.position);
|
|
15796
|
-
settings = settings || {
|
|
15797
|
-
|
|
15798
|
-
returnClosestOnly: false,
|
|
15799
|
-
treatAsDisplacement: false
|
|
15800
|
-
};
|
|
15801
|
-
if (settings.treatAsDisplacement) {
|
|
15728
|
+
settings = settings || {};
|
|
15729
|
+
if (settings?.treatAsDisplacement ?? false) {
|
|
15802
15730
|
displacement.copy(displacementOrEndPosition);
|
|
15803
15731
|
} else {
|
|
15804
15732
|
displacement.zero();
|
|
@@ -16063,7 +15991,21 @@ class IntersectShapeCollector extends CollisionCollector {
|
|
|
16063
15991
|
}
|
|
16064
15992
|
const intersectShapeCollector = /* @__PURE__ */ new IntersectShapeCollector();
|
|
16065
15993
|
const displacement = /* @__PURE__ */ Vec3.create();
|
|
16066
|
-
const castSettings =
|
|
15994
|
+
const castSettings = {
|
|
15995
|
+
maxSeparation: 0,
|
|
15996
|
+
collisionTolerance: 1e-4,
|
|
15997
|
+
activeEdgeMode: ActiveEdgeMode.CollideOnlyWithActive,
|
|
15998
|
+
collectFacesMode: CollectFacesMode.NoFaces,
|
|
15999
|
+
penetrationTolerance: 1e-4,
|
|
16000
|
+
activeEdgeMovementDirectionX: 0,
|
|
16001
|
+
activeEdgeMovementDirectionY: 0,
|
|
16002
|
+
activeEdgeMovementDirectionZ: 0,
|
|
16003
|
+
backFaceMode: BackFaceMode.IgnoreBackFaces,
|
|
16004
|
+
backFaceModeConvex: BackFaceMode.IgnoreBackFaces,
|
|
16005
|
+
backFaceModeTriangles: BackFaceMode.IgnoreBackFaces,
|
|
16006
|
+
useShrunkenShapeAndConvexRadius: false,
|
|
16007
|
+
returnDeepestPoint: false
|
|
16008
|
+
};
|
|
16067
16009
|
class CastShapeCollector extends CastCollector {
|
|
16068
16010
|
constructor() {
|
|
16069
16011
|
super(...arguments);
|
|
@@ -16077,6 +16019,7 @@ class CastShapeCollector extends CastCollector {
|
|
|
16077
16019
|
}
|
|
16078
16020
|
}
|
|
16079
16021
|
const castShapeCollector = /* @__PURE__ */ new CastShapeCollector();
|
|
16022
|
+
const tempBasicTransform = /* @__PURE__ */ BasicTransform.create();
|
|
16080
16023
|
export {
|
|
16081
16024
|
Aabb,
|
|
16082
16025
|
ActiveEdgeMode,
|