mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-22 15:17:23 +01:00
refactor: Remove lastDrawnIcons tracking to simplify terrainLayer drawing logic
This commit is contained in:
parent
70e3eea4d1
commit
c7793d2578
1 changed files with 1 additions and 6 deletions
|
|
@ -16,7 +16,6 @@ const atlases = Object.fromEntries(
|
||||||
);
|
);
|
||||||
|
|
||||||
const terrainLayer = new TextureAtlasLayer("terrain", atlases);
|
const terrainLayer = new TextureAtlasLayer("terrain", atlases);
|
||||||
let lastDrawnIcons: ReliefIcon[] | null = null;
|
|
||||||
|
|
||||||
function resolveQuads(icons: ReliefIcon[]) {
|
function resolveQuads(icons: ReliefIcon[]) {
|
||||||
return icons.map((r) => {
|
return icons.map((r) => {
|
||||||
|
|
@ -54,16 +53,12 @@ window.drawRelief = (
|
||||||
if (type === "svg") {
|
if (type === "svg") {
|
||||||
drawSvg(icons, parentEl);
|
drawSvg(icons, parentEl);
|
||||||
} else {
|
} else {
|
||||||
if (icons !== lastDrawnIcons) {
|
terrainLayer.draw(resolveQuads(icons));
|
||||||
terrainLayer.draw(resolveQuads(icons));
|
|
||||||
lastDrawnIcons = icons;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.undrawRelief = () => {
|
window.undrawRelief = () => {
|
||||||
terrainLayer.clear();
|
terrainLayer.clear();
|
||||||
lastDrawnIcons = null;
|
|
||||||
const terrainEl = byId("terrain");
|
const terrainEl = byId("terrain");
|
||||||
if (terrainEl) terrainEl.innerHTML = "";
|
if (terrainEl) terrainEl.innerHTML = "";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue