From 01cc1eec30b51832baf610267b9262cc3a8c1a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20Gergely?= Date: Sun, 15 Aug 2021 04:41:59 +0200 Subject: [PATCH] effective distanceScale --- index.html | 20 ++++++++++++++------ main.js | 1 + modules/river-generator.js | 8 ++++---- modules/ui/submap.js | 4 ++-- modules/ui/units-editor.js | 2 ++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 6fc0083b..a92f5148 100644 --- a/index.html +++ b/index.html @@ -3506,14 +3506,22 @@ diff --git a/main.js b/main.js index 9b0ef9b8..f3845190 100644 --- a/main.js +++ b/main.js @@ -153,6 +153,7 @@ let mapCoordinates = {}; // map coordinates on globe options.winds = [225, 45, 225, 315, 135, 315]; // default wind directions let populationRate = +document.getElementById("populationRateInput").value; +let distanceScale = +document.getElementById("distanceScaleInput").value; let urbanization = +document.getElementById("urbanizationInput").value; applyStoredOptions(); diff --git a/modules/river-generator.js b/modules/river-generator.js index a17cff87..6e2ff7ef 100644 --- a/modules/river-generator.js +++ b/modules/river-generator.js @@ -31,14 +31,14 @@ window.Rivers = (function () { TIME && console.timeEnd("generateRivers"); function drainWater() { - const MIN_FLUX_TO_FORM_RIVER = 30; + const MIN_FLUX_TO_FORM_RIVER = 10 * distanceScale; const prec = grid.cells.prec; - const area = pack.cells.area; + const area = c => pack.cells.area[c] * distanceScale * distanceScale; const land = cells.i.filter(i => h[i] >= 20).sort((a, b) => h[b] - h[a]); const lakeOutCells = Lakes.setClimateData(h); land.forEach(function (i) { - cells.fl[i] += prec[cells.g[i]] * area[i] / 100; // add flux from precipitation + cells.fl[i] += prec[cells.g[i]] * area(i) / 1000; // add flux from precipitation // create lake outlet if lake is not in deep depression and flux > evaporation const lakes = lakeOutCells[i] ? features.filter(feature => i === feature.outCell && feature.flux > feature.evaporation) : []; @@ -166,7 +166,7 @@ window.Rivers = (function () { const mouth = riverCells[riverCells.length - 2]; const parent = riverParents[key] || 0; - const widthFactor = !parent || parent === riverId ? 1.2 : 1; + const widthFactor = (!parent || parent === riverId ? 3.6 : 3) / distanceScale; const meanderedPoints = addMeandering(riverCells); const discharge = cells.fl[mouth]; // m3 in second const length = rn(getApproximateLength(meanderedPoints), 2); diff --git a/modules/ui/submap.js b/modules/ui/submap.js index 6a99461b..d89aa4df 100644 --- a/modules/ui/submap.js +++ b/modules/ui/submap.js @@ -33,8 +33,8 @@ const generateSubmap = debounce(async function () { } // fix scale - distanceScaleInput.value = distanceScaleOutput.value = distanceScaleOutput.value / scale; - populationRateInput.value = populationRateOutput.value = populationRateOutput.value / scale; + distanceScale = distanceScaleInput.value = distanceScaleOutput.value = distanceScaleOutput.value / scale; + populationRate = populationRateInput.value = populationRateOutput.value = populationRateOutput.value / scale; customization = 0; undraw(); diff --git a/modules/ui/units-editor.js b/modules/ui/units-editor.js index 54571191..34725e33 100644 --- a/modules/ui/units-editor.js +++ b/modules/ui/units-editor.js @@ -55,6 +55,7 @@ function editUnits() { } function changeDistanceScale() { + distanceScale = +document.getElementById("distanceScaleInput").value; drawScaleBar(); calculateFriendlyGridSize(); } @@ -95,6 +96,7 @@ function editUnits() { function restoreDefaultUnits() { // distanceScale + distanceScale = 3; document.getElementById("distanceScaleOutput").value = 3; document.getElementById("distanceScaleInput").value = 3; unlock("distanceScale");