diff --git a/src/common/common.js b/src/common/common.js index ddd03e99..d2461d28 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -213,6 +213,7 @@ export const SAVE_KEY = [ 'editable', 'isSortedPoints', 'isMultipleOf45', + 'from', ] export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype, fabric.Group.prototype] diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 8f4a2a7e..d95cf077 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -133,7 +133,7 @@ export function useModuleBasicSetting(tabNum) { const offsetObjects = moduleSelectionData.roofConstructions.find((item) => item.addRoof.index === roofIndex) roof.lines.forEach((line) => { - line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type) } + line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type, roof.pitch, roof.from) } }) //배치면 설치 영역 makeModuleInstArea(roof, detail) @@ -167,19 +167,45 @@ export function useModuleBasicSetting(tabNum) { } } - const getOffset = (data, type) => { + const getOffset = (data, type, pitch, from = '') => { + const degree = getDegreeByChon(pitch) //각도 + + // 계산 값 + function calculateExpression(thetaDegrees) { + const thetaRadians = (thetaDegrees * Math.PI) / 180 // 각도를 라디안으로 변환 + const cosTheta = Math.cos(thetaRadians) + + if (cosTheta === 0) { + throw new Error('cos(θ) is zero') + } + + const numerator = Math.sqrt(1 + Math.pow(1 / cosTheta, 2)) + const denominator = Math.sqrt(2) + + return numerator / denominator + } + + //경사 신장률은 1 / cos쎄타 + const calculateHeightRate = 1 / Math.cos((degree * Math.PI) / 180) + const calculateValue = calculateHeightRate / calculateExpression(degree) + + const eavesResult = from === 'roofCover' ? (data.eavesMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.eavesMargin / 10 + const ridgeResult = from === 'roofCover' ? (data.ridgeMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.ridgeMargin / 10 + const kerabaMargin = from === 'roofCover' ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10 + switch (type) { case LINE_TYPE.WALLLINE.EAVES: - return data.eavesMargin / 10 + return eavesResult case LINE_TYPE.WALLLINE.GABLE: - return data.kerabaMargin / 10 + return kerabaMargin case LINE_TYPE.SUBLINE.RIDGE: case LINE_TYPE.WALLLINE.SHED: - return data.ridgeMargin / 10 + return ridgeResult default: return 200 / 10 } } + //선택 배치면 배열` let selectedModuleInstSurfaceArray = [] diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index b83d4ac4..5aa4b7f1 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -1158,6 +1158,7 @@ export const usePolygon = () => { originY: 'center', selectable: true, defense: defense, + from: 'roofCover', direction: polygonDirection ?? defense, pitch: pitch, })