mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
refactor: roads - Urquhart graph approach
This commit is contained in:
parent
bc98757b96
commit
b0f081b3ba
6 changed files with 167 additions and 46 deletions
|
|
@ -6,7 +6,7 @@ export function drawRoutes() {
|
|||
routes.selectAll("path").remove();
|
||||
|
||||
const {cells, burgs} = pack;
|
||||
const lineGen = d3.line().curve(d3.curveBasis);
|
||||
const lineGen = d3.line().curve(d3.curveCatmullRom.alpha(0.1));
|
||||
|
||||
const getBurgCoords = (burgId: number): TPoint => {
|
||||
if (!burgId) throw new Error("burgId must be positive");
|
||||
|
|
@ -24,8 +24,8 @@ export function drawRoutes() {
|
|||
|
||||
const routePaths: Dict<string[]> = {};
|
||||
|
||||
for (const {i, type, cells: routeCells} of pack.routes) {
|
||||
const points = getPathPoints(routeCells);
|
||||
for (const {i, type, cells} of pack.routes) {
|
||||
const points = getPathPoints(cells);
|
||||
const path = round(lineGen(points)!, 1);
|
||||
|
||||
if (!routePaths[type]) routePaths[type] = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue