restore layers - don't hide, remove unused

This commit is contained in:
Azgaar 2021-07-31 15:06:14 +03:00
parent a17457ae35
commit 90c87853b1
2 changed files with 16 additions and 14 deletions

View file

@ -122,9 +122,10 @@ function restoreLayers() {
if (layerIsOn("toggleIce")) drawIce();
if (layerIsOn("toggleEmblems")) drawEmblems();
// states are getting rendered each time, if it's not required than layers should be hidden
if (!layerIsOn("toggleBorders")) $("#borders").fadeOut();
if (!layerIsOn("toggleStates")) regions.style("display", "none").selectAll("path").remove();
// some layers are rendered each time, remove them if they are not on
if (!layerIsOn("toggleBorders")) borders.selectAll("path").remove();
if (!layerIsOn("toggleStates")) regions.selectAll("path").remove();
if (!layerIsOn("toggleRivers")) rivers.selectAll("*").remove();
}
function toggleHeight(event) {
@ -1034,13 +1035,14 @@ function drawBorders() {
TIME && console.time("drawBorders");
borders.selectAll("path").remove();
const cells = pack.cells,
vertices = pack.vertices,
n = cells.i.length;
const sPath = [],
pPath = [];
const sUsed = new Array(pack.states.length).fill("").map(a => []);
const pUsed = new Array(pack.provinces.length).fill("").map(a => []);
const {cells, vertices} = pack;
const n = cells.i.length;
const sPath = [];
const pPath = [];
const sUsed = new Array(pack.states.length).fill("").map(_ => []);
const pUsed = new Array(pack.provinces.length).fill("").map(_ => []);
for (let i = 0; i < cells.i.length; i++) {
if (!cells.state[i]) continue;

View file

@ -544,15 +544,15 @@ function randomizeHeightmapTemplate() {
volcano: 3,
highIsland: 22,
lowIsland: 9,
continents: 20,
archipelago: 25,
mediterranean: 3,
continents: 19,
archipelago: 23,
mediterranean: 5,
peninsula: 3,
pangea: 5,
isthmus: 2,
atoll: 1,
shattered: 7,
taklamakan: 2
taklamakan: 1
};
document.getElementById("templateInput").value = rw(templates);
}