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