fix particle trail error (#4337)

* fix particle trail error

* fix stretch billboard error
This commit is contained in:
zxg0622
2019-04-29 15:34:50 +08:00
committed by Weiliang Wang
parent 9c8761bd8e
commit e9552af84b
4 changed files with 32 additions and 1 deletions
@@ -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.
@@ -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);
@@ -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;
@@ -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;