mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix an error when switching scene from ui containing 3d model (#4861)
This commit is contained in:
@@ -158,12 +158,14 @@ export class ModelComponent extends RenderableComponent {
|
||||
}
|
||||
|
||||
public recreateModel () {
|
||||
if (this._model) {
|
||||
this._model.destroy();
|
||||
this._model.scene.destroyModel(this._model);
|
||||
this._model = null;
|
||||
if (this.isValid) {
|
||||
if (this._model) {
|
||||
this._model.destroy();
|
||||
this._model.scene.destroyModel(this._model);
|
||||
this._model = null;
|
||||
}
|
||||
this._updateModels();
|
||||
}
|
||||
this._updateModels();
|
||||
}
|
||||
|
||||
protected _updateModels () {
|
||||
|
||||
@@ -408,14 +408,16 @@ export class ParticleSystemComponent extends RenderableComponent {
|
||||
}
|
||||
|
||||
public recreateModel () {
|
||||
const r = this.renderer as any;
|
||||
if (r._model) {
|
||||
r._model.destroy();
|
||||
r._model = null;
|
||||
r.onEnable();
|
||||
r._updateModel();
|
||||
r._updateMaterialParams();
|
||||
r._updateTrailMaterial();
|
||||
if (this.isValid) {
|
||||
const r = this.renderer as any;
|
||||
if (r && r._model) {
|
||||
r._model.destroy();
|
||||
r._model = null;
|
||||
r.onEnable();
|
||||
r._updateModel();
|
||||
r._updateMaterialParams();
|
||||
r._updateTrailMaterial();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user