fix an error when switching scene from ui containing 3d model (#4861)

This commit is contained in:
zxg0622
2019-07-12 10:01:10 +08:00
committed by Weiliang Wang
parent 1e87219396
commit 2ac03ce8f8
2 changed files with 17 additions and 13 deletions
+7 -5
View File
@@ -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();
}
}
}