Refactor terrain material presentation update into a dedicated method
This commit is contained in:
@@ -7930,21 +7930,28 @@ export class ViewportHost {
|
||||
}
|
||||
|
||||
for (const terrain of Object.values(this.currentDocument.terrains)) {
|
||||
const renderObjects = this.terrainRenderObjects.get(terrain.id);
|
||||
|
||||
if (renderObjects === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const displayedTerrain =
|
||||
this.getDisplayedTerrainState(terrain.id) ?? terrain;
|
||||
const previousMaterial = renderObjects.mesh.material;
|
||||
renderObjects.mesh.material =
|
||||
this.createTerrainMaterial(displayedTerrain);
|
||||
previousMaterial.dispose();
|
||||
this.refreshTerrainPresentationForId(terrain.id);
|
||||
}
|
||||
}
|
||||
|
||||
private refreshTerrainPresentationForId(terrainId: string) {
|
||||
if (this.currentDocument === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const terrain = this.currentDocument.terrains[terrainId];
|
||||
const renderObjects = this.terrainRenderObjects.get(terrainId);
|
||||
|
||||
if (terrain === undefined || renderObjects === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const displayedTerrain = this.getDisplayedTerrainState(terrainId) ?? terrain;
|
||||
const previousMaterial = renderObjects.mesh.material;
|
||||
renderObjects.mesh.material = this.createTerrainMaterial(displayedTerrain);
|
||||
previousMaterial.dispose();
|
||||
}
|
||||
|
||||
private getDisplayedTerrainState(terrainId: string): Terrain | null {
|
||||
if (
|
||||
this.activeTerrainBrushStroke !== null &&
|
||||
|
||||
Reference in New Issue
Block a user