fix particle bug (#4424)

This commit is contained in:
zxg0622
2019-05-16 11:34:35 +08:00
committed by Weiliang Wang
parent 283edb8d22
commit 60cd117eb0
3 changed files with 6 additions and 5 deletions
@@ -401,6 +401,7 @@ export class ParticleSystemComponent extends RenderableComponent {
}
this._isPlaying = true;
this._isEmitting = true;
// prewarm
if (this._prewarm) {
@@ -491,7 +492,9 @@ export class ParticleSystemComponent extends RenderableComponent {
this._emit(scaledDeltaTime);
// simulation, update particles.
this.renderer!._updateParticles(scaledDeltaTime);
if (this.renderer!._updateParticles(scaledDeltaTime) === 0 && !this._isEmitting) {
this.stop();
}
// update render data
this.renderer!._updateRenderData();
@@ -580,15 +583,12 @@ export class ParticleSystemComponent extends RenderableComponent {
// emit particles.
const startDelay = this.startDelay.evaluate(0, 1)!;
if (this._time > startDelay) {
if (!this._isStopped) {
this._isEmitting = true;
}
if (this._time > (this.duration + startDelay)) {
// this._time = startDelay; // delay will not be applied from the second loop.(Unity)
// this._emitRateTimeCounter = 0.0;
// this._emitRateDistanceCounter = 0.0;
if (!this.loop) {
this.stop();
this._isEmitting = false;
return;
}
}
@@ -318,6 +318,7 @@ export default class ParticleSystemRenderer {
this.particleSystem.trailModule.animate(p, dt);
}
}
return this._particles!.length;
}
// internal function