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) }