From d60a38594c7d6baae36c5fd261ba7db771ecaf21 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 13 Mar 2025 11:21:11 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B0=80=EB=8C=80=20=EC=84=A4=EC=B9=98=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useTrestle.js | 40 +++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index da4e8a30..b4f06250 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -1730,7 +1730,7 @@ export const useTrestle = () => { const { width, height } = { ...module } widthArr.push(width) heightArr.push(height) - centerPoints.push({ x, y, width: Math.floor(width), height: Math.floor(height), index, moduleInfo: module.moduleInfo }) + centerPoints.push({ x, y, width: Math.floor(width), height: Math.floor(height), index, moduleInfo: module.moduleInfo, module }) }) //widthArr 중복 제거 1이상 차이가 나지 않으면 같은 너비로 간주 @@ -1804,7 +1804,13 @@ export const useTrestle = () => { let rightExposedHalfTopPoints = [] centerPoints.forEach((centerPoint, index) => { - let { x, y, width, height, widthArr, heightArr } = { ...centerPoint } + let { x, y, width, height, widthArr, heightArr, module } = { ...centerPoint } + + /* 디버깅용 + const originFill = module.fill + module.set('fill', 'red') + canvas.renderAll()*/ + // centerPoints중에 현재 centerPoint와 x값이 같고, y값이 y-height값과 같은 centerPoint가 있는지 확인 let bottomCell let bottomLeftPoint @@ -1894,7 +1900,12 @@ export const useTrestle = () => { break } + /** + * 디버깅용 + module.set('fill', originFill) + canvas.renderAll() + */ if (bottomCell) { return } @@ -1911,13 +1922,18 @@ export const useTrestle = () => { } } else if (leftBottomCnt + rightBottomCnt === 0) { exposedBottomPoints.push(centerPoint) + } else if (leftBottomCnt + rightBottomCnt === 2) { + touchDimension++ } }) // 노출상면 및 접면 체크 centerPoints.forEach((centerPoint, index) => { - let { x, y, width, height, widthArr, heightArr } = { ...centerPoint } - + let { x, y, width, height, widthArr, heightArr, module } = { ...centerPoint } + const originFill = module.fill + /* 디버깅용 + module.set('fill', 'blue') + canvas.renderAll()*/ let topCell let topLeftPoint let topRightPoint @@ -1930,7 +1946,8 @@ export const useTrestle = () => { height = height + vertical heightArr.forEach((h) => { if (topCell) return - topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + h)) < maxY) + topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - h)) < maxY) + if (leftTopCnt === 0) { topLeftPoint = { x: x - width / 2, y: y - h } leftTopCnt = centerPoints.filter( @@ -1949,7 +1966,7 @@ export const useTrestle = () => { height = height + vertical heightArr.forEach((h) => { if (topCell) return - topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - h)) < maxY) + topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + h)) < maxY) if (leftTopCnt === 0) { topLeftPoint = { x: x + width / 2, y: y + h } leftTopCnt = centerPoints.filter( @@ -1968,7 +1985,7 @@ export const useTrestle = () => { width = width + horizontal widthArr.forEach((w) => { if (topCell) return - topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + w)) < maxX && Math.abs(centerPoint.y - y) < maxY) + topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - w)) < maxX && Math.abs(centerPoint.y - y) < maxY) if (leftTopCnt === 0) { topLeftPoint = { x: x - w, y: y + height / 2 } leftTopCnt = centerPoints.filter( @@ -1988,7 +2005,7 @@ export const useTrestle = () => { width = width + horizontal widthArr.forEach((w) => { if (topCell) return - topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - w)) < maxX && Math.abs(centerPoint.y - y) < maxY) + topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + w)) < maxX && Math.abs(centerPoint.y - y) < maxY) if (leftTopCnt === 0) { topLeftPoint = { x: x + w, y: y - height / 2 } leftTopCnt = centerPoints.filter( @@ -2010,6 +2027,13 @@ export const useTrestle = () => { return } + /** + * 디버깅 용 + + module.set('fill', originFill) + canvas.renderAll() + */ + if (leftTopCnt + rightTopCnt === 2) { touchDimension++ return