mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 10:31:24 +01:00
efficiency
This commit is contained in:
parent
20dfb7cfcb
commit
21df872ca2
7 changed files with 466 additions and 210 deletions
|
|
@ -98,7 +98,21 @@ function overviewRoutes() {
|
|||
function zoomToRoute() {
|
||||
const routeId = +this.parentNode.dataset.id;
|
||||
const route = routes.select("#route" + routeId).node();
|
||||
highlightElement(route, 3);
|
||||
if (route) {
|
||||
highlightElement(route, 3);
|
||||
return;
|
||||
}
|
||||
// Fallback if SVG element not yet in DOM: center on route points
|
||||
const r = pack.routes.find(r => r.i === routeId);
|
||||
if (!r || !r.points || r.points.length === 0) return;
|
||||
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
||||
for (const [x, y] of r.points) {
|
||||
if (x < minX) minX = x; if (x > maxX) maxX = x;
|
||||
if (y < minY) minY = y; if (y > maxY) maxY = y;
|
||||
}
|
||||
const cx = (minX + maxX) / 2;
|
||||
const cy = (minY + maxY) / 2;
|
||||
zoomTo(cx, cy, 3, 1200);
|
||||
}
|
||||
|
||||
function downloadRoutesData() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue