From 4403e36e0f348f6e9de97220ebfc0fbb20ad182d Mon Sep 17 00:00:00 2001 From: yjnoh Date: Mon, 7 Oct 2024 15:27:22 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8F=84=EB=A8=B8=20=EB=B0=B8=EB=A6=AC?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=ED=94=84=EB=A1=9C=ED=8D=BC=ED=8B=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useMode.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/hooks/useMode.js b/src/hooks/useMode.js index ec0842b8..04ec7685 100644 --- a/src/hooks/useMode.js +++ b/src/hooks/useMode.js @@ -4873,13 +4873,14 @@ export function useMode() { let turfPolygon let manualDrawCells = drewRoofCells // 앞에서 자동으로 했을때 추가됨 let direction - + let trestlePolygon canvas.on('mouse:move', (e) => { //마우스 이벤트 삭제 후 재추가 const mousePoint = canvas.getPointer(e.e) for (let i = 0; i < trestlePolygons.length; i++) { turfPolygon = polygonToTurfPolygon(trestlePolygons[i]) + trestlePolygon = trestlePolygons[i] direction = trestlePolygons[i].direction //도형의 방향 let width = direction === 'south' || direction === 'north' ? 172 : 113 let height = direction === 'south' || direction === 'north' ? 113 : 172 @@ -5050,6 +5051,7 @@ export function useMode() { fabricPolygon.setCoords() canvas?.renderAll() inside = true + break } else { inside = false } @@ -5078,12 +5080,12 @@ export function useMode() { fabricPolygon.set({ points: rectPoints }) const tempTurfModule = polygonToTurfPolygon(fabricPolygon) + //도머 객체를 가져옴 if (dormerTrestlePolygons) { dormerTrestlePolygons.forEach((dormerTrestle) => { - const dormerTurfPolygon = polygonToTurfPolygon(dormerTrestle) - - const intersection = turf.intersect(turf.featureCollection([dormerTurfPolygon, tempTurfModule])) - + const dormerTurfPolygon = polygonToTurfPolygon(dormerTrestle) //turf객체로 변환 + const intersection = turf.intersect(turf.featureCollection([dormerTurfPolygon, tempTurfModule])) //겹치는지 확인 + //겹치면 안됨 if (intersection) { alert('도머위에 모듈을 올릴 수 없습니다.') isIntersection = false @@ -5097,18 +5099,21 @@ export function useMode() { if (turf.booleanWithin(tempTurfModule, turfPolygon)) { //마우스 클릭시 set으로 해당 위치에 셀을 넣음 - - const isOverlap = manualDrawCells.some((cell) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(cell))) + const isOverlap = manualDrawCells.some((cell) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(cell))) //겹치는지 확인 if (!isOverlap) { //안겹치면 넣는다 fabricPolygon.setCoords() fabricPolygon.set({ name: 'cell', fill: '#BFFD9F' }) - manualDrawCells.push(fabricPolygon) + manualDrawCells.push(fabricPolygon) //모듈배열에 추가 + //해당 모듈에 프로퍼티로 넣는다 + trestlePolygon.set({ + modules: manualDrawCells, + }) } else { alert('셀끼리 겹치면 안되죠?') } } else { - alert('나갔으요!!') + alert('나갔죠?!!') } setDrewRoofCells(manualDrawCells) }