@galacean/engine-math 1.1.0-alpha.2 → 1.1.0-alpha.4

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.
@@ -4938,6 +4938,44 @@ var Rect = /*#__PURE__*/ function() {
4938
4938
  return SphericalHarmonics3;
4939
4939
  }();
4940
4940
 
4941
+ /**
4942
+ * Random number generator based on the xorshift128+ algorithm.
4943
+ * https://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
4944
+ */ var Rand = /*#__PURE__*/ function() {
4945
+ function Rand(seed0, seed1) {
4946
+ this.reset(seed0, seed1);
4947
+ }
4948
+ var _proto = Rand.prototype;
4949
+ /**
4950
+ * Generate a integer 32bit random number.
4951
+ * @returns - A random number
4952
+ */ _proto.randomInt32 = function randomInt32() {
4953
+ var x = this._state0;
4954
+ var y = this._state1;
4955
+ this._state0 = y;
4956
+ x ^= x << 23;
4957
+ x ^= x >>> 17;
4958
+ x ^= y ^ y >>> 26;
4959
+ this._state1 = x;
4960
+ return this._state0 + this._state1 >>> 0;
4961
+ };
4962
+ /**
4963
+ * Generate a number between 0 and 1.
4964
+ * @returns - A random number
4965
+ */ _proto.random = function random() {
4966
+ return this.randomInt32() / 0xffffffff; // 2^32 - 1
4967
+ };
4968
+ /**
4969
+ * Reset the generator by new seeds.
4970
+ * @param seed0 - Random seed0
4971
+ * @param seed1 - Random seed1
4972
+ */ _proto.reset = function reset(seed0, seed1) {
4973
+ this._state0 = seed0 >>> 0;
4974
+ this._state1 = seed1 >>> 0;
4975
+ };
4976
+ return Rand;
4977
+ }();
4978
+
4941
4979
  exports.BoundingBox = BoundingBox;
4942
4980
  exports.BoundingFrustum = BoundingFrustum;
4943
4981
  exports.BoundingSphere = BoundingSphere;
@@ -4948,6 +4986,7 @@ exports.Matrix = Matrix;
4948
4986
  exports.Matrix3x3 = Matrix3x3;
4949
4987
  exports.Plane = Plane;
4950
4988
  exports.Quaternion = Quaternion;
4989
+ exports.Rand = Rand;
4951
4990
  exports.Ray = Ray;
4952
4991
  exports.Rect = Rect;
4953
4992
  exports.SphericalHarmonics3 = SphericalHarmonics3;
package/dist/module.js CHANGED
@@ -4934,5 +4934,43 @@ var Rect = /*#__PURE__*/ function() {
4934
4934
  return SphericalHarmonics3;
4935
4935
  }();
4936
4936
 
4937
- export { BoundingBox, BoundingFrustum, BoundingSphere, CollisionUtil, Color, ContainmentType, FrustumFace, MathUtil, Matrix, Matrix3x3, Plane, PlaneIntersectionType, Quaternion, Ray, Rect, SphericalHarmonics3, Vector2, Vector3, Vector4 };
4937
+ /**
4938
+ * Random number generator based on the xorshift128+ algorithm.
4939
+ * https://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
4940
+ */ var Rand = /*#__PURE__*/ function() {
4941
+ function Rand(seed0, seed1) {
4942
+ this.reset(seed0, seed1);
4943
+ }
4944
+ var _proto = Rand.prototype;
4945
+ /**
4946
+ * Generate a integer 32bit random number.
4947
+ * @returns - A random number
4948
+ */ _proto.randomInt32 = function randomInt32() {
4949
+ var x = this._state0;
4950
+ var y = this._state1;
4951
+ this._state0 = y;
4952
+ x ^= x << 23;
4953
+ x ^= x >>> 17;
4954
+ x ^= y ^ y >>> 26;
4955
+ this._state1 = x;
4956
+ return this._state0 + this._state1 >>> 0;
4957
+ };
4958
+ /**
4959
+ * Generate a number between 0 and 1.
4960
+ * @returns - A random number
4961
+ */ _proto.random = function random() {
4962
+ return this.randomInt32() / 0xffffffff; // 2^32 - 1
4963
+ };
4964
+ /**
4965
+ * Reset the generator by new seeds.
4966
+ * @param seed0 - Random seed0
4967
+ * @param seed1 - Random seed1
4968
+ */ _proto.reset = function reset(seed0, seed1) {
4969
+ this._state0 = seed0 >>> 0;
4970
+ this._state1 = seed1 >>> 0;
4971
+ };
4972
+ return Rand;
4973
+ }();
4974
+
4975
+ export { BoundingBox, BoundingFrustum, BoundingSphere, CollisionUtil, Color, ContainmentType, FrustumFace, MathUtil, Matrix, Matrix3x3, Plane, PlaneIntersectionType, Quaternion, Rand, Ray, Rect, SphericalHarmonics3, Vector2, Vector3, Vector4 };
4938
4976
  //# sourceMappingURL=module.js.map