mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix particle trail error (#4337)
* fix particle trail error * fix stretch billboard error
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user