diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index a8942814..3e706b84 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -982,15 +982,15 @@ export const usePolygon = () => { /*line.set({ strokeWidth: 5, stroke: 'green' }) canvas.add(line) canvas.renderAll()*/ - const startPoint = line.startPoint // 시작점 - let arrivalPoint = line.endPoint // 도착점 + const startPoint = { ...line.startPoint } // 시작점 + let arrivalPoint = { ...line.endPoint } // 도착점 let currentPoint = startPoint - const roofPoints = [startPoint] + let roofPoints = [startPoint] - const startLine = line - const visitPoints = [startPoint] - const visitLines = [startLine] + let startLine = line + let visitPoints = [startPoint] + let visitLines = [startLine] let notVisitedLines = [] let cnt = 0 @@ -1018,7 +1018,10 @@ export const usePolygon = () => { if (notVisitedLines.length === 0) { break } else { - // nextLines = [...notVisitedLines.shift().line] + let notVisitedLine = notVisitedLines.shift() + roofPoints = [...notVisitedLine.roofPoints] + currentPoint = { ...notVisitedLine.currentPoint } + continue } } @@ -1059,6 +1062,7 @@ export const usePolygon = () => { currentPoint = { ...minDistancePoint } roofPoints.push(currentPoint) cnt++ + if (cnt > 100) { break }