Browse Source

Update babylon.particleSystem.ts

Added a custom update function called for each particle (cf thread http://www.html5gamedevs.com/topic/11278-controlling-particles/)
Temechon 10 years ago
parent
commit
a162684abe
1 changed files with 6 additions and 1 deletions
  1. 6 1
      Babylon/Particles/babylon.particleSystem.ts

+ 6 - 1
Babylon/Particles/babylon.particleSystem.ts

@@ -39,6 +39,7 @@
 
 
         public onDispose: () => void;
         public onDispose: () => void;
 
 
+        public customParticleUpdate: (part: Particle) => void;
         public blendMode = ParticleSystem.BLENDMODE_ONEONE;
         public blendMode = ParticleSystem.BLENDMODE_ONEONE;
 
 
         public forceDepthWrite = false;
         public forceDepthWrite = false;
@@ -173,6 +174,10 @@
                 var particle = this.particles[index];
                 var particle = this.particles[index];
                 particle.age += this._scaledUpdateSpeed;
                 particle.age += this._scaledUpdateSpeed;
 
 
+                if (this.customParticleUpdate) {
+                    this.customParticleUpdate(particle);
+                }
+                
                 if (particle.age >= particle.lifeTime) {
                 if (particle.age >= particle.lifeTime) {
                     this._stockParticles.push(this.particles.splice(index, 1)[0]);
                     this._stockParticles.push(this.particles.splice(index, 1)[0]);
                     index--;
                     index--;
@@ -429,4 +434,4 @@
             return result;
             return result;
         }
         }
     }
     }
-}  
+}