Add method to clear terrain meshes in RuntimeHost
This commit is contained in:
@@ -811,6 +811,7 @@ export class RuntimeHost {
|
||||
this.resizeObserver = null;
|
||||
this.clearLocalLights();
|
||||
this.clearBrushMeshes();
|
||||
this.clearTerrainMeshes();
|
||||
this.clearModelRenderObjects();
|
||||
this.collisionWorldRequestId += 1;
|
||||
this.clearCollisionWorld();
|
||||
@@ -2702,6 +2703,16 @@ export class RuntimeHost {
|
||||
this.runtimeWaterContactUniforms.length = 0;
|
||||
}
|
||||
|
||||
private clearTerrainMeshes() {
|
||||
for (const mesh of this.terrainMeshes.values()) {
|
||||
this.terrainGroup.remove(mesh);
|
||||
mesh.geometry.dispose();
|
||||
mesh.material.dispose();
|
||||
}
|
||||
|
||||
this.terrainMeshes.clear();
|
||||
}
|
||||
|
||||
private disposeUniqueMaterials(materials: Material[]) {
|
||||
for (const material of new Set(materials)) {
|
||||
material.dispose();
|
||||
|
||||
Reference in New Issue
Block a user