사이즈 변경 시 1. 왼쪽 위 고정, 2. 오른쪽 아래 고정
This commit is contained in:
parent
58fbb34c74
commit
ad5fa31576
@ -88,15 +88,26 @@ export default function AuxiliarySize(props) {
|
|||||||
// 현재 선분의 길이와 입력된 길이의 차이를 구한다.
|
// 현재 선분의 길이와 입력된 길이의 차이를 구한다.
|
||||||
const scaleFactor = Big(size).div(distance)
|
const scaleFactor = Big(size).div(distance)
|
||||||
|
|
||||||
//1지점 선택일때는 2지점의 좌표, 2지점 선택일때는 1지점의 좌표를 조정한다.
|
// [SIZE-ANCHOR 2026-06-22] 저장된 x1/x2 끝점 순서가 라인마다 달라(왼쪽 선은 1지점이 위, 오른쪽 선은 1지점이 아래)
|
||||||
|
// 동일하게 늘려도 방향이 반대로 보이던 문제 수정. 화면 기준으로 1지점=왼쪽 위, 2지점=오른쪽 아래로 통일한다.
|
||||||
|
// (외벽선 오프셋 useWallLineOffsetSetting 의 "1지점=down/right, 2지점=up/left" 컨벤션과 동일)
|
||||||
|
// 수직선(x 동일)은 위쪽을, 그 외는 왼쪽을 1지점(왼쪽 위)으로 판별한다.
|
||||||
|
const VERTICAL_EPS = 1 // 캔버스 단위(≈10mm) — 이 이하의 x 차이는 수직선으로 간주
|
||||||
|
const p1IsTopLeft = Math.abs(x1 - x2) > VERTICAL_EPS ? x1 < x2 : y1 <= y2
|
||||||
|
const topLeft = p1IsTopLeft ? { x: x1, y: y1 } : { x: x2, y: y2 }
|
||||||
|
const bottomRight = p1IsTopLeft ? { x: x2, y: y2 } : { x: x1, y: y1 }
|
||||||
|
|
||||||
|
//1지점(왼쪽 위) 고정 → 오른쪽 아래 끝점을 늘린다(down/right). 2지점(오른쪽 아래) 고정 → 왼쪽 위 끝점을 늘린다(up/left).
|
||||||
if (checkedRadio === 1) {
|
if (checkedRadio === 1) {
|
||||||
const newX2 = Big(x1).plus(dx.times(scaleFactor)).toNumber()
|
const newBrX = Big(topLeft.x).plus(Big(bottomRight.x).minus(topLeft.x).times(scaleFactor)).toNumber()
|
||||||
const newY2 = Big(y1).plus(dy.times(scaleFactor)).toNumber()
|
const newBrY = Big(topLeft.y).plus(Big(bottomRight.y).minus(topLeft.y).times(scaleFactor)).toNumber()
|
||||||
currentObject.set({ x2: newX2, y2: newY2 })
|
if (p1IsTopLeft) currentObject.set({ x2: newBrX, y2: newBrY })
|
||||||
|
else currentObject.set({ x1: newBrX, y1: newBrY })
|
||||||
} else if (checkedRadio === 2) {
|
} else if (checkedRadio === 2) {
|
||||||
const newX1 = Big(x2).minus(dx.times(scaleFactor)).toNumber()
|
const newTlX = Big(bottomRight.x).plus(Big(topLeft.x).minus(bottomRight.x).times(scaleFactor)).toNumber()
|
||||||
const newY1 = Big(y2).minus(dy.times(scaleFactor)).toNumber()
|
const newTlY = Big(bottomRight.y).plus(Big(topLeft.y).minus(bottomRight.y).times(scaleFactor)).toNumber()
|
||||||
currentObject.set({ x1: newX1, y1: newY1 })
|
if (p1IsTopLeft) currentObject.set({ x1: newTlX, y1: newTlY })
|
||||||
|
else currentObject.set({ x2: newTlX, y2: newTlY })
|
||||||
}
|
}
|
||||||
//planeSize와 actualSize를 재계산한다.
|
//planeSize와 actualSize를 재계산한다.
|
||||||
currentObject.attributes.planeSize = calcLinePlaneSize({
|
currentObject.attributes.planeSize = calcLinePlaneSize({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user