@galacean/engine-math 0.9.19 → 0.9.21

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.
@@ -2,27 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- /**
6
- * Defines how the bounding volumes intersects or contain one another.
7
- */ exports.ContainmentType = void 0;
5
+ var _create_class = require('@swc/helpers/src/_create_class.mjs');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var _create_class__default = /*#__PURE__*/_interopDefaultLegacy(_create_class);
10
+
8
11
  (function(ContainmentType) {
9
12
  ContainmentType[ContainmentType[/** Indicates that there is no overlap between two bounding volumes. */ "Disjoint"] = 0] = "Disjoint";
10
13
  ContainmentType[ContainmentType[/** Indicates that one bounding volume completely contains another volume. */ "Contains"] = 1] = "Contains";
11
14
  ContainmentType[ContainmentType[/** Indicates that bounding volumes partially overlap one another. */ "Intersects"] = 2] = "Intersects";
12
15
  })(exports.ContainmentType || (exports.ContainmentType = {}));
13
16
 
14
- /**
15
- * Defines the intersection between a plane and a bounding volume.
16
- */ exports.PlaneIntersectionType = void 0;
17
17
  (function(PlaneIntersectionType) {
18
18
  PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the back of the plane. */ "Back"] = 0] = "Back";
19
19
  PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the front of the plane. */ "Front"] = 1] = "Front";
20
20
  PlaneIntersectionType[PlaneIntersectionType[/** The plane is intersected. */ "Intersecting"] = 2] = "Intersecting";
21
21
  })(exports.PlaneIntersectionType || (exports.PlaneIntersectionType = {}));
22
22
 
23
- /**
24
- * Frustum face
25
- */ exports.FrustumFace = void 0;
26
23
  (function(FrustumFace) {
27
24
  FrustumFace[FrustumFace[/** Near face */ "Near"] = 0] = "Near";
28
25
  FrustumFace[FrustumFace[/** Far face */ "Far"] = 1] = "Far";
@@ -32,24 +29,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
32
29
  FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
33
30
  })(exports.FrustumFace || (exports.FrustumFace = {}));
34
31
 
35
- function _defineProperties(target, props) {
36
- for (var i = 0; i < props.length; i++) {
37
- var descriptor = props[i];
38
- descriptor.enumerable = descriptor.enumerable || false;
39
- descriptor.configurable = true;
40
-
41
- if ("value" in descriptor) descriptor.writable = true;
42
-
43
- Object.defineProperty(target, descriptor.key, descriptor);
44
- }
45
- }
46
- function _create_class(Constructor, protoProps, staticProps) {
47
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
48
- if (staticProps) _defineProperties(Constructor, staticProps);
49
-
50
- return Constructor;
51
- }
52
-
53
32
  /**
54
33
  * Common utility methods for math operations.
55
34
  */ var MathUtil = /*#__PURE__*/ function() {
@@ -95,15 +74,9 @@ function _create_class(Constructor, protoProps, staticProps) {
95
74
  };
96
75
  return MathUtil;
97
76
  }();
98
- (function() {
99
- /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
100
- })();
101
- (function() {
102
- /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
103
- })();
104
- (function() {
105
- /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
106
- })();
77
+ /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
78
+ /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
79
+ /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
107
80
 
108
81
  /**
109
82
  * Describes a 3D-vector.
@@ -562,7 +535,7 @@ function _create_class(Constructor, protoProps, staticProps) {
562
535
  out._z = iz * qw - iw * qz - ix * qy + iy * qx;
563
536
  out._onValueChanged && out._onValueChanged();
564
537
  };
565
- _create_class(Vector3, [
538
+ _create_class__default['default'](Vector3, [
566
539
  {
567
540
  key: "x",
568
541
  get: /**
@@ -602,12 +575,8 @@ function _create_class(Constructor, protoProps, staticProps) {
602
575
  ]);
603
576
  return Vector3;
604
577
  }();
605
- (function() {
606
- /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
607
- })();
608
- (function() {
609
- /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
610
- })();
578
+ /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
579
+ /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
611
580
 
612
581
  /**
613
582
  * A bounding sphere.
@@ -676,9 +645,7 @@ function _create_class(Constructor, protoProps, staticProps) {
676
645
  };
677
646
  return BoundingSphere;
678
647
  }();
679
- (function() {
680
- BoundingSphere._tempVec30 = new Vector3();
681
- })();
648
+ BoundingSphere._tempVec30 = new Vector3();
682
649
 
683
650
  /**
684
651
  * Axis Aligned Bound Box (AABB).
@@ -837,12 +804,8 @@ function _create_class(Constructor, protoProps, staticProps) {
837
804
  };
838
805
  return BoundingBox;
839
806
  }();
840
- (function() {
841
- BoundingBox._tempVec30 = new Vector3();
842
- })();
843
- (function() {
844
- BoundingBox._tempVec31 = new Vector3();
845
- })();
807
+ BoundingBox._tempVec30 = new Vector3();
808
+ BoundingBox._tempVec31 = new Vector3();
846
809
 
847
810
  /**
848
811
  * Contains static methods to help in determining intersections, containment, etc.
@@ -1191,15 +1154,9 @@ function _create_class(Constructor, protoProps, staticProps) {
1191
1154
  };
1192
1155
  return CollisionUtil;
1193
1156
  }();
1194
- (function() {
1195
- CollisionUtil._tempVec30 = new Vector3();
1196
- })();
1197
- (function() {
1198
- CollisionUtil._tempVec31 = new Vector3();
1199
- })();
1200
- (function() {
1201
- CollisionUtil._tempVec32 = new Vector3();
1202
- })();
1157
+ CollisionUtil._tempVec30 = new Vector3();
1158
+ CollisionUtil._tempVec31 = new Vector3();
1159
+ CollisionUtil._tempVec32 = new Vector3();
1203
1160
 
1204
1161
  /**
1205
1162
  * Represents a plane in three-dimensional space.
@@ -2523,7 +2480,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2523
2480
  out._w = a._w * s;
2524
2481
  out._onValueChanged && out._onValueChanged();
2525
2482
  };
2526
- _create_class(Quaternion, [
2483
+ _create_class__default['default'](Quaternion, [
2527
2484
  {
2528
2485
  key: "x",
2529
2486
  get: /**
@@ -2583,12 +2540,8 @@ function _create_class(Constructor, protoProps, staticProps) {
2583
2540
  ]);
2584
2541
  return Quaternion;
2585
2542
  }();
2586
- (function() {
2587
- /** @internal */ Quaternion._tempVector3 = new Vector3();
2588
- })();
2589
- (function() {
2590
- /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2591
- })();
2543
+ /** @internal */ Quaternion._tempVector3 = new Vector3();
2544
+ /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2592
2545
 
2593
2546
  /**
2594
2547
  * Represents a 4x4 mathematical matrix.
@@ -3534,21 +3487,11 @@ function _create_class(Constructor, protoProps, staticProps) {
3534
3487
  };
3535
3488
  return Matrix;
3536
3489
  }();
3537
- (function() {
3538
- Matrix._tempVec30 = new Vector3();
3539
- })();
3540
- (function() {
3541
- Matrix._tempVec31 = new Vector3();
3542
- })();
3543
- (function() {
3544
- Matrix._tempVec32 = new Vector3();
3545
- })();
3546
- (function() {
3547
- Matrix._tempMat30 = new Matrix3x3();
3548
- })();
3549
- (function() {
3550
- /** @internal Identity matrix. */ Matrix._identity = new Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
3551
- })();
3490
+ Matrix._tempVec30 = new Vector3();
3491
+ Matrix._tempVec31 = new Vector3();
3492
+ Matrix._tempVec32 = new Vector3();
3493
+ Matrix._tempMat30 = new Matrix3x3();
3494
+ /** @internal Identity matrix. */ Matrix._identity = new Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
3552
3495
 
3553
3496
  /**
3554
3497
  * Represents a ray with an origin and a direction in 3D space.
@@ -3884,7 +3827,7 @@ function _create_class(Constructor, protoProps, staticProps) {
3884
3827
  out._y = left._y * s;
3885
3828
  out._onValueChanged && out._onValueChanged();
3886
3829
  };
3887
- _create_class(Vector2, [
3830
+ _create_class__default['default'](Vector2, [
3888
3831
  {
3889
3832
  key: "x",
3890
3833
  get: /**
@@ -3912,12 +3855,8 @@ function _create_class(Constructor, protoProps, staticProps) {
3912
3855
  ]);
3913
3856
  return Vector2;
3914
3857
  }();
3915
- (function() {
3916
- /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3917
- })();
3918
- (function() {
3919
- /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
3920
- })();
3858
+ /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3859
+ /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
3921
3860
 
3922
3861
  /**
3923
3862
  * Describes a 4D-vector.
@@ -4298,7 +4237,7 @@ function _create_class(Constructor, protoProps, staticProps) {
4298
4237
  out._w = w;
4299
4238
  out._onValueChanged && out._onValueChanged();
4300
4239
  };
4301
- _create_class(Vector4, [
4240
+ _create_class__default['default'](Vector4, [
4302
4241
  {
4303
4242
  key: "x",
4304
4243
  get: /**
@@ -4350,12 +4289,8 @@ function _create_class(Constructor, protoProps, staticProps) {
4350
4289
  ]);
4351
4290
  return Vector4;
4352
4291
  }();
4353
- (function() {
4354
- /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4355
- })();
4356
- (function() {
4357
- /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
4358
- })();
4292
+ /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4293
+ /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
4359
4294
 
4360
4295
  /**
4361
4296
  * Describes a color in the from of RGBA (in order: R, G, B, A).
@@ -4565,7 +4500,7 @@ function _create_class(Constructor, protoProps, staticProps) {
4565
4500
  out._onValueChanged && out._onValueChanged();
4566
4501
  return out;
4567
4502
  };
4568
- _create_class(Color, [
4503
+ _create_class__default['default'](Color, [
4569
4504
  {
4570
4505
  key: "r",
4571
4506
  get: /**
package/dist/module.js CHANGED
@@ -1,3 +1,5 @@
1
+ import _create_class from '@swc/helpers/src/_create_class.mjs';
2
+
1
3
  /**
2
4
  * Defines how the bounding volumes intersects or contain one another.
3
5
  */ var ContainmentType;
@@ -28,24 +30,6 @@
28
30
  FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
29
31
  })(FrustumFace || (FrustumFace = {}));
30
32
 
31
- function _defineProperties(target, props) {
32
- for (var i = 0; i < props.length; i++) {
33
- var descriptor = props[i];
34
- descriptor.enumerable = descriptor.enumerable || false;
35
- descriptor.configurable = true;
36
-
37
- if ("value" in descriptor) descriptor.writable = true;
38
-
39
- Object.defineProperty(target, descriptor.key, descriptor);
40
- }
41
- }
42
- function _create_class(Constructor, protoProps, staticProps) {
43
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
44
- if (staticProps) _defineProperties(Constructor, staticProps);
45
-
46
- return Constructor;
47
- }
48
-
49
33
  /**
50
34
  * Common utility methods for math operations.
51
35
  */ var MathUtil = /*#__PURE__*/ function() {
@@ -91,15 +75,9 @@ function _create_class(Constructor, protoProps, staticProps) {
91
75
  };
92
76
  return MathUtil;
93
77
  }();
94
- (function() {
95
- /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
96
- })();
97
- (function() {
98
- /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
99
- })();
100
- (function() {
101
- /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
102
- })();
78
+ /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
79
+ /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
80
+ /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
103
81
 
104
82
  /**
105
83
  * Describes a 3D-vector.
@@ -598,12 +576,8 @@ function _create_class(Constructor, protoProps, staticProps) {
598
576
  ]);
599
577
  return Vector3;
600
578
  }();
601
- (function() {
602
- /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
603
- })();
604
- (function() {
605
- /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
606
- })();
579
+ /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
580
+ /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
607
581
 
608
582
  /**
609
583
  * A bounding sphere.
@@ -672,9 +646,7 @@ function _create_class(Constructor, protoProps, staticProps) {
672
646
  };
673
647
  return BoundingSphere;
674
648
  }();
675
- (function() {
676
- BoundingSphere._tempVec30 = new Vector3();
677
- })();
649
+ BoundingSphere._tempVec30 = new Vector3();
678
650
 
679
651
  /**
680
652
  * Axis Aligned Bound Box (AABB).
@@ -833,12 +805,8 @@ function _create_class(Constructor, protoProps, staticProps) {
833
805
  };
834
806
  return BoundingBox;
835
807
  }();
836
- (function() {
837
- BoundingBox._tempVec30 = new Vector3();
838
- })();
839
- (function() {
840
- BoundingBox._tempVec31 = new Vector3();
841
- })();
808
+ BoundingBox._tempVec30 = new Vector3();
809
+ BoundingBox._tempVec31 = new Vector3();
842
810
 
843
811
  /**
844
812
  * Contains static methods to help in determining intersections, containment, etc.
@@ -1187,15 +1155,9 @@ function _create_class(Constructor, protoProps, staticProps) {
1187
1155
  };
1188
1156
  return CollisionUtil;
1189
1157
  }();
1190
- (function() {
1191
- CollisionUtil._tempVec30 = new Vector3();
1192
- })();
1193
- (function() {
1194
- CollisionUtil._tempVec31 = new Vector3();
1195
- })();
1196
- (function() {
1197
- CollisionUtil._tempVec32 = new Vector3();
1198
- })();
1158
+ CollisionUtil._tempVec30 = new Vector3();
1159
+ CollisionUtil._tempVec31 = new Vector3();
1160
+ CollisionUtil._tempVec32 = new Vector3();
1199
1161
 
1200
1162
  /**
1201
1163
  * Represents a plane in three-dimensional space.
@@ -2579,12 +2541,8 @@ function _create_class(Constructor, protoProps, staticProps) {
2579
2541
  ]);
2580
2542
  return Quaternion;
2581
2543
  }();
2582
- (function() {
2583
- /** @internal */ Quaternion._tempVector3 = new Vector3();
2584
- })();
2585
- (function() {
2586
- /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2587
- })();
2544
+ /** @internal */ Quaternion._tempVector3 = new Vector3();
2545
+ /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2588
2546
 
2589
2547
  /**
2590
2548
  * Represents a 4x4 mathematical matrix.
@@ -3530,21 +3488,11 @@ function _create_class(Constructor, protoProps, staticProps) {
3530
3488
  };
3531
3489
  return Matrix;
3532
3490
  }();
3533
- (function() {
3534
- Matrix._tempVec30 = new Vector3();
3535
- })();
3536
- (function() {
3537
- Matrix._tempVec31 = new Vector3();
3538
- })();
3539
- (function() {
3540
- Matrix._tempVec32 = new Vector3();
3541
- })();
3542
- (function() {
3543
- Matrix._tempMat30 = new Matrix3x3();
3544
- })();
3545
- (function() {
3546
- /** @internal Identity matrix. */ Matrix._identity = new Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
3547
- })();
3491
+ Matrix._tempVec30 = new Vector3();
3492
+ Matrix._tempVec31 = new Vector3();
3493
+ Matrix._tempVec32 = new Vector3();
3494
+ Matrix._tempMat30 = new Matrix3x3();
3495
+ /** @internal Identity matrix. */ Matrix._identity = new Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
3548
3496
 
3549
3497
  /**
3550
3498
  * Represents a ray with an origin and a direction in 3D space.
@@ -3908,12 +3856,8 @@ function _create_class(Constructor, protoProps, staticProps) {
3908
3856
  ]);
3909
3857
  return Vector2;
3910
3858
  }();
3911
- (function() {
3912
- /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3913
- })();
3914
- (function() {
3915
- /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
3916
- })();
3859
+ /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3860
+ /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
3917
3861
 
3918
3862
  /**
3919
3863
  * Describes a 4D-vector.
@@ -4346,12 +4290,8 @@ function _create_class(Constructor, protoProps, staticProps) {
4346
4290
  ]);
4347
4291
  return Vector4;
4348
4292
  }();
4349
- (function() {
4350
- /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4351
- })();
4352
- (function() {
4353
- /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
4354
- })();
4293
+ /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4294
+ /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
4355
4295
 
4356
4296
  /**
4357
4297
  * Describes a color in the from of RGBA (in order: R, G, B, A).