@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.
package/dist/main.js CHANGED
@@ -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;