@perplexdotgg/bounce 1.0.0 → 1.0.1

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 (134) 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
@@ -1,64 +0,0 @@
1
- import { createClass, MonomorphType, PropertyDefinitionMap } from "monomorph";
2
- import { Mat4 } from "./mat4";
3
- import { Quat } from "./quat";
4
- import { Vec3 } from "./vec3";
5
- import { Mat3 } from "./mat3";
6
-
7
- const isometryProps = {
8
- matrix: MonomorphType(Mat4),
9
- } as const satisfies PropertyDefinitionMap;
10
-
11
- const tempTranslation = /*@__PURE__*/ Vec3.create();
12
- const tempRotation = /*@__PURE__*/ Quat.create();
13
- const rotation = /*@__PURE__*/ Mat3.create();
14
-
15
- const inverseMatrix = /*@__PURE__*/ Mat4.create();
16
-
17
- export class Isometry extends createClass<Isometry, typeof isometryProps>(isometryProps) {
18
- fromRotationAndTranslation(rotation?: Quat, translation?: Vec3) {
19
- if (rotation) {
20
- tempRotation.copy(rotation);
21
- } else {
22
- tempRotation.identity();
23
- }
24
-
25
- if (translation) {
26
- tempTranslation.copy(translation);
27
- } else {
28
- tempTranslation.zero();
29
- }
30
-
31
- this.matrix.fromRotationTranslation(tempRotation, tempTranslation);
32
- return this;
33
- }
34
-
35
- fromInverseRotationAndTranslation(rotation: Quat, translation: Vec3) {
36
- this.matrix.fromRotationTranslation(rotation, translation);
37
- this.matrix.invert();
38
- return this;
39
- }
40
-
41
- rotateVector(vector: Vec3) {
42
- rotation.fromMat4(this.matrix);
43
- vector.transformVectorFromMat3(vector, rotation);
44
- return vector;
45
- }
46
-
47
- inverseRotateVector(out: Vec3, vector: Vec3) {
48
- rotation.fromMat4(this.matrix);
49
- rotation.invert();
50
- out.transformVectorFromMat3(vector, rotation);
51
- return out;
52
- }
53
-
54
- transformPoint(point: Vec3) {
55
- point.transformFromMat4(this.matrix);
56
- return point;
57
- }
58
-
59
- inverseTransformPoint(point: Vec3) {
60
- inverseMatrix.invertMatrix(this.matrix);
61
- point.transformFromMat4(inverseMatrix);
62
- return point;
63
- }
64
- }
package/src/math/mat3.ts DELETED
@@ -1,529 +0,0 @@
1
- import { createClass, NumberType, PropertyDefinitionMap } from "monomorph";
2
- import { Mat4 } from "./mat4";
3
- import { Quat } from "./quat";
4
- import { Vec3 } from "./vec3";
5
-
6
- export const mat3Keys = ["e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8"] as const;
7
-
8
- const mat3Props = {
9
- e0: NumberType(0),
10
- e1: NumberType(0),
11
- e2: NumberType(0),
12
-
13
- e3: NumberType(0),
14
- e4: NumberType(0),
15
- e5: NumberType(0),
16
-
17
- e6: NumberType(0),
18
- e7: NumberType(0),
19
- e8: NumberType(0),
20
- } as const satisfies PropertyDefinitionMap;
21
-
22
- export class Mat3 extends createClass<Mat3, typeof mat3Props>(mat3Props) {
23
- adjointMatrix(a: Mat3) {
24
- let a00 = a.e0,
25
- a01 = a.e1,
26
- a02 = a.e2;
27
- let a10 = a.e3,
28
- a11 = a.e4,
29
- a12 = a.e5;
30
- let a20 = a.e6,
31
- a21 = a.e7,
32
- a22 = a.e8;
33
-
34
- this.e0 = a11 * a22 - a12 * a21;
35
- this.e1 = a02 * a21 - a01 * a22;
36
- this.e2 = a01 * a12 - a02 * a11;
37
- this.e3 = a12 * a20 - a10 * a22;
38
- this.e4 = a00 * a22 - a02 * a20;
39
- this.e5 = a02 * a10 - a00 * a12;
40
- this.e6 = a10 * a21 - a11 * a20;
41
- this.e7 = a01 * a20 - a00 * a21;
42
- this.e8 = a00 * a11 - a01 * a10;
43
- return this;
44
- }
45
-
46
- adjoint() {
47
- let a00 = this.e0,
48
- a01 = this.e1,
49
- a02 = this.e2;
50
- let a10 = this.e3,
51
- a11 = this.e4,
52
- a12 = this.e5;
53
- let a20 = this.e6,
54
- a21 = this.e7,
55
- a22 = this.e8;
56
-
57
- this.e0 = a11 * a22 - a12 * a21;
58
- this.e1 = a02 * a21 - a01 * a22;
59
- this.e2 = a01 * a12 - a02 * a11;
60
- this.e3 = a12 * a20 - a10 * a22;
61
- this.e4 = a00 * a22 - a02 * a20;
62
- this.e5 = a02 * a10 - a00 * a12;
63
- this.e6 = a10 * a21 - a11 * a20;
64
- this.e7 = a01 * a20 - a00 * a21;
65
- this.e8 = a00 * a11 - a01 * a10;
66
- return this;
67
- }
68
-
69
- computeDeterminant() {
70
- let a00 = this.e0,
71
- a01 = this.e1,
72
- a02 = this.e2;
73
- let a10 = this.e3,
74
- a11 = this.e4,
75
- a12 = this.e5;
76
- let a20 = this.e6,
77
- a21 = this.e7,
78
- a22 = this.e8;
79
-
80
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
81
- }
82
-
83
- setColumns(column0: Vec3, column1: Vec3, column2: Vec3): void {
84
- this.e0 = column0.x;
85
- this.e1 = column0.y;
86
- this.e2 = column0.z;
87
- this.e3 = column1.x;
88
- this.e4 = column1.y;
89
- this.e5 = column1.z;
90
- this.e6 = column2.x;
91
- this.e7 = column2.y;
92
- this.e8 = column2.z;
93
- }
94
-
95
- fill(value: number) {
96
- this.e0 = value;
97
- this.e1 = value;
98
- this.e2 = value;
99
- this.e3 = value;
100
- this.e4 = value;
101
- this.e5 = value;
102
- this.e6 = value;
103
- this.e7 = value;
104
- this.e8 = value;
105
- }
106
-
107
- fillDiagonal(value: number) {
108
- this.e0 = value;
109
- this.e4 = value;
110
- this.e8 = value;
111
- }
112
-
113
- fillOffDiagonal(value: number) {
114
- this.e1 = value;
115
- this.e2 = value;
116
- this.e3 = value;
117
- this.e5 = value;
118
- this.e6 = value;
119
- this.e7 = value;
120
- }
121
-
122
- fromMat4(a: Mat4) {
123
- this.e0 = a.e0;
124
- this.e1 = a.e1;
125
- this.e2 = a.e2;
126
- this.e3 = a.e4;
127
- this.e4 = a.e5;
128
- this.e5 = a.e6;
129
- this.e6 = a.e8;
130
- this.e7 = a.e9;
131
- this.e8 = a.e10;
132
-
133
- return this;
134
- }
135
-
136
- transpose() {
137
- const a01 = this.e1;
138
- const a02 = this.e2;
139
- const a12 = this.e5;
140
- this.e1 = this.e3;
141
- this.e2 = this.e6;
142
- this.e3 = a01;
143
- this.e5 = this.e7;
144
- this.e6 = a02;
145
- this.e7 = a12;
146
-
147
- return this;
148
- }
149
-
150
- transposeMatrix(a: Mat3) {
151
- this.e0 = a.e0;
152
- this.e1 = a.e3;
153
- this.e2 = a.e6;
154
- this.e3 = a.e1;
155
- this.e4 = a.e4;
156
- this.e5 = a.e7;
157
- this.e6 = a.e2;
158
- this.e7 = a.e5;
159
- this.e8 = a.e8;
160
-
161
- return this;
162
- }
163
-
164
- invert(): Mat3 | null {
165
- const a00 = this.e0;
166
- const a01 = this.e1;
167
- const a02 = this.e2;
168
- const a10 = this.e3;
169
- const a11 = this.e4;
170
- const a12 = this.e5;
171
- const a20 = this.e6;
172
- const a21 = this.e7;
173
- const a22 = this.e8;
174
-
175
- const b01 = a22 * a11 - a12 * a21;
176
- const b11 = -a22 * a10 + a12 * a20;
177
- const b21 = a21 * a10 - a11 * a20;
178
-
179
- // Calculate the determinant
180
- let det = a00 * b01 + a01 * b11 + a02 * b21;
181
-
182
- if (!det) {
183
- return null;
184
- }
185
- det = 1.0 / det;
186
-
187
- this.e0 = b01 * det;
188
- this.e1 = (-a22 * a01 + a02 * a21) * det;
189
- this.e2 = (a12 * a01 - a02 * a11) * det;
190
- this.e3 = b11 * det;
191
- this.e4 = (a22 * a00 - a02 * a20) * det;
192
- this.e5 = (-a12 * a00 + a02 * a10) * det;
193
- this.e6 = b21 * det;
194
- this.e7 = (-a21 * a00 + a01 * a20) * det;
195
- this.e8 = (a11 * a00 - a01 * a10) * det;
196
- return this;
197
- }
198
-
199
- invertMat3(a: Mat3): Mat3 | null {
200
- const a00 = a.e0;
201
- const a01 = a.e1;
202
- const a02 = a.e2;
203
- const a10 = a.e3;
204
- const a11 = a.e4;
205
- const a12 = a.e5;
206
- const a20 = a.e6;
207
- const a21 = a.e7;
208
- const a22 = a.e8;
209
-
210
- const b01 = a22 * a11 - a12 * a21;
211
- const b11 = -a22 * a10 + a12 * a20;
212
- const b21 = a21 * a10 - a11 * a20;
213
-
214
- // Calculate the determinant
215
- let det = a00 * b01 + a01 * b11 + a02 * b21;
216
-
217
- if (!det) {
218
- return null;
219
- }
220
- det = 1.0 / det;
221
-
222
- this.e0 = b01 * det;
223
- this.e1 = (-a22 * a01 + a02 * a21) * det;
224
- this.e2 = (a12 * a01 - a02 * a11) * det;
225
- this.e3 = b11 * det;
226
- this.e4 = (a22 * a00 - a02 * a20) * det;
227
- this.e5 = (-a12 * a00 + a02 * a10) * det;
228
- this.e6 = b21 * det;
229
- this.e7 = (-a21 * a00 + a01 * a20) * det;
230
- this.e8 = (a11 * a00 - a01 * a10) * det;
231
- return this;
232
- }
233
-
234
- zero() {
235
- this.e0 = 0;
236
- this.e1 = 0;
237
- this.e2 = 0;
238
- this.e3 = 0;
239
- this.e4 = 0;
240
- this.e5 = 0;
241
- this.e6 = 0;
242
- this.e7 = 0;
243
- this.e8 = 0;
244
-
245
- return this;
246
- }
247
-
248
- multiplyMat3(b: Mat3): Mat3 {
249
- const a00 = this.e0;
250
- const a01 = this.e1;
251
- const a02 = this.e2;
252
- const a10 = this.e3;
253
- const a11 = this.e4;
254
- const a12 = this.e5;
255
- const a20 = this.e6;
256
- const a21 = this.e7;
257
- const a22 = this.e8;
258
-
259
- const b00 = b.e0;
260
- const b01 = b.e1;
261
- const b02 = b.e2;
262
- const b10 = b.e3;
263
- const b11 = b.e4;
264
- const b12 = b.e5;
265
- const b20 = b.e6;
266
- const b21 = b.e7;
267
- const b22 = b.e8;
268
-
269
- this.e0 = b00 * a00 + b01 * a10 + b02 * a20;
270
- this.e1 = b00 * a01 + b01 * a11 + b02 * a21;
271
- this.e2 = b00 * a02 + b01 * a12 + b02 * a22;
272
-
273
- this.e3 = b10 * a00 + b11 * a10 + b12 * a20;
274
- this.e4 = b10 * a01 + b11 * a11 + b12 * a21;
275
- this.e5 = b10 * a02 + b11 * a12 + b12 * a22;
276
-
277
- this.e6 = b20 * a00 + b21 * a10 + b22 * a20;
278
- this.e7 = b20 * a01 + b21 * a11 + b22 * a21;
279
- this.e8 = b20 * a02 + b21 * a12 + b22 * a22;
280
- return this;
281
- }
282
-
283
- addMatrix(a: Mat3) {
284
- this.e0 += a.e0;
285
- this.e1 += a.e1;
286
- this.e2 += a.e2;
287
- this.e3 += a.e3;
288
- this.e4 += a.e4;
289
- this.e5 += a.e5;
290
- this.e6 += a.e6;
291
- this.e7 += a.e7;
292
- this.e8 += a.e8;
293
-
294
- return this;
295
- }
296
-
297
- addMatrices(a: Mat3, b: Mat3) {
298
- this.e0 = a.e0 + b.e0;
299
- this.e1 = a.e1 + b.e1;
300
- this.e2 = a.e2 + b.e2;
301
- this.e3 = a.e3 + b.e3;
302
- this.e4 = a.e4 + b.e4;
303
- this.e5 = a.e5 + b.e5;
304
- this.e6 = a.e6 + b.e6;
305
- this.e7 = a.e7 + b.e7;
306
- this.e8 = a.e8 + b.e8;
307
- return this;
308
- }
309
-
310
- subtractMatrix(a: Mat3) {
311
- this.e0 -= a.e0;
312
- this.e1 -= a.e1;
313
- this.e2 -= a.e2;
314
- this.e3 -= a.e3;
315
- this.e4 -= a.e4;
316
- this.e5 -= a.e5;
317
- this.e6 -= a.e6;
318
- this.e7 -= a.e7;
319
- this.e8 -= a.e8;
320
-
321
- return this;
322
- }
323
-
324
- subtractMatrices(a: Mat3, b: Mat3) {
325
- this.e0 = a.e0 - b.e0;
326
- this.e1 = a.e1 - b.e1;
327
- this.e2 = a.e2 - b.e2;
328
- this.e3 = a.e3 - b.e3;
329
- this.e4 = a.e4 - b.e4;
330
- this.e5 = a.e5 - b.e5;
331
- this.e6 = a.e6 - b.e6;
332
- this.e7 = a.e7 - b.e7;
333
- this.e8 = a.e8 - b.e8;
334
- return this;
335
- }
336
-
337
- outerProduct(a: Vec3, b: Vec3) {
338
- this.e0 = a.x * b.x;
339
- this.e1 = a.y * b.x;
340
- this.e2 = a.z * b.x;
341
- this.e3 = a.x * b.y;
342
- this.e4 = a.y * b.y;
343
- this.e5 = a.z * b.y;
344
- this.e6 = a.x * b.z;
345
- this.e7 = a.y * b.z;
346
- this.e8 = a.z * b.z;
347
- return this;
348
- }
349
-
350
- multiplyByScalar(b: number) {
351
- this.e0 *= b;
352
- this.e1 *= b;
353
- this.e2 *= b;
354
- this.e3 *= b;
355
- this.e4 *= b;
356
- this.e5 *= b;
357
- this.e6 *= b;
358
- this.e7 *= b;
359
- this.e8 *= b;
360
-
361
- return this;
362
- }
363
-
364
- multiplyMatrixByScalar(a: Mat3, b: number) {
365
- this.e0 = a.e0 * b;
366
- this.e1 = a.e1 * b;
367
- this.e2 = a.e2 * b;
368
- this.e3 = a.e3 * b;
369
- this.e4 = a.e4 * b;
370
- this.e5 = a.e5 * b;
371
- this.e6 = a.e6 * b;
372
- this.e7 = a.e7 * b;
373
- this.e8 = a.e8 * b;
374
- return this;
375
- }
376
-
377
- identity() {
378
- this.e0 = 1;
379
- this.e1 = 0;
380
- this.e2 = 0;
381
- this.e3 = 0;
382
- this.e4 = 1;
383
- this.e5 = 0;
384
- this.e6 = 0;
385
- this.e7 = 0;
386
- this.e8 = 1;
387
-
388
- return this;
389
- }
390
-
391
- multiplyMat3RightTransposed(a: Mat3) {
392
- rightTransposed.transposeMatrix(a);
393
- this.multiplyMat3s(this, rightTransposed);
394
- return this;
395
- }
396
-
397
- multiplyMat3s(a: Mat3, b: Mat3): Mat3 {
398
- const a00 = a.e0;
399
- const a01 = a.e1;
400
- const a02 = a.e2;
401
- const a10 = a.e3;
402
- const a11 = a.e4;
403
- const a12 = a.e5;
404
- const a20 = a.e6;
405
- const a21 = a.e7;
406
- const a22 = a.e8;
407
-
408
- const b00 = b.e0;
409
- const b01 = b.e1;
410
- const b02 = b.e2;
411
- const b10 = b.e3;
412
- const b11 = b.e4;
413
- const b12 = b.e5;
414
- const b20 = b.e6;
415
- const b21 = b.e7;
416
- const b22 = b.e8;
417
-
418
- this.e0 = b00 * a00 + b01 * a10 + b02 * a20;
419
- this.e1 = b00 * a01 + b01 * a11 + b02 * a21;
420
- this.e2 = b00 * a02 + b01 * a12 + b02 * a22;
421
-
422
- this.e3 = b10 * a00 + b11 * a10 + b12 * a20;
423
- this.e4 = b10 * a01 + b11 * a11 + b12 * a21;
424
- this.e5 = b10 * a02 + b11 * a12 + b12 * a22;
425
-
426
- this.e6 = b20 * a00 + b21 * a10 + b22 * a20;
427
- this.e7 = b20 * a01 + b21 * a11 + b22 * a21;
428
- this.e8 = b20 * a02 + b21 * a12 + b22 * a22;
429
- return this;
430
- }
431
-
432
- fromQuat(q: Quat): Mat3 {
433
- const x = q.x;
434
- const y = q.y;
435
- const z = q.z;
436
- const w = q.w;
437
- const x2 = x + x;
438
- const y2 = y + y;
439
- const z2 = z + z;
440
-
441
- const xx = x * x2;
442
- const yx = y * x2;
443
- const yy = y * y2;
444
- const zx = z * x2;
445
- const zy = z * y2;
446
- const zz = z * z2;
447
- const wx = w * x2;
448
- const wy = w * y2;
449
- const wz = w * z2;
450
-
451
- this.e0 = 1 - yy - zz;
452
- this.e3 = yx - wz;
453
- this.e6 = zx + wy;
454
-
455
- this.e1 = yx + wz;
456
- this.e4 = 1 - xx - zz;
457
- this.e7 = zy - wx;
458
-
459
- this.e2 = zx - wy;
460
- this.e5 = zy + wx;
461
- this.e8 = 1 - xx - yy;
462
-
463
- return this;
464
- }
465
-
466
- isExactlyZero() {
467
- return (
468
- this.e0 === 0 &&
469
- this.e1 === 0 &&
470
- this.e2 === 0 &&
471
- this.e3 === 0 &&
472
- this.e4 === 0 &&
473
- this.e5 === 0 &&
474
- this.e6 === 0 &&
475
- this.e7 === 0 &&
476
- this.e8 === 0
477
- );
478
- }
479
-
480
- asSkewSymmetricMatrix(a: Vec3) {
481
- this.e0 = +0;
482
- this.e1 = +a.z;
483
- this.e2 = -a.y;
484
- this.e3 = -a.z;
485
- this.e4 = +0;
486
- this.e5 = +a.x;
487
- this.e6 = +a.y;
488
- this.e7 = -a.x;
489
- this.e8 = +0;
490
- return this;
491
- }
492
-
493
- multiplyMatrices(a: Mat3, b: Mat3) {
494
- let a00 = a.e0,
495
- a01 = a.e1,
496
- a02 = a.e2;
497
- let a10 = a.e3,
498
- a11 = a.e4,
499
- a12 = a.e5;
500
- let a20 = a.e6,
501
- a21 = a.e7,
502
- a22 = a.e8;
503
-
504
- let b00 = b.e0,
505
- b01 = b.e1,
506
- b02 = b.e2;
507
- let b10 = b.e3,
508
- b11 = b.e4,
509
- b12 = b.e5;
510
- let b20 = b.e6,
511
- b21 = b.e7,
512
- b22 = b.e8;
513
-
514
- this.e0 = b00 * a00 + b01 * a10 + b02 * a20;
515
- this.e1 = b00 * a01 + b01 * a11 + b02 * a21;
516
- this.e2 = b00 * a02 + b01 * a12 + b02 * a22;
517
-
518
- this.e3 = b10 * a00 + b11 * a10 + b12 * a20;
519
- this.e4 = b10 * a01 + b11 * a11 + b12 * a21;
520
- this.e5 = b10 * a02 + b11 * a12 + b12 * a22;
521
-
522
- this.e6 = b20 * a00 + b21 * a10 + b22 * a20;
523
- this.e7 = b20 * a01 + b21 * a11 + b22 * a21;
524
- this.e8 = b20 * a02 + b21 * a12 + b22 * a22;
525
- return this;
526
- }
527
- }
528
-
529
- const rightTransposed = /*@__PURE__*/ Mat3.create();