도머 밸리데이션 추가 모듈 프로퍼티 추가
This commit is contained in:
parent
98c37b725a
commit
4403e36e0f
@ -4873,13 +4873,14 @@ export function useMode() {
|
|||||||
let turfPolygon
|
let turfPolygon
|
||||||
let manualDrawCells = drewRoofCells // 앞에서 자동으로 했을때 추가됨
|
let manualDrawCells = drewRoofCells // 앞에서 자동으로 했을때 추가됨
|
||||||
let direction
|
let direction
|
||||||
|
let trestlePolygon
|
||||||
canvas.on('mouse:move', (e) => {
|
canvas.on('mouse:move', (e) => {
|
||||||
//마우스 이벤트 삭제 후 재추가
|
//마우스 이벤트 삭제 후 재추가
|
||||||
const mousePoint = canvas.getPointer(e.e)
|
const mousePoint = canvas.getPointer(e.e)
|
||||||
|
|
||||||
for (let i = 0; i < trestlePolygons.length; i++) {
|
for (let i = 0; i < trestlePolygons.length; i++) {
|
||||||
turfPolygon = polygonToTurfPolygon(trestlePolygons[i])
|
turfPolygon = polygonToTurfPolygon(trestlePolygons[i])
|
||||||
|
trestlePolygon = trestlePolygons[i]
|
||||||
direction = trestlePolygons[i].direction //도형의 방향
|
direction = trestlePolygons[i].direction //도형의 방향
|
||||||
let width = direction === 'south' || direction === 'north' ? 172 : 113
|
let width = direction === 'south' || direction === 'north' ? 172 : 113
|
||||||
let height = direction === 'south' || direction === 'north' ? 113 : 172
|
let height = direction === 'south' || direction === 'north' ? 113 : 172
|
||||||
@ -5050,6 +5051,7 @@ export function useMode() {
|
|||||||
fabricPolygon.setCoords()
|
fabricPolygon.setCoords()
|
||||||
canvas?.renderAll()
|
canvas?.renderAll()
|
||||||
inside = true
|
inside = true
|
||||||
|
break
|
||||||
} else {
|
} else {
|
||||||
inside = false
|
inside = false
|
||||||
}
|
}
|
||||||
@ -5078,12 +5080,12 @@ export function useMode() {
|
|||||||
fabricPolygon.set({ points: rectPoints })
|
fabricPolygon.set({ points: rectPoints })
|
||||||
const tempTurfModule = polygonToTurfPolygon(fabricPolygon)
|
const tempTurfModule = polygonToTurfPolygon(fabricPolygon)
|
||||||
|
|
||||||
|
//도머 객체를 가져옴
|
||||||
if (dormerTrestlePolygons) {
|
if (dormerTrestlePolygons) {
|
||||||
dormerTrestlePolygons.forEach((dormerTrestle) => {
|
dormerTrestlePolygons.forEach((dormerTrestle) => {
|
||||||
const dormerTurfPolygon = polygonToTurfPolygon(dormerTrestle)
|
const dormerTurfPolygon = polygonToTurfPolygon(dormerTrestle) //turf객체로 변환
|
||||||
|
const intersection = turf.intersect(turf.featureCollection([dormerTurfPolygon, tempTurfModule])) //겹치는지 확인
|
||||||
const intersection = turf.intersect(turf.featureCollection([dormerTurfPolygon, tempTurfModule]))
|
//겹치면 안됨
|
||||||
|
|
||||||
if (intersection) {
|
if (intersection) {
|
||||||
alert('도머위에 모듈을 올릴 수 없습니다.')
|
alert('도머위에 모듈을 올릴 수 없습니다.')
|
||||||
isIntersection = false
|
isIntersection = false
|
||||||
@ -5097,18 +5099,21 @@ export function useMode() {
|
|||||||
|
|
||||||
if (turf.booleanWithin(tempTurfModule, turfPolygon)) {
|
if (turf.booleanWithin(tempTurfModule, turfPolygon)) {
|
||||||
//마우스 클릭시 set으로 해당 위치에 셀을 넣음
|
//마우스 클릭시 set으로 해당 위치에 셀을 넣음
|
||||||
|
const isOverlap = manualDrawCells.some((cell) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(cell))) //겹치는지 확인
|
||||||
const isOverlap = manualDrawCells.some((cell) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(cell)))
|
|
||||||
if (!isOverlap) {
|
if (!isOverlap) {
|
||||||
//안겹치면 넣는다
|
//안겹치면 넣는다
|
||||||
fabricPolygon.setCoords()
|
fabricPolygon.setCoords()
|
||||||
fabricPolygon.set({ name: 'cell', fill: '#BFFD9F' })
|
fabricPolygon.set({ name: 'cell', fill: '#BFFD9F' })
|
||||||
manualDrawCells.push(fabricPolygon)
|
manualDrawCells.push(fabricPolygon) //모듈배열에 추가
|
||||||
|
//해당 모듈에 프로퍼티로 넣는다
|
||||||
|
trestlePolygon.set({
|
||||||
|
modules: manualDrawCells,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
alert('셀끼리 겹치면 안되죠?')
|
alert('셀끼리 겹치면 안되죠?')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert('나갔으요!!')
|
alert('나갔죠?!!')
|
||||||
}
|
}
|
||||||
setDrewRoofCells(manualDrawCells)
|
setDrewRoofCells(manualDrawCells)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user