mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 04:21:24 +01:00
refactor and fix saved grid algo.
This commit is contained in:
parent
4291777bc4
commit
f4b3662cba
7 changed files with 37 additions and 33 deletions
|
|
@ -263,7 +263,9 @@ function getName(id) {
|
|||
}
|
||||
|
||||
function getGraph(currentGraph) {
|
||||
const newGraph = shouldRegenerateGrid(currentGraph) ? generateGrid() : deepCopy(currentGraph);
|
||||
const newGraph = shouldRegenerateGrid(currentGraph)
|
||||
? generateGrid(currentGraph.cellsDesired, currentGraph.generator)
|
||||
: deepCopy(currentGraph);
|
||||
delete newGraph.cells.h;
|
||||
return newGraph;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ function getMapData() {
|
|||
stylePreset.value,
|
||||
+rescaleLabels.checked,
|
||||
urbanDensity,
|
||||
byId('gridAlgorithm').value,
|
||||
grid.generator.name,
|
||||
].join("|");
|
||||
const coords = JSON.stringify(mapCoordinates);
|
||||
const biomes = [biomesData.color, biomesData.habitability, biomesData.name].join("|");
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ window.Submap = (function () {
|
|||
|
||||
// create new grid
|
||||
applyMapSize();
|
||||
grid = generateGrid(options.gridAlgorithm);
|
||||
grid = generateGrid(options.cellsDesired, options.gridAlgorithm);
|
||||
|
||||
drawScaleBar(scale);
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,6 @@ window.UISubmap = (function () {
|
|||
WARN && console.warn("Resampling current map");
|
||||
const cellNumId = +byId("submapPointsInput").value;
|
||||
if (!cellsDensityMap[cellNumId]) return console.error("Unknown cell number!");
|
||||
const gridAlgorithm = window[document.getElementById('gridAlgorithm').value];
|
||||
|
||||
const {angle, shiftX, shiftY, ratio, mirrorH, mirrorV} = getTransformInput();
|
||||
|
||||
|
|
@ -204,7 +203,8 @@ window.UISubmap = (function () {
|
|||
smoothHeightMap: false,
|
||||
rescaleStyles: false,
|
||||
scale: 1,
|
||||
gridAlgorithm,
|
||||
gridAlgorithm: globalThis[byId('gridAlgorithm').value],
|
||||
cellsDesired: +byId("pointsInput").dataset.cells,
|
||||
projection,
|
||||
inverse
|
||||
});
|
||||
|
|
@ -232,7 +232,8 @@ window.UISubmap = (function () {
|
|||
inverse: (x, y) => [x / origScale + x0, y / origScale + y0],
|
||||
projection: (x, y) => [(x - x0) * origScale, (y - y0) * origScale],
|
||||
scale: origScale,
|
||||
gridAlgorithm: window[byId('gridAlgorithm').value],
|
||||
gridAlgorithm: globalThis[byId('gridAlgorithm').value],
|
||||
cellsDesired: +byId("pointsInput").dataset.cells,
|
||||
};
|
||||
|
||||
// converting map position on the planet
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue