fix terrain model render (#7847)

Co-authored-by: Myway3D1 <404793124@qq.com>
This commit is contained in:
Myway
2020-11-24 09:52:18 +08:00
committed by GitHub
parent 6a555ad1a9
commit ae13853320
+15
View File
@@ -198,6 +198,14 @@ class TerrainRenderable extends RenderableComponent {
return super.destroy();
}
public _destroyModel () {
// this._invalidMaterial();
if (this._model != null) {
legacyCC.director.root.destroyModel(this._model);
this._model = null;
}
}
public _invalidMaterial () {
if (this._currentMaterial == null) {
return;
@@ -399,6 +407,8 @@ export class TerrainBlock {
}
public destroy () {
this._renderable._destroyModel();
if (this._node != null) {
this._node.destroy();
}
@@ -1228,6 +1238,11 @@ export class Terrain extends Component {
}
public onDestroy () {
for (const i of this._blocks) {
i.destroy();
}
this._blocks = [];
for (let i = 0; i < this._layers.length; ++i) {
this._layers[i] = null;
}