Browse Source

reset start size when particle system starts

Trevor Baron 7 năm trước cách đây
mục cha
commit
8ea48b3c8d
1 tập tin đã thay đổi với 11 bổ sung11 xóa
  1. 11 11
      src/Particles/babylon.particleSystem.ts

+ 11 - 11
src/Particles/babylon.particleSystem.ts

@@ -682,17 +682,6 @@
             }
             }
 
 
             this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
             this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
-
-            if (!this._currentStartSizeGradient) {
-                this._currentStartSizeGradient = this._startSizeGradients[0];
-                this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
-                this._currentStartSize2 = this._currentStartSize1;
-            }
-
-            if (this._startSizeGradients.length === 2) {
-                this._currentStartSize2 = this._startSizeGradients[1].getFactor();
-            }
-
             return this;
             return this;
         }
         }
 
 
@@ -1035,6 +1024,17 @@
                     this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
                     this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
                 }
                 }
             }
             }
+            // Reset start size gradient so it acts the same on every start
+            if(this._startSizeGradients){
+                if(this._startSizeGradients.length > 0){
+                    this._currentStartSizeGradient = this._startSizeGradients[0];
+                    this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
+                    this._currentStartSize2 = this._currentStartSize1;
+                }
+                if(this._startSizeGradients.length > 1){
+                    this._currentStartSize2 = this._startSizeGradients[1].getFactor();
+                }
+            }
 
 
             if (this.preWarmCycles) {
             if (this.preWarmCycles) {
                 if (this.emitter instanceof AbstractMesh) {
                 if (this.emitter instanceof AbstractMesh) {