refactor and fix saved grid algo.

This commit is contained in:
GoteGuru 2022-06-20 18:39:50 +02:00
parent 4291777bc4
commit f4b3662cba
7 changed files with 37 additions and 33 deletions

View file

@ -631,7 +631,7 @@ void (function addDragToUpload() {
});
})();
const gridOptimizationRequired = () => window[document.getElementById('gridAlgorithm').value] == voronoiPoints;
const gridOptimizationRequired = () => globalThis[byId('gridAlgorithm').value] == jitteredGridPoints;
async function generate(options) {
try {
const timeStart = performance.now();
@ -643,10 +643,10 @@ async function generate(options) {
applyMapSize();
randomizeOptions();
const method = window[document.getElementById('gridAlgorithm').value];
console.log('gird generation method', method);
const method = globalThis[byId('gridAlgorithm').value];
if (shouldRegenerateGrid(grid, method)) grid = precreatedGraph || generateGrid(method);
const cellsDesired = +byId("pointsInput").dataset.cells;
if (shouldRegenerateGrid(grid, method)) grid = precreatedGraph || generateGrid(cellsDesired, method);
else delete grid.cells.h;
grid.cells.h = await HeightmapGenerator.generate(grid);