Quellcode durchsuchen

Finalize explosion for particle helper

David Catuhe vor 7 Jahren
Ursprung
Commit
8e9b66987d

Datei-Diff unterdrückt, da er zu groß ist
+ 1339 - 0
assets/particles/systems/explosion.json


+ 4 - 4
assets/particles/systems/fire.json

@@ -192,7 +192,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false
+            "preventAutoStart": true
         },
         {
             "name": "sparksEdge",
@@ -431,7 +431,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false
+            "preventAutoStart": true
         },
         {
             "name": "fireSystem2",
@@ -624,7 +624,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false
+            "preventAutoStart": true
         },
         {
             "name": "fireSystem3",
@@ -817,7 +817,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false
+            "preventAutoStart": true
         }
     ]
 }

+ 3 - 3
assets/particles/systems/rain.json

@@ -136,7 +136,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false
+            "preventAutoStart": true
         },
         {
             "name": "rainSplash",
@@ -273,7 +273,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false,
+            "preventAutoStart": true,
             "subEmitters":
             [
                 [
@@ -368,7 +368,7 @@
                                 1
                             ],
                             "customShader": null,
-                            "preventAutoStart": false
+                            "preventAutoStart": true
                         }
                     }
                 ]

+ 1 - 1
assets/particles/systems/smoke.json

@@ -154,7 +154,7 @@
                 1
             ],
             "customShader": null,
-            "preventAutoStart": false,
+            "preventAutoStart": true,
             "isAnimationSheetEnabled": true
         }
     ]

BIN
assets/particles/textures/explosion/FlameBlastSpriteSheet.png


BIN
assets/particles/textures/explosion/Flare.png


BIN
assets/particles/textures/explosion/FlashParticle.png


BIN
assets/particles/textures/explosion/Smoke_SpriteSheet_8x8.png


+ 20 - 0
src/Particles/babylon.IParticleSystem.ts

@@ -207,6 +207,26 @@ module BABYLON {
         limitVelocityDamping: number;
 
         /**
+         * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
+         */
+        beginAnimationOnStart: boolean;
+
+        /**
+         * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
+         */
+        beginAnimationFrom: number;
+
+        /**
+         * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
+         */        
+        beginAnimationTo: number;
+
+        /**
+         * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
+         */
+        beginAnimationLoop: boolean;       
+
+        /**
          * Gets the maximum number of particles active at the same time.
          * @returns The max number of active particles.
          */

+ 25 - 3
src/Particles/babylon.baseParticleSystem.ts

@@ -158,11 +158,10 @@ module BABYLON {
         public customShader: any = null;
 
         /**
-         * By default particle system starts as soon as they are created. This prevents the 
+         * By default particle system does not start as soon as they are created. This prevents the 
          * automatic start to happen and let you decide when to start emitting particles.
          */
-        public preventAutoStart: boolean = false;
-
+        public preventAutoStart: boolean = true
         /**
          * Gets or sets a texture used to add random noise to particle positions
          */
@@ -223,6 +222,26 @@ module BABYLON {
 
         /** @hidden */
         protected _isAnimationSheetEnabled: boolean;
+
+        /**
+         * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
+         */
+        public beginAnimationOnStart = false;
+
+        /**
+         * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
+         */
+        public beginAnimationFrom = 0;
+
+        /**
+         * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
+         */        
+        public beginAnimationTo = 60;
+
+        /**
+         * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
+         */
+        public beginAnimationLoop = false;
        
         /**
          * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
@@ -476,6 +495,9 @@ module BABYLON {
          */
         public particleEmitterType: IParticleEmitterType;
 
+        /** @hidden */
+        public _isSubEmitter = false;
+
         /**
          * Gets or sets the billboard mode to use when isBillboardBased = true.
          * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED

+ 5 - 0
src/Particles/babylon.gpuParticleSystem.ts

@@ -132,6 +132,11 @@
             this._started = true;
             this._stopped = false;
             this._preWarmDone = false;
+
+            // Animations
+            if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
+                this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
+            }
         }
 
         /**

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

@@ -1005,11 +1005,6 @@
                     } else if (subEmitter instanceof Array) {
                         this._subEmitters.push(subEmitter);
                     }
-                    this._subEmitters[this._subEmitters.length-1].forEach((se)=>{
-                        if (!(se.particleSystem.emitter instanceof AbstractMesh) && se.inheritDirection) {
-                            Tools.Warn("subEmitter.inheritDirection is not supported with non-mesh emitter type");
-                        }
-                    })
                 });
             }
         }
@@ -1060,6 +1055,11 @@
                     }
                 }
             }
+
+            // Animations
+            if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
+                this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
+            }
         }
 
         /**
@@ -2013,6 +2013,10 @@
 
             // Animations
             Animation.AppendSerializedAnimations(particleSystem, serializationObject);
+            serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
+            serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
+            serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
+            serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
 
             // Particle system
             serializationObject.startDelay = particleSystem.startDelay;
@@ -2289,6 +2293,10 @@
                     var parsedAnimation = parsedParticleSystem.animations[animationIndex];
                     particleSystem.animations.push(Animation.Parse(parsedAnimation));
                 }
+                particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
+                particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
+                particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
+                particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
             }
 
             if (parsedParticleSystem.autoAnimate) {
@@ -2428,6 +2436,12 @@
                     case "ConeParticleEmitter":
                         emitterType = new ConeParticleEmitter();
                         break;
+                    case "CylinderParticleEmitter":
+                        emitterType = new CylinderParticleEmitter();
+                        break;
+                    case "HemisphericParticleEmitter":
+                        emitterType = new HemisphericParticleEmitter();
+                        break;                   
                     case "BoxEmitter":
                     case "BoxParticleEmitter":
                     default:

+ 1 - 0
src/Particles/babylon.subEmitter.ts

@@ -95,6 +95,7 @@ module BABYLON {
             subEmitter.type = serializationObject.type;
             subEmitter.inheritDirection = serializationObject.inheritDirection;
             subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
+            subEmitter.particleSystem._isSubEmitter = true;
 
             return subEmitter;
         }