mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-05 18:11:23 +01:00
fix: submap
This commit is contained in:
parent
580c98adaf
commit
2484faad72
6 changed files with 38 additions and 40 deletions
15
main.js
15
main.js
|
|
@ -548,21 +548,6 @@ function invokeActiveZooming() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function renderGroupCOAs(g) {
|
|
||||||
const [group, type] =
|
|
||||||
g.id === "burgEmblems"
|
|
||||||
? [pack.burgs, "burg"]
|
|
||||||
: g.id === "provinceEmblems"
|
|
||||||
? [pack.provinces, "province"]
|
|
||||||
: [pack.states, "state"];
|
|
||||||
for (let use of g.children) {
|
|
||||||
const i = +use.dataset.i;
|
|
||||||
const id = type + "COA" + i;
|
|
||||||
COArenderer.trigger(id, group[i].coa);
|
|
||||||
use.setAttribute("href", "#" + id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add drag to upload logic, pull request from @evyatron
|
// add drag to upload logic, pull request from @evyatron
|
||||||
void (function addDragToUpload() {
|
void (function addDragToUpload() {
|
||||||
document.addEventListener("dragover", function (e) {
|
document.addEventListener("dragover", function (e) {
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ async function getMapURL(type, options) {
|
||||||
noWater = false,
|
noWater = false,
|
||||||
noScaleBar = false,
|
noScaleBar = false,
|
||||||
noIce = false,
|
noIce = false,
|
||||||
|
noVignette = false,
|
||||||
fullMap = false
|
fullMap = false
|
||||||
} = options || {};
|
} = options || {};
|
||||||
|
|
||||||
|
|
@ -199,6 +200,7 @@ async function getMapURL(type, options) {
|
||||||
clone.select("#oceanPattern").attr("opacity", 0);
|
clone.select("#oceanPattern").attr("opacity", 0);
|
||||||
}
|
}
|
||||||
if (noIce) clone.select("#ice")?.remove();
|
if (noIce) clone.select("#ice")?.remove();
|
||||||
|
if (noVignette) clone.select("#vignette")?.remove();
|
||||||
if (fullMap) {
|
if (fullMap) {
|
||||||
// reset transform to show the whole map
|
// reset transform to show the whole map
|
||||||
clone.attr("width", graphWidth).attr("height", graphHeight);
|
clone.attr("width", graphWidth).attr("height", graphHeight);
|
||||||
|
|
|
||||||
|
|
@ -109,3 +109,21 @@ function drawEmblems() {
|
||||||
|
|
||||||
TIME && console.timeEnd("drawEmblems");
|
TIME && console.timeEnd("drawEmblems");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getDataAndType = id => {
|
||||||
|
if (id === "burgEmblems") return [pack.burgs, "burg"];
|
||||||
|
if (id === "provinceEmblems") return [pack.provinces, "province"];
|
||||||
|
if (id === "stateEmblems") return [pack.states, "state"];
|
||||||
|
throw new Error(`Unknown emblem type: ${id}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
async function renderGroupCOAs(g) {
|
||||||
|
const [data, type] = getDataAndType(g.id);
|
||||||
|
|
||||||
|
for (let use of g.children) {
|
||||||
|
const i = +use.dataset.i;
|
||||||
|
const id = type + "COA" + i;
|
||||||
|
COArenderer.trigger(id, data[i].coa);
|
||||||
|
use.setAttribute("href", "#" + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,26 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/*
|
|
||||||
Cell resampler module used by submapper and resampler (transform)
|
|
||||||
main function: resample(options);
|
|
||||||
*/
|
|
||||||
|
|
||||||
window.Submap = (function () {
|
window.Submap = (function () {
|
||||||
const isWater = (pack, id) => pack.cells.h[id] < 20;
|
const isWater = (pack, id) => pack.cells.h[id] < 20;
|
||||||
const inMap = (x, y) => x > 0 && x < graphWidth && y > 0 && y < graphHeight;
|
const inMap = (x, y) => x > 0 && x < graphWidth && y > 0 && y < graphHeight;
|
||||||
|
|
||||||
function resample(parentMap, options) {
|
/*
|
||||||
/*
|
|
||||||
generate new map based on an existing one (resampling parentMap)
|
generate new map based on an existing one (resampling parentMap)
|
||||||
parentMap: {seed, grid, pack} from original map
|
parentMap: {seed, grid, pack} from original map
|
||||||
options = {
|
options = {
|
||||||
projection: f(Number,Number)->[Number, Number]
|
projection: f(Number,Number)->[Number, Number]
|
||||||
function to calculate new coordinates
|
function to calculate new coordinates
|
||||||
inverse: g(Number,Number)->[Number, Number]
|
inverse: g(Number,Number)->[Number, Number]
|
||||||
inverse of f
|
inverse of f
|
||||||
depressRivers: Bool carve out riverbeds?
|
depressRivers: Bool carve out riverbeds?
|
||||||
smoothHeightMap: Bool run smooth filter on heights
|
smoothHeightMap: Bool run smooth filter on heights
|
||||||
addLakesInDepressions: call FMG original funtion on heightmap
|
addLakesInDepressions: call FMG original funtion on heightmap
|
||||||
|
|
||||||
lockMarkers: Bool Auto lock all copied markers
|
lockMarkers: Bool Auto lock all copied markers
|
||||||
lockBurgs: Bool Auto lock all copied burgs
|
lockBurgs: Bool Auto lock all copied burgs
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
function resample(parentMap, options) {
|
||||||
const projection = options.projection;
|
const projection = options.projection;
|
||||||
const inverse = options.inverse;
|
const inverse = options.inverse;
|
||||||
const stage = s => INFO && console.info("SUBMAP:", s);
|
const stage = s => INFO && console.info("SUBMAP:", s);
|
||||||
|
|
@ -38,7 +33,6 @@ window.Submap = (function () {
|
||||||
INFO && console.group("SubMap with seed: " + seed);
|
INFO && console.group("SubMap with seed: " + seed);
|
||||||
DEBUG && console.info("Using Options:", options);
|
DEBUG && console.info("Using Options:", options);
|
||||||
|
|
||||||
// create new grid
|
|
||||||
applyGraphSize();
|
applyGraphSize();
|
||||||
grid = generateGrid();
|
grid = generateGrid();
|
||||||
|
|
||||||
|
|
@ -119,8 +113,8 @@ window.Submap = (function () {
|
||||||
OceanLayers();
|
OceanLayers();
|
||||||
|
|
||||||
calculateMapCoordinates();
|
calculateMapCoordinates();
|
||||||
// calculateTemperatures();
|
calculateTemperatures();
|
||||||
// generatePrecipitation();
|
generatePrecipitation();
|
||||||
stage("Cell cleanup");
|
stage("Cell cleanup");
|
||||||
reGraph();
|
reGraph();
|
||||||
|
|
||||||
|
|
@ -244,6 +238,7 @@ window.Submap = (function () {
|
||||||
? pack.burgs[s.capital].cell // capital is the best bet
|
? pack.burgs[s.capital].cell // capital is the best bet
|
||||||
: pack.cells.state.findIndex(x => x === i); // otherwise use the first valid cell
|
: pack.cells.state.findIndex(x => x === i); // otherwise use the first valid cell
|
||||||
});
|
});
|
||||||
|
BurgsAndStates.getPoles();
|
||||||
|
|
||||||
// transfer provinces, mark provinces without land as removed.
|
// transfer provinces, mark provinces without land as removed.
|
||||||
stage("Porting provinces");
|
stage("Porting provinces");
|
||||||
|
|
@ -259,12 +254,11 @@ window.Submap = (function () {
|
||||||
const newCenters = forwardMap[p.center];
|
const newCenters = forwardMap[p.center];
|
||||||
p.center = newCenters.length ? newCenters[0] : pack.cells.province.findIndex(x => x === i);
|
p.center = newCenters.length ? newCenters[0] : pack.cells.province.findIndex(x => x === i);
|
||||||
});
|
});
|
||||||
|
Provinces.getPoles();
|
||||||
|
|
||||||
stage("Regenerating routes network");
|
stage("Regenerating routes network");
|
||||||
regenerateRoutes();
|
regenerateRoutes();
|
||||||
|
|
||||||
drawStateLabels();
|
|
||||||
|
|
||||||
Rivers.specify();
|
Rivers.specify();
|
||||||
Features.specify();
|
Features.specify();
|
||||||
|
|
||||||
|
|
@ -279,7 +273,6 @@ window.Submap = (function () {
|
||||||
}
|
}
|
||||||
s.military = s.military.filter(m => m.cell).map((m, i) => ({...m, i}));
|
s.military = s.military.filter(m => m.cell).map((m, i) => ({...m, i}));
|
||||||
}
|
}
|
||||||
drawMilitary();
|
|
||||||
|
|
||||||
stage("Copying markers");
|
stage("Copying markers");
|
||||||
for (const m of pack.markers) {
|
for (const m of pack.markers) {
|
||||||
|
|
@ -295,8 +288,6 @@ window.Submap = (function () {
|
||||||
}
|
}
|
||||||
if (layerIsOn("toggleMarkers")) drawMarkers();
|
if (layerIsOn("toggleMarkers")) drawMarkers();
|
||||||
|
|
||||||
stage("Redraw emblems");
|
|
||||||
drawEmblems();
|
|
||||||
stage("Regenerating Zones");
|
stage("Regenerating Zones");
|
||||||
Zones.generate();
|
Zones.generate();
|
||||||
Names.getMapName();
|
Names.getMapName();
|
||||||
|
|
|
||||||
|
|
@ -444,6 +444,7 @@ window.ThreeD = (function () {
|
||||||
const url = await getMapURL("mesh", {
|
const url = await getMapURL("mesh", {
|
||||||
noLabels: options.labels3d,
|
noLabels: options.labels3d,
|
||||||
noWater: options.extendedWater,
|
noWater: options.extendedWater,
|
||||||
|
noViewbox: true,
|
||||||
fullMap: true
|
fullMap: true
|
||||||
});
|
});
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
|
|
@ -623,7 +624,7 @@ window.ThreeD = (function () {
|
||||||
material.map = texture;
|
material.map = texture;
|
||||||
if (addMesh) addGlobe3dMesh();
|
if (addMesh) addGlobe3dMesh();
|
||||||
};
|
};
|
||||||
img2.src = await getMapURL("mesh", {noScaleBar: true, fullMap: true});
|
img2.src = await getMapURL("mesh", {noScaleBar: true, fullMap: true, noVignette: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addGlobe3dMesh() {
|
function addGlobe3dMesh() {
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ window.UISubmap = (function () {
|
||||||
fullMap: true,
|
fullMap: true,
|
||||||
noLabels: true,
|
noLabels: true,
|
||||||
noScaleBar: true,
|
noScaleBar: true,
|
||||||
|
noVignette: true,
|
||||||
noIce: true
|
noIce: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue