@galacean/engine-math 0.0.0-experimental-double11.4 → 0.0.0-experimental-double11.5

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.
@@ -4475,6 +4475,31 @@ function _create_class(Constructor, protoProps, staticProps) {
4475
4475
  return this;
4476
4476
  };
4477
4477
  /**
4478
+ * Copy from array like object.
4479
+ * @param source - Array like object
4480
+ * @param offset - The start offset
4481
+ * @returns This color
4482
+ */ _proto.copyFromArray = function copyFromArray(source, offset) {
4483
+ if (offset === void 0) offset = 0;
4484
+ this._r = source[offset];
4485
+ this._g = source[offset + 1];
4486
+ this._b = source[offset + 2];
4487
+ this._a = source[offset + 3];
4488
+ this._onValueChanged && this._onValueChanged();
4489
+ return this;
4490
+ };
4491
+ /**
4492
+ * Copy the value of this color to an array.
4493
+ * @param out - The color
4494
+ * @param outOffset - The start offset
4495
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
4496
+ if (outOffset === void 0) outOffset = 0;
4497
+ out[outOffset] = this._r;
4498
+ out[outOffset + 1] = this._g;
4499
+ out[outOffset + 2] = this._b;
4500
+ out[outOffset + 3] = this._a;
4501
+ };
4502
+ /**
4478
4503
  * Modify components (r, g, b) of this color from gamma space to linear space.
4479
4504
  * @param out - The color in linear space
4480
4505
  * @returns The color in linear space
@@ -4938,6 +4963,44 @@ var Rect = /*#__PURE__*/ function() {
4938
4963
  return SphericalHarmonics3;
4939
4964
  }();
4940
4965
 
4966
+ /**
4967
+ * Random number generator based on the xorshift128+ algorithm.
4968
+ * https://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
4969
+ */ var Rand = /*#__PURE__*/ function() {
4970
+ function Rand(seed0, seed1) {
4971
+ this.reset(seed0, seed1);
4972
+ }
4973
+ var _proto = Rand.prototype;
4974
+ /**
4975
+ * Generate a integer 32bit random number.
4976
+ * @returns - A random number
4977
+ */ _proto.randomInt32 = function randomInt32() {
4978
+ var x = this._state0;
4979
+ var y = this._state1;
4980
+ this._state0 = y;
4981
+ x ^= x << 23;
4982
+ x ^= x >>> 17;
4983
+ x ^= y ^ y >>> 26;
4984
+ this._state1 = x;
4985
+ return this._state0 + this._state1 >>> 0;
4986
+ };
4987
+ /**
4988
+ * Generate a number between 0 and 1.
4989
+ * @returns - A random number
4990
+ */ _proto.random = function random() {
4991
+ return this.randomInt32() / 0xffffffff; // 2^32 - 1
4992
+ };
4993
+ /**
4994
+ * Reset the generator by new seeds.
4995
+ * @param seed0 - Random seed0
4996
+ * @param seed1 - Random seed1
4997
+ */ _proto.reset = function reset(seed0, seed1) {
4998
+ this._state0 = seed0 >>> 0;
4999
+ this._state1 = seed1 >>> 0;
5000
+ };
5001
+ return Rand;
5002
+ }();
5003
+
4941
5004
  exports.BoundingBox = BoundingBox;
4942
5005
  exports.BoundingFrustum = BoundingFrustum;
4943
5006
  exports.BoundingSphere = BoundingSphere;
@@ -4948,6 +5011,7 @@ exports.Matrix = Matrix;
4948
5011
  exports.Matrix3x3 = Matrix3x3;
4949
5012
  exports.Plane = Plane;
4950
5013
  exports.Quaternion = Quaternion;
5014
+ exports.Rand = Rand;
4951
5015
  exports.Ray = Ray;
4952
5016
  exports.Rect = Rect;
4953
5017
  exports.SphericalHarmonics3 = SphericalHarmonics3;
package/dist/module.js CHANGED
@@ -4471,6 +4471,31 @@ function _create_class(Constructor, protoProps, staticProps) {
4471
4471
  return this;
4472
4472
  };
4473
4473
  /**
4474
+ * Copy from array like object.
4475
+ * @param source - Array like object
4476
+ * @param offset - The start offset
4477
+ * @returns This color
4478
+ */ _proto.copyFromArray = function copyFromArray(source, offset) {
4479
+ if (offset === void 0) offset = 0;
4480
+ this._r = source[offset];
4481
+ this._g = source[offset + 1];
4482
+ this._b = source[offset + 2];
4483
+ this._a = source[offset + 3];
4484
+ this._onValueChanged && this._onValueChanged();
4485
+ return this;
4486
+ };
4487
+ /**
4488
+ * Copy the value of this color to an array.
4489
+ * @param out - The color
4490
+ * @param outOffset - The start offset
4491
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
4492
+ if (outOffset === void 0) outOffset = 0;
4493
+ out[outOffset] = this._r;
4494
+ out[outOffset + 1] = this._g;
4495
+ out[outOffset + 2] = this._b;
4496
+ out[outOffset + 3] = this._a;
4497
+ };
4498
+ /**
4474
4499
  * Modify components (r, g, b) of this color from gamma space to linear space.
4475
4500
  * @param out - The color in linear space
4476
4501
  * @returns The color in linear space
@@ -4934,5 +4959,43 @@ var Rect = /*#__PURE__*/ function() {
4934
4959
  return SphericalHarmonics3;
4935
4960
  }();
4936
4961
 
4937
- export { BoundingBox, BoundingFrustum, BoundingSphere, CollisionUtil, Color, ContainmentType, FrustumFace, MathUtil, Matrix, Matrix3x3, Plane, PlaneIntersectionType, Quaternion, Ray, Rect, SphericalHarmonics3, Vector2, Vector3, Vector4 };
4962
+ /**
4963
+ * Random number generator based on the xorshift128+ algorithm.
4964
+ * https://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
4965
+ */ var Rand = /*#__PURE__*/ function() {
4966
+ function Rand(seed0, seed1) {
4967
+ this.reset(seed0, seed1);
4968
+ }
4969
+ var _proto = Rand.prototype;
4970
+ /**
4971
+ * Generate a integer 32bit random number.
4972
+ * @returns - A random number
4973
+ */ _proto.randomInt32 = function randomInt32() {
4974
+ var x = this._state0;
4975
+ var y = this._state1;
4976
+ this._state0 = y;
4977
+ x ^= x << 23;
4978
+ x ^= x >>> 17;
4979
+ x ^= y ^ y >>> 26;
4980
+ this._state1 = x;
4981
+ return this._state0 + this._state1 >>> 0;
4982
+ };
4983
+ /**
4984
+ * Generate a number between 0 and 1.
4985
+ * @returns - A random number
4986
+ */ _proto.random = function random() {
4987
+ return this.randomInt32() / 0xffffffff; // 2^32 - 1
4988
+ };
4989
+ /**
4990
+ * Reset the generator by new seeds.
4991
+ * @param seed0 - Random seed0
4992
+ * @param seed1 - Random seed1
4993
+ */ _proto.reset = function reset(seed0, seed1) {
4994
+ this._state0 = seed0 >>> 0;
4995
+ this._state1 = seed1 >>> 0;
4996
+ };
4997
+ return Rand;
4998
+ }();
4999
+
5000
+ export { BoundingBox, BoundingFrustum, BoundingSphere, CollisionUtil, Color, ContainmentType, FrustumFace, MathUtil, Matrix, Matrix3x3, Plane, PlaneIntersectionType, Quaternion, Rand, Ray, Rect, SphericalHarmonics3, Vector2, Vector3, Vector4 };
4938
5001
  //# sourceMappingURL=module.js.map