mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
fix added river basin selection
This commit is contained in:
parent
dbcf46f83b
commit
424980f5be
3 changed files with 10 additions and 10 deletions
|
|
@ -259,7 +259,7 @@
|
|||
};
|
||||
|
||||
// add points at 1/3 and 2/3 of a line between adjacents river cells
|
||||
const addMeandering = function (riverCells, meandering = 0.5, riverPoints = null) {
|
||||
const addMeandering = function (riverCells, riverPoints = null, meandering = 0.5) {
|
||||
const {fl, conf, h} = pack.cells;
|
||||
const meandered = [];
|
||||
const lastStep = riverCells.length - 1;
|
||||
|
|
|
|||
|
|
@ -1457,7 +1457,7 @@ function drawRivers() {
|
|||
const {addMeandering, getRiverPath} = Rivers;
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
const riverPaths = pack.rivers.map(river => {
|
||||
const riverMeandered = addMeandering(river.cells, 0.5, river.points);
|
||||
const riverMeandered = addMeandering(river.cells, river.points);
|
||||
const widthFactor = river.widthFactor || 1;
|
||||
const startingWidth = river.startingWidth || 0;
|
||||
const path = getRiverPath(riverMeandered, widthFactor, startingWidth);
|
||||
|
|
|
|||
|
|
@ -540,8 +540,8 @@ function addRiverOnClick() {
|
|||
|
||||
const {alterHeights, resolveDepressions, addMeandering, getRiverPath, getBasin, getName, getType, getWidth, getOffset, getApproximateLength} = Rivers;
|
||||
const riverCells = [];
|
||||
let riverId = last(rivers).id + 1;
|
||||
let parent = 0;
|
||||
let riverId = last(rivers).i + 1;
|
||||
let parent = riverId;
|
||||
|
||||
const initialFlux = grid.cells.prec[cells.g[i]];
|
||||
cells.fl[i] = initialFlux;
|
||||
|
|
@ -562,7 +562,7 @@ function addRiverOnClick() {
|
|||
|
||||
const feature = pack.features[cells.f[min]];
|
||||
if (feature.type === "lake") {
|
||||
parent = feature.outlet || 0;
|
||||
if (feature.outlet) parent = feature.outlet;
|
||||
feature.inlets ? feature.inlets.push(riverId) : (feature.inlets = [riverId]);
|
||||
}
|
||||
break;
|
||||
|
|
@ -618,11 +618,11 @@ function addRiverOnClick() {
|
|||
const source = riverCells[0];
|
||||
const mouth = riverCells[riverCells.length - 2];
|
||||
const widthFactor = river?.widthFactor || (!parent || parent === riverId ? 1.2 : 1);
|
||||
const riverMeandered = addMeandering(riverCells);
|
||||
const meanderedPoints = addMeandering(riverCells);
|
||||
|
||||
const discharge = cells.fl[mouth]; // m3 in second
|
||||
const length = getApproximateLength(riverMeandered);
|
||||
const width = getWidth(getOffset(discharge, riverMeandered.length, widthFactor));
|
||||
const length = getApproximateLength(meanderedPoints);
|
||||
const width = getWidth(getOffset(discharge, meanderedPoints.length, widthFactor));
|
||||
|
||||
if (river) {
|
||||
river.source = source;
|
||||
|
|
@ -640,10 +640,10 @@ function addRiverOnClick() {
|
|||
|
||||
// render river
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
const path = getRiverPath(riverMeandered, widthFactor);
|
||||
const path = getRiverPath(meanderedPoints, widthFactor);
|
||||
const id = "river" + riverId;
|
||||
const riversG = viewbox.select("#rivers");
|
||||
riversG.append("path").attr("d", path).attr("id", id);
|
||||
riversG.append("path").attr("id", id).attr("d", path);
|
||||
|
||||
if (d3.event.shiftKey === false) {
|
||||
Lakes.cleanupLakeData();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue