mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
* feat: render states - use global fn * feat: render states - separate pole detection from layer render * feat: render provinces * chore: unify drawFillWithGap * refactor: drawIce * refactor: drawBorders * refactor: drawHeightmap * refactor: drawTemperature * refactor: drawBiomes * refactor: drawPrec * refactor: drawPrecipitation * refactor: drawPopulation * refactor: drawCells * refactor: geColor * refactor: drawMarkers * refactor: drawScaleBar * refactor: drawScaleBar * refactor: drawMilitary * refactor: pump version to 1.104.00 * refactor: pump version to 1.104.00 * refactor: drawCoastline and createDefaultRuler * refactor: drawCoastline * refactor: Features module start * refactor: features - define distance fields * feat: drawFeatures * feat: drawIce don't hide * feat: detect coastline - fix issue with border feature * feat: separate labels rendering from generation process * feat: auto-update and restore layers * refactor - change layers * refactor - sort layers * fix: regenerate burgs to re-render layers * fix: getColor is not defined * fix: burgs overview - don't auto-show labels on hover * fix: redraw population on change * refactor: improve tooltip logic for burg labels and icons * chore: pump version to 1.104.0 * fefactor: edit coastline and lake * fix: minot fixes * fix: submap --------- Co-authored-by: Azgaar <azgaar.fmg@yandex.com>
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
"use strict";
|
|
|
|
function drawFeatures() {
|
|
TIME && console.time("drawFeatures");
|
|
const featurePaths = defs.select("#featurePaths");
|
|
const landMask = defs.select("#land");
|
|
const waterMask = defs.select("#water");
|
|
|
|
for (const feature of pack.features) {
|
|
if (!feature || feature.type === "ocean") continue;
|
|
|
|
featurePaths
|
|
.append("path")
|
|
.attr("d", getFeaturePath(feature))
|
|
.attr("id", "feature_" + feature.i)
|
|
.attr("data-f", feature.i);
|
|
|
|
if (feature.type === "lake") {
|
|
landMask
|
|
.append("use")
|
|
.attr("href", "#feature_" + feature.i)
|
|
.attr("data-f", feature.i)
|
|
.attr("fill", "black");
|
|
lakes
|
|
.select(`#${feature.group}`)
|
|
.append("use")
|
|
.attr("href", "#feature_" + feature.i)
|
|
.attr("data-f", feature.i);
|
|
} else {
|
|
landMask
|
|
.append("use")
|
|
.attr("href", "#feature_" + feature.i)
|
|
.attr("data-f", feature.i)
|
|
.attr("fill", "white");
|
|
waterMask
|
|
.append("use")
|
|
.attr("href", "#feature_" + feature.i)
|
|
.attr("data-f", feature.i)
|
|
.attr("fill", "black");
|
|
const coastlineGroup = feature.group === "lake_island" ? "#lake_island" : "#sea_island";
|
|
coastline
|
|
.select(coastlineGroup)
|
|
.append("use")
|
|
.attr("href", "#feature_" + feature.i)
|
|
.attr("data-f", feature.i);
|
|
}
|
|
}
|
|
|
|
TIME && console.timeEnd("drawFeatures");
|
|
}
|
|
|
|
function getFeaturePath(feature) {
|
|
const points = feature.vertices.map(vertex => pack.vertices.p[vertex]);
|
|
const simplifiedPoints = simplify(points, 0.3);
|
|
const clippedPoints = clipPoly(simplifiedPoints, 1);
|
|
|
|
const lineGen = d3.line().curve(d3.curveBasisClosed);
|
|
const path = round(lineGen(clippedPoints));
|
|
|
|
return path;
|
|
}
|