Przeglądaj źródła

Fixing recycling particle

Ibraheem Osama 7 lat temu
rodzic
commit
632cfc6b21
1 zmienionych plików z 4 dodań i 5 usunięć
  1. 4 5
      src/Particles/babylon.particleSystem.ts

+ 4 - 5
src/Particles/babylon.particleSystem.ts

@@ -576,11 +576,10 @@
          * Its lifetime will start back at 0.
          * Its lifetime will start back at 0.
          */
          */
         public recycleParticle: (particle: Particle) => void = (particle) => {
         public recycleParticle: (particle: Particle) => void = (particle) => {
-            var lastParticle = <Particle>this._particles.pop();
-
-            if (lastParticle !== particle) {
-                lastParticle.copyTo(particle);
-                this._stockParticles.push(lastParticle);
+            var index = this._particles.indexOf(particle, 0);
+            if (index > -1) {
+                this._particles.splice(index, 1);
+                this._stockParticles.push(particle);
             }
             }
         };
         };