浏览代码

Added limit velocity gradient for particles

David Catuhe 7 年之前
父节点
当前提交
384af36dd4

文件差异内容过多而无法显示
+ 11197 - 11132
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 28 - 28
dist/preview release/babylon.js


+ 130 - 4
dist/preview release/babylon.max.js

@@ -55390,6 +55390,10 @@ var BABYLON;
             this._currentVelocity1 = 0;
             /** @hidden */
             this._currentVelocity2 = 0;
+            /** @hidden */
+            this._currentLimitVelocity1 = 0;
+            /** @hidden */
+            this._currentLimitVelocity2 = 0;
             if (!this.particleSystem.isAnimationSheetEnabled) {
                 return;
             }
@@ -55454,6 +55458,11 @@ var BABYLON;
                 other._currentVelocity1 = this._currentVelocity1;
                 other._currentVelocity2 = this._currentVelocity2;
             }
+            if (this._currentLimitVelocityGradient) {
+                other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
+                other._currentLimitVelocity1 = this._currentLimitVelocity1;
+                other._currentLimitVelocity2 = this._currentLimitVelocity2;
+            }
             if (this.particleSystem.isAnimationSheetEnabled) {
                 other._initialStartSpriteCellID = this._initialStartSpriteCellID;
                 other._initialEndSpriteCellID = this._initialEndSpriteCellID;
@@ -55633,6 +55642,9 @@ var BABYLON;
             this._lifeTimeGradients = null;
             this._angularSpeedGradients = null;
             this._velocityGradients = null;
+            this._limitVelocityGradients = null;
+            /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
+            this.limitVelocityDamping = 0.4;
             /**
              * Random color of each particle after it has been emitted, between color1 and color2 vectors
              */
@@ -55676,6 +55688,14 @@ var BABYLON;
             configurable: true
         });
         /**
+         * Gets the current list of limit velocity gradients.
+         * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
+         * @returns the list of limit velocity gradients
+         */
+        BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
+            return this._limitVelocityGradients;
+        };
+        /**
          * Gets the current list of color gradients.
          * You must use addColorGradient and removeColorGradient to udpate this list
          * @returns the list of color gradients
@@ -56053,6 +56073,7 @@ var BABYLON;
                         particle.angle += particle.angularSpeed * _this._scaledUpdateSpeed;
                         // Direction
                         var directionScale_1 = _this._scaledUpdateSpeed;
+                        /// Velocity
                         if (_this._velocityGradients && _this._velocityGradients.length > 0) {
                             BABYLON.Tools.GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
                                 if (currentGradient !== particle._currentVelocityGradient) {
@@ -56063,6 +56084,20 @@ var BABYLON;
                                 directionScale_1 *= BABYLON.Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
                         }
+                        /// Limit velocity
+                        if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
+                            BABYLON.Tools.GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
+                                if (currentGradient !== particle._currentLimitVelocityGradient) {
+                                    particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
+                                    particle._currentLimitVelocity2 = nextGradient.getFactor();
+                                    particle._currentLimitVelocityGradient = currentGradient;
+                                }
+                                var limitVelocity = BABYLON.Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
+                                if (directionScale_1 / _this._scaledUpdateSpeed > limitVelocity) {
+                                    directionScale_1 *= _this.limitVelocityDamping;
+                                }
+                            });
+                        }
                         particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         particle.position.addInPlace(_this._scaledDirection);
                         // Noise
@@ -56223,7 +56258,7 @@ var BABYLON;
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed  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
          */
@@ -56246,7 +56281,7 @@ var BABYLON;
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the velocity 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
          */
@@ -56267,6 +56302,29 @@ var BABYLON;
             return this;
         };
         /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity 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.addLimitVelocityGradient = function (gradient, factor, factor2) {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
+            return this;
+        };
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
+            this._removeFactorGradient(this._limitVelocityGradients, 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
@@ -56630,6 +56688,17 @@ var BABYLON;
                         particle._currentVelocity2 = particle._currentVelocity1;
                     }
                 }
+                // Limit velocity
+                if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
+                    particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
+                    particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
+                    if (this_1._limitVelocityGradients.length > 1) {
+                        particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
+                    }
+                    else {
+                        particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
+                    }
+                }
                 // Color
                 if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
                     step = BABYLON.Scalar.RandomRange(0, 1.0);
@@ -57074,6 +57143,22 @@ var BABYLON;
                     serializationObject.velocityGradients.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];
+                    var serializedGradient = {
+                        gradient: limitVelocityGradient.gradient,
+                        factor1: limitVelocityGradient.factor1
+                    };
+                    if (limitVelocityGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = limitVelocityGradient.factor2;
+                    }
+                    serializationObject.limitVelocityGradients.push(serializedGradient);
+                }
+                serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
+            }
             if (particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
                 var noiseTexture = particleSystem.noiseTexture;
                 serializationObject.noiseTexture = noiseTexture.serialize();
@@ -57171,6 +57256,13 @@ var BABYLON;
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }
+            if (parsedParticleSystem.limitVelocityGradients) {
+                for (var _h = 0, _j = parsedParticleSystem.limitVelocityGradients; _h < _j.length; _h++) {
+                    var limitVelocityGradient = _j[_h];
+                    particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
+                }
+                particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
+            }
             if (parsedParticleSystem.noiseTexture) {
                 particleSystem.noiseTexture = BABYLON.ProceduralTexture.Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
             }
@@ -60658,7 +60750,7 @@ var BABYLON;
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed to affect to the specified gradient
          * @returns the current particle system
          */
         GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
@@ -60686,7 +60778,7 @@ var BABYLON;
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the velocity to affect to the specified gradient
          * @returns the current particle system
          */
         GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
@@ -60711,6 +60803,34 @@ var BABYLON;
             this._velocityGradientsTexture = null;
             return this;
         };
+        /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity value to affect to the specified gradient
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                this._limitVelocityGradientsTexture = null;
+            }
+            this._releaseBuffers();
+            return this;
+        };
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
+            this._removeGradient(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
+            this._limitVelocityGradientsTexture = null;
+            return this;
+        };
         GPUParticleSystem.prototype._reset = function () {
             this._releaseBuffers();
         };
@@ -61211,6 +61331,10 @@ var BABYLON;
                 this._velocityGradientsTexture.dispose();
                 this._velocityGradientsTexture = null;
             }
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                this._limitVelocityGradientsTexture = null;
+            }
             if (this._randomTexture) {
                 this._randomTexture.dispose();
                 this._randomTexture = null;
@@ -105535,6 +105659,8 @@ var BABYLON;
             // Emission speed
             system.minEmitPower = 2;
             system.maxEmitPower = 2;
+            // Update speed
+            system.updateSpeed = 1 / 60;
             system.emitRate = 30;
             return system;
         };

+ 130 - 4
dist/preview release/babylon.no-module.max.js

@@ -55357,6 +55357,10 @@ var BABYLON;
             this._currentVelocity1 = 0;
             /** @hidden */
             this._currentVelocity2 = 0;
+            /** @hidden */
+            this._currentLimitVelocity1 = 0;
+            /** @hidden */
+            this._currentLimitVelocity2 = 0;
             if (!this.particleSystem.isAnimationSheetEnabled) {
                 return;
             }
@@ -55421,6 +55425,11 @@ var BABYLON;
                 other._currentVelocity1 = this._currentVelocity1;
                 other._currentVelocity2 = this._currentVelocity2;
             }
+            if (this._currentLimitVelocityGradient) {
+                other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
+                other._currentLimitVelocity1 = this._currentLimitVelocity1;
+                other._currentLimitVelocity2 = this._currentLimitVelocity2;
+            }
             if (this.particleSystem.isAnimationSheetEnabled) {
                 other._initialStartSpriteCellID = this._initialStartSpriteCellID;
                 other._initialEndSpriteCellID = this._initialEndSpriteCellID;
@@ -55600,6 +55609,9 @@ var BABYLON;
             this._lifeTimeGradients = null;
             this._angularSpeedGradients = null;
             this._velocityGradients = null;
+            this._limitVelocityGradients = null;
+            /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
+            this.limitVelocityDamping = 0.4;
             /**
              * Random color of each particle after it has been emitted, between color1 and color2 vectors
              */
@@ -55643,6 +55655,14 @@ var BABYLON;
             configurable: true
         });
         /**
+         * Gets the current list of limit velocity gradients.
+         * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
+         * @returns the list of limit velocity gradients
+         */
+        BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
+            return this._limitVelocityGradients;
+        };
+        /**
          * Gets the current list of color gradients.
          * You must use addColorGradient and removeColorGradient to udpate this list
          * @returns the list of color gradients
@@ -56020,6 +56040,7 @@ var BABYLON;
                         particle.angle += particle.angularSpeed * _this._scaledUpdateSpeed;
                         // Direction
                         var directionScale_1 = _this._scaledUpdateSpeed;
+                        /// Velocity
                         if (_this._velocityGradients && _this._velocityGradients.length > 0) {
                             BABYLON.Tools.GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
                                 if (currentGradient !== particle._currentVelocityGradient) {
@@ -56030,6 +56051,20 @@ var BABYLON;
                                 directionScale_1 *= BABYLON.Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
                         }
+                        /// Limit velocity
+                        if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
+                            BABYLON.Tools.GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
+                                if (currentGradient !== particle._currentLimitVelocityGradient) {
+                                    particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
+                                    particle._currentLimitVelocity2 = nextGradient.getFactor();
+                                    particle._currentLimitVelocityGradient = currentGradient;
+                                }
+                                var limitVelocity = BABYLON.Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
+                                if (directionScale_1 / _this._scaledUpdateSpeed > limitVelocity) {
+                                    directionScale_1 *= _this.limitVelocityDamping;
+                                }
+                            });
+                        }
                         particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         particle.position.addInPlace(_this._scaledDirection);
                         // Noise
@@ -56190,7 +56225,7 @@ var BABYLON;
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed  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
          */
@@ -56213,7 +56248,7 @@ var BABYLON;
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the velocity 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
          */
@@ -56234,6 +56269,29 @@ var BABYLON;
             return this;
         };
         /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity 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.addLimitVelocityGradient = function (gradient, factor, factor2) {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
+            return this;
+        };
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
+            this._removeFactorGradient(this._limitVelocityGradients, 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
@@ -56597,6 +56655,17 @@ var BABYLON;
                         particle._currentVelocity2 = particle._currentVelocity1;
                     }
                 }
+                // Limit velocity
+                if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
+                    particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
+                    particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
+                    if (this_1._limitVelocityGradients.length > 1) {
+                        particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
+                    }
+                    else {
+                        particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
+                    }
+                }
                 // Color
                 if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
                     step = BABYLON.Scalar.RandomRange(0, 1.0);
@@ -57041,6 +57110,22 @@ var BABYLON;
                     serializationObject.velocityGradients.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];
+                    var serializedGradient = {
+                        gradient: limitVelocityGradient.gradient,
+                        factor1: limitVelocityGradient.factor1
+                    };
+                    if (limitVelocityGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = limitVelocityGradient.factor2;
+                    }
+                    serializationObject.limitVelocityGradients.push(serializedGradient);
+                }
+                serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
+            }
             if (particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
                 var noiseTexture = particleSystem.noiseTexture;
                 serializationObject.noiseTexture = noiseTexture.serialize();
@@ -57138,6 +57223,13 @@ var BABYLON;
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }
+            if (parsedParticleSystem.limitVelocityGradients) {
+                for (var _h = 0, _j = parsedParticleSystem.limitVelocityGradients; _h < _j.length; _h++) {
+                    var limitVelocityGradient = _j[_h];
+                    particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
+                }
+                particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
+            }
             if (parsedParticleSystem.noiseTexture) {
                 particleSystem.noiseTexture = BABYLON.ProceduralTexture.Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
             }
@@ -60625,7 +60717,7 @@ var BABYLON;
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed to affect to the specified gradient
          * @returns the current particle system
          */
         GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
@@ -60653,7 +60745,7 @@ var BABYLON;
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the velocity to affect to the specified gradient
          * @returns the current particle system
          */
         GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
@@ -60678,6 +60770,34 @@ var BABYLON;
             this._velocityGradientsTexture = null;
             return this;
         };
+        /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity value to affect to the specified gradient
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                this._limitVelocityGradientsTexture = null;
+            }
+            this._releaseBuffers();
+            return this;
+        };
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
+            this._removeGradient(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
+            this._limitVelocityGradientsTexture = null;
+            return this;
+        };
         GPUParticleSystem.prototype._reset = function () {
             this._releaseBuffers();
         };
@@ -61178,6 +61298,10 @@ var BABYLON;
                 this._velocityGradientsTexture.dispose();
                 this._velocityGradientsTexture = null;
             }
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                this._limitVelocityGradientsTexture = null;
+            }
             if (this._randomTexture) {
                 this._randomTexture.dispose();
                 this._randomTexture = null;
@@ -105502,6 +105626,8 @@ var BABYLON;
             // Emission speed
             system.minEmitPower = 2;
             system.maxEmitPower = 2;
+            // Update speed
+            system.updateSpeed = 1 / 60;
             system.emitRate = 30;
             return system;
         };

文件差异内容过多而无法显示
+ 28 - 28
dist/preview release/babylon.worker.js


+ 130 - 4
dist/preview release/es6.js

@@ -55357,6 +55357,10 @@ var BABYLON;
             this._currentVelocity1 = 0;
             /** @hidden */
             this._currentVelocity2 = 0;
+            /** @hidden */
+            this._currentLimitVelocity1 = 0;
+            /** @hidden */
+            this._currentLimitVelocity2 = 0;
             if (!this.particleSystem.isAnimationSheetEnabled) {
                 return;
             }
@@ -55421,6 +55425,11 @@ var BABYLON;
                 other._currentVelocity1 = this._currentVelocity1;
                 other._currentVelocity2 = this._currentVelocity2;
             }
+            if (this._currentLimitVelocityGradient) {
+                other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
+                other._currentLimitVelocity1 = this._currentLimitVelocity1;
+                other._currentLimitVelocity2 = this._currentLimitVelocity2;
+            }
             if (this.particleSystem.isAnimationSheetEnabled) {
                 other._initialStartSpriteCellID = this._initialStartSpriteCellID;
                 other._initialEndSpriteCellID = this._initialEndSpriteCellID;
@@ -55600,6 +55609,9 @@ var BABYLON;
             this._lifeTimeGradients = null;
             this._angularSpeedGradients = null;
             this._velocityGradients = null;
+            this._limitVelocityGradients = null;
+            /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
+            this.limitVelocityDamping = 0.4;
             /**
              * Random color of each particle after it has been emitted, between color1 and color2 vectors
              */
@@ -55643,6 +55655,14 @@ var BABYLON;
             configurable: true
         });
         /**
+         * Gets the current list of limit velocity gradients.
+         * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
+         * @returns the list of limit velocity gradients
+         */
+        BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
+            return this._limitVelocityGradients;
+        };
+        /**
          * Gets the current list of color gradients.
          * You must use addColorGradient and removeColorGradient to udpate this list
          * @returns the list of color gradients
@@ -56020,6 +56040,7 @@ var BABYLON;
                         particle.angle += particle.angularSpeed * _this._scaledUpdateSpeed;
                         // Direction
                         var directionScale_1 = _this._scaledUpdateSpeed;
+                        /// Velocity
                         if (_this._velocityGradients && _this._velocityGradients.length > 0) {
                             BABYLON.Tools.GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
                                 if (currentGradient !== particle._currentVelocityGradient) {
@@ -56030,6 +56051,20 @@ var BABYLON;
                                 directionScale_1 *= BABYLON.Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
                         }
+                        /// Limit velocity
+                        if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
+                            BABYLON.Tools.GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
+                                if (currentGradient !== particle._currentLimitVelocityGradient) {
+                                    particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
+                                    particle._currentLimitVelocity2 = nextGradient.getFactor();
+                                    particle._currentLimitVelocityGradient = currentGradient;
+                                }
+                                var limitVelocity = BABYLON.Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
+                                if (directionScale_1 / _this._scaledUpdateSpeed > limitVelocity) {
+                                    directionScale_1 *= _this.limitVelocityDamping;
+                                }
+                            });
+                        }
                         particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         particle.position.addInPlace(_this._scaledDirection);
                         // Noise
@@ -56190,7 +56225,7 @@ var BABYLON;
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed  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
          */
@@ -56213,7 +56248,7 @@ var BABYLON;
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the velocity 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
          */
@@ -56234,6 +56269,29 @@ var BABYLON;
             return this;
         };
         /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity 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.addLimitVelocityGradient = function (gradient, factor, factor2) {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
+            return this;
+        };
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
+            this._removeFactorGradient(this._limitVelocityGradients, 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
@@ -56597,6 +56655,17 @@ var BABYLON;
                         particle._currentVelocity2 = particle._currentVelocity1;
                     }
                 }
+                // Limit velocity
+                if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
+                    particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
+                    particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
+                    if (this_1._limitVelocityGradients.length > 1) {
+                        particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
+                    }
+                    else {
+                        particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
+                    }
+                }
                 // Color
                 if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
                     step = BABYLON.Scalar.RandomRange(0, 1.0);
@@ -57041,6 +57110,22 @@ var BABYLON;
                     serializationObject.velocityGradients.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];
+                    var serializedGradient = {
+                        gradient: limitVelocityGradient.gradient,
+                        factor1: limitVelocityGradient.factor1
+                    };
+                    if (limitVelocityGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = limitVelocityGradient.factor2;
+                    }
+                    serializationObject.limitVelocityGradients.push(serializedGradient);
+                }
+                serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
+            }
             if (particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
                 var noiseTexture = particleSystem.noiseTexture;
                 serializationObject.noiseTexture = noiseTexture.serialize();
@@ -57138,6 +57223,13 @@ var BABYLON;
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }
+            if (parsedParticleSystem.limitVelocityGradients) {
+                for (var _h = 0, _j = parsedParticleSystem.limitVelocityGradients; _h < _j.length; _h++) {
+                    var limitVelocityGradient = _j[_h];
+                    particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
+                }
+                particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
+            }
             if (parsedParticleSystem.noiseTexture) {
                 particleSystem.noiseTexture = BABYLON.ProceduralTexture.Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
             }
@@ -60625,7 +60717,7 @@ var BABYLON;
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed to affect to the specified gradient
          * @returns the current particle system
          */
         GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
@@ -60653,7 +60745,7 @@ var BABYLON;
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the velocity to affect to the specified gradient
          * @returns the current particle system
          */
         GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
@@ -60678,6 +60770,34 @@ var BABYLON;
             this._velocityGradientsTexture = null;
             return this;
         };
+        /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity value to affect to the specified gradient
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                this._limitVelocityGradientsTexture = null;
+            }
+            this._releaseBuffers();
+            return this;
+        };
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
+            this._removeGradient(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
+            this._limitVelocityGradientsTexture = null;
+            return this;
+        };
         GPUParticleSystem.prototype._reset = function () {
             this._releaseBuffers();
         };
@@ -61178,6 +61298,10 @@ var BABYLON;
                 this._velocityGradientsTexture.dispose();
                 this._velocityGradientsTexture = null;
             }
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                this._limitVelocityGradientsTexture = null;
+            }
             if (this._randomTexture) {
                 this._randomTexture.dispose();
                 this._randomTexture = null;
@@ -105502,6 +105626,8 @@ var BABYLON;
             // Emission speed
             system.minEmitPower = 2;
             system.maxEmitPower = 2;
+            // Update speed
+            system.updateSpeed = 1 / 60;
             system.emitRate = 30;
             return system;
         };

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/viewer/babylon.viewer.js


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/viewer/babylon.viewer.max.js


+ 2 - 0
dist/preview release/what's new.md

@@ -26,6 +26,8 @@
   - Added support for size gradients. [Doc](https://doc.babylonjs.com/babylon101/particles#size)
   - Added support for life time gradients. [Doc](https://doc.babylonjs.com/babylon101/particles#lifetime)
   - Added support for angular speed gradients. [Doc](https://doc.babylonjs.com/babylon101/particles#rotation)
+  - Added support for velocty gradients. [Doc](https://doc.babylonjs.com/babylon101/particles#velocity-over-time)
+  - Added support for limit velocty gradients. [Doc](https://doc.babylonjs.com/babylon101/particles#limit-velocity-over-time)
   - Added support for noise textures. [Doc](http://doc.babylonjs.com/babylon101/particles#noise-texture)
 - Added SceneComponent to help decoupling Scene from its components. ([sebavan](http://www.github.com/sebavan))
 - Playground can now be used with TypeScript directly!. [Demo](https://www.babylonjs-playground.com/ts.html) ([Deltakosh](https://github.com/deltakosh), [NasimiAsl](https://github.com/NasimiAsl))

+ 25 - 2
src/Particles/babylon.IParticleSystem.ts

@@ -190,6 +190,9 @@ module BABYLON {
          */
         billboardMode: number;
 
+        /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
+        limitVelocityDamping: number;
+
         /**
          * Gets the maximum number of particles active at the same time.
          * @returns The max number of active particles.
@@ -308,7 +311,7 @@ module BABYLON {
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient
+         * @param factor defines the angular speed 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
          */
@@ -328,7 +331,7 @@ module BABYLON {
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient         
+         * @param factor defines the velocity 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
          */
@@ -339,5 +342,25 @@ module BABYLON {
          * @returns the current particle system
          */
         removeVelocityGradient(gradient: number): IParticleSystem;
+        /**
+         * Gets the current list of limit velocity gradients.
+         * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
+         * @returns the list of limit velocity gradients
+         */
+        getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
+        /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity 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
+         */
+        addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        removeLimitVelocityGradient(gradient: number): IParticleSystem;        
     }  
 }

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

@@ -239,6 +239,19 @@ module BABYLON {
         protected _lifeTimeGradients: Nullable<Array<FactorGradient>> = null;
         protected _angularSpeedGradients: Nullable<Array<FactorGradient>> = null;
         protected _velocityGradients: Nullable<Array<FactorGradient>> = null;
+        protected _limitVelocityGradients: Nullable<Array<FactorGradient>> = null;
+
+        /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
+        public limitVelocityDamping = 0.4;
+
+        /**
+         * Gets the current list of limit velocity gradients.
+         * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
+         * @returns the list of limit velocity gradients
+         */
+        public getLimitVelocityGradients(): Nullable<Array<FactorGradient>> {
+            return this._limitVelocityGradients;
+        }        
 
         /**
          * Gets the current list of color gradients.

+ 45 - 4
src/Particles/babylon.gpuParticleSystem.ts

@@ -234,6 +234,7 @@
         private _angularSpeedGradientsTexture: RawTexture;           
         private _sizeGradientsTexture: RawTexture;             
         private _velocityGradientsTexture: RawTexture;    
+        private _limitVelocityGradientsTexture: RawTexture;    
 
         private _addFactorGradient(factorGradients: FactorGradient[], gradient: number, factor: number) {
             let valueGradient = new FactorGradient();
@@ -292,7 +293,7 @@
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient    
+         * @param factor defines the angular speed to affect to the specified gradient    
          * @returns the current particle system     
          */
         public addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem {
@@ -327,7 +328,7 @@
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient    
+         * @param factor defines the velocity to affect to the specified gradient    
          * @returns the current particle system     
          */
         public addVelocityGradient(gradient: number, factor: number): GPUParticleSystem {
@@ -357,7 +358,42 @@
             (<any>this._velocityGradientsTexture) = null;
 
             return this;           
-        }          
+        }       
+        
+        /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity value to affect to the specified gradient    
+         * @returns the current particle system     
+         */
+        public addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
+
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                (<any>this._limitVelocityGradientsTexture) = null;
+            }
+
+            this._releaseBuffers();   
+
+            return this;
+        }
+
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        public removeLimitVelocityGradient(gradient: number): GPUParticleSystem {
+            this._removeGradient(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
+            (<any>this._limitVelocityGradientsTexture) = null;
+
+            return this;           
+        }           
 
         /**
          * Instantiates a GPU particle system.
@@ -1060,7 +1096,12 @@
             if (this._velocityGradientsTexture) {
                 this._velocityGradientsTexture.dispose();
                 (<any>this._velocityGradientsTexture) = null;
-            }                
+            }  
+
+            if (this._limitVelocityGradientsTexture) {
+                this._limitVelocityGradientsTexture.dispose();
+                (<any>this._limitVelocityGradientsTexture) = null;
+            }         
          
             if (this._randomTexture) {
                 this._randomTexture.dispose();

+ 14 - 2
src/Particles/babylon.particle.ts

@@ -93,7 +93,14 @@
         /** @hidden */
         public _currentVelocity1 = 0;
         /** @hidden */
-        public _currentVelocity2 = 0;             
+        public _currentVelocity2 = 0;           
+        
+        /** @hidden */
+        public _currentLimitVelocityGradient: Nullable<FactorGradient>;
+        /** @hidden */
+        public _currentLimitVelocity1 = 0;
+        /** @hidden */
+        public _currentLimitVelocity2 = 0;            
 
         /**
          * Creates a new instance Particle
@@ -170,7 +177,12 @@
                 other._currentVelocityGradient = this._currentVelocityGradient;
                 other._currentVelocity1 = this._currentVelocity1;
                 other._currentVelocity2 = this._currentVelocity2;
-            }                  
+            }     
+            if (this._currentLimitVelocityGradient) {
+                other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
+                other._currentLimitVelocity1 = this._currentLimitVelocity1;
+                other._currentLimitVelocity2 = this._currentLimitVelocity2;
+            }                           
             if (this.particleSystem.isAnimationSheetEnabled) {
                 other._initialStartSpriteCellID = this._initialStartSpriteCellID;
                 other._initialEndSpriteCellID = this._initialEndSpriteCellID;

+ 3 - 0
src/Particles/babylon.particleHelper.ts

@@ -35,6 +35,9 @@ module BABYLON {
             system.minEmitPower = 2;
             system.maxEmitPower = 2;
 
+            // Update speed
+            system.updateSpeed = 1 / 60;
+
             system.emitRate = 30;
 
             return system;

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

@@ -200,6 +200,8 @@
 
                         // Direction
                         let directionScale = this._scaledUpdateSpeed;
+
+                        /// Velocity
                         if (this._velocityGradients && this._velocityGradients.length > 0) {                  
                             Tools.GetCurrentGradient(ratio, this._velocityGradients, (currentGradient, nextGradient, scale) => {
                                 if (currentGradient !== particle._currentVelocityGradient) {
@@ -209,7 +211,24 @@
                                 }                                
                                 directionScale *= Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
-                        }                          
+                        }                  
+                        
+                        /// Limit velocity
+                        if (this._limitVelocityGradients && this._limitVelocityGradients.length > 0) {                  
+                            Tools.GetCurrentGradient(ratio, this._limitVelocityGradients, (currentGradient, nextGradient, scale) => {
+                                if (currentGradient !== particle._currentLimitVelocityGradient) {
+                                    particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
+                                    particle._currentLimitVelocity2 = (<FactorGradient>nextGradient).getFactor();    
+                                    particle._currentLimitVelocityGradient = (<FactorGradient>currentGradient);
+                                }                                
+                                let limitVelocity = Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
+
+                                if (directionScale / this._scaledUpdateSpeed > limitVelocity) {
+                                    directionScale *= this.limitVelocityDamping;
+                                }
+                            });
+                        }   
+
                         particle.direction.scaleToRef(directionScale, this._scaledDirection);
                         particle.position.addInPlace(this._scaledDirection);
 
@@ -351,7 +370,7 @@
         /**
          * Adds a new angular speed gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient         
+         * @param factor defines the angular speed  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
          */
@@ -379,7 +398,7 @@
         /**
          * Adds a new velocity gradient
          * @param gradient defines the gradient to use (between 0 and 1)
-         * @param factor defines the size factor to affect to the specified gradient         
+         * @param factor defines the velocity 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
          */
@@ -402,7 +421,35 @@
             this._removeFactorGradient(this._velocityGradients, gradient);
 
             return this;
-        }         
+        }     
+        
+        /**
+         * Adds a new limit velocity gradient
+         * @param gradient defines the gradient to use (between 0 and 1)
+         * @param factor defines the limit velocity 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 addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem {
+            if (!this._limitVelocityGradients) {
+                this._limitVelocityGradients = [];
+            }
+
+            this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
+
+            return this;
+        }
+
+        /**
+         * Remove a specific limit velocity gradient
+         * @param gradient defines the gradient to remove
+         * @returns the current particle system
+         */
+        public removeLimitVelocityGradient(gradient: number): IParticleSystem {
+            this._removeFactorGradient(this._limitVelocityGradients, gradient);
+
+            return this;
+        }            
 
         /**
          * Adds a new color gradient
@@ -858,7 +905,19 @@
                     } else {
                         particle._currentVelocity2 = particle._currentVelocity1;
                     }
-                }                
+                }        
+                
+                // Limit velocity
+                if (this._limitVelocityGradients && this._limitVelocityGradients.length > 0) {
+                    particle._currentLimitVelocityGradient = this._limitVelocityGradients[0];
+                    particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
+
+                    if (this._limitVelocityGradients.length > 1) {
+                        particle._currentLimitVelocity2 = this._limitVelocityGradients[1].getFactor();
+                    } else {
+                        particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
+                    }
+                }                   
 
                 // Color
                 if (!this._colorGradients || this._colorGradients.length === 0) {
@@ -1382,6 +1441,26 @@
                     serializationObject.velocityGradients.push(serializedGradient);
                 }
             }    
+
+            let limitVelocityGradients = particleSystem.getLimitVelocityGradients();
+            if (limitVelocityGradients) {
+                serializationObject.limitVelocityGradients = [];
+                for (var limitVelocityGradient of limitVelocityGradients) {
+
+                    var serializedGradient: any = {
+                        gradient: limitVelocityGradient.gradient,
+                        factor1: limitVelocityGradient.factor1
+                    };
+
+                    if (limitVelocityGradient.factor2 !== undefined) {
+                        serializedGradient.factor2 = limitVelocityGradient.factor2;
+                    }
+
+                    serializationObject.limitVelocityGradients.push(serializedGradient);
+                }
+
+                serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
+            }   
             
             if (particleSystem.noiseTexture && particleSystem.noiseTexture instanceof ProceduralTexture) {
                 const noiseTexture = particleSystem.noiseTexture as ProceduralTexture;
@@ -1491,6 +1570,13 @@
                     particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ?  velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
                 }
             }     
+
+            if (parsedParticleSystem.limitVelocityGradients) {
+                for (var limitVelocityGradient of parsedParticleSystem.limitVelocityGradients) {
+                    particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ?  limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
+                }
+                particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
+            }               
             
             if (parsedParticleSystem.noiseTexture) {
                 particleSystem.noiseTexture = ProceduralTexture.Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);