mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 18:41:23 +01:00
fefactor: edit coastline and lake
This commit is contained in:
parent
0f86a08012
commit
2744d32ca0
5 changed files with 164 additions and 168 deletions
|
|
@ -2,24 +2,16 @@
|
|||
|
||||
function drawFeatures() {
|
||||
TIME && console.time("drawFeatures");
|
||||
const {vertices, features} = pack;
|
||||
|
||||
const featurePaths = defs.select("#featurePaths");
|
||||
const landMask = defs.select("#land");
|
||||
const waterMask = defs.select("#water");
|
||||
const lineGen = d3.line().curve(d3.curveBasisClosed);
|
||||
|
||||
for (const feature of features) {
|
||||
for (const feature of pack.features) {
|
||||
if (!feature || feature.type === "ocean") continue;
|
||||
|
||||
const points = feature.vertices.map(vertex => vertices.p[vertex]);
|
||||
const simplifiedPoints = simplify(points, 0.3);
|
||||
const clippedPoints = clipPoly(simplifiedPoints, 1);
|
||||
const path = round(lineGen(clippedPoints));
|
||||
|
||||
featurePaths
|
||||
.append("path")
|
||||
.attr("d", path)
|
||||
.attr("d", getFeaturePath(feature))
|
||||
.attr("id", "feature_" + feature.i)
|
||||
.attr("data-f", feature.i);
|
||||
|
||||
|
|
@ -56,3 +48,14 @@ function drawFeatures() {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue