Ver código fonte

Fix limit velocity

David Catuhe 7 anos atrás
pai
commit
04e2a18e04

Diferenças do arquivo suprimidas por serem muito extensas
+ 15774 - 15774
dist/preview release/babylon.d.ts


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/babylon.js


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

@@ -56084,6 +56084,7 @@ var BABYLON;
                                 directionScale_1 *= BABYLON.Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
                         }
+                        particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         /// Limit velocity
                         if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
                             BABYLON.Tools.GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
@@ -56093,12 +56094,12 @@ var BABYLON;
                                     particle._currentLimitVelocityGradient = currentGradient;
                                 }
                                 var limitVelocity = BABYLON.Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
-                                if (directionScale_1 / _this._scaledUpdateSpeed > limitVelocity) {
-                                    directionScale_1 *= _this.limitVelocityDamping;
+                                var currentVelocity = particle.direction.length();
+                                if (currentVelocity > limitVelocity) {
+                                    particle.direction.scaleInPlace(_this.limitVelocityDamping);
                                 }
                             });
                         }
-                        particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         particle.position.addInPlace(_this._scaledDirection);
                         // Noise
                         if (noiseTextureData && noiseTextureSize) {

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

@@ -56051,6 +56051,7 @@ var BABYLON;
                                 directionScale_1 *= BABYLON.Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
                         }
+                        particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         /// Limit velocity
                         if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
                             BABYLON.Tools.GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
@@ -56060,12 +56061,12 @@ var BABYLON;
                                     particle._currentLimitVelocityGradient = currentGradient;
                                 }
                                 var limitVelocity = BABYLON.Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
-                                if (directionScale_1 / _this._scaledUpdateSpeed > limitVelocity) {
-                                    directionScale_1 *= _this.limitVelocityDamping;
+                                var currentVelocity = particle.direction.length();
+                                if (currentVelocity > limitVelocity) {
+                                    particle.direction.scaleInPlace(_this.limitVelocityDamping);
                                 }
                             });
                         }
-                        particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         particle.position.addInPlace(_this._scaledDirection);
                         // Noise
                         if (noiseTextureData && noiseTextureSize) {

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/babylon.worker.js


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

@@ -56051,6 +56051,7 @@ var BABYLON;
                                 directionScale_1 *= BABYLON.Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
                             });
                         }
+                        particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         /// Limit velocity
                         if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
                             BABYLON.Tools.GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
@@ -56060,12 +56061,12 @@ var BABYLON;
                                     particle._currentLimitVelocityGradient = currentGradient;
                                 }
                                 var limitVelocity = BABYLON.Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
-                                if (directionScale_1 / _this._scaledUpdateSpeed > limitVelocity) {
-                                    directionScale_1 *= _this.limitVelocityDamping;
+                                var currentVelocity = particle.direction.length();
+                                if (currentVelocity > limitVelocity) {
+                                    particle.direction.scaleInPlace(_this.limitVelocityDamping);
                                 }
                             });
                         }
-                        particle.direction.scaleToRef(directionScale_1, _this._scaledDirection);
                         particle.position.addInPlace(_this._scaledDirection);
                         // Noise
                         if (noiseTextureData && noiseTextureSize) {

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -213,6 +213,8 @@
                             });
                         }                  
                         
+                        particle.direction.scaleToRef(directionScale, this._scaledDirection);
+
                         /// Limit velocity
                         if (this._limitVelocityGradients && this._limitVelocityGradients.length > 0) {                  
                             Tools.GetCurrentGradient(ratio, this._limitVelocityGradients, (currentGradient, nextGradient, scale) => {
@@ -221,15 +223,16 @@
                                     particle._currentLimitVelocity2 = (<FactorGradient>nextGradient).getFactor();    
                                     particle._currentLimitVelocityGradient = (<FactorGradient>currentGradient);
                                 }                                
+                                
                                 let limitVelocity = Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
+                                let currentVelocity = particle.direction.length();
 
-                                if (directionScale / this._scaledUpdateSpeed > limitVelocity) {
-                                    directionScale *= this.limitVelocityDamping;
+                                if (currentVelocity > limitVelocity) {
+                                    particle.direction.scaleInPlace(this.limitVelocityDamping);
                                 }
                             });
                         }   
 
-                        particle.direction.scaleToRef(directionScale, this._scaledDirection);
                         particle.position.addInPlace(this._scaledDirection);
 
                         // Noise