Browse Source

Fully Implement Particle System Auto Start

Fix particle system ‘preventAutoStart’ for all instances, including
clones.
MackeyK24 8 years ago
parent
commit
82af788841
1 changed files with 12 additions and 3 deletions
  1. 12 3
      src/Particles/babylon.particleSystem.ts

+ 12 - 3
src/Particles/babylon.particleSystem.ts

@@ -42,7 +42,8 @@
         public layerMask: number = 0x0FFFFFFF;
         public layerMask: number = 0x0FFFFFFF;
 
 
         public customShader: any = null;
         public customShader: any = null;
-
+        public preventAutoStart: boolean = false;
+        
         /**
         /**
         * An event triggered when the system is disposed.
         * An event triggered when the system is disposed.
         * @type {BABYLON.Observable}
         * @type {BABYLON.Observable}
@@ -470,7 +471,9 @@
                 result.particleTexture = new Texture(this.particleTexture.url, this._scene);
                 result.particleTexture = new Texture(this.particleTexture.url, this._scene);
             }
             }
 
 
-            result.start();
+            if (!this.preventAutoStart) {
+                result.start();
+            }
 
 
             return result;
             return result;
         }
         }
@@ -520,6 +523,7 @@
             serializationObject.textureMask = this.textureMask.asArray();
             serializationObject.textureMask = this.textureMask.asArray();
             serializationObject.blendMode = this.blendMode;
             serializationObject.blendMode = this.blendMode;
             serializationObject.customShader = this.customShader;
             serializationObject.customShader = this.customShader;
+            serializationObject.preventAutoStart = this.preventAutoStart;
 
 
             return serializationObject;
             return serializationObject;
         }
         }
@@ -540,6 +544,11 @@
                 particleSystem.id = parsedParticleSystem.id;
                 particleSystem.id = parsedParticleSystem.id;
             }
             }
 
 
+            // Auto start
+            if (parsedParticleSystem.preventAutoStart) {
+                particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
+            }
+
             // Texture
             // Texture
             if (parsedParticleSystem.textureName) {
             if (parsedParticleSystem.textureName) {
                 particleSystem.particleTexture = new Texture(rootUrl + parsedParticleSystem.textureName, scene);
                 particleSystem.particleTexture = new Texture(rootUrl + parsedParticleSystem.textureName, scene);
@@ -588,7 +597,7 @@
             particleSystem.textureMask = Color4.FromArray(parsedParticleSystem.textureMask);
             particleSystem.textureMask = Color4.FromArray(parsedParticleSystem.textureMask);
             particleSystem.blendMode = parsedParticleSystem.blendMode;
             particleSystem.blendMode = parsedParticleSystem.blendMode;
 
 
-            if (!parsedParticleSystem.preventAutoStart) {
+            if (!particleSystem.preventAutoStart) {
                 particleSystem.start();
                 particleSystem.start();
             }
             }