From fecc4e999a39fb4b263a5a9f405964cea917b3ff Mon Sep 17 00:00:00 2001 From: Cha Date: Sun, 2 Nov 2025 00:48:53 +0900 Subject: [PATCH 1/2] =?UTF-8?q?baseLine=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useMovementSetting.js | 35 ++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/hooks/roofcover/useMovementSetting.js b/src/hooks/roofcover/useMovementSetting.js index 91ca0093..e52003b3 100644 --- a/src/hooks/roofcover/useMovementSetting.js +++ b/src/hooks/roofcover/useMovementSetting.js @@ -263,12 +263,33 @@ export function useMovementSetting(id) { const currentY = Big(getIntersectMousePoint(e).y) let value = '' - if (Math.abs(target.y1 - target.y2) < 0.5) { + let direction = '' + + if (Math.abs(target.y1 - target.y2) < 0.5) { // 수평 라인 value = Big(targetTop).minus(currentY).times(10).round(0) - } else { + + // 방향 감지 + if (value.toNumber() > 0) { + direction = 'up' // 마우스가 라인 위쪽에 있음 (위로 움직임) + } else if (value.toNumber() < 0) { + direction = 'down' // 마우스가 라인 아래쪽에 있음 (아래로 움직임) + } + } else { // 수직 라인 value = Big(targetLeft).minus(currentX).times(10).round(0).neg() + + // 방향 감지 + if (value.toNumber() > 0) { + direction = 'right' // 마우스가 라인 오른쪽에 있음 (오른쪽으로 움직임) + } else if (value.toNumber() < 0) { + direction = 'left' // 마우스가 라인 왼쪽에 있음 (왼쪽으로 움직임) + } } + // 방향 정보를 사용하여 라디오 버튼 상태 업데이트 + + console.log(`방향: ${direction}, 값: ${value.toNumber()}`) + + currentCalculatedValue = value.toNumber() if (typeRef.current === TYPE.FLOW_LINE) { @@ -286,6 +307,8 @@ export function useMovementSetting(id) { const midY = Big(target.y1).plus(target.y2).div(2) const wall = canvas.getObjects().find((obj) => obj.id === target.attributes.wallId) + + const result = getSelectLinePosition(wall, target, { testDistance: 5, // 테스트 거리 debug: true // 디버깅 로그 출력 @@ -294,6 +317,7 @@ export function useMovementSetting(id) { //console.log("1111linePosition:::::", result.position); // 'top', 'bottom', 'left', 'right' let linePosition = result.position; +console.log("1111linePosition:::::", direction, linePosition); if (target.y1 === target.y2) { //수평벽 @@ -312,7 +336,9 @@ export function useMovementSetting(id) { setRadioStates(value.s !== 1); } + if(direction === 'up') { + } /* checkPoint = { x: midX.toNumber(), y: midY.plus(10).toNumber() } if (wall.inPolygon(checkPoint)) { //선택라인이 내부 @@ -376,6 +402,7 @@ export function useMovementSetting(id) { */ } } + } @@ -623,8 +650,8 @@ export function useMovementSetting(id) { debug: true // 디버깅 로그 출력 }); - //console.log("2222linePosition:::::", result.position); - + console.log("2222linePosition:::::", result.position); + console.log("222moveDirect:::::", roof.moveDirect); // 디버깅용 분류 결과 확인 From a3d1704390613ee9bfd133dc558d20576c236689 Mon Sep 17 00:00:00 2001 From: Cha Date: Sun, 2 Nov 2025 00:51:49 +0900 Subject: [PATCH 2/2] =?UTF-8?q?baseLine=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useMovementSetting.js | 8 ++++---- src/util/skeleton-utils.js | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/hooks/roofcover/useMovementSetting.js b/src/hooks/roofcover/useMovementSetting.js index e52003b3..cb5c0f02 100644 --- a/src/hooks/roofcover/useMovementSetting.js +++ b/src/hooks/roofcover/useMovementSetting.js @@ -287,7 +287,7 @@ export function useMovementSetting(id) { // 방향 정보를 사용하여 라디오 버튼 상태 업데이트 - console.log(`방향: ${direction}, 값: ${value.toNumber()}`) + //console.log(`방향: ${direction}, 값: ${value.toNumber()}`) currentCalculatedValue = value.toNumber() @@ -317,7 +317,7 @@ export function useMovementSetting(id) { //console.log("1111linePosition:::::", result.position); // 'top', 'bottom', 'left', 'right' let linePosition = result.position; -console.log("1111linePosition:::::", direction, linePosition); +//console.log("1111linePosition:::::", direction, linePosition); if (target.y1 === target.y2) { //수평벽 @@ -650,8 +650,8 @@ console.log("1111linePosition:::::", direction, linePosition); debug: true // 디버깅 로그 출력 }); - console.log("2222linePosition:::::", result.position); - console.log("222moveDirect:::::", roof.moveDirect); + //console.log("2222linePosition:::::", result.position); + //console.log("222moveDirect:::::", roof.moveDirect); // 디버깅용 분류 결과 확인 diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index 0571569b..6294faaf 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -1989,6 +1989,23 @@ export const getSelectLinePosition = (wall, selectLine, options = {}) => { const { x1, y1, x2, y2 } = lineCoords; + console.log('wall.points', wall.baseLines); + for(const line of wall.baseLines) { + console.log('line', line); + const basePoint = extractLineCoords(line); + const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = basePoint; + console.log('x1, y1, x2, y2', bx1, by1, bx2, by2); + + // 객체 비교 대신 좌표값 비교 + if (Math.abs(bx1 - x1) < 0.1 && + Math.abs(by1 - y1) < 0.1 && + Math.abs(bx2 - x2) < 0.1 && + Math.abs(by2 - y2) < 0.1) { + console.log('basePoint 일치!!!', basePoint); + } + } + + // 라인 방향 분석 const lineInfo = analyzeLineOrientation(x1, y1, x2, y2, epsilon); @@ -2086,10 +2103,6 @@ export const getSelectLinePosition = (wall, selectLine, options = {}) => { // 점이 다각형 내부에 있는지 확인하는 함수 const checkPointInPolygon = (point, wall) => { - // 1. wall의 inPolygon 메서드가 있으면 사용 - if (typeof wall.inPolygon === 'function') { - return wall.inPolygon(point); - } // 2. wall.baseLines를 이용한 Ray Casting Algorithm if (!wall.baseLines || !Array.isArray(wall.baseLines)) {