@galacean/engine-math 1.0.0-alpha.6 → 1.0.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/dist/main.js CHANGED
@@ -33,19 +33,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
33
33
  })(exports.FrustumFace || (exports.FrustumFace = {}));
34
34
 
35
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
- if ("value" in descriptor) descriptor.writable = true;
41
- Object.defineProperty(target, descriptor.key, descriptor);
42
- }
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
+ }
43
45
  }
46
+ function _create_class(Constructor, protoProps, staticProps) {
47
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
48
+ if (staticProps) _defineProperties(Constructor, staticProps);
44
49
 
45
- function _createClass(Constructor, protoProps, staticProps) {
46
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
47
- if (staticProps) _defineProperties(Constructor, staticProps);
48
- return Constructor;
50
+ return Constructor;
49
51
  }
50
52
 
51
53
  /**
@@ -93,9 +95,15 @@ function _createClass(Constructor, protoProps, staticProps) {
93
95
  };
94
96
  return MathUtil;
95
97
  }();
96
- /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
97
- /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
98
- /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
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
+ })();
99
107
 
100
108
  /**
101
109
  * Describes a 3D-vector.
@@ -554,7 +562,7 @@ function _createClass(Constructor, protoProps, staticProps) {
554
562
  out._z = iz * qw - iw * qz - ix * qy + iy * qx;
555
563
  out._onValueChanged && out._onValueChanged();
556
564
  };
557
- _createClass(Vector3, [
565
+ _create_class(Vector3, [
558
566
  {
559
567
  key: "x",
560
568
  get: /**
@@ -594,8 +602,12 @@ function _createClass(Constructor, protoProps, staticProps) {
594
602
  ]);
595
603
  return Vector3;
596
604
  }();
597
- /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
598
- /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
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
+ })();
599
611
 
600
612
  /**
601
613
  * A bounding sphere.
@@ -664,7 +676,9 @@ function _createClass(Constructor, protoProps, staticProps) {
664
676
  };
665
677
  return BoundingSphere;
666
678
  }();
667
- BoundingSphere._tempVec30 = new Vector3();
679
+ (function() {
680
+ BoundingSphere._tempVec30 = new Vector3();
681
+ })();
668
682
 
669
683
  /**
670
684
  * Axis Aligned Bound Box (AABB).
@@ -823,8 +837,12 @@ BoundingSphere._tempVec30 = new Vector3();
823
837
  };
824
838
  return BoundingBox;
825
839
  }();
826
- BoundingBox._tempVec30 = new Vector3();
827
- BoundingBox._tempVec31 = new Vector3();
840
+ (function() {
841
+ BoundingBox._tempVec30 = new Vector3();
842
+ })();
843
+ (function() {
844
+ BoundingBox._tempVec31 = new Vector3();
845
+ })();
828
846
 
829
847
  /**
830
848
  * Contains static methods to help in determining intersections, containment, etc.
@@ -1110,50 +1128,6 @@ BoundingBox._tempVec31 = new Vector3();
1110
1128
  return true;
1111
1129
  };
1112
1130
  /**
1113
- * Get the containment type between a frustum and a point.
1114
- * @param frustum - The frustum
1115
- * @param point - The point
1116
- * @returns The containment type
1117
- */ CollisionUtil.frustumContainsPoint = function frustumContainsPoint(frustum, point) {
1118
- var distance = CollisionUtil.distancePlaneAndPoint(frustum.near, point);
1119
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1120
- return exports.ContainmentType.Intersects;
1121
- } else if (distance < 0) {
1122
- return exports.ContainmentType.Disjoint;
1123
- }
1124
- distance = CollisionUtil.distancePlaneAndPoint(frustum.far, point);
1125
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1126
- return exports.ContainmentType.Intersects;
1127
- } else if (distance < 0) {
1128
- return exports.ContainmentType.Disjoint;
1129
- }
1130
- distance = CollisionUtil.distancePlaneAndPoint(frustum.left, point);
1131
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1132
- return exports.ContainmentType.Intersects;
1133
- } else if (distance < 0) {
1134
- return exports.ContainmentType.Disjoint;
1135
- }
1136
- distance = CollisionUtil.distancePlaneAndPoint(frustum.right, point);
1137
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1138
- return exports.ContainmentType.Intersects;
1139
- } else if (distance < 0) {
1140
- return exports.ContainmentType.Disjoint;
1141
- }
1142
- distance = CollisionUtil.distancePlaneAndPoint(frustum.top, point);
1143
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1144
- return exports.ContainmentType.Intersects;
1145
- } else if (distance < 0) {
1146
- return exports.ContainmentType.Disjoint;
1147
- }
1148
- distance = CollisionUtil.distancePlaneAndPoint(frustum.bottom, point);
1149
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1150
- return exports.ContainmentType.Intersects;
1151
- } else if (distance < 0) {
1152
- return exports.ContainmentType.Disjoint;
1153
- }
1154
- return exports.ContainmentType.Contains;
1155
- };
1156
- /**
1157
1131
  * Get the containment type between a frustum and a box (AABB).
1158
1132
  * @param frustum - The frustum
1159
1133
  * @param box - The box
@@ -1217,9 +1191,15 @@ BoundingBox._tempVec31 = new Vector3();
1217
1191
  };
1218
1192
  return CollisionUtil;
1219
1193
  }();
1220
- CollisionUtil._tempVec30 = new Vector3();
1221
- CollisionUtil._tempVec31 = new Vector3();
1222
- CollisionUtil._tempVec32 = new Vector3();
1194
+ (function() {
1195
+ CollisionUtil._tempVec30 = new Vector3();
1196
+ })();
1197
+ (function() {
1198
+ CollisionUtil._tempVec31 = new Vector3();
1199
+ })();
1200
+ (function() {
1201
+ CollisionUtil._tempVec32 = new Vector3();
1202
+ })();
1223
1203
 
1224
1204
  /**
1225
1205
  * Represents a plane in three-dimensional space.
@@ -2543,7 +2523,7 @@ CollisionUtil._tempVec32 = new Vector3();
2543
2523
  out._w = a._w * s;
2544
2524
  out._onValueChanged && out._onValueChanged();
2545
2525
  };
2546
- _createClass(Quaternion, [
2526
+ _create_class(Quaternion, [
2547
2527
  {
2548
2528
  key: "x",
2549
2529
  get: /**
@@ -2603,8 +2583,12 @@ CollisionUtil._tempVec32 = new Vector3();
2603
2583
  ]);
2604
2584
  return Quaternion;
2605
2585
  }();
2606
- /** @internal */ Quaternion._tempVector3 = new Vector3();
2607
- /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2586
+ (function() {
2587
+ /** @internal */ Quaternion._tempVector3 = new Vector3();
2588
+ })();
2589
+ (function() {
2590
+ /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2591
+ })();
2608
2592
 
2609
2593
  /**
2610
2594
  * Represents a 4x4 mathematical matrix.
@@ -3550,11 +3534,21 @@ CollisionUtil._tempVec32 = new Vector3();
3550
3534
  };
3551
3535
  return Matrix;
3552
3536
  }();
3553
- Matrix._tempVec30 = new Vector3();
3554
- Matrix._tempVec31 = new Vector3();
3555
- Matrix._tempVec32 = new Vector3();
3556
- Matrix._tempMat30 = new Matrix3x3();
3557
- /** @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);
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
+ })();
3558
3552
 
3559
3553
  /**
3560
3554
  * Represents a ray with an origin and a direction in 3D space.
@@ -3890,7 +3884,7 @@ Matrix._tempMat30 = new Matrix3x3();
3890
3884
  out._y = left._y * s;
3891
3885
  out._onValueChanged && out._onValueChanged();
3892
3886
  };
3893
- _createClass(Vector2, [
3887
+ _create_class(Vector2, [
3894
3888
  {
3895
3889
  key: "x",
3896
3890
  get: /**
@@ -3918,8 +3912,12 @@ Matrix._tempMat30 = new Matrix3x3();
3918
3912
  ]);
3919
3913
  return Vector2;
3920
3914
  }();
3921
- /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3922
- /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
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
+ })();
3923
3921
 
3924
3922
  /**
3925
3923
  * Describes a 4D-vector.
@@ -4300,7 +4298,7 @@ Matrix._tempMat30 = new Matrix3x3();
4300
4298
  out._w = w;
4301
4299
  out._onValueChanged && out._onValueChanged();
4302
4300
  };
4303
- _createClass(Vector4, [
4301
+ _create_class(Vector4, [
4304
4302
  {
4305
4303
  key: "x",
4306
4304
  get: /**
@@ -4352,8 +4350,12 @@ Matrix._tempMat30 = new Matrix3x3();
4352
4350
  ]);
4353
4351
  return Vector4;
4354
4352
  }();
4355
- /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4356
- /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
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
+ })();
4357
4359
 
4358
4360
  /**
4359
4361
  * Describes a color in the from of RGBA (in order: R, G, B, A).
@@ -4563,7 +4565,7 @@ Matrix._tempMat30 = new Matrix3x3();
4563
4565
  out._onValueChanged && out._onValueChanged();
4564
4566
  return out;
4565
4567
  };
4566
- _createClass(Color, [
4568
+ _create_class(Color, [
4567
4569
  {
4568
4570
  key: "r",
4569
4571
  get: /**