mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-04-04 14:37:24 +02:00
feat: relief three.js renderer
This commit is contained in:
parent
7a49098425
commit
7481a2843e
19 changed files with 828 additions and 120 deletions
|
|
@ -32,13 +32,12 @@ async function saveMap(method) {
|
|||
$(this).dialog("close");
|
||||
}
|
||||
},
|
||||
position: { my: "center", at: "center", of: "svg" }
|
||||
position: {my: "center", at: "center", of: "svg"}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function prepareMapData() {
|
||||
|
||||
const date = new Date();
|
||||
const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator";
|
||||
|
|
@ -79,7 +78,10 @@ function prepareMapData() {
|
|||
const fonts = JSON.stringify(getUsedFonts(svg.node()));
|
||||
|
||||
// save svg
|
||||
// Temporarily inject <use> elements so the SVG snapshot includes relief icon data
|
||||
if (typeof prepareReliefForSave === "function") prepareReliefForSave();
|
||||
const cloneEl = document.getElementById("map").cloneNode(true);
|
||||
if (typeof restoreReliefAfterSave === "function") restoreReliefAfterSave();
|
||||
|
||||
// reset transform values to default
|
||||
cloneEl.setAttribute("width", graphWidth);
|
||||
|
|
@ -90,8 +92,8 @@ function prepareMapData() {
|
|||
|
||||
const serializedSVG = new XMLSerializer().serializeToString(cloneEl);
|
||||
|
||||
const { spacing, cellsX, cellsY, boundary, points, features, cellsDesired } = grid;
|
||||
const gridGeneral = JSON.stringify({ spacing, cellsX, cellsY, boundary, points, features, cellsDesired });
|
||||
const {spacing, cellsX, cellsY, boundary, points, features, cellsDesired} = grid;
|
||||
const gridGeneral = JSON.stringify({spacing, cellsX, cellsY, boundary, points, features, cellsDesired});
|
||||
const packFeatures = JSON.stringify(pack.features);
|
||||
const cultures = JSON.stringify(pack.cultures);
|
||||
const states = JSON.stringify(pack.states);
|
||||
|
|
@ -165,14 +167,14 @@ function prepareMapData() {
|
|||
|
||||
// save map file to indexedDB
|
||||
async function saveToStorage(mapData, showTip = false) {
|
||||
const blob = new Blob([mapData], { type: "text/plain" });
|
||||
const blob = new Blob([mapData], {type: "text/plain"});
|
||||
await ldb.set("lastMap", blob);
|
||||
showTip && tip("Map is saved to the browser storage", false, "success");
|
||||
}
|
||||
|
||||
// download map file
|
||||
function saveToMachine(mapData, filename) {
|
||||
const blob = new Blob([mapData], { type: "text/plain" });
|
||||
const blob = new Blob([mapData], {type: "text/plain"});
|
||||
const URL = window.URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement("a");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue