diff --git a/cocos/3d/framework/particle/particle-system-component.ts b/cocos/3d/framework/particle/particle-system-component.ts index 3715e53647..944c7ece87 100644 --- a/cocos/3d/framework/particle/particle-system-component.ts +++ b/cocos/3d/framework/particle/particle-system-component.ts @@ -272,16 +272,18 @@ export class ParticleSystemComponent extends Component { protected onDestroy () { // this._system.remove(this); + this.trailModule.destroy(); } protected onEnable () { if (this.playOnAwake) { this.play(); } + this.trailModule.onEnable(); } protected onDisable () { - + this.trailModule.onDisable(); } // TODO: fastforward current particle system by simulating particles over given period of time, then pause it. diff --git a/cocos/3d/framework/particle/renderer/particle-system-renderer.ts b/cocos/3d/framework/particle/renderer/particle-system-renderer.ts index 23ac847a36..7ce31d7ed9 100644 --- a/cocos/3d/framework/particle/renderer/particle-system-renderer.ts +++ b/cocos/3d/framework/particle/renderer/particle-system-renderer.ts @@ -319,6 +319,8 @@ export default class ParticleSystemRenderer extends RenderableComponent { if (uploadVel) { this.attrs[attrNum++] = p.ultimateVelocity; + } else { + this.attrs[attrNum++] = null; } this._model!.addParticleVertexData(idx++, this.attrs); diff --git a/cocos/3d/framework/particle/renderer/trail.ts b/cocos/3d/framework/particle/renderer/trail.ts index f82ed1c370..26291a17db 100644 --- a/cocos/3d/framework/particle/renderer/trail.ts +++ b/cocos/3d/framework/particle/renderer/trail.ts @@ -114,6 +114,9 @@ export default class TrailModule { if (this._enable) { this._createModel(); } + if (this._trailModel) { + this._trailModel.enabled = val; + } } @property({ @@ -231,6 +234,25 @@ export default class TrailModule { } } + public onEnable () { + if (this._enable && this._trailModel) { + this._trailModel.enabled = true; + } + } + + public onDisable () { + if (this._enable && this._trailModel) { + this._trailModel.enabled = false; + } + } + + public destroy () { + if (this._trailModel) { + this._particleSystem._getRenderScene().destroyModel(this._trailModel!); + this._trailModel = null; + } + } + private _createModel () { if (this._trailModel) { return; diff --git a/cocos/renderer/models/particle-batch-model.ts b/cocos/renderer/models/particle-batch-model.ts index 0e389dbe8b..8f7eddb7f2 100644 --- a/cocos/renderer/models/particle-batch-model.ts +++ b/cocos/renderer/models/particle-batch-model.ts @@ -185,6 +185,11 @@ export default class ParticleBatchModel extends Model { this._vdataF32![offset++] = pvdata[2].x; this._vdataF32![offset++] = pvdata[2].y; this._vdataUint32![offset++] = pvdata[3]; + if (pvdata[4]) { + this._vdataF32![offset++] = pvdata[4].x; + this._vdataF32![offset++] = pvdata[4].y; + this._vdataF32![offset++] = pvdata[4].z; + } } else { for (let i = 0; i < this._vertCount; i++) { let offset: number = (index * this._vertCount + i) * this._vertAttrsFloatCount;