Update material assignment, add distant terrain material creation, and fix resource disposal in RuntimeHost

This commit is contained in:
2026-04-29 23:18:12 +02:00
parent d271ebea50
commit 3b8cae6ea9

View File

@@ -4130,6 +4130,10 @@ export class RuntimeHost {
chunk.activeLevelIndex = nextLevelIndex; chunk.activeLevelIndex = nextLevelIndex;
chunk.mesh.geometry = chunk.levelGeometries[nextLevelIndex]!; chunk.mesh.geometry = chunk.levelGeometries[nextLevelIndex]!;
chunk.mesh.userData.terrainLodLevel = nextLevelIndex; chunk.mesh.userData.terrainLodLevel = nextLevelIndex;
chunk.mesh.material =
nextLevelIndex >= 2
? renderObjects.distantMaterial
: renderObjects.detailMaterial;
} }
} }
} }
@@ -4147,6 +4151,16 @@ export class RuntimeHost {
}); });
} }
private createRuntimeTerrainDistantMaterial(terrain: RuntimeTerrain): Material {
const layerColors = terrain.layers.map((layer) =>
getTerrainLayerPreviewColor(layer.material)
) as [number, number, number, number];
return createTerrainLayerColorBlendMaterial({
layerColors
});
}
private createFogMaterialSet( private createFogMaterialSet(
brush: RuntimeBoxBrushInstance, brush: RuntimeBoxBrushInstance,
volumeRenderPaths: { volumeRenderPaths: {
@@ -4952,7 +4966,8 @@ export class RuntimeHost {
geometry.dispose(); geometry.dispose();
} }
renderObjects.material.dispose(); renderObjects.detailMaterial.dispose();
renderObjects.distantMaterial.dispose();
} }
this.terrainMeshes.clear(); this.terrainMeshes.clear();