drawRivers: exit if no cells

This commit is contained in:
Azgaar 2021-08-24 11:17:51 +03:00
parent ad1a8cf17e
commit 6a9ba5109e

View file

@ -1458,14 +1458,15 @@ function drawRivers() {
TIME && console.time("drawRivers"); TIME && console.time("drawRivers");
const {addMeandering, getRiverPath} = Rivers; const {addMeandering, getRiverPath} = Rivers;
lineGen.curve(d3.curveCatmullRom.alpha(0.1)); lineGen.curve(d3.curveCatmullRom.alpha(0.1));
const riverPaths = pack.rivers.map(river => {
const meanderedPoints = addMeandering(river.cells, river.points); const riverPaths = pack.rivers.map(({cells, points, i, widthFactor, sourceWidth}) => {
const widthFactor = river.widthFactor || 1; if (!cells || cells.length < 2) return;
const startingWidth = river.sourceWidth || 0; const meanderedPoints = addMeandering(cells, points);
const path = getRiverPath(meanderedPoints, widthFactor, startingWidth); const path = getRiverPath(meanderedPoints, widthFactor, sourceWidth);
return `<path id="river${river.i}" d="${path}"/>`; return `<path id="river${i}" d="${path}"/>`;
}); });
rivers.html(riverPaths.join("")); rivers.html(riverPaths.join(""));
TIME && console.timeEnd("drawRivers"); TIME && console.timeEnd("drawRivers");
} }