Refactor terrain material assignment to update all meshes in render objects
This commit is contained in:
@@ -8961,9 +8961,18 @@ export class ViewportHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const displayedTerrain = this.getDisplayedTerrainState(terrainId) ?? terrain;
|
const displayedTerrain = this.getDisplayedTerrainState(terrainId) ?? terrain;
|
||||||
const previousMaterial = renderObjects.mesh.material;
|
const previousMaterial = renderObjects.material;
|
||||||
renderObjects.mesh.material = this.createTerrainMaterial(displayedTerrain);
|
const nextMaterial = this.createTerrainMaterial(displayedTerrain);
|
||||||
|
|
||||||
|
for (const chunk of renderObjects.chunks) {
|
||||||
|
for (const mesh of chunk.levels) {
|
||||||
|
mesh.material = nextMaterial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderObjects.material = nextMaterial;
|
||||||
previousMaterial.dispose();
|
previousMaterial.dispose();
|
||||||
|
this.updateTerrainLodVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDisplayedTerrainState(terrainId: string): Terrain | null {
|
private getDisplayedTerrainState(terrainId: string): Terrain | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user