David Catuhe %!s(int64=7) %!d(string=hai) anos
pai
achega
da057772d6

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 6562 - 6487
dist/preview release/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/babylon.js


+ 146 - 7
dist/preview release/babylon.max.js

@@ -28617,6 +28617,26 @@ var BABYLON;
             this.createPickingRayInCameraSpaceToRef(x, y, this._tempPickingRay, camera);
             return this._internalPickSprites(this._tempPickingRay, predicate, fastCheck, camera);
         };
+        /** Use the given ray to pick a sprite in the scene
+         * @param ray The ray (in world space) to use to pick meshes
+         * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
+         * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
+         * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
+         * @returns a PickingInfo
+         */
+        Scene.prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
+            if (!this._cachedRayForTransform) {
+                this._cachedRayForTransform = BABYLON.Ray.Zero();
+            }
+            if (!camera) {
+                if (!this.activeCamera) {
+                    return null;
+                }
+                camera = this.activeCamera;
+            }
+            BABYLON.Ray.TransformToRef(ray, camera.getViewMatrix(), this._cachedRayForTransform);
+            return this._internalPickSprites(this._cachedRayForTransform, predicate, fastCheck, camera);
+        };
         /** Use the given ray to pick a mesh in the scene
          * @param ray The ray to use to pick meshes
          * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
@@ -56080,6 +56100,7 @@ var BABYLON;
             this._velocityGradients = null;
             this._limitVelocityGradients = null;
             this._dragGradients = null;
+            this._emitRateGradients = null;
             /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
             this.limitVelocityDamping = 0.4;
             /**
@@ -56184,6 +56205,14 @@ var BABYLON;
         BaseParticleSystem.prototype.getVelocityGradients = function () {
             return this._velocityGradients;
         };
+        /**
+         * Gets the current list of emit rate gradients.
+         * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
+         * @returns the list of emit rate gradients
+         */
+        BaseParticleSystem.prototype.getEmitRateGradients = function () {
+            return this._emitRateGradients;
+        };
         Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
@@ -56481,6 +56510,10 @@ var BABYLON;
             _this._started = false;
             _this._stopped = false;
             _this._actualFrame = 0;
+            /** @hidden */
+            _this._currentEmitRate1 = 0;
+            /** @hidden */
+            _this._currentEmitRate2 = 0;
             // start of sub system methods
             /**
              * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
@@ -56867,6 +56900,37 @@ var BABYLON;
             return this;
         };
         /**
+         * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
+            if (!this._emitRateGradients) {
+                this._emitRateGradients = [];
+            }
+            this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
+            if (!this._currentEmitRateGradient) {
+                this._currentEmitRateGradient = this._emitRateGradients[0];
+                this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
+                this._currentEmitRate2 = this._currentEmitRate1;
+            }
+            if (this._emitRateGradients.length === 2) {
+                this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
+            }
+            return this;
+        };
+        /**
+         * Remove a specific emit rate gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
+            this._removeFactorGradient(this._emitRateGradients, gradient);
+            return this;
+        };
+        /**
          * Adds a new color gradient
          * @param gradient defines the gradient to use (between 0 and 1)
          * @param color defines the color to affect to the specified gradient
@@ -57360,6 +57424,7 @@ var BABYLON;
          * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
          */
         ParticleSystem.prototype.animate = function (preWarmOnly) {
+            var _this = this;
             if (preWarmOnly === void 0) { preWarmOnly = false; }
             if (!this._started)
                 return;
@@ -57374,7 +57439,7 @@ var BABYLON;
                 this._currentRenderId = this._scene.getRenderId();
             }
             this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
-            // determine the number of particles we need to create
+            // Determine the number of particles we need to create
             var newParticles;
             if (this.manualEmitCount > -1) {
                 newParticles = this.manualEmitCount;
@@ -57382,8 +57447,20 @@ var BABYLON;
                 this.manualEmitCount = 0;
             }
             else {
-                newParticles = ((this.emitRate * this._scaledUpdateSpeed) >> 0);
-                this._newPartsExcess += this.emitRate * this._scaledUpdateSpeed - newParticles;
+                var rate_1 = this.emitRate;
+                if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
+                    var ratio = this._actualFrame / this.targetStopDuration;
+                    BABYLON.Tools.GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
+                        if (currentGradient !== _this._currentEmitRateGradient) {
+                            _this._currentEmitRate1 = _this._currentEmitRate2;
+                            _this._currentEmitRate2 = nextGradient.getFactor();
+                            _this._currentEmitRateGradient = currentGradient;
+                        }
+                        rate_1 = BABYLON.Scalar.Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
+                    });
+                }
+                newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
+                this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
             }
             if (this._newPartsExcess > 1.0) {
                 newParticles += this._newPartsExcess >> 0;
@@ -57720,11 +57797,41 @@ var BABYLON;
                     serializationObject.velocityGradients.push(serializedGradient);
                 }
             }
+            var dragGradients = particleSystem.getDragGradients();
+            if (dragGradients) {
+                serializationObject.dragyGradients = [];
+                for (var _d = 0, dragGradients_1 = dragGradients; _d < dragGradients_1.length; _d++) {
+                    var dragGradient = dragGradients_1[_d];
+                    var serializedGradient = {
+                        gradient: dragGradient.gradient,
+                        factor1: dragGradient.factor1
+                    };
+                    if (dragGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = dragGradient.factor2;
+                    }
+                    serializationObject.dragGradients.push(serializedGradient);
+                }
+            }
+            var emitRateGradients = particleSystem.getEmitRateGradients();
+            if (emitRateGradients) {
+                serializationObject.emitRateGradients = [];
+                for (var _e = 0, emitRateGradients_1 = emitRateGradients; _e < emitRateGradients_1.length; _e++) {
+                    var emitRateGradient = emitRateGradients_1[_e];
+                    var serializedGradient = {
+                        gradient: emitRateGradient.gradient,
+                        factor1: emitRateGradient.factor1
+                    };
+                    if (emitRateGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = emitRateGradient.factor2;
+                    }
+                    serializationObject.emitRateGradients.push(serializedGradient);
+                }
+            }
             var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
             if (limitVelocityGradients) {
                 serializationObject.limitVelocityGradients = [];
-                for (var _d = 0, limitVelocityGradients_1 = limitVelocityGradients; _d < limitVelocityGradients_1.length; _d++) {
-                    var limitVelocityGradient = limitVelocityGradients_1[_d];
+                for (var _f = 0, limitVelocityGradients_1 = limitVelocityGradients; _f < limitVelocityGradients_1.length; _f++) {
+                    var limitVelocityGradient = limitVelocityGradients_1[_f];
                     var serializedGradient = {
                         gradient: limitVelocityGradient.gradient,
                         factor1: limitVelocityGradient.factor1
@@ -57833,9 +57940,21 @@ var BABYLON;
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }
+            if (parsedParticleSystem.dragGradients) {
+                for (var _h = 0, _j = parsedParticleSystem.dragGradients; _h < _j.length; _h++) {
+                    var dragGradient = _j[_h];
+                    particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
+                }
+            }
+            if (parsedParticleSystem.emitRateGradients) {
+                for (var _k = 0, _l = parsedParticleSystem.emitRateGradients; _k < _l.length; _k++) {
+                    var emitRateGradient = _l[_k];
+                    particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
+                }
+            }
             if (parsedParticleSystem.limitVelocityGradients) {
-                for (var _h = 0, _j = parsedParticleSystem.limitVelocityGradients; _h < _j.length; _h++) {
-                    var limitVelocityGradient = _j[_h];
+                for (var _m = 0, _o = parsedParticleSystem.limitVelocityGradients; _m < _o.length; _m++) {
+                    var limitVelocityGradient = _o[_m];
                     particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
                 }
                 particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
@@ -61595,6 +61714,26 @@ var BABYLON;
             this._dragGradientsTexture = null;
             return this;
         };
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        };
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        };
         GPUParticleSystem.prototype._reset = function () {
             this._releaseBuffers();
         };

+ 146 - 7
dist/preview release/babylon.no-module.max.js

@@ -28584,6 +28584,26 @@ var BABYLON;
             this.createPickingRayInCameraSpaceToRef(x, y, this._tempPickingRay, camera);
             return this._internalPickSprites(this._tempPickingRay, predicate, fastCheck, camera);
         };
+        /** Use the given ray to pick a sprite in the scene
+         * @param ray The ray (in world space) to use to pick meshes
+         * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
+         * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
+         * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
+         * @returns a PickingInfo
+         */
+        Scene.prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
+            if (!this._cachedRayForTransform) {
+                this._cachedRayForTransform = BABYLON.Ray.Zero();
+            }
+            if (!camera) {
+                if (!this.activeCamera) {
+                    return null;
+                }
+                camera = this.activeCamera;
+            }
+            BABYLON.Ray.TransformToRef(ray, camera.getViewMatrix(), this._cachedRayForTransform);
+            return this._internalPickSprites(this._cachedRayForTransform, predicate, fastCheck, camera);
+        };
         /** Use the given ray to pick a mesh in the scene
          * @param ray The ray to use to pick meshes
          * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
@@ -56047,6 +56067,7 @@ var BABYLON;
             this._velocityGradients = null;
             this._limitVelocityGradients = null;
             this._dragGradients = null;
+            this._emitRateGradients = null;
             /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
             this.limitVelocityDamping = 0.4;
             /**
@@ -56151,6 +56172,14 @@ var BABYLON;
         BaseParticleSystem.prototype.getVelocityGradients = function () {
             return this._velocityGradients;
         };
+        /**
+         * Gets the current list of emit rate gradients.
+         * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
+         * @returns the list of emit rate gradients
+         */
+        BaseParticleSystem.prototype.getEmitRateGradients = function () {
+            return this._emitRateGradients;
+        };
         Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
@@ -56448,6 +56477,10 @@ var BABYLON;
             _this._started = false;
             _this._stopped = false;
             _this._actualFrame = 0;
+            /** @hidden */
+            _this._currentEmitRate1 = 0;
+            /** @hidden */
+            _this._currentEmitRate2 = 0;
             // start of sub system methods
             /**
              * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
@@ -56834,6 +56867,37 @@ var BABYLON;
             return this;
         };
         /**
+         * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
+            if (!this._emitRateGradients) {
+                this._emitRateGradients = [];
+            }
+            this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
+            if (!this._currentEmitRateGradient) {
+                this._currentEmitRateGradient = this._emitRateGradients[0];
+                this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
+                this._currentEmitRate2 = this._currentEmitRate1;
+            }
+            if (this._emitRateGradients.length === 2) {
+                this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
+            }
+            return this;
+        };
+        /**
+         * Remove a specific emit rate gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
+            this._removeFactorGradient(this._emitRateGradients, gradient);
+            return this;
+        };
+        /**
          * Adds a new color gradient
          * @param gradient defines the gradient to use (between 0 and 1)
          * @param color defines the color to affect to the specified gradient
@@ -57327,6 +57391,7 @@ var BABYLON;
          * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
          */
         ParticleSystem.prototype.animate = function (preWarmOnly) {
+            var _this = this;
             if (preWarmOnly === void 0) { preWarmOnly = false; }
             if (!this._started)
                 return;
@@ -57341,7 +57406,7 @@ var BABYLON;
                 this._currentRenderId = this._scene.getRenderId();
             }
             this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
-            // determine the number of particles we need to create
+            // Determine the number of particles we need to create
             var newParticles;
             if (this.manualEmitCount > -1) {
                 newParticles = this.manualEmitCount;
@@ -57349,8 +57414,20 @@ var BABYLON;
                 this.manualEmitCount = 0;
             }
             else {
-                newParticles = ((this.emitRate * this._scaledUpdateSpeed) >> 0);
-                this._newPartsExcess += this.emitRate * this._scaledUpdateSpeed - newParticles;
+                var rate_1 = this.emitRate;
+                if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
+                    var ratio = this._actualFrame / this.targetStopDuration;
+                    BABYLON.Tools.GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
+                        if (currentGradient !== _this._currentEmitRateGradient) {
+                            _this._currentEmitRate1 = _this._currentEmitRate2;
+                            _this._currentEmitRate2 = nextGradient.getFactor();
+                            _this._currentEmitRateGradient = currentGradient;
+                        }
+                        rate_1 = BABYLON.Scalar.Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
+                    });
+                }
+                newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
+                this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
             }
             if (this._newPartsExcess > 1.0) {
                 newParticles += this._newPartsExcess >> 0;
@@ -57687,11 +57764,41 @@ var BABYLON;
                     serializationObject.velocityGradients.push(serializedGradient);
                 }
             }
+            var dragGradients = particleSystem.getDragGradients();
+            if (dragGradients) {
+                serializationObject.dragyGradients = [];
+                for (var _d = 0, dragGradients_1 = dragGradients; _d < dragGradients_1.length; _d++) {
+                    var dragGradient = dragGradients_1[_d];
+                    var serializedGradient = {
+                        gradient: dragGradient.gradient,
+                        factor1: dragGradient.factor1
+                    };
+                    if (dragGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = dragGradient.factor2;
+                    }
+                    serializationObject.dragGradients.push(serializedGradient);
+                }
+            }
+            var emitRateGradients = particleSystem.getEmitRateGradients();
+            if (emitRateGradients) {
+                serializationObject.emitRateGradients = [];
+                for (var _e = 0, emitRateGradients_1 = emitRateGradients; _e < emitRateGradients_1.length; _e++) {
+                    var emitRateGradient = emitRateGradients_1[_e];
+                    var serializedGradient = {
+                        gradient: emitRateGradient.gradient,
+                        factor1: emitRateGradient.factor1
+                    };
+                    if (emitRateGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = emitRateGradient.factor2;
+                    }
+                    serializationObject.emitRateGradients.push(serializedGradient);
+                }
+            }
             var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
             if (limitVelocityGradients) {
                 serializationObject.limitVelocityGradients = [];
-                for (var _d = 0, limitVelocityGradients_1 = limitVelocityGradients; _d < limitVelocityGradients_1.length; _d++) {
-                    var limitVelocityGradient = limitVelocityGradients_1[_d];
+                for (var _f = 0, limitVelocityGradients_1 = limitVelocityGradients; _f < limitVelocityGradients_1.length; _f++) {
+                    var limitVelocityGradient = limitVelocityGradients_1[_f];
                     var serializedGradient = {
                         gradient: limitVelocityGradient.gradient,
                         factor1: limitVelocityGradient.factor1
@@ -57800,9 +57907,21 @@ var BABYLON;
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }
+            if (parsedParticleSystem.dragGradients) {
+                for (var _h = 0, _j = parsedParticleSystem.dragGradients; _h < _j.length; _h++) {
+                    var dragGradient = _j[_h];
+                    particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
+                }
+            }
+            if (parsedParticleSystem.emitRateGradients) {
+                for (var _k = 0, _l = parsedParticleSystem.emitRateGradients; _k < _l.length; _k++) {
+                    var emitRateGradient = _l[_k];
+                    particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
+                }
+            }
             if (parsedParticleSystem.limitVelocityGradients) {
-                for (var _h = 0, _j = parsedParticleSystem.limitVelocityGradients; _h < _j.length; _h++) {
-                    var limitVelocityGradient = _j[_h];
+                for (var _m = 0, _o = parsedParticleSystem.limitVelocityGradients; _m < _o.length; _m++) {
+                    var limitVelocityGradient = _o[_m];
                     particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
                 }
                 particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
@@ -61562,6 +61681,26 @@ var BABYLON;
             this._dragGradientsTexture = null;
             return this;
         };
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        };
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        };
         GPUParticleSystem.prototype._reset = function () {
             this._releaseBuffers();
         };

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/babylon.worker.js


+ 146 - 7
dist/preview release/es6.js

@@ -28584,6 +28584,26 @@ var BABYLON;
             this.createPickingRayInCameraSpaceToRef(x, y, this._tempPickingRay, camera);
             return this._internalPickSprites(this._tempPickingRay, predicate, fastCheck, camera);
         };
+        /** Use the given ray to pick a sprite in the scene
+         * @param ray The ray (in world space) to use to pick meshes
+         * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
+         * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
+         * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
+         * @returns a PickingInfo
+         */
+        Scene.prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
+            if (!this._cachedRayForTransform) {
+                this._cachedRayForTransform = BABYLON.Ray.Zero();
+            }
+            if (!camera) {
+                if (!this.activeCamera) {
+                    return null;
+                }
+                camera = this.activeCamera;
+            }
+            BABYLON.Ray.TransformToRef(ray, camera.getViewMatrix(), this._cachedRayForTransform);
+            return this._internalPickSprites(this._cachedRayForTransform, predicate, fastCheck, camera);
+        };
         /** Use the given ray to pick a mesh in the scene
          * @param ray The ray to use to pick meshes
          * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
@@ -56047,6 +56067,7 @@ var BABYLON;
             this._velocityGradients = null;
             this._limitVelocityGradients = null;
             this._dragGradients = null;
+            this._emitRateGradients = null;
             /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
             this.limitVelocityDamping = 0.4;
             /**
@@ -56151,6 +56172,14 @@ var BABYLON;
         BaseParticleSystem.prototype.getVelocityGradients = function () {
             return this._velocityGradients;
         };
+        /**
+         * Gets the current list of emit rate gradients.
+         * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
+         * @returns the list of emit rate gradients
+         */
+        BaseParticleSystem.prototype.getEmitRateGradients = function () {
+            return this._emitRateGradients;
+        };
         Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
@@ -56448,6 +56477,10 @@ var BABYLON;
             _this._started = false;
             _this._stopped = false;
             _this._actualFrame = 0;
+            /** @hidden */
+            _this._currentEmitRate1 = 0;
+            /** @hidden */
+            _this._currentEmitRate2 = 0;
             // start of sub system methods
             /**
              * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
@@ -56834,6 +56867,37 @@ var BABYLON;
             return this;
         };
         /**
+         * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
+            if (!this._emitRateGradients) {
+                this._emitRateGradients = [];
+            }
+            this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
+            if (!this._currentEmitRateGradient) {
+                this._currentEmitRateGradient = this._emitRateGradients[0];
+                this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
+                this._currentEmitRate2 = this._currentEmitRate1;
+            }
+            if (this._emitRateGradients.length === 2) {
+                this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
+            }
+            return this;
+        };
+        /**
+         * Remove a specific emit rate gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
+            this._removeFactorGradient(this._emitRateGradients, gradient);
+            return this;
+        };
+        /**
          * Adds a new color gradient
          * @param gradient defines the gradient to use (between 0 and 1)
          * @param color defines the color to affect to the specified gradient
@@ -57327,6 +57391,7 @@ var BABYLON;
          * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
          */
         ParticleSystem.prototype.animate = function (preWarmOnly) {
+            var _this = this;
             if (preWarmOnly === void 0) { preWarmOnly = false; }
             if (!this._started)
                 return;
@@ -57341,7 +57406,7 @@ var BABYLON;
                 this._currentRenderId = this._scene.getRenderId();
             }
             this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
-            // determine the number of particles we need to create
+            // Determine the number of particles we need to create
             var newParticles;
             if (this.manualEmitCount > -1) {
                 newParticles = this.manualEmitCount;
@@ -57349,8 +57414,20 @@ var BABYLON;
                 this.manualEmitCount = 0;
             }
             else {
-                newParticles = ((this.emitRate * this._scaledUpdateSpeed) >> 0);
-                this._newPartsExcess += this.emitRate * this._scaledUpdateSpeed - newParticles;
+                var rate_1 = this.emitRate;
+                if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
+                    var ratio = this._actualFrame / this.targetStopDuration;
+                    BABYLON.Tools.GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
+                        if (currentGradient !== _this._currentEmitRateGradient) {
+                            _this._currentEmitRate1 = _this._currentEmitRate2;
+                            _this._currentEmitRate2 = nextGradient.getFactor();
+                            _this._currentEmitRateGradient = currentGradient;
+                        }
+                        rate_1 = BABYLON.Scalar.Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
+                    });
+                }
+                newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
+                this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
             }
             if (this._newPartsExcess > 1.0) {
                 newParticles += this._newPartsExcess >> 0;
@@ -57687,11 +57764,41 @@ var BABYLON;
                     serializationObject.velocityGradients.push(serializedGradient);
                 }
             }
+            var dragGradients = particleSystem.getDragGradients();
+            if (dragGradients) {
+                serializationObject.dragyGradients = [];
+                for (var _d = 0, dragGradients_1 = dragGradients; _d < dragGradients_1.length; _d++) {
+                    var dragGradient = dragGradients_1[_d];
+                    var serializedGradient = {
+                        gradient: dragGradient.gradient,
+                        factor1: dragGradient.factor1
+                    };
+                    if (dragGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = dragGradient.factor2;
+                    }
+                    serializationObject.dragGradients.push(serializedGradient);
+                }
+            }
+            var emitRateGradients = particleSystem.getEmitRateGradients();
+            if (emitRateGradients) {
+                serializationObject.emitRateGradients = [];
+                for (var _e = 0, emitRateGradients_1 = emitRateGradients; _e < emitRateGradients_1.length; _e++) {
+                    var emitRateGradient = emitRateGradients_1[_e];
+                    var serializedGradient = {
+                        gradient: emitRateGradient.gradient,
+                        factor1: emitRateGradient.factor1
+                    };
+                    if (emitRateGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = emitRateGradient.factor2;
+                    }
+                    serializationObject.emitRateGradients.push(serializedGradient);
+                }
+            }
             var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
             if (limitVelocityGradients) {
                 serializationObject.limitVelocityGradients = [];
-                for (var _d = 0, limitVelocityGradients_1 = limitVelocityGradients; _d < limitVelocityGradients_1.length; _d++) {
-                    var limitVelocityGradient = limitVelocityGradients_1[_d];
+                for (var _f = 0, limitVelocityGradients_1 = limitVelocityGradients; _f < limitVelocityGradients_1.length; _f++) {
+                    var limitVelocityGradient = limitVelocityGradients_1[_f];
                     var serializedGradient = {
                         gradient: limitVelocityGradient.gradient,
                         factor1: limitVelocityGradient.factor1
@@ -57800,9 +57907,21 @@ var BABYLON;
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }
+            if (parsedParticleSystem.dragGradients) {
+                for (var _h = 0, _j = parsedParticleSystem.dragGradients; _h < _j.length; _h++) {
+                    var dragGradient = _j[_h];
+                    particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
+                }
+            }
+            if (parsedParticleSystem.emitRateGradients) {
+                for (var _k = 0, _l = parsedParticleSystem.emitRateGradients; _k < _l.length; _k++) {
+                    var emitRateGradient = _l[_k];
+                    particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
+                }
+            }
             if (parsedParticleSystem.limitVelocityGradients) {
-                for (var _h = 0, _j = parsedParticleSystem.limitVelocityGradients; _h < _j.length; _h++) {
-                    var limitVelocityGradient = _j[_h];
+                for (var _m = 0, _o = parsedParticleSystem.limitVelocityGradients; _m < _o.length; _m++) {
+                    var limitVelocityGradient = _o[_m];
                     particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
                 }
                 particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
@@ -61562,6 +61681,26 @@ var BABYLON;
             this._dragGradientsTexture = null;
             return this;
         };
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        };
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        };
         GPUParticleSystem.prototype._reset = function () {
             this._releaseBuffers();
         };

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2 - 2
dist/preview release/viewer/babylon.viewer.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 27 - 1
src/Particles/babylon.IParticleSystem.ts

@@ -370,6 +370,32 @@ module BABYLON {
          * @param gradient defines the gradient to remove
          * @returns the current particle system
          */
-        removeDragGradient(gradient: number): IParticleSystem;               
+        removeDragGradient(gradient: number): IParticleSystem;   
+        /**
+         * Gets the current list of drag gradients.
+         * You must use addDragGradient and removeDragGradient to udpate this list
+         * @returns the list of drag gradients
+         */
+        getDragGradients(): Nullable<Array<FactorGradient>>;                    
+        /**
+         * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate to affect to the specified gradient         
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
+        /**
+         * Remove a specific emit rate gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        removeEmitRateGradient(gradient: number): IParticleSystem;    
+        /**
+         * Gets the current list of emit rate gradients.
+         * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
+         * @returns the list of emit rate gradients
+         */
+        getEmitRateGradients(): Nullable<Array<FactorGradient>>;                        
     }  
 }

+ 10 - 0
src/Particles/babylon.baseParticleSystem.ts

@@ -244,6 +244,7 @@ module BABYLON {
         protected _velocityGradients: Nullable<Array<FactorGradient>> = null;
         protected _limitVelocityGradients: Nullable<Array<FactorGradient>> = null;
         protected _dragGradients: Nullable<Array<FactorGradient>> = null;
+        protected _emitRateGradients: Nullable<Array<FactorGradient>> = null;
 
         /**
          * Gets the current list of drag gradients.
@@ -312,6 +313,15 @@ module BABYLON {
         }         
 
         /**
+         * Gets the current list of emit rate gradients.
+         * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
+         * @returns the list of emit rate gradients
+         */
+        public getEmitRateGradients(): Nullable<Array<FactorGradient>> {
+            return this._emitRateGradients;
+        }             
+
+        /**
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          * This only works when particleEmitterTyps is a BoxParticleEmitter
          */

+ 23 - 1
src/Particles/babylon.gpuParticleSystem.ts

@@ -428,7 +428,29 @@
             (<any>this._dragGradientsTexture) = null;
 
             return this;
-        }        
+        }   
+        
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient         
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        public addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        }
+
+        /**
+         * Not supported by GPUParticleSystem
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        public removeEmitRateGradient(gradient: number): IParticleSystem {
+            // Do nothing as emit rate is not supported by GPUParticleSystem
+            return this;
+        } 
 
         /**
          * Instantiates a GPU particle system.

+ 114 - 6
src/Particles/babylon.particleSystem.ts

@@ -80,6 +80,13 @@
         private _scaledUpdateSpeed: number;
         private _vertexBufferSize: number;
 
+        /** @hidden */
+        public _currentEmitRateGradient: Nullable<FactorGradient>;
+        /** @hidden */
+        public _currentEmitRate1 = 0;
+        /** @hidden */
+        public _currentEmitRate2 = 0;              
+
         // end of sheet animation
 
         // Sub-emitters
@@ -413,8 +420,8 @@
             this._removeFactorGradient(this._angularSpeedGradients, gradient);
 
             return this;
-        }          
-        
+        }     
+                   
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
@@ -497,6 +504,44 @@
             this._removeFactorGradient(this._dragGradients, gradient);
 
             return this;
+        }         
+        
+        /**
+         * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the emit rate value to affect to the specified gradient         
+         * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
+         * @returns the current particle system
+         */
+        public addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem {
+            if (!this._emitRateGradients) {
+                this._emitRateGradients = [];
+            }
+
+            this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
+
+            if (!this._currentEmitRateGradient) {
+                this._currentEmitRateGradient = this._emitRateGradients[0];
+                this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
+                this._currentEmitRate2 = this._currentEmitRate1;
+            }
+
+            if (this._emitRateGradients.length === 2) {
+                this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
+            }
+
+            return this;
+        }
+
+        /**
+         * Remove a specific emit rate gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        public removeEmitRateGradient(gradient: number): IParticleSystem {
+            this._removeFactorGradient(this._emitRateGradients, gradient);
+
+            return this;
         }           
 
         /**
@@ -977,7 +1022,7 @@
                     } else {
                         particle._currentDrag2 = particle._currentDrag1;
                     }
-                }          
+                }            
 
                 // Color
                 if (!this._colorGradients || this._colorGradients.length === 0) {
@@ -1125,7 +1170,7 @@
 
             this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
 
-            // determine the number of particles we need to create
+            // Determine the number of particles we need to create
             var newParticles;
 
             if (this.manualEmitCount > -1) {
@@ -1133,8 +1178,23 @@
                 this._newPartsExcess = 0;
                 this.manualEmitCount = 0;
             } else {
-                newParticles = ((this.emitRate * this._scaledUpdateSpeed) >> 0);
-                this._newPartsExcess += this.emitRate * this._scaledUpdateSpeed - newParticles;
+                let rate = this.emitRate;
+
+                if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {   
+                    const ratio = this._actualFrame / this.targetStopDuration;               
+                    Tools.GetCurrentGradient(ratio, this._emitRateGradients, (currentGradient, nextGradient, scale) => {
+                        if (currentGradient !== this._currentEmitRateGradient) {
+                            this._currentEmitRate1 = this._currentEmitRate2;
+                            this._currentEmitRate2 = (<FactorGradient>nextGradient).getFactor();    
+                            this._currentEmitRateGradient = (<FactorGradient>currentGradient);
+                        }                                
+                        
+                        rate = Scalar.Lerp(this._currentEmitRate1, this._currentEmitRate2, scale);
+                    });
+                }                   
+
+                newParticles = ((rate * this._scaledUpdateSpeed) >> 0);
+                this._newPartsExcess += rate * this._scaledUpdateSpeed - newParticles;
             }
 
             if (this._newPartsExcess > 1.0) {
@@ -1533,6 +1593,42 @@
                 }
             }    
 
+            let dragGradients = particleSystem.getDragGradients();
+            if (dragGradients) {
+                serializationObject.dragyGradients = [];
+                for (var dragGradient of dragGradients) {
+
+                    var serializedGradient: any = {
+                        gradient: dragGradient.gradient,
+                        factor1: dragGradient.factor1
+                    };
+
+                    if (dragGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = dragGradient.factor2;
+                    }
+
+                    serializationObject.dragGradients.push(serializedGradient);
+                }
+            }    
+            
+            let emitRateGradients = particleSystem.getEmitRateGradients();
+            if (emitRateGradients) {
+                serializationObject.emitRateGradients = [];
+                for (var emitRateGradient of emitRateGradients) {
+
+                    var serializedGradient: any = {
+                        gradient: emitRateGradient.gradient,
+                        factor1: emitRateGradient.factor1
+                    };
+
+                    if (emitRateGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = emitRateGradient.factor2;
+                    }
+
+                    serializationObject.emitRateGradients.push(serializedGradient);
+                }
+            }                
+
             let limitVelocityGradients = particleSystem.getLimitVelocityGradients();
             if (limitVelocityGradients) {
                 serializationObject.limitVelocityGradients = [];
@@ -1662,6 +1758,18 @@
                 }
             }     
 
+            if (parsedParticleSystem.dragGradients) {
+                for (var dragGradient of parsedParticleSystem.dragGradients) {
+                    particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ?  dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
+                }
+            }        
+            
+            if (parsedParticleSystem.emitRateGradients) {
+                for (var emitRateGradient of parsedParticleSystem.emitRateGradients) {
+                    particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ?  emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
+                }
+            }               
+
             if (parsedParticleSystem.limitVelocityGradients) {
                 for (var limitVelocityGradient of parsedParticleSystem.limitVelocityGradients) {
                     particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ?  limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);