@perplexdotgg/bounce 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/build/bounce.d.ts +39501 -0
  2. package/build/bounce.js +17166 -0
  3. package/package.json +1 -1
  4. package/src/builders/ConvexHullBuilder.ts +0 -437
  5. package/src/builders/ConvexHullBuilder2d.ts +0 -344
  6. package/src/builders/ConvexHullBuilder3d.ts +0 -1689
  7. package/src/builders/HeightMapBuilder.ts +0 -414
  8. package/src/builders/TriangleMeshBuilder.ts +0 -92
  9. package/src/collision/CastShapesModule.ts +0 -184
  10. package/src/collision/CollideShapesModule.ts +0 -152
  11. package/src/collision/HeightMapCaster.ts +0 -38
  12. package/src/collision/HeightMapCollider.ts +0 -33
  13. package/src/collision/TriangleCaster.ts +0 -249
  14. package/src/collision/TriangleCollider.ts +0 -308
  15. package/src/collision/TriangleCollider2.ts +0 -379
  16. package/src/collision/activeEdge.ts +0 -146
  17. package/src/collision/cast/cast.ts +0 -139
  18. package/src/collision/cast/castCompoundVsCompound.ts +0 -59
  19. package/src/collision/cast/castCompoundVsConvex.ts +0 -116
  20. package/src/collision/cast/castConvexVsCompound.ts +0 -123
  21. package/src/collision/cast/castConvexVsConvex.ts +0 -213
  22. package/src/collision/cast/castConvexVsHeightMap.ts +0 -73
  23. package/src/collision/cast/castConvexVsTriangleMesh.ts +0 -56
  24. package/src/collision/cast/castRayVsCompound.ts +0 -44
  25. package/src/collision/cast/castRayVsConvex.ts +0 -45
  26. package/src/collision/cast/castRayVsHeightMap.ts +0 -58
  27. package/src/collision/cast/castRayVsTriangleMesh.ts +0 -58
  28. package/src/collision/closestPoints/closestPoints.ts +0 -23
  29. package/src/collision/closestPoints/computeBarycentricCoordinates2d.ts +0 -32
  30. package/src/collision/closestPoints/computeBarycentricCoordinates3d.ts +0 -81
  31. package/src/collision/closestPoints/computeClosestPointOnLine.ts +0 -30
  32. package/src/collision/closestPoints/computeClosestPointOnTetrahedron.ts +0 -96
  33. package/src/collision/closestPoints/computeClosestPointOnTriangle.ts +0 -195
  34. package/src/collision/closestPoints/isOriginOutsideOfPlane.ts +0 -25
  35. package/src/collision/closestPoints/isOriginOutsideOfTrianglePlanes.ts +0 -72
  36. package/src/collision/collide/collide.ts +0 -146
  37. package/src/collision/collide/collideCompoundVsCompound.ts +0 -60
  38. package/src/collision/collide/collideCompoundVsConvex.ts +0 -59
  39. package/src/collision/collide/collideCompoundVsHeightMap.ts +0 -73
  40. package/src/collision/collide/collideCompoundVsTriangleMesh.ts +0 -56
  41. package/src/collision/collide/collideConvexVsCompound.ts +0 -57
  42. package/src/collision/collide/collideConvexVsConvex.ts +0 -225
  43. package/src/collision/collide/collideConvexVsConvexImp.ts +0 -236
  44. package/src/collision/collide/collideConvexVsHeightMap.ts +0 -53
  45. package/src/collision/collide/collideConvexVsTriangleMesh.ts +0 -58
  46. package/src/collision/collide/collideHeightMapVsCompound.ts +0 -69
  47. package/src/collision/collide/collideHeightMapVsConvex.ts +0 -53
  48. package/src/collision/collide/collideSphereVsSphere.ts +0 -81
  49. package/src/collision/collide/collideTriangleMeshVsCompound.ts +0 -58
  50. package/src/collision/collide/collideTriangleMeshVsConvex.ts +0 -58
  51. package/src/collision/epa/EpaConvexHullBuilder.ts +0 -397
  52. package/src/collision/epa/StaticArray.ts +0 -154
  53. package/src/collision/epa/TriangleFactory.ts +0 -32
  54. package/src/collision/epa/arrays.ts +0 -99
  55. package/src/collision/epa/binaryHeap.ts +0 -82
  56. package/src/collision/epa/structs.ts +0 -227
  57. package/src/collision/gjk/GjkModule.ts +0 -864
  58. package/src/collision/gjk/PenetrationDepthModule.ts +0 -493
  59. package/src/collision/gjk/SupportPoints.ts +0 -50
  60. package/src/collision/imp/MinkowskiDifference.ts +0 -36
  61. package/src/collision/imp/computeExploredDistanceLowerUpperBound.ts +0 -40
  62. package/src/collision/imp/finalizeImpResult.ts +0 -69
  63. package/src/collision/imp/findContactImp.ts +0 -196
  64. package/src/collision/imp/imp.ts +0 -28
  65. package/src/collision/imp/incrementalMinimumDistanceExploreDirection.ts +0 -207
  66. package/src/collision/mpr/findPortal.ts +0 -152
  67. package/src/collision/mpr/mpr.ts +0 -29
  68. package/src/collision/mpr/updatePortal.ts +0 -52
  69. package/src/constraints/BaseConstraint.ts +0 -50
  70. package/src/constraints/ConstraintOptions.ts +0 -22
  71. package/src/constraints/ConstraintSolver.ts +0 -119
  72. package/src/constraints/DistanceConstraint.ts +0 -229
  73. package/src/constraints/FixedConstraint.ts +0 -203
  74. package/src/constraints/HingeConstraint.ts +0 -460
  75. package/src/constraints/PointConstraint.ts +0 -108
  76. package/src/constraints/components/AngleComponent.ts +0 -226
  77. package/src/constraints/components/AxisComponent.ts +0 -263
  78. package/src/constraints/components/HingeComponent.ts +0 -215
  79. package/src/constraints/components/Motor.ts +0 -36
  80. package/src/constraints/components/PointConstraintComponent.ts +0 -179
  81. package/src/constraints/components/RotationEulerComponent.ts +0 -139
  82. package/src/constraints/components/Spring.ts +0 -30
  83. package/src/constraints/components/SpringComponent.ts +0 -71
  84. package/src/constraints/types.ts +0 -6
  85. package/src/helpers.ts +0 -147
  86. package/src/index.ts +0 -50
  87. package/src/math/BasicTransform.ts +0 -19
  88. package/src/math/NumberValue.ts +0 -13
  89. package/src/math/isometry.ts +0 -64
  90. package/src/math/mat3.ts +0 -529
  91. package/src/math/mat4.ts +0 -588
  92. package/src/math/quat.ts +0 -193
  93. package/src/math/scalar.ts +0 -81
  94. package/src/math/tensor.ts +0 -17
  95. package/src/math/vec3.ts +0 -589
  96. package/src/math/vec4.ts +0 -10
  97. package/src/physics/Body.ts +0 -581
  98. package/src/physics/CollisionFilter.ts +0 -52
  99. package/src/physics/SleepModule.ts +0 -163
  100. package/src/physics/broadphase/BodyPairsModule.ts +0 -363
  101. package/src/physics/broadphase/BvhModule.ts +0 -237
  102. package/src/physics/broadphase/BvhTree.ts +0 -803
  103. package/src/physics/broadphase/ConstraintPairsModule.ts +0 -385
  104. package/src/physics/broadphase/TriangleMeshBvhTree.ts +0 -379
  105. package/src/physics/manifold/ContactManifold.ts +0 -227
  106. package/src/physics/manifold/ContactManifoldModule.ts +0 -623
  107. package/src/physics/manifold/Face.ts +0 -119
  108. package/src/physics/manifold/ManifoldCache.ts +0 -116
  109. package/src/physics/manifold/clipping/clipPolyVsEdge.ts +0 -131
  110. package/src/physics/manifold/clipping/clipPolyVsPlane.ts +0 -73
  111. package/src/physics/manifold/clipping/clipPolyVsPoly.ts +0 -72
  112. package/src/physics/narrowphase/CollideBodiesModule.ts +0 -755
  113. package/src/physics/solver/ContactConstraintModule.ts +0 -659
  114. package/src/physics/solver/ManifoldConstraint.ts +0 -420
  115. package/src/physics/solver/estimateCollisionResponse.ts +0 -146
  116. package/src/shape/Aabb.ts +0 -400
  117. package/src/shape/Box.ts +0 -231
  118. package/src/shape/Capsule.ts +0 -332
  119. package/src/shape/CompoundShape.ts +0 -288
  120. package/src/shape/Convex.ts +0 -130
  121. package/src/shape/ConvexHull.ts +0 -423
  122. package/src/shape/Cylinder.ts +0 -313
  123. package/src/shape/HeightMap.ts +0 -511
  124. package/src/shape/Line.ts +0 -14
  125. package/src/shape/Plane.ts +0 -116
  126. package/src/shape/Ray.ts +0 -81
  127. package/src/shape/Segment.ts +0 -25
  128. package/src/shape/Shape.ts +0 -77
  129. package/src/shape/Sphere.ts +0 -181
  130. package/src/shape/TransformedShape.ts +0 -51
  131. package/src/shape/Triangle.ts +0 -122
  132. package/src/shape/TriangleMesh.ts +0 -186
  133. package/src/types.ts +0 -1
  134. package/src/world.ts +0 -1335
  135. package/tests/BodyPairsModule.test.ts +0 -71
  136. package/tests/BvhTree.test.ts +0 -406
  137. package/tests/test.md +0 -642
  138. package/tests/vec3.test.ts +0 -12
package/src/math/mat4.ts DELETED
@@ -1,588 +0,0 @@
1
- import { createClass, NumberType, PropertyDefinitionMap } from "monomorph";
2
- import { Vec3 } from "./vec3";
3
- import { Mat3 } from "./mat3";
4
- import { Quat } from "./quat";
5
-
6
- const rotationMatrix = /*@__PURE__*/ Mat3.create();
7
- const scaling = /*@__PURE__*/ Vec3.create();
8
- const conjugatedRotation = /*@__PURE__*/ Quat.create();
9
- const rotatedTranslation = /*@__PURE__*/ Vec3.create();
10
-
11
- const mat4Props = {
12
- e0: NumberType(0),
13
- e1: NumberType(0),
14
- e2: NumberType(0),
15
- e3: NumberType(0),
16
-
17
- e4: NumberType(0),
18
- e5: NumberType(0),
19
- e6: NumberType(0),
20
- e7: NumberType(0),
21
-
22
- e8: NumberType(0),
23
- e9: NumberType(0),
24
- e10: NumberType(0),
25
- e11: NumberType(0),
26
-
27
- e12: NumberType(0),
28
- e13: NumberType(0),
29
- e14: NumberType(0),
30
- e15: NumberType(0),
31
- } as const satisfies PropertyDefinitionMap;
32
-
33
- export class Mat4 extends createClass<Mat4, typeof mat4Props>(mat4Props) {
34
- multiply3x3(out: Vec3, a: Vec3): Vec3 {
35
- const x = a.x;
36
- const y = a.y;
37
- const z = a.z;
38
- out.x = this.e0 * x + this.e4 * y + this.e8 * z;
39
- out.y = this.e1 * x + this.e5 * y + this.e9 * z;
40
- out.z = this.e2 * x + this.e6 * y + this.e10 * z;
41
- return out;
42
- }
43
-
44
- multiply3x3Transposed(out: Vec3, a: Vec3): void {
45
- rotationMatrix.fromMat4(this);
46
- rotationMatrix.transpose();
47
- out.transformVectorFromMat3(a, rotationMatrix);
48
- }
49
-
50
- computeScaling(out: Vec3) {
51
- let m11 = this.e0;
52
- let m12 = this.e1;
53
- let m13 = this.e2;
54
- let m21 = this.e4;
55
- let m22 = this.e5;
56
- let m23 = this.e6;
57
- let m31 = this.e8;
58
- let m32 = this.e9;
59
- let m33 = this.e10;
60
-
61
- out.x = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);
62
- out.y = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);
63
- out.z = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);
64
-
65
- return out;
66
- }
67
-
68
- computeRotation(out: Quat): Quat {
69
- this.computeScaling(scaling);
70
-
71
- let is1 = 1 / scaling.x;
72
- let is2 = 1 / scaling.y;
73
- let is3 = 1 / scaling.z;
74
-
75
- let sm11 = this.e0 * is1;
76
- let sm12 = this.e1 * is2;
77
- let sm13 = this.e2 * is3;
78
- let sm21 = this.e4 * is1;
79
- let sm22 = this.e5 * is2;
80
- let sm23 = this.e6 * is3;
81
- let sm31 = this.e8 * is1;
82
- let sm32 = this.e9 * is2;
83
- let sm33 = this.e10 * is3;
84
-
85
- let trace = sm11 + sm22 + sm33;
86
- let S = 0;
87
-
88
- if (trace > 0) {
89
- S = Math.sqrt(trace + 1) * 2;
90
- out.w = 0.25 * S;
91
- out.x = (sm23 - sm32) / S;
92
- out.y = (sm31 - sm13) / S;
93
- out.z = (sm12 - sm21) / S;
94
- } else if (sm11 > sm22 && sm11 > sm33) {
95
- S = Math.sqrt(1 + sm11 - sm22 - sm33) * 2;
96
- out.w = (sm23 - sm32) / S;
97
- out.x = 0.25 * S;
98
- out.y = (sm12 + sm21) / S;
99
- out.z = (sm31 + sm13) / S;
100
- } else if (sm22 > sm33) {
101
- S = Math.sqrt(1 + sm22 - sm11 - sm33) * 2;
102
- out.w = (sm31 - sm13) / S;
103
- out.x = (sm12 + sm21) / S;
104
- out.y = 0.25 * S;
105
- out.z = (sm23 + sm32) / S;
106
- } else {
107
- S = Math.sqrt(1 + sm33 - sm11 - sm22) * 2;
108
- out.w = (sm12 - sm21) / S;
109
- out.x = (sm31 + sm13) / S;
110
- out.y = (sm23 + sm32) / S;
111
- out.z = 0.25 * S;
112
- }
113
-
114
- return out;
115
- }
116
-
117
- getTranslation(out: Vec3) {
118
- out.x = this.e12;
119
- out.y = this.e13;
120
- out.z = this.e14;
121
- }
122
-
123
- setTranslation(v: Vec3): void {
124
- this.e12 = v.x;
125
- this.e13 = v.y;
126
- this.e14 = v.z;
127
- this.e15 = 1;
128
- }
129
-
130
- preTranslated(translation: Vec3): Mat4 {
131
- this.e12 += this.e0 * translation.x + this.e4 * translation.y + this.e8 * translation.z;
132
- this.e13 += this.e1 * translation.x + this.e5 * translation.y + this.e9 * translation.z;
133
- this.e14 += this.e2 * translation.x + this.e6 * translation.y + this.e10 * translation.z;
134
- this.e15 = 1;
135
- return this;
136
- }
137
-
138
- postTranslated(translation: Vec3): Mat4 {
139
- this.e12 += translation.x;
140
- this.e13 += translation.y;
141
- this.e14 += translation.z;
142
- this.e15 = 1;
143
- return this;
144
- }
145
-
146
- postTranslatedMatrix(mat: Mat4, translation: Vec3) {
147
- this.e0 = mat.e0;
148
- this.e1 = mat.e1;
149
- this.e2 = mat.e2;
150
- this.e3 = mat.e3;
151
- this.e4 = mat.e4;
152
- this.e5 = mat.e5;
153
- this.e6 = mat.e6;
154
- this.e7 = mat.e7;
155
- this.e8 = mat.e8;
156
- this.e9 = mat.e9;
157
- this.e10 = mat.e10;
158
- this.e11 = mat.e11;
159
- this.e12 = mat.e12 + translation.x;
160
- this.e13 = mat.e13 + translation.y;
161
- this.e14 = mat.e14 + translation.z;
162
- this.e15 = 1;
163
- return this;
164
- }
165
-
166
- fromRotationTranslation(q: Quat, v: Vec3): Mat4 {
167
- const x = q.x;
168
- const y = q.y;
169
- const z = q.z;
170
- const w = q.w;
171
- const x2 = x + x;
172
- const y2 = y + y;
173
- const z2 = z + z;
174
-
175
- const xx = x * x2;
176
- const xy = x * y2;
177
- const xz = x * z2;
178
- const yy = y * y2;
179
- const yz = y * z2;
180
- const zz = z * z2;
181
- const wx = w * x2;
182
- const wy = w * y2;
183
- const wz = w * z2;
184
-
185
- this.e0 = 1 - (yy + zz);
186
- this.e1 = xy + wz;
187
- this.e2 = xz - wy;
188
- this.e3 = 0;
189
- this.e4 = xy - wz;
190
- this.e5 = 1 - (xx + zz);
191
- this.e6 = yz + wx;
192
- this.e7 = 0;
193
- this.e8 = xz + wy;
194
- this.e9 = yz - wx;
195
- this.e10 = 1 - (xx + yy);
196
- this.e11 = 0;
197
- this.e12 = v.x;
198
- this.e13 = v.y;
199
- this.e14 = v.z;
200
- this.e15 = 1;
201
-
202
- return this;
203
- }
204
-
205
- fromAxisAngle(axis: Vec3, angle: number): Mat4 {
206
- rotation.setAxisAngle(axis, angle);
207
- this.fromQuat(rotation);
208
- this.e12 = 0;
209
- this.e13 = 0;
210
- this.e14 = 0;
211
- this.e15 = 1;
212
- return this;
213
- }
214
-
215
- fromQuat(q: Quat): Mat4 {
216
- let x = q.x,
217
- y = q.y,
218
- z = q.z,
219
- w = q.w;
220
- let x2 = x + x;
221
- let y2 = y + y;
222
- let z2 = z + z;
223
-
224
- let xx = x * x2;
225
- let yx = y * x2;
226
- let yy = y * y2;
227
- let zx = z * x2;
228
- let zy = z * y2;
229
- let zz = z * z2;
230
- let wx = w * x2;
231
- let wy = w * y2;
232
- let wz = w * z2;
233
-
234
- this.e0 = 1 - yy - zz;
235
- this.e1 = yx + wz;
236
- this.e2 = zx - wy;
237
- this.e3 = 0;
238
-
239
- this.e4 = yx - wz;
240
- this.e5 = 1 - xx - zz;
241
- this.e6 = zy + wx;
242
- this.e7 = 0;
243
-
244
- this.e8 = zx + wy;
245
- this.e9 = zy - wx;
246
- this.e10 = 1 - xx - yy;
247
- this.e11 = 0;
248
-
249
- this.e12 = 0;
250
- this.e13 = 0;
251
- this.e14 = 0;
252
- this.e15 = 1;
253
-
254
- return this;
255
- }
256
-
257
- fromInverseRotationAndTranslation(rotation: Quat, translation: Vec3) {
258
- conjugatedRotation.conjugateQuat(rotation);
259
- this.fromQuat(conjugatedRotation);
260
- this.multiply3x3(rotatedTranslation, translation);
261
- rotatedTranslation.negate();
262
- this.setTranslation(rotatedTranslation);
263
- return this;
264
- }
265
-
266
- invert() {
267
- const a00 = this.e0;
268
- const a01 = this.e1;
269
- const a02 = this.e2;
270
- const a03 = this.e3;
271
- const a10 = this.e4;
272
- const a11 = this.e5;
273
- const a12 = this.e6;
274
- const a13 = this.e7;
275
- const a20 = this.e8;
276
- const a21 = this.e9;
277
- const a22 = this.e10;
278
- const a23 = this.e11;
279
- const a30 = this.e12;
280
- const a31 = this.e13;
281
- const a32 = this.e14;
282
- const a33 = this.e15;
283
-
284
- const b00 = a00 * a11 - a01 * a10;
285
- const b01 = a00 * a12 - a02 * a10;
286
- const b02 = a00 * a13 - a03 * a10;
287
- const b03 = a01 * a12 - a02 * a11;
288
- const b04 = a01 * a13 - a03 * a11;
289
- const b05 = a02 * a13 - a03 * a12;
290
- const b06 = a20 * a31 - a21 * a30;
291
- const b07 = a20 * a32 - a22 * a30;
292
- const b08 = a20 * a33 - a23 * a30;
293
- const b09 = a21 * a32 - a22 * a31;
294
- const b10 = a21 * a33 - a23 * a31;
295
- const b11 = a22 * a33 - a23 * a32;
296
-
297
- // Calculate the determinant
298
- let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
299
-
300
- if (!det) {
301
- return null;
302
- }
303
- det = 1.0 / det;
304
-
305
- this.e0 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
306
- this.e1 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
307
- this.e2 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
308
- this.e3 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
309
- this.e4 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
310
- this.e5 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
311
- this.e6 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
312
- this.e7 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
313
- this.e8 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
314
- this.e9 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
315
- this.e10 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
316
- this.e11 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
317
- this.e12 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
318
- this.e13 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
319
- this.e14 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
320
- this.e15 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
321
-
322
- return this;
323
- }
324
-
325
- invertMatrix(a: Mat4) {
326
- const a00 = a.e0;
327
- const a01 = a.e1;
328
- const a02 = a.e2;
329
- const a03 = a.e3;
330
- const a10 = a.e4;
331
- const a11 = a.e5;
332
- const a12 = a.e6;
333
- const a13 = a.e7;
334
- const a20 = a.e8;
335
- const a21 = a.e9;
336
- const a22 = a.e10;
337
- const a23 = a.e11;
338
- const a30 = a.e12;
339
- const a31 = a.e13;
340
- const a32 = a.e14;
341
- const a33 = a.e15;
342
-
343
- const b00 = a00 * a11 - a01 * a10;
344
- const b01 = a00 * a12 - a02 * a10;
345
- const b02 = a00 * a13 - a03 * a10;
346
- const b03 = a01 * a12 - a02 * a11;
347
- const b04 = a01 * a13 - a03 * a11;
348
- const b05 = a02 * a13 - a03 * a12;
349
- const b06 = a20 * a31 - a21 * a30;
350
- const b07 = a20 * a32 - a22 * a30;
351
- const b08 = a20 * a33 - a23 * a30;
352
- const b09 = a21 * a32 - a22 * a31;
353
- const b10 = a21 * a33 - a23 * a31;
354
- const b11 = a22 * a33 - a23 * a32;
355
-
356
- // Calculate the determinant
357
- let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
358
-
359
- if (!det) {
360
- return null;
361
- }
362
- det = 1.0 / det;
363
-
364
- this.e0 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
365
- this.e1 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
366
- this.e2 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
367
- this.e3 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
368
- this.e4 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
369
- this.e5 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
370
- this.e6 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
371
- this.e7 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
372
- this.e8 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
373
- this.e9 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
374
- this.e10 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
375
- this.e11 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
376
- this.e12 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
377
- this.e13 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
378
- this.e14 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
379
- this.e15 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
380
-
381
- return this;
382
- }
383
-
384
- getColumn3(out: Vec3, index: number) {
385
- switch (index) {
386
- case 0: {
387
- out.x = this.e0;
388
- out.y = this.e1;
389
- out.z = this.e2;
390
- break;
391
- }
392
-
393
- case 1: {
394
- out.x = this.e4;
395
- out.y = this.e5;
396
- out.z = this.e6;
397
- break;
398
- }
399
-
400
- case 2: {
401
- out.x = this.e8;
402
- out.y = this.e9;
403
- out.z = this.e10;
404
- break;
405
- }
406
- }
407
- }
408
-
409
- multiplyMatrix(b: Mat4) {
410
- let a00 = this.e0,
411
- a01 = this.e1,
412
- a02 = this.e2,
413
- a03 = this.e3;
414
- let a10 = this.e4,
415
- a11 = this.e5,
416
- a12 = this.e6,
417
- a13 = this.e7;
418
- let a20 = this.e8,
419
- a21 = this.e9,
420
- a22 = this.e10,
421
- a23 = this.e11;
422
- let a30 = this.e12,
423
- a31 = this.e13,
424
- a32 = this.e14,
425
- a33 = this.e15;
426
-
427
- let b0 = b.e0,
428
- b1 = b.e1,
429
- b2 = b.e2,
430
- b3 = b.e3;
431
- this.e0 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
432
- this.e1 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
433
- this.e2 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
434
- this.e3 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
435
-
436
- b0 = b.e4;
437
- b1 = b.e5;
438
- b2 = b.e6;
439
- b3 = b.e7;
440
- this.e4 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
441
- this.e5 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
442
- this.e6 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
443
- this.e7 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
444
-
445
- b0 = b.e8;
446
- b1 = b.e9;
447
- b2 = b.e10;
448
- b3 = b.e11;
449
- this.e8 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
450
- this.e9 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
451
- this.e10 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
452
- this.e11 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
453
-
454
- b0 = b.e12;
455
- b1 = b.e13;
456
- b2 = b.e14;
457
- b3 = b.e15;
458
- this.e12 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
459
- this.e13 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
460
- this.e14 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
461
- this.e15 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
462
- return this;
463
- }
464
-
465
- multiplyMatrices(a: Mat4, b: Mat4) {
466
- let a00 = a.e0,
467
- a01 = a.e1,
468
- a02 = a.e2,
469
- a03 = a.e3;
470
- let a10 = a.e4,
471
- a11 = a.e5,
472
- a12 = a.e6,
473
- a13 = a.e7;
474
- let a20 = a.e8,
475
- a21 = a.e9,
476
- a22 = a.e10,
477
- a23 = a.e11;
478
- let a30 = a.e12,
479
- a31 = a.e13,
480
- a32 = a.e14,
481
- a33 = a.e15;
482
-
483
- let b0 = b.e0,
484
- b1 = b.e1,
485
- b2 = b.e2,
486
- b3 = b.e3;
487
- this.e0 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
488
- this.e1 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
489
- this.e2 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
490
- this.e3 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
491
-
492
- b0 = b.e4;
493
- b1 = b.e5;
494
- b2 = b.e6;
495
- b3 = b.e7;
496
- this.e4 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
497
- this.e5 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
498
- this.e6 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
499
- this.e7 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
500
-
501
- b0 = b.e8;
502
- b1 = b.e9;
503
- b2 = b.e10;
504
- b3 = b.e11;
505
- this.e8 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
506
- this.e9 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
507
- this.e10 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
508
- this.e11 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
509
-
510
- b0 = b.e12;
511
- b1 = b.e13;
512
- b2 = b.e14;
513
- b3 = b.e15;
514
- this.e12 = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
515
- this.e13 = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
516
- this.e14 = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
517
- this.e15 = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
518
- return this;
519
- }
520
-
521
- preScaled(scale: Vec3) {
522
- this.e0 *= scale.x;
523
- this.e1 *= scale.x;
524
- this.e2 *= scale.x;
525
- this.e4 *= scale.y;
526
- this.e5 *= scale.y;
527
- this.e6 *= scale.y;
528
- this.e8 *= scale.z;
529
- this.e9 *= scale.z;
530
- this.e10 *= scale.z;
531
- return this;
532
- }
533
-
534
- toObject() {
535
- return {
536
- e0: this.e0,
537
- e1: this.e1,
538
- e2: this.e2,
539
- e3: this.e3,
540
- e4: this.e4,
541
- e5: this.e5,
542
- e6: this.e6,
543
- e7: this.e7,
544
- e8: this.e8,
545
- e9: this.e9,
546
- e10: this.e10,
547
- e11: this.e11,
548
- e12: this.e12,
549
- e13: this.e13,
550
- e14: this.e14,
551
- e15: this.e15,
552
- };
553
- }
554
-
555
- identity() {
556
- this.e0 = 1;
557
- this.e1 = 0;
558
- this.e2 = 0;
559
- this.e3 = 0;
560
-
561
- this.e4 = 0;
562
- this.e5 = 1;
563
- this.e6 = 0;
564
- this.e7 = 0;
565
-
566
- this.e8 = 0;
567
- this.e9 = 0;
568
- this.e10 = 1;
569
- this.e11 = 0;
570
-
571
- this.e12 = 0;
572
- this.e13 = 0;
573
- this.e14 = 0;
574
- this.e15 = 1;
575
-
576
- return this;
577
- }
578
-
579
- getRotationMatrix4(out: Mat4) {
580
- out.copy(this);
581
- out.e12 = 0;
582
- out.e13 = 0;
583
- out.e14 = 0;
584
- out.e15 = 1;
585
- }
586
- }
587
-
588
- const rotation = /*@__PURE__*/ Quat.create();