동선이동 수정
This commit is contained in:
parent
c58146ca53
commit
46710533b5
@ -411,6 +411,35 @@ export function useMovementSetting(id) {
|
||||
|
||||
targetBaseLines.sort((a, b) => a.distance - b.distance)
|
||||
targetBaseLines = targetBaseLines.filter((line) => line.distance === targetBaseLines[0].distance)
|
||||
|
||||
if (isGableRoof) {
|
||||
const zeroLengthLines = targetBaseLines.filter(
|
||||
(line) => Math.sqrt(Math.pow(line.line.x2 - line.line.x1, 2) + Math.pow(line.line.y2 - line.line.y1, 2)) < 1,
|
||||
)
|
||||
if (zeroLengthLines.length > 0) {
|
||||
zeroLengthLines.forEach((line) => {
|
||||
const findLine = line.line
|
||||
const findCoords = [
|
||||
{ x: findLine.x1, y: findLine.y1 },
|
||||
{ x: findLine.x2, y: findLine.y2 },
|
||||
]
|
||||
wall.baseLines
|
||||
.filter((baseLine) => {
|
||||
return findCoords.some(
|
||||
(coord) =>
|
||||
(Math.abs(coord.x - baseLine.x1) < 0.1 && Math.abs(coord.y - baseLine.y1) < 0.1) ||
|
||||
(Math.abs(coord.x - baseLine.x2) < 0.1 && Math.abs(coord.y - baseLine.y2) < 0.1),
|
||||
)
|
||||
})
|
||||
.forEach((baseLine) => {
|
||||
const isAlready = targetBaseLines.find((target) => target.line === baseLine)
|
||||
if (isAlready) return
|
||||
targetBaseLines.push({ line: baseLine, distance: targetBaseLines[0].distance })
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let value
|
||||
if (typeRef.current === TYPE.FLOW_LINE) {
|
||||
value =
|
||||
@ -445,58 +474,56 @@ export function useMovementSetting(id) {
|
||||
}
|
||||
}
|
||||
value = value.div(10)
|
||||
targetBaseLines.forEach((target) => {
|
||||
const currentLine = target.line
|
||||
const index = baseLines.findIndex((line) => line === currentLine)
|
||||
const nextLine = baseLines[(index + 1) % baseLines.length]
|
||||
const prevLine = baseLines[(index - 1 + baseLines.length) % baseLines.length]
|
||||
let deltaX = 0
|
||||
let deltaY = 0
|
||||
if (currentLine.y1 === currentLine.y2) {
|
||||
deltaY = value.toNumber()
|
||||
} else {
|
||||
deltaX = value.toNumber()
|
||||
}
|
||||
targetBaseLines
|
||||
.filter((line) => Math.sqrt(Math.pow(line.line.x2 - line.line.x1, 2) + Math.pow(line.line.y2 - line.line.y1, 2)) >= 1)
|
||||
.forEach((target) => {
|
||||
const currentLine = target.line
|
||||
const index = baseLines.findIndex((line) => line === currentLine)
|
||||
const nextLine = baseLines[(index + 1) % baseLines.length]
|
||||
const prevLine = baseLines[(index - 1 + baseLines.length) % baseLines.length]
|
||||
let deltaX = 0
|
||||
let deltaY = 0
|
||||
if (currentLine.y1 === currentLine.y2) {
|
||||
deltaY = value.toNumber()
|
||||
} else {
|
||||
deltaX = value.toNumber()
|
||||
}
|
||||
|
||||
currentLine.set({
|
||||
x1: currentLine.x1 + deltaX,
|
||||
y1: currentLine.y1 + deltaY,
|
||||
x2: currentLine.x2 + deltaX,
|
||||
y2: currentLine.y2 + deltaY,
|
||||
startPoint: { x: currentLine.x1 + deltaX, y: currentLine.y1 + deltaY },
|
||||
endPoint: { x: currentLine.x2 + deltaX, y: currentLine.y2 + deltaY },
|
||||
})
|
||||
const currentSize = calcLinePlaneSize({
|
||||
x1: currentLine.x1,
|
||||
y1: currentLine.y1,
|
||||
x2: currentLine.x2,
|
||||
y2: currentLine.y2,
|
||||
})
|
||||
currentLine.attributes.planeSize = currentSize
|
||||
currentLine.attributes.actualSize = currentSize
|
||||
currentLine.set({
|
||||
x1: currentLine.x1 + deltaX,
|
||||
y1: currentLine.y1 + deltaY,
|
||||
x2: currentLine.x2 + deltaX,
|
||||
y2: currentLine.y2 + deltaY,
|
||||
startPoint: { x: currentLine.x1 + deltaX, y: currentLine.y1 + deltaY },
|
||||
endPoint: { x: currentLine.x2 + deltaX, y: currentLine.y2 + deltaY },
|
||||
})
|
||||
const currentSize = calcLinePlaneSize({
|
||||
x1: currentLine.x1,
|
||||
y1: currentLine.y1,
|
||||
x2: currentLine.x2,
|
||||
y2: currentLine.y2,
|
||||
})
|
||||
currentLine.attributes.planeSize = currentSize
|
||||
currentLine.attributes.actualSize = currentSize
|
||||
|
||||
const nextOldActualSize = nextLine.attributes.planeSize
|
||||
nextLine.set({
|
||||
x1: nextLine.x1 + deltaX,
|
||||
y1: nextLine.y1 + deltaY,
|
||||
startPoint: { x: nextLine.x1 + deltaX, y: nextLine.y1 + deltaY },
|
||||
})
|
||||
const nextSize = calcLinePlaneSize({ x1: nextLine.x1, y1: nextLine.y1, x2: nextLine.x2, y2: nextLine.y2 })
|
||||
nextLine.attributes.planeSize = nextSize
|
||||
nextLine.attributes.actualSize = nextSize
|
||||
nextLine.set({
|
||||
x1: currentLine.x2,
|
||||
y1: currentLine.y2,
|
||||
startPoint: { x: currentLine.x2, y: currentLine.y2 },
|
||||
})
|
||||
const nextSize = calcLinePlaneSize({ x1: nextLine.x1, y1: nextLine.y1, x2: nextLine.x2, y2: nextLine.y2 })
|
||||
nextLine.attributes.planeSize = nextSize
|
||||
nextLine.attributes.actualSize = nextSize
|
||||
|
||||
const prevOldActualSize = prevLine.attributes.planeSize
|
||||
prevLine.set({
|
||||
x2: prevLine.x2 + deltaX,
|
||||
y2: prevLine.y2 + deltaY,
|
||||
endPoint: { x: prevLine.x2 + deltaX, y: prevLine.y2 + deltaY },
|
||||
prevLine.set({
|
||||
x2: currentLine.x1,
|
||||
y2: currentLine.y1,
|
||||
endPoint: { x: currentLine.x1, y: currentLine.y1 },
|
||||
})
|
||||
const prevSize = calcLinePlaneSize({ x1: prevLine.x1, y1: prevLine.y1, x2: prevLine.x2, y2: prevLine.y2 })
|
||||
prevLine.attributes.planeSize = prevSize
|
||||
prevLine.attributes.actualSize = prevSize
|
||||
})
|
||||
const prevSize = calcLinePlaneSize({ x1: prevLine.x1, y1: prevLine.y1, x2: prevLine.x2, y2: prevLine.y2 })
|
||||
prevLine.attributes.planeSize = prevSize
|
||||
prevLine.attributes.actualSize = prevSize
|
||||
|
||||
canvas.renderAll()
|
||||
})
|
||||
|
||||
roof.drawHelpLine()
|
||||
initEvent()
|
||||
|
||||
@ -600,9 +600,10 @@ export const drawGableRoof = (roofId, canvas, textMode) => {
|
||||
}
|
||||
})
|
||||
|
||||
let currentRoof = intersectRoofLines.find((roof) => isPointOnLineNew(roof.roofLine, roof.intersect))
|
||||
intersectRoofLines.sort((a, b) => a.length - b.length)
|
||||
let currentRoof = intersectRoofLines.find((roof) => isPointOnLineNew(roof.roofLine, roof.intersect) && roof.length - offset < 0.1)
|
||||
if (!currentRoof) {
|
||||
currentRoof = intersectRoofLines.sort((a, b) => a.length - b.length)[0]
|
||||
currentRoof = intersectRoofLines[0]
|
||||
}
|
||||
|
||||
let startPoint, endPoint
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user