@galacean/engine-core 1.3.10 → 1.3.12

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
@@ -2244,7 +2244,7 @@ var ShadowLib = {
2244
2244
 
2245
2245
  var particle_common = "#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}"; // eslint-disable-line
2246
2246
 
2247
- var velocity_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge)evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}"; // eslint-disable-line
2247
+ var velocity_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}"; // eslint-disable-line
2248
2248
 
2249
2249
  var rotation_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n"; // eslint-disable-line
2250
2250
 
@@ -6611,13 +6611,17 @@ SlicedSpriteAssembler = __decorate([
6611
6611
  */ var DisorderedArray = /*#__PURE__*/ function() {
6612
6612
  function DisorderedArray(count) {
6613
6613
  if (count === void 0) count = 0;
6614
- this.length = 0;
6615
- this._isLooping = false;
6614
+ /** The length of the array. */ this.length = 0;
6615
+ this._loopCounter = 0 // Ignore nested loops, use counter to solve the problem
6616
+ ;
6616
6617
  this._blankCount = 0;
6617
6618
  this._elements = new Array(count);
6618
6619
  }
6619
6620
  var _proto = DisorderedArray.prototype;
6620
- _proto.add = function add(element) {
6621
+ /**
6622
+ * Add an element to disordered array.
6623
+ * @param element - The element to be added
6624
+ */ _proto.add = function add(element) {
6621
6625
  if (this.length === this._elements.length) {
6622
6626
  this._elements.push(element);
6623
6627
  } else {
@@ -6625,18 +6629,29 @@ SlicedSpriteAssembler = __decorate([
6625
6629
  }
6626
6630
  this.length++;
6627
6631
  };
6628
- _proto.delete = function _delete(element) {
6632
+ /**
6633
+ * Delete the specified element.
6634
+ * @param element - The element to be deleted
6635
+ */ _proto.delete = function _delete(element) {
6629
6636
  // @todo: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
6630
6637
  var index = this._elements.indexOf(element);
6631
6638
  this.deleteByIndex(index);
6632
6639
  };
6633
- _proto.set = function set(index, element) {
6640
+ /**
6641
+ * Set the element at the specified index.
6642
+ * @param index - The index of the element to be set
6643
+ * @param element - The element to be set
6644
+ */ _proto.set = function set(index, element) {
6634
6645
  if (index >= this.length) {
6635
6646
  throw "Index is out of range.";
6636
6647
  }
6637
6648
  this._elements[index] = element;
6638
6649
  };
6639
- _proto.get = function get(index) {
6650
+ /**
6651
+ * Get the element at the specified index.
6652
+ * @param index - The index of the element to be get
6653
+ * @returns The element at the specified index
6654
+ */ _proto.get = function get(index) {
6640
6655
  if (index >= this.length) {
6641
6656
  throw "Index is out of range.";
6642
6657
  }
@@ -6649,7 +6664,7 @@ SlicedSpriteAssembler = __decorate([
6649
6664
  */ _proto.deleteByIndex = function deleteByIndex(index) {
6650
6665
  var elements = this._elements;
6651
6666
  var end;
6652
- if (this._isLooping) {
6667
+ if (this._loopCounter > 0) {
6653
6668
  this._elements[index] = null;
6654
6669
  this._blankCount++;
6655
6670
  } else {
@@ -6663,41 +6678,57 @@ SlicedSpriteAssembler = __decorate([
6663
6678
  }
6664
6679
  return end;
6665
6680
  };
6666
- _proto.forEach = function forEach(callbackFn, swapFn) {
6681
+ /**
6682
+ * Loop through all elements.
6683
+ * @param callbackFn - The callback function
6684
+ * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
6685
+ */ _proto.forEach = function forEach(callbackFn, swapFn) {
6667
6686
  this._startLoop();
6668
6687
  var elements = this._elements;
6669
6688
  for(var i = 0, n = this.length; i < n; i++){
6670
6689
  var element = elements[i];
6671
- element && callbackFn(element);
6690
+ element && callbackFn(element, i);
6672
6691
  }
6673
6692
  this._endLoop(swapFn);
6674
6693
  };
6675
- _proto.forEachAndClean = function forEachAndClean(callbackFn, swapFn) {
6694
+ /**
6695
+ * Loop through all elements and clean up the blank elements.
6696
+ * @param callbackFn - The callback function
6697
+ * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
6698
+ */ _proto.forEachAndClean = function forEachAndClean(callbackFn, swapFn) {
6676
6699
  this._startLoop();
6677
6700
  var preEnd = this.length;
6678
6701
  var elements = this._elements;
6679
6702
  for(var i = 0, n = preEnd; i < n; i++){
6680
6703
  var element = elements[i];
6681
- element && callbackFn(element);
6704
+ element && callbackFn(element, i);
6682
6705
  }
6683
6706
  this._endLoopAndClean(preEnd, elements, swapFn);
6684
6707
  };
6685
- _proto.sort = function sort(compareFn) {
6708
+ /**
6709
+ * Sort the array.
6710
+ * @param compareFn - The comparison function
6711
+ */ _proto.sort = function sort(compareFn) {
6686
6712
  Utils._quickSort(this._elements, 0, this.length, compareFn);
6687
6713
  };
6688
- _proto.garbageCollection = function garbageCollection() {
6714
+ /**
6715
+ * Garbage collection, clean up all cached elements.
6716
+ */ _proto.garbageCollection = function garbageCollection() {
6689
6717
  this._elements.length = this.length;
6690
6718
  };
6691
6719
  _proto._startLoop = function _startLoop() {
6692
- this._isLooping = true;
6720
+ ++this._loopCounter;
6693
6721
  };
6694
6722
  _proto._endLoop = function _endLoop(swapFn) {
6695
- this._isLooping = false;
6723
+ if (--this._loopCounter !== 0) {
6724
+ return;
6725
+ }
6696
6726
  if (this._blankCount) {
6697
6727
  var from = 0;
6698
6728
  var to = this.length - 1;
6699
6729
  var elements = this._elements;
6700
6730
  partition: do {
6731
+ var _swapFn;
6701
6732
  while(elements[from])if (++from >= to) {
6702
6733
  break partition;
6703
6734
  }
@@ -6705,7 +6736,7 @@ SlicedSpriteAssembler = __decorate([
6705
6736
  break partition;
6706
6737
  }
6707
6738
  var swapElement = elements[to];
6708
- swapFn(swapElement, from);
6739
+ (_swapFn = swapFn) == null ? void 0 : _swapFn(swapElement, from);
6709
6740
  elements[from++] = swapElement;
6710
6741
  elements[to--] = null;
6711
6742
  }while (from < to);
@@ -6714,18 +6745,31 @@ SlicedSpriteAssembler = __decorate([
6714
6745
  }
6715
6746
  };
6716
6747
  _proto._endLoopAndClean = function _endLoopAndClean(preEnd, elements, swapFn) {
6748
+ if (--this._loopCounter !== 0) {
6749
+ return;
6750
+ }
6717
6751
  var index = 0;
6718
6752
  for(var i = preEnd, n = this.length; i < n; i++){
6753
+ var _swapFn;
6719
6754
  var element = elements[i];
6720
6755
  if (!element) continue;
6721
6756
  elements[index] = element;
6722
- swapFn(element, index);
6757
+ (_swapFn = swapFn) == null ? void 0 : _swapFn(element, index);
6723
6758
  index++;
6724
6759
  }
6725
- this._isLooping = false;
6726
6760
  this.length = index;
6727
6761
  this._blankCount = 0;
6728
6762
  };
6763
+ _create_class(DisorderedArray, [
6764
+ {
6765
+ key: "isLopping",
6766
+ get: /**
6767
+ * Get whether the array is in the loop.
6768
+ */ function get() {
6769
+ return this._loopCounter > 0;
6770
+ }
6771
+ }
6772
+ ]);
6729
6773
  return DisorderedArray;
6730
6774
  }();
6731
6775
 
@@ -34464,6 +34508,7 @@ exports.CubeProbe = CubeProbe;
34464
34508
  exports.CurveKey = CurveKey;
34465
34509
  exports.DepthState = DepthState;
34466
34510
  exports.DirectLight = DirectLight;
34511
+ exports.DisorderedArray = DisorderedArray;
34467
34512
  exports.DynamicCollider = DynamicCollider;
34468
34513
  exports.EmissionModule = EmissionModule;
34469
34514
  exports.Engine = Engine;