From 59d3bd61e2d45a05fbaa406c7d5ea1b3f6a01a86 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 24 Jul 2025 13:19:09 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=80=EB=B6=95=EB=A9=B4=20=ED=95=A0?= =?UTF-8?q?=EB=8B=B9=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/usePolygon.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 988213f7..21429d66 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -1444,22 +1444,23 @@ export const usePolygon = () => { startLines.forEach((startLine) => { // 현재 남아있는 line들로 그래프 생성 const graph = {} - const edges = remainingLines - .filter((line2) => line2 !== startLine) - .map((line) => { - return [line.startPoint, line.endPoint] - }) - for (const [p1, p2] of edges) { + for (const line of remainingLines.filter((line2) => line2 !== startLine)) { + const p1 = line.startPoint + const p2 = line.endPoint const key1 = pointToKey(p1) const key2 = pointToKey(p2) const distance = calcDistance(p1, p2) + const isStartLine = line.attributes?.isStart === true if (!graph[key1]) graph[key1] = [] if (!graph[key2]) graph[key2] = [] - graph[key1].push({ point: p2, distance }) - graph[key2].push({ point: p1, distance }) + // isStart가 아닌 line을 우선하도록 distance 조정 + const adjustedDistance = isStartLine ? distance + 1000 : distance + + graph[key1].push({ point: p2, distance: adjustedDistance, line }) + graph[key2].push({ point: p1, distance: adjustedDistance, line }) } const startPoint = { ...startLine.startPoint } // 시작점