Add method to clear terrain meshes in RuntimeHost

This commit is contained in:
2026-04-18 19:54:56 +02:00
parent 597cbefc97
commit 2076ab7c55

View File

@@ -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();