보조선 관련된 흡착점 추가
This commit is contained in:
parent
8226f6cf3d
commit
10d7a6476a
@ -132,7 +132,7 @@ export function useEvent() {
|
|||||||
const roofsPoints = roofs.map((roof) => roof.points).flat()
|
const roofsPoints = roofs.map((roof) => roof.points).flat()
|
||||||
roofAdsorptionPoints.current = [...roofsPoints]
|
roofAdsorptionPoints.current = [...roofsPoints]
|
||||||
|
|
||||||
const auxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine' && !obj.isFixed)
|
const auxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine')
|
||||||
const otherAdsorptionPoints = []
|
const otherAdsorptionPoints = []
|
||||||
|
|
||||||
auxiliaryLines.forEach((line1) => {
|
auxiliaryLines.forEach((line1) => {
|
||||||
@ -179,7 +179,38 @@ export function useEvent() {
|
|||||||
|
|
||||||
const allAuxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine')
|
const allAuxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine')
|
||||||
|
|
||||||
const adsorptionPoints = [
|
allAuxiliaryLines.forEach((aux) => {
|
||||||
|
const roofs = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF)
|
||||||
|
|
||||||
|
roofs.forEach((roof) => {
|
||||||
|
//지붕과 보조선이 만나는 지점
|
||||||
|
roof.lines.forEach((line) => {
|
||||||
|
const intersectionPoint = calculateIntersection(aux, line)
|
||||||
|
if (intersectionPoint) {
|
||||||
|
intersectionPoints.current.push(intersectionPoint)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
//innerLines와 보조선이 만나는 지점
|
||||||
|
roof.innerLines.forEach((line) => {
|
||||||
|
const intersectionPoint = calculateIntersection(aux, line)
|
||||||
|
if (intersectionPoint) {
|
||||||
|
intersectionPoints.current.push(intersectionPoint)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// outerLines와의 교점
|
||||||
|
const outerLines = canvas.getObjects().filter((obj) => obj.name === 'outerLine')
|
||||||
|
outerLines.forEach((outerLine) => {
|
||||||
|
const intersectionPoint = calculateIntersection(aux, outerLine)
|
||||||
|
if (intersectionPoint) {
|
||||||
|
intersectionPoints.current.push(intersectionPoint)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
let adsorptionPoints = [
|
||||||
...getAdsorptionPoints(),
|
...getAdsorptionPoints(),
|
||||||
...roofAdsorptionPoints.current,
|
...roofAdsorptionPoints.current,
|
||||||
...otherAdsorptionPoints,
|
...otherAdsorptionPoints,
|
||||||
@ -200,6 +231,8 @@ export function useEvent() {
|
|||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
adsorptionPoints = removeDuplicatePoints(adsorptionPoints)
|
||||||
|
|
||||||
if (dotLineGridSetting.LINE || canvas.getObjects().filter((obj) => ['lineGrid', 'tempGrid'].includes(obj.name)).length > 1) {
|
if (dotLineGridSetting.LINE || canvas.getObjects().filter((obj) => ['lineGrid', 'tempGrid'].includes(obj.name)).length > 1) {
|
||||||
const closestLine = getClosestLineGrid(pointer)
|
const closestLine = getClosestLineGrid(pointer)
|
||||||
|
|
||||||
@ -451,6 +484,17 @@ export function useEvent() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const removeDuplicatePoints = (points) => {
|
||||||
|
const map = new Map()
|
||||||
|
points.forEach((point) => {
|
||||||
|
const key = `${point.x},${point.y}`
|
||||||
|
if (!map.has(key)) {
|
||||||
|
map.set(key, point)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return Array.from(map.values())
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addDocumentEventListener,
|
addDocumentEventListener,
|
||||||
addCanvasMouseEventListener,
|
addCanvasMouseEventListener,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user