|
@@ -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;
|
|
|
};
|