@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/MathUtilsWorker.js +1 -8
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
- package/dist/_virtual/filterBoxWorker.js +1 -8
- package/dist/_virtual/highlightWorker.js +1 -8
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
- package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -5
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
- package/dist/constant/annotation.js +1 -127
- package/dist/constant/annotationTask.js +1 -30
- package/dist/constant/defaultConfig.js +1 -266
- package/dist/constant/keyCode.js +1 -38
- package/dist/constant/style.js +1 -98
- package/dist/constant/tool.js +1 -236
- package/dist/core/index.js +1 -150
- package/dist/core/pointCloud/OrbitControls.js +1 -665
- package/dist/core/pointCloud/PCDLoader.js +2 -260
- package/dist/core/pointCloud/annotation.js +1 -215
- package/dist/core/pointCloud/cache.js +1 -53
- package/dist/core/pointCloud/index.js +5 -991
- package/dist/core/pointCloud/matrix.js +1 -138
- package/dist/core/scheduler.js +1 -233
- package/dist/core/toolOperation/LineToolOperation.js +1 -1434
- package/dist/core/toolOperation/ScribbleTool.js +1 -292
- package/dist/core/toolOperation/TextToolOperation.js +1 -131
- package/dist/core/toolOperation/ViewOperation.js +1 -556
- package/dist/core/toolOperation/basicToolOperation.js +1 -881
- package/dist/core/toolOperation/checkOperation.js +1 -208
- package/dist/core/toolOperation/cuboidOperation.js +1 -754
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
- package/dist/core/toolOperation/eventListener.js +1 -37
- package/dist/core/toolOperation/measureOperation.js +1 -41
- package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
- package/dist/core/toolOperation/pointOperation.js +1 -696
- package/dist/core/toolOperation/polygonOperation.js +1 -1251
- package/dist/core/toolOperation/rectOperation.js +1 -1233
- package/dist/core/toolOperation/segmentByRect.js +1 -174
- package/dist/core/toolOperation/tagOperation.js +3 -201
- package/dist/core/toolOperation/textAttributeClass.js +16 -182
- package/dist/index.js +1 -185
- package/dist/locales/constants.js +1 -24
- package/dist/locales/en_US/message.js +1 -25
- package/dist/locales/index.js +1 -19
- package/dist/locales/zh_CN/message.js +1 -25
- package/dist/newCore/CanvasScheduler.js +1 -35
- package/dist/types/core/pointCloud/index.d.ts +2 -2
- package/dist/utils/ActionsHistory.js +1 -84
- package/dist/utils/ImgUtils.js +1 -23
- package/dist/utils/MathUtils.js +2 -385
- package/dist/utils/VectorUtils.js +1 -25
- package/dist/utils/tool/AttributeUtils.js +1 -218
- package/dist/utils/tool/AxisUtils.js +1 -340
- package/dist/utils/tool/CanvasUtils.js +1 -62
- package/dist/utils/tool/CommonToolUtils.js +1 -174
- package/dist/utils/tool/CuboidUtils.js +1 -704
- package/dist/utils/tool/DblClickEventListener.js +1 -102
- package/dist/utils/tool/DrawUtils.js +3 -492
- package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
- package/dist/utils/tool/ImgPosUtils.js +1 -58
- package/dist/utils/tool/LineToolUtils.js +1 -261
- package/dist/utils/tool/MarkerUtils.js +1 -56
- package/dist/utils/tool/PolygonUtils.js +1 -460
- package/dist/utils/tool/RectUtils.js +1 -155
- package/dist/utils/tool/RenderDomClass.js +7 -57
- package/dist/utils/tool/RenderDomUtils.js +4 -21
- package/dist/utils/tool/StyleUtils.js +1 -31
- package/dist/utils/tool/TagUtils.js +1 -129
- package/dist/utils/tool/UnitUtils.js +1 -12
- package/dist/utils/tool/ZoomUtils.js +1 -72
- package/dist/utils/tool/polygonTool.js +1 -133
- package/dist/utils/uuid.js +1 -26
- package/es/_virtual/MathUtilsWorker.js +1 -6
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
- package/es/_virtual/filterBoxWorker.js +1 -6
- package/es/_virtual/highlightWorker.js +1 -6
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
- package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
- package/es/constant/annotation.js +1 -113
- package/es/constant/annotationTask.js +1 -25
- package/es/constant/defaultConfig.js +1 -260
- package/es/constant/keyCode.js +1 -36
- package/es/constant/style.js +1 -74
- package/es/constant/tool.js +1 -220
- package/es/core/index.js +1 -148
- package/es/core/pointCloud/OrbitControls.js +1 -661
- package/es/core/pointCloud/PCDLoader.js +2 -256
- package/es/core/pointCloud/annotation.js +1 -211
- package/es/core/pointCloud/cache.js +1 -49
- package/es/core/pointCloud/index.js +5 -962
- package/es/core/pointCloud/matrix.js +1 -109
- package/es/core/scheduler.js +1 -228
- package/es/core/toolOperation/LineToolOperation.js +1 -1421
- package/es/core/toolOperation/ScribbleTool.js +1 -290
- package/es/core/toolOperation/TextToolOperation.js +1 -129
- package/es/core/toolOperation/ViewOperation.js +1 -549
- package/es/core/toolOperation/basicToolOperation.js +1 -877
- package/es/core/toolOperation/checkOperation.js +1 -206
- package/es/core/toolOperation/cuboidOperation.js +1 -752
- package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
- package/es/core/toolOperation/eventListener.js +1 -35
- package/es/core/toolOperation/measureOperation.js +1 -39
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
- package/es/core/toolOperation/pointOperation.js +1 -690
- package/es/core/toolOperation/polygonOperation.js +1 -1245
- package/es/core/toolOperation/rectOperation.js +1 -1228
- package/es/core/toolOperation/segmentByRect.js +1 -172
- package/es/core/toolOperation/tagOperation.js +3 -199
- package/es/core/toolOperation/textAttributeClass.js +16 -180
- package/es/index.js +1 -46
- package/es/locales/constants.js +1 -22
- package/es/locales/en_US/message.js +1 -23
- package/es/locales/index.js +1 -17
- package/es/locales/zh_CN/message.js +1 -23
- package/es/newCore/CanvasScheduler.js +1 -31
- package/es/utils/ActionsHistory.js +1 -78
- package/es/utils/ImgUtils.js +1 -21
- package/es/utils/MathUtils.js +2 -380
- package/es/utils/VectorUtils.js +1 -23
- package/es/utils/tool/AttributeUtils.js +1 -212
- package/es/utils/tool/AxisUtils.js +1 -335
- package/es/utils/tool/CanvasUtils.js +1 -60
- package/es/utils/tool/CommonToolUtils.js +1 -172
- package/es/utils/tool/CuboidUtils.js +1 -680
- package/es/utils/tool/DblClickEventListener.js +1 -100
- package/es/utils/tool/DrawUtils.js +3 -490
- package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
- package/es/utils/tool/ImgPosUtils.js +1 -56
- package/es/utils/tool/LineToolUtils.js +1 -255
- package/es/utils/tool/MarkerUtils.js +1 -54
- package/es/utils/tool/PolygonUtils.js +1 -458
- package/es/utils/tool/RectUtils.js +1 -153
- package/es/utils/tool/RenderDomClass.js +7 -55
- package/es/utils/tool/RenderDomUtils.js +4 -19
- package/es/utils/tool/StyleUtils.js +1 -29
- package/es/utils/tool/TagUtils.js +1 -127
- package/es/utils/tool/UnitUtils.js +1 -10
- package/es/utils/tool/ZoomUtils.js +1 -70
- package/es/utils/tool/polygonTool.js +1 -126
- package/es/utils/uuid.js +1 -24
- package/package.json +3 -4
- package/LICENSE +0 -203
- package/dist/core/pointCloud/segmentation.js +0 -144
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
- package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
- package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
- package/es/core/pointCloud/segmentation.js +0 -120
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
- package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
- package/es/core/toolOperation/scribbleTool2.js +0 -249
|
@@ -1,680 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ECuboidPlain, ECuboidPosition, ECuboidDirection, EDragTarget, DIAGONAL_POINT, ECuboidLineDirection, CUBOID_ROW, CUBOID_COLUMN } from '../../constant/annotation.js';
|
|
3
|
-
import AxisUtils from './AxisUtils.js';
|
|
4
|
-
import Vector from '../VectorUtils.js';
|
|
5
|
-
import LineToolUtils from './LineToolUtils.js';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __defProps = Object.defineProperties;
|
|
9
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
14
|
-
var __spreadValues = (a, b) => {
|
|
15
|
-
for (var prop in b || (b = {}))
|
|
16
|
-
if (__hasOwnProp.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
if (__getOwnPropSymbols)
|
|
19
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
-
if (__propIsEnum.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
};
|
|
25
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
function getPlanePointsBasicInfo({tr, tl, br}) {
|
|
27
|
-
return {
|
|
28
|
-
width: Math.abs(tr.x - tl.x),
|
|
29
|
-
height: Math.abs(br.y - tr.y),
|
|
30
|
-
centerPoints: {
|
|
31
|
-
x: (tl.x + br.x) / 2,
|
|
32
|
-
y: (tl.y + br.y) / 2
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function getCuboidBasicInfo({
|
|
37
|
-
frontPoints,
|
|
38
|
-
backPoints
|
|
39
|
-
}) {
|
|
40
|
-
const {width: frontWidth, height: frontHeight, centerPoints: frontCenter} = getPlanePointsBasicInfo(frontPoints);
|
|
41
|
-
const {width: backWidth, height: backHeight, centerPoints: backCenter} = getPlanePointsBasicInfo(backPoints);
|
|
42
|
-
return {
|
|
43
|
-
frontCenter,
|
|
44
|
-
backCenter,
|
|
45
|
-
frontWidth,
|
|
46
|
-
frontHeight,
|
|
47
|
-
backWidth,
|
|
48
|
-
backHeight,
|
|
49
|
-
isLeftSide: backCenter.x < frontCenter.x
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function getPlainPointsByDiagonalPoints(p1, p2) {
|
|
53
|
-
return {
|
|
54
|
-
tl: {
|
|
55
|
-
x: Math.min(p1.x, p2.x),
|
|
56
|
-
y: Math.min(p1.y, p2.y)
|
|
57
|
-
},
|
|
58
|
-
tr: {
|
|
59
|
-
x: Math.max(p1.x, p2.x),
|
|
60
|
-
y: Math.min(p1.y, p2.y)
|
|
61
|
-
},
|
|
62
|
-
bl: {
|
|
63
|
-
x: Math.min(p1.x, p2.x),
|
|
64
|
-
y: Math.max(p1.y, p2.y)
|
|
65
|
-
},
|
|
66
|
-
br: {
|
|
67
|
-
x: Math.max(p1.x, p2.x),
|
|
68
|
-
y: Math.max(p1.y, p2.y)
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function getMaxExternalQuadrilateral(points) {
|
|
73
|
-
const minX = Object.values(points).reduce((acc, coord) => coord.x < acc ? coord.x : acc, Number.MAX_SAFE_INTEGER);
|
|
74
|
-
const maxX = Object.values(points).reduce((acc, coord) => coord.x > acc ? coord.x : acc, 0);
|
|
75
|
-
const minY = Object.values(points).reduce((acc, coord) => coord.y < acc ? coord.y : acc, Number.MAX_SAFE_INTEGER);
|
|
76
|
-
const maxY = Object.values(points).reduce((acc, coord) => coord.y > acc ? coord.y : acc, 0);
|
|
77
|
-
return {
|
|
78
|
-
tl: {
|
|
79
|
-
x: minX,
|
|
80
|
-
y: minY
|
|
81
|
-
},
|
|
82
|
-
tr: {
|
|
83
|
-
x: maxX,
|
|
84
|
-
y: minY
|
|
85
|
-
},
|
|
86
|
-
bl: {
|
|
87
|
-
x: minX,
|
|
88
|
-
y: maxY
|
|
89
|
-
},
|
|
90
|
-
br: {
|
|
91
|
-
x: maxX,
|
|
92
|
-
y: maxY
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function judgeCuboidLineIsRowOrColumn(pointList) {
|
|
97
|
-
const [firstPosition, secondPosition] = pointList;
|
|
98
|
-
if (CUBOID_ROW[firstPosition.position] === secondPosition.position) {
|
|
99
|
-
return ECuboidLineDirection.Row;
|
|
100
|
-
}
|
|
101
|
-
if (CUBOID_COLUMN[firstPosition.position] === secondPosition.position) {
|
|
102
|
-
return ECuboidLineDirection.Column;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function getPointsByBottomRightPoint({
|
|
106
|
-
coord,
|
|
107
|
-
points
|
|
108
|
-
}) {
|
|
109
|
-
const {width, height} = getPlanePointsBasicInfo(points);
|
|
110
|
-
return {
|
|
111
|
-
br: coord,
|
|
112
|
-
tr: {
|
|
113
|
-
x: coord.x,
|
|
114
|
-
y: coord.y - height
|
|
115
|
-
},
|
|
116
|
-
tl: {
|
|
117
|
-
x: coord.x - width,
|
|
118
|
-
y: coord.y - height
|
|
119
|
-
},
|
|
120
|
-
bl: {
|
|
121
|
-
x: coord.x - width,
|
|
122
|
-
y: coord.y
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function getPointsByBottomLeftPoint({
|
|
127
|
-
coord,
|
|
128
|
-
points
|
|
129
|
-
}) {
|
|
130
|
-
const {width, height} = getPlanePointsBasicInfo(points);
|
|
131
|
-
return {
|
|
132
|
-
bl: coord,
|
|
133
|
-
tr: {
|
|
134
|
-
x: coord.x + width,
|
|
135
|
-
y: coord.y - height
|
|
136
|
-
},
|
|
137
|
-
tl: {
|
|
138
|
-
x: coord.x,
|
|
139
|
-
y: coord.y - height
|
|
140
|
-
},
|
|
141
|
-
br: {
|
|
142
|
-
x: coord.x + width,
|
|
143
|
-
y: coord.y
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function getCuboidShowingSideLine({
|
|
148
|
-
frontPoints,
|
|
149
|
-
backPoints
|
|
150
|
-
}) {
|
|
151
|
-
const {isLeftSide} = getCuboidBasicInfo({frontPoints, backPoints});
|
|
152
|
-
if (isLeftSide) {
|
|
153
|
-
return {
|
|
154
|
-
top: {
|
|
155
|
-
p1: frontPoints.tl,
|
|
156
|
-
p2: backPoints.tl
|
|
157
|
-
},
|
|
158
|
-
bottom: {
|
|
159
|
-
p1: frontPoints.bl,
|
|
160
|
-
p2: backPoints.bl
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
top: {
|
|
166
|
-
p1: frontPoints.tr,
|
|
167
|
-
p2: backPoints.tr
|
|
168
|
-
},
|
|
169
|
-
bottom: {
|
|
170
|
-
p1: frontPoints.br,
|
|
171
|
-
p2: backPoints.br
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function getPointsByIntersection({
|
|
176
|
-
frontPoints,
|
|
177
|
-
backPoints
|
|
178
|
-
}) {
|
|
179
|
-
const {isLeftSide} = getCuboidBasicInfo({frontPoints, backPoints});
|
|
180
|
-
let newBackPoints = __spreadValues({}, backPoints);
|
|
181
|
-
const sideLine = getCuboidShowingSideLine({frontPoints, backPoints});
|
|
182
|
-
const intersectionPoint = LineToolUtils.lineIntersection({pointA: sideLine.bottom.p1, pointB: sideLine.bottom.p2}, {pointA: sideLine.top.p1, pointB: sideLine.top.p2});
|
|
183
|
-
if (isLeftSide) {
|
|
184
|
-
const newBRPoint = LineToolUtils.lineIntersection({pointA: backPoints.bl, pointB: backPoints.br}, {pointA: frontPoints.br, pointB: intersectionPoint});
|
|
185
|
-
if (newBRPoint) {
|
|
186
|
-
newBackPoints = __spreadProps(__spreadValues({}, backPoints), {
|
|
187
|
-
br: newBRPoint,
|
|
188
|
-
tr: {
|
|
189
|
-
x: newBRPoint.x,
|
|
190
|
-
y: backPoints.tl.y
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
const newBLPoint = LineToolUtils.lineIntersection({pointA: backPoints.bl, pointB: backPoints.br}, {pointA: frontPoints.bl, pointB: intersectionPoint});
|
|
196
|
-
if (newBLPoint) {
|
|
197
|
-
newBackPoints = __spreadProps(__spreadValues({}, backPoints), {
|
|
198
|
-
bl: newBLPoint,
|
|
199
|
-
tl: {
|
|
200
|
-
x: newBLPoint.x,
|
|
201
|
-
y: backPoints.tr.y
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
backPoints: newBackPoints
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function getBackPointsByFrontPoints({
|
|
211
|
-
frontPoints,
|
|
212
|
-
backPoints
|
|
213
|
-
}) {
|
|
214
|
-
const {isLeftSide, frontHeight, backHeight} = getCuboidBasicInfo({frontPoints, backPoints});
|
|
215
|
-
let newBackPoints = __spreadValues({}, backPoints);
|
|
216
|
-
if (isLeftSide) {
|
|
217
|
-
newBackPoints = getPointsByBottomLeftPoint({coord: backPoints.bl, points: frontPoints});
|
|
218
|
-
} else {
|
|
219
|
-
newBackPoints = getPointsByBottomRightPoint({coord: backPoints.br, points: frontPoints});
|
|
220
|
-
}
|
|
221
|
-
if (frontHeight > backHeight) {
|
|
222
|
-
newBackPoints = getPointsByIntersection({frontPoints, backPoints}).backPoints;
|
|
223
|
-
}
|
|
224
|
-
return {frontPoints, backPoints: newBackPoints};
|
|
225
|
-
}
|
|
226
|
-
function getFrontPointsByBackPoints({
|
|
227
|
-
frontPoints,
|
|
228
|
-
backPoints
|
|
229
|
-
}) {
|
|
230
|
-
const {isLeftSide, frontHeight, backHeight, frontWidth, backWidth} = getCuboidBasicInfo({
|
|
231
|
-
frontPoints,
|
|
232
|
-
backPoints
|
|
233
|
-
});
|
|
234
|
-
let newFrontPoints = __spreadValues({}, frontPoints);
|
|
235
|
-
let newBackPoints = backPoints;
|
|
236
|
-
if (isLeftSide || backWidth > frontWidth) {
|
|
237
|
-
newFrontPoints = getPointsByBottomLeftPoint({coord: frontPoints.bl, points: backPoints});
|
|
238
|
-
} else {
|
|
239
|
-
newFrontPoints = getPointsByBottomRightPoint({coord: frontPoints.br, points: backPoints});
|
|
240
|
-
}
|
|
241
|
-
if (frontHeight > backHeight) {
|
|
242
|
-
newFrontPoints.tl.y = frontPoints.tl.y;
|
|
243
|
-
newFrontPoints.tr.y = frontPoints.tr.y;
|
|
244
|
-
newBackPoints = getPointsByIntersection({backPoints, frontPoints}).backPoints;
|
|
245
|
-
}
|
|
246
|
-
if (frontWidth >= backWidth) {
|
|
247
|
-
Object.keys(newFrontPoints).forEach((key) => {
|
|
248
|
-
newFrontPoints[key].x = frontPoints[key].x;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
frontPoints: newFrontPoints,
|
|
253
|
-
backPoints: newBackPoints
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
function getCuboidAllSideLine({frontPoints, backPoints}) {
|
|
257
|
-
return [
|
|
258
|
-
{
|
|
259
|
-
p1: frontPoints.bl,
|
|
260
|
-
p2: backPoints.bl
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
p1: frontPoints.tl,
|
|
264
|
-
p2: backPoints.tl
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
p1: frontPoints.tr,
|
|
268
|
-
p2: backPoints.tr
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
p1: frontPoints.br,
|
|
272
|
-
p2: backPoints.br
|
|
273
|
-
}
|
|
274
|
-
];
|
|
275
|
-
}
|
|
276
|
-
function getHighlightLines(cuboid) {
|
|
277
|
-
const {frontPoints, backPoints} = cuboid;
|
|
278
|
-
const {isLeftSide} = getCuboidBasicInfo(cuboid);
|
|
279
|
-
const frontLine = [
|
|
280
|
-
{
|
|
281
|
-
p1: frontPoints.tl,
|
|
282
|
-
p2: frontPoints.tr,
|
|
283
|
-
positions: [
|
|
284
|
-
{
|
|
285
|
-
plain: ECuboidPlain.Front,
|
|
286
|
-
position: ECuboidPosition.TL
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
plain: ECuboidPlain.Front,
|
|
290
|
-
position: ECuboidPosition.TR
|
|
291
|
-
}
|
|
292
|
-
]
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
p1: frontPoints.tr,
|
|
296
|
-
p2: frontPoints.br,
|
|
297
|
-
plain: ECuboidPlain.Front,
|
|
298
|
-
positions: [
|
|
299
|
-
{
|
|
300
|
-
plain: ECuboidPlain.Front,
|
|
301
|
-
position: ECuboidPosition.TR
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
plain: ECuboidPlain.Front,
|
|
305
|
-
position: ECuboidPosition.BR
|
|
306
|
-
}
|
|
307
|
-
]
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
p1: frontPoints.br,
|
|
311
|
-
p2: frontPoints.bl,
|
|
312
|
-
plain: ECuboidPlain.Front,
|
|
313
|
-
positions: [
|
|
314
|
-
{
|
|
315
|
-
plain: ECuboidPlain.Front,
|
|
316
|
-
position: ECuboidPosition.BR
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
plain: ECuboidPlain.Front,
|
|
320
|
-
position: ECuboidPosition.BL
|
|
321
|
-
}
|
|
322
|
-
]
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
p1: frontPoints.bl,
|
|
326
|
-
p2: frontPoints.tl,
|
|
327
|
-
plain: ECuboidPlain.Front,
|
|
328
|
-
positions: [
|
|
329
|
-
{
|
|
330
|
-
plain: ECuboidPlain.Front,
|
|
331
|
-
position: ECuboidPosition.BL
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
plain: ECuboidPlain.Front,
|
|
335
|
-
position: ECuboidPosition.TL
|
|
336
|
-
}
|
|
337
|
-
]
|
|
338
|
-
}
|
|
339
|
-
];
|
|
340
|
-
if (isLeftSide) {
|
|
341
|
-
return [
|
|
342
|
-
...frontLine,
|
|
343
|
-
{
|
|
344
|
-
p1: backPoints.tl,
|
|
345
|
-
p2: backPoints.bl,
|
|
346
|
-
positions: [
|
|
347
|
-
{
|
|
348
|
-
plain: ECuboidPlain.Back,
|
|
349
|
-
position: ECuboidPosition.TL
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
plain: ECuboidPlain.Back,
|
|
353
|
-
position: ECuboidPosition.BL
|
|
354
|
-
}
|
|
355
|
-
]
|
|
356
|
-
}
|
|
357
|
-
];
|
|
358
|
-
}
|
|
359
|
-
return [
|
|
360
|
-
...frontLine,
|
|
361
|
-
{
|
|
362
|
-
p1: backPoints.tr,
|
|
363
|
-
p2: backPoints.br,
|
|
364
|
-
positions: [
|
|
365
|
-
{
|
|
366
|
-
plain: ECuboidPlain.Back,
|
|
367
|
-
position: ECuboidPosition.TR
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
plain: ECuboidPlain.Back,
|
|
371
|
-
position: ECuboidPosition.BR
|
|
372
|
-
}
|
|
373
|
-
]
|
|
374
|
-
}
|
|
375
|
-
];
|
|
376
|
-
}
|
|
377
|
-
function getHighlightPoints(cuboid) {
|
|
378
|
-
const {backPoints} = cuboid;
|
|
379
|
-
const {isLeftSide} = getCuboidBasicInfo(cuboid);
|
|
380
|
-
const frontPointsData = Object.entries(cuboid.frontPoints).map(([position, point]) => ({
|
|
381
|
-
positions: [
|
|
382
|
-
{
|
|
383
|
-
plain: ECuboidPlain.Front,
|
|
384
|
-
position
|
|
385
|
-
}
|
|
386
|
-
],
|
|
387
|
-
point
|
|
388
|
-
}));
|
|
389
|
-
if (isLeftSide) {
|
|
390
|
-
return [
|
|
391
|
-
{point: backPoints.tl, positions: [{position: ECuboidPosition.TL, plain: ECuboidPlain.Back}]},
|
|
392
|
-
{point: backPoints.bl, positions: [{position: ECuboidPosition.BL, plain: ECuboidPlain.Back}]},
|
|
393
|
-
...frontPointsData
|
|
394
|
-
];
|
|
395
|
-
}
|
|
396
|
-
return [
|
|
397
|
-
{point: backPoints.tr, positions: [{position: ECuboidPosition.TR, plain: ECuboidPlain.Back}]},
|
|
398
|
-
{point: backPoints.br, positions: [{position: ECuboidPosition.BR, plain: ECuboidPlain.Back}]},
|
|
399
|
-
...frontPointsData
|
|
400
|
-
];
|
|
401
|
-
}
|
|
402
|
-
function getCuboidHoverRange(cuboid) {
|
|
403
|
-
const {frontPoints, backPoints} = cuboid;
|
|
404
|
-
const {backCenter, frontCenter, frontHeight, frontWidth, backHeight, backWidth, isLeftSide} = getCuboidBasicInfo(cuboid);
|
|
405
|
-
const diffWidth = Math.abs(frontWidth - backWidth);
|
|
406
|
-
const diffHeight = Math.abs(frontHeight - backHeight);
|
|
407
|
-
const diffCenterX = Math.abs(frontCenter.x - backCenter.x);
|
|
408
|
-
const diffCenterY = Math.abs(frontCenter.y - backCenter.y);
|
|
409
|
-
const isOverX = diffCenterX > diffWidth;
|
|
410
|
-
const isOverY = diffCenterY > diffHeight;
|
|
411
|
-
const isNested = !(isOverX || isOverY);
|
|
412
|
-
if (isNested) {
|
|
413
|
-
return [frontPoints.tl, frontPoints.tr, frontPoints.br, frontPoints.bl];
|
|
414
|
-
}
|
|
415
|
-
if (isOverY && !isOverX) {
|
|
416
|
-
return [frontPoints.tl, backPoints.tl, backPoints.tr, frontPoints.tr, frontPoints.br, frontPoints.bl];
|
|
417
|
-
}
|
|
418
|
-
if (isOverX && !isOverY) {
|
|
419
|
-
if (isLeftSide) {
|
|
420
|
-
return [frontPoints.tl, frontPoints.tr, frontPoints.br, frontPoints.bl, backPoints.bl, backPoints.tl];
|
|
421
|
-
}
|
|
422
|
-
return [frontPoints.tl, frontPoints.tr, backPoints.tr, backPoints.br, frontPoints.br, frontPoints.bl];
|
|
423
|
-
}
|
|
424
|
-
if (isOverX && isOverY) {
|
|
425
|
-
if (isLeftSide) {
|
|
426
|
-
return [backPoints.tl, backPoints.tr, frontPoints.tr, frontPoints.br, frontPoints.bl, backPoints.bl];
|
|
427
|
-
}
|
|
428
|
-
return [frontPoints.tl, backPoints.tl, backPoints.tr, backPoints.br, frontPoints.br, frontPoints.bl];
|
|
429
|
-
}
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
function getNewPointsAfterOffset({
|
|
433
|
-
offset,
|
|
434
|
-
frontPoints,
|
|
435
|
-
backPoints,
|
|
436
|
-
positions
|
|
437
|
-
}) {
|
|
438
|
-
let newFrontPoints = cloneDeep(frontPoints);
|
|
439
|
-
let newBackPoints = cloneDeep(backPoints);
|
|
440
|
-
if ((positions == null ? void 0 : positions.length) === 2) {
|
|
441
|
-
const isFrontPlain = positions.every((v) => v.plain === ECuboidPlain.Front);
|
|
442
|
-
const isBackPlain = !isFrontPlain;
|
|
443
|
-
const lineDirection = judgeCuboidLineIsRowOrColumn([positions[0], positions[1]]);
|
|
444
|
-
const forbidX = lineDirection === ECuboidLineDirection.Row;
|
|
445
|
-
const forbidY = lineDirection === ECuboidLineDirection.Column;
|
|
446
|
-
let newOffset = offset;
|
|
447
|
-
if (forbidX) {
|
|
448
|
-
newOffset = {
|
|
449
|
-
x: 0,
|
|
450
|
-
y: offset.y
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
if (forbidY) {
|
|
454
|
-
newOffset = {
|
|
455
|
-
y: 0,
|
|
456
|
-
x: offset.x
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
if (isFrontPlain) {
|
|
460
|
-
positions == null ? void 0 : positions.forEach(({position}) => {
|
|
461
|
-
const points = newFrontPoints;
|
|
462
|
-
const movePoint = points[position];
|
|
463
|
-
points[position] = {
|
|
464
|
-
x: movePoint.x + newOffset.x,
|
|
465
|
-
y: movePoint.y + newOffset.y
|
|
466
|
-
};
|
|
467
|
-
});
|
|
468
|
-
newFrontPoints = getMaxExternalQuadrilateral(newFrontPoints);
|
|
469
|
-
newBackPoints = getMaxExternalQuadrilateral(newBackPoints);
|
|
470
|
-
}
|
|
471
|
-
if (isBackPlain) {
|
|
472
|
-
Object.keys(newBackPoints).forEach((key) => {
|
|
473
|
-
newBackPoints[key] = {
|
|
474
|
-
x: newBackPoints[key].x + newOffset.x,
|
|
475
|
-
y: newBackPoints[key].y + newOffset.y
|
|
476
|
-
};
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
const getNewPlainPoints = isFrontPlain ? getBackPointsByFrontPoints : getFrontPointsByBackPoints;
|
|
480
|
-
const {frontPoints: newFrontPoints2, backPoints: newBackPoints2} = getNewPlainPoints({
|
|
481
|
-
frontPoints: newFrontPoints,
|
|
482
|
-
backPoints: newBackPoints
|
|
483
|
-
});
|
|
484
|
-
newFrontPoints = newFrontPoints2;
|
|
485
|
-
newBackPoints = newBackPoints2;
|
|
486
|
-
}
|
|
487
|
-
return {
|
|
488
|
-
frontPoints: newFrontPoints,
|
|
489
|
-
backPoints: newBackPoints
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
function moveCuboidByCuboid({offset, cuboid}) {
|
|
493
|
-
const {frontPoints, backPoints} = cuboid;
|
|
494
|
-
const newFrontPoints = Object.entries(frontPoints).reduce((acc, [key, point]) => {
|
|
495
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
496
|
-
[key]: {
|
|
497
|
-
x: point.x + offset.x,
|
|
498
|
-
y: point.y + offset.y
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}, {});
|
|
502
|
-
const newBackPoints = Object.entries(backPoints).reduce((acc, [key, point]) => {
|
|
503
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
504
|
-
[key]: {
|
|
505
|
-
x: point.x + offset.x,
|
|
506
|
-
y: point.y + offset.y
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
}, {});
|
|
510
|
-
return {
|
|
511
|
-
frontPoints: newFrontPoints,
|
|
512
|
-
backPoints: newBackPoints
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
function moveCuboidByLine({
|
|
516
|
-
offset,
|
|
517
|
-
cuboid,
|
|
518
|
-
positions
|
|
519
|
-
}) {
|
|
520
|
-
const {frontPoints, backPoints} = cuboid;
|
|
521
|
-
return getNewPointsAfterOffset({
|
|
522
|
-
offset,
|
|
523
|
-
frontPoints,
|
|
524
|
-
backPoints,
|
|
525
|
-
positions
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
function moveCuboidByPoints({
|
|
529
|
-
offset,
|
|
530
|
-
cuboid,
|
|
531
|
-
positions
|
|
532
|
-
}) {
|
|
533
|
-
if (!(positions == null ? void 0 : positions[0])) {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
const {frontPoints, backPoints} = cuboid;
|
|
537
|
-
const pointPosition = positions[0];
|
|
538
|
-
const isFrontPlain = pointPosition.plain === ECuboidPlain.Front;
|
|
539
|
-
const movePoints = isFrontPlain ? frontPoints : backPoints;
|
|
540
|
-
let movePoint = movePoints[pointPosition.position];
|
|
541
|
-
const diagonalPoint = movePoints[DIAGONAL_POINT[pointPosition.position]];
|
|
542
|
-
if (!movePoint || !diagonalPoint) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
movePoint = Vector.add(movePoint, offset);
|
|
546
|
-
const newPlainsPoints = getPlainPointsByDiagonalPoints(movePoint, diagonalPoint);
|
|
547
|
-
const getNewPlainPoints = isFrontPlain ? getBackPointsByFrontPoints : getFrontPointsByBackPoints;
|
|
548
|
-
let payload = {
|
|
549
|
-
frontPoints,
|
|
550
|
-
backPoints: newPlainsPoints
|
|
551
|
-
};
|
|
552
|
-
if (isFrontPlain) {
|
|
553
|
-
payload = {
|
|
554
|
-
frontPoints: newPlainsPoints,
|
|
555
|
-
backPoints
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
return getNewPlainPoints(payload);
|
|
559
|
-
}
|
|
560
|
-
function getCuboidDragMove({
|
|
561
|
-
offset,
|
|
562
|
-
cuboid,
|
|
563
|
-
dragTarget,
|
|
564
|
-
positions
|
|
565
|
-
}) {
|
|
566
|
-
switch (dragTarget) {
|
|
567
|
-
case EDragTarget.Cuboid: {
|
|
568
|
-
const newCuboidPoints = moveCuboidByCuboid({offset, cuboid});
|
|
569
|
-
return __spreadValues(__spreadValues({}, cuboid), newCuboidPoints);
|
|
570
|
-
}
|
|
571
|
-
case EDragTarget.Line: {
|
|
572
|
-
const newCuboidPoints = moveCuboidByLine({offset, cuboid, positions});
|
|
573
|
-
return __spreadValues(__spreadValues({}, cuboid), newCuboidPoints);
|
|
574
|
-
}
|
|
575
|
-
case EDragTarget.Point: {
|
|
576
|
-
const newCuboidPoints = moveCuboidByPoints({cuboid, offset, positions});
|
|
577
|
-
if (newCuboidPoints) {
|
|
578
|
-
return __spreadValues(__spreadValues({}, cuboid), newCuboidPoints);
|
|
579
|
-
}
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
default: {
|
|
583
|
-
console.error("No DragTarget");
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
function getPointListsByDirection({
|
|
589
|
-
direction,
|
|
590
|
-
frontPoints,
|
|
591
|
-
backPoints
|
|
592
|
-
}) {
|
|
593
|
-
if (direction && frontPoints && backPoints) {
|
|
594
|
-
let points = frontPoints;
|
|
595
|
-
switch (direction) {
|
|
596
|
-
case ECuboidDirection.Back:
|
|
597
|
-
points = backPoints;
|
|
598
|
-
break;
|
|
599
|
-
case ECuboidDirection.Left:
|
|
600
|
-
points = {
|
|
601
|
-
bl: backPoints.bl,
|
|
602
|
-
br: frontPoints.bl,
|
|
603
|
-
tl: backPoints.tl,
|
|
604
|
-
tr: frontPoints.tl
|
|
605
|
-
};
|
|
606
|
-
break;
|
|
607
|
-
case ECuboidDirection.Right:
|
|
608
|
-
points = {
|
|
609
|
-
bl: backPoints.br,
|
|
610
|
-
br: frontPoints.br,
|
|
611
|
-
tl: backPoints.tr,
|
|
612
|
-
tr: frontPoints.tr
|
|
613
|
-
};
|
|
614
|
-
break;
|
|
615
|
-
case ECuboidDirection.Top:
|
|
616
|
-
points = {
|
|
617
|
-
bl: backPoints.tl,
|
|
618
|
-
br: frontPoints.tl,
|
|
619
|
-
tl: backPoints.tr,
|
|
620
|
-
tr: frontPoints.tr
|
|
621
|
-
};
|
|
622
|
-
break;
|
|
623
|
-
default:
|
|
624
|
-
points = frontPoints;
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
return AxisUtils.transformPlain2PointList(points);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
function getToggleDirectionButtonOffset({
|
|
631
|
-
cuboid,
|
|
632
|
-
currentPos,
|
|
633
|
-
zoom
|
|
634
|
-
}) {
|
|
635
|
-
const {frontPoints} = cuboid;
|
|
636
|
-
const toggleSize = {
|
|
637
|
-
width: 40,
|
|
638
|
-
height: 74
|
|
639
|
-
};
|
|
640
|
-
const frontPointsCenter = {
|
|
641
|
-
x: (frontPoints.bl.x + frontPoints.tl.x) / 2,
|
|
642
|
-
y: (frontPoints.bl.y + frontPoints.tl.y) / 2
|
|
643
|
-
};
|
|
644
|
-
const leftOffset = toggleSize.width + 10;
|
|
645
|
-
const topOffset = toggleSize.height / 2;
|
|
646
|
-
const moveCoordinate = {
|
|
647
|
-
x: frontPointsCenter.x,
|
|
648
|
-
y: frontPointsCenter.y
|
|
649
|
-
};
|
|
650
|
-
const coordinate = AxisUtils.getOffsetCoordinate(moveCoordinate, currentPos, zoom);
|
|
651
|
-
return {
|
|
652
|
-
left: coordinate.x - leftOffset,
|
|
653
|
-
top: coordinate.y - topOffset
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
function getCuboidTextAttributeOffset({
|
|
657
|
-
cuboid,
|
|
658
|
-
currentPos,
|
|
659
|
-
zoom,
|
|
660
|
-
leftOffset = 16,
|
|
661
|
-
topOffset = 2
|
|
662
|
-
}) {
|
|
663
|
-
const {frontPoints} = cuboid;
|
|
664
|
-
const moveCoordinate = {
|
|
665
|
-
x: frontPoints.bl.x,
|
|
666
|
-
y: frontPoints.bl.y
|
|
667
|
-
};
|
|
668
|
-
const coordinate = AxisUtils.getOffsetCoordinate(moveCoordinate, currentPos, zoom);
|
|
669
|
-
return {
|
|
670
|
-
left: coordinate.x + leftOffset,
|
|
671
|
-
top: coordinate.y + topOffset
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
function isCuboidWithInLimits({cuboid, config}) {
|
|
675
|
-
const {minHeight, minWidth} = config;
|
|
676
|
-
const {width, height} = getPlanePointsBasicInfo(cuboid.frontPoints);
|
|
677
|
-
return width >= minWidth && height >= minHeight;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
export { getBackPointsByFrontPoints, getCuboidAllSideLine, getCuboidBasicInfo, getCuboidDragMove, getCuboidHoverRange, getCuboidShowingSideLine, getCuboidTextAttributeOffset, getFrontPointsByBackPoints, getHighlightLines, getHighlightPoints, getMaxExternalQuadrilateral, getNewPointsAfterOffset, getPlainPointsByDiagonalPoints, getPlanePointsBasicInfo, getPointListsByDirection, getPointsByBottomLeftPoint, getPointsByBottomRightPoint, getPointsByIntersection, getToggleDirectionButtonOffset, isCuboidWithInLimits, judgeCuboidLineIsRowOrColumn };
|
|
1
|
+
import{cloneDeep as D}from"lodash";import{ECuboidPlain as a,ECuboidPosition as p,ECuboidDirection as B,EDragTarget as L,DIAGONAL_POINT as U,ECuboidLineDirection as P,CUBOID_ROW as X,CUBOID_COLUMN as Y}from"../../constant/annotation.js";import v from"./AxisUtils.js";import G from"../VectorUtils.js";import _ from"./LineToolUtils.js";var V=Object.defineProperty,z=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,S=(n,t,i)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,f=(n,t)=>{for(var i in t||(t={}))q.call(t,i)&&S(n,i,t[i]);if(I)for(var i of I(t))J.call(t,i)&&S(n,i,t[i]);return n},w=(n,t)=>z(n,Q(t));function m({tr:n,tl:t,br:i}){return{width:Math.abs(n.x-t.x),height:Math.abs(i.y-n.y),centerPoints:{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}}function x({frontPoints:n,backPoints:t}){const{width:i,height:e,centerPoints:r}=m(n),{width:o,height:s,centerPoints:l}=m(t);return{frontCenter:r,backCenter:l,frontWidth:i,frontHeight:e,backWidth:o,backHeight:s,isLeftSide:l.x<r.x}}function k(n,t){return{tl:{x:Math.min(n.x,t.x),y:Math.min(n.y,t.y)},tr:{x:Math.max(n.x,t.x),y:Math.min(n.y,t.y)},bl:{x:Math.min(n.x,t.x),y:Math.max(n.y,t.y)},br:{x:Math.max(n.x,t.x),y:Math.max(n.y,t.y)}}}function F(n){const t=Object.values(n).reduce((o,s)=>s.x<o?s.x:o,Number.MAX_SAFE_INTEGER),i=Object.values(n).reduce((o,s)=>s.x>o?s.x:o,0),e=Object.values(n).reduce((o,s)=>s.y<o?s.y:o,Number.MAX_SAFE_INTEGER),r=Object.values(n).reduce((o,s)=>s.y>o?s.y:o,0);return{tl:{x:t,y:e},tr:{x:i,y:e},bl:{x:t,y:r},br:{x:i,y:r}}}function N(n){const[t,i]=n;if(X[t.position]===i.position)return P.Row;if(Y[t.position]===i.position)return P.Column}function M({coord:n,points:t}){const{width:i,height:e}=m(t);return{br:n,tr:{x:n.x,y:n.y-e},tl:{x:n.x-i,y:n.y-e},bl:{x:n.x-i,y:n.y}}}function j({coord:n,points:t}){const{width:i,height:e}=m(t);return{bl:n,tr:{x:n.x+i,y:n.y-e},tl:{x:n.x,y:n.y-e},br:{x:n.x+i,y:n.y}}}function H({frontPoints:n,backPoints:t}){const{isLeftSide:i}=x({frontPoints:n,backPoints:t});return i?{top:{p1:n.tl,p2:t.tl},bottom:{p1:n.bl,p2:t.bl}}:{top:{p1:n.tr,p2:t.tr},bottom:{p1:n.br,p2:t.br}}}function R({frontPoints:n,backPoints:t}){const{isLeftSide:i}=x({frontPoints:n,backPoints:t});let e=f({},t);const r=H({frontPoints:n,backPoints:t}),o=_.lineIntersection({pointA:r.bottom.p1,pointB:r.bottom.p2},{pointA:r.top.p1,pointB:r.top.p2});if(i){const s=_.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:n.br,pointB:o});s&&(e=w(f({},t),{br:s,tr:{x:s.x,y:t.tl.y}}))}else{const s=_.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:n.bl,pointB:o});s&&(e=w(f({},t),{bl:s,tl:{x:s.x,y:t.tr.y}}))}return{backPoints:e}}function T({frontPoints:n,backPoints:t}){const{isLeftSide:i,frontHeight:e,backHeight:r}=x({frontPoints:n,backPoints:t});let o=f({},t);return i?o=j({coord:t.bl,points:n}):o=M({coord:t.br,points:n}),e>r&&(o=R({frontPoints:n,backPoints:t}).backPoints),{frontPoints:n,backPoints:o}}function A({frontPoints:n,backPoints:t}){const{isLeftSide:i,frontHeight:e,backHeight:r,frontWidth:o,backWidth:s}=x({frontPoints:n,backPoints:t});let l=f({},n),c=t;return i||s>o?l=j({coord:n.bl,points:t}):l=M({coord:n.br,points:t}),e>r&&(l.tl.y=n.tl.y,l.tr.y=n.tr.y,c=R({backPoints:t,frontPoints:n}).backPoints),o>=s&&Object.keys(l).forEach(u=>{l[u].x=n[u].x}),{frontPoints:l,backPoints:c}}function K({frontPoints:n,backPoints:t}){return[{p1:n.bl,p2:t.bl},{p1:n.tl,p2:t.tl},{p1:n.tr,p2:t.tr},{p1:n.br,p2:t.br}]}function Z(n){const{frontPoints:t,backPoints:i}=n,{isLeftSide:e}=x(n),r=[{p1:t.tl,p2:t.tr,positions:[{plain:a.Front,position:p.TL},{plain:a.Front,position:p.TR}]},{p1:t.tr,p2:t.br,plain:a.Front,positions:[{plain:a.Front,position:p.TR},{plain:a.Front,position:p.BR}]},{p1:t.br,p2:t.bl,plain:a.Front,positions:[{plain:a.Front,position:p.BR},{plain:a.Front,position:p.BL}]},{p1:t.bl,p2:t.tl,plain:a.Front,positions:[{plain:a.Front,position:p.BL},{plain:a.Front,position:p.TL}]}];return e?[...r,{p1:i.tl,p2:i.bl,positions:[{plain:a.Back,position:p.TL},{plain:a.Back,position:p.BL}]}]:[...r,{p1:i.tr,p2:i.br,positions:[{plain:a.Back,position:p.TR},{plain:a.Back,position:p.BR}]}]}function $(n){const{backPoints:t}=n,{isLeftSide:i}=x(n),e=Object.entries(n.frontPoints).map(([r,o])=>({positions:[{plain:a.Front,position:r}],point:o}));return i?[{point:t.tl,positions:[{position:p.TL,plain:a.Back}]},{point:t.bl,positions:[{position:p.BL,plain:a.Back}]},...e]:[{point:t.tr,positions:[{position:p.TR,plain:a.Back}]},{point:t.br,positions:[{position:p.BR,plain:a.Back}]},...e]}function tt(n){const{frontPoints:t,backPoints:i}=n,{backCenter:e,frontCenter:r,frontHeight:o,frontWidth:s,backHeight:l,backWidth:c,isLeftSide:u}=x(n),h=Math.abs(s-c),y=Math.abs(o-l),g=Math.abs(r.x-e.x),O=Math.abs(r.y-e.y),d=g>h,b=O>y;return d||b?b&&!d?[t.tl,i.tl,i.tr,t.tr,t.br,t.bl]:d&&!b?u?[t.tl,t.tr,t.br,t.bl,i.bl,i.tl]:[t.tl,t.tr,i.tr,i.br,t.br,t.bl]:d&&b?u?[i.tl,i.tr,t.tr,t.br,t.bl,i.bl]:[t.tl,i.tl,i.tr,i.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function W({offset:n,frontPoints:t,backPoints:i,positions:e}){let r=D(t),o=D(i);if((e==null?void 0:e.length)===2){const s=e.every(b=>b.plain===a.Front),l=!s,c=N([e[0],e[1]]),u=c===P.Row,h=c===P.Column;let y=n;u&&(y={x:0,y:n.y}),h&&(y={y:0,x:n.x}),s&&(e==null||e.forEach(({position:b})=>{const C=r,E=C[b];C[b]={x:E.x+y.x,y:E.y+y.y}}),r=F(r),o=F(o)),l&&Object.keys(o).forEach(b=>{o[b]={x:o[b].x+y.x,y:o[b].y+y.y}});const g=s?T:A,{frontPoints:O,backPoints:d}=g({frontPoints:r,backPoints:o});r=O,o=d}return{frontPoints:r,backPoints:o}}function nt({offset:n,cuboid:t}){const{frontPoints:i,backPoints:e}=t,r=Object.entries(i).reduce((s,[l,c])=>w(f({},s),{[l]:{x:c.x+n.x,y:c.y+n.y}}),{}),o=Object.entries(e).reduce((s,[l,c])=>w(f({},s),{[l]:{x:c.x+n.x,y:c.y+n.y}}),{});return{frontPoints:r,backPoints:o}}function it({offset:n,cuboid:t,positions:i}){const{frontPoints:e,backPoints:r}=t;return W({offset:n,frontPoints:e,backPoints:r,positions:i})}function et({offset:n,cuboid:t,positions:i}){if(!(i==null?void 0:i[0]))return;const{frontPoints:e,backPoints:r}=t,o=i[0],s=o.plain===a.Front,l=s?e:r;let c=l[o.position];const u=l[U[o.position]];if(!c||!u)return;c=G.add(c,n);const h=k(c,u),y=s?T:A;let g={frontPoints:e,backPoints:h};return s&&(g={frontPoints:h,backPoints:r}),y(g)}function ot({offset:n,cuboid:t,dragTarget:i,positions:e}){switch(i){case L.Cuboid:{const r=nt({offset:n,cuboid:t});return f(f({},t),r)}case L.Line:{const r=it({offset:n,cuboid:t,positions:e});return f(f({},t),r)}case L.Point:{const r=et({cuboid:t,offset:n,positions:e});if(r)return f(f({},t),r);break}default:{console.error("No DragTarget");break}}}function rt({direction:n,frontPoints:t,backPoints:i}){if(n&&t&&i){let e=t;switch(n){case B.Back:e=i;break;case B.Left:e={bl:i.bl,br:t.bl,tl:i.tl,tr:t.tl};break;case B.Right:e={bl:i.br,br:t.br,tl:i.tr,tr:t.tr};break;case B.Top:e={bl:i.tl,br:t.tl,tl:i.tr,tr:t.tr};break;default:e=t;break}return v.transformPlain2PointList(e)}}function st({cuboid:n,currentPos:t,zoom:i}){const{frontPoints:e}=n,r={width:40,height:74},o={x:(e.bl.x+e.tl.x)/2,y:(e.bl.y+e.tl.y)/2},s=r.width+10,l=r.height/2,c={x:o.x,y:o.y},u=v.getOffsetCoordinate(c,t,i);return{left:u.x-s,top:u.y-l}}function lt({cuboid:n,currentPos:t,zoom:i,leftOffset:e=16,topOffset:r=2}){const{frontPoints:o}=n,s={x:o.bl.x,y:o.bl.y},l=v.getOffsetCoordinate(s,t,i);return{left:l.x+e,top:l.y+r}}function at({cuboid:n,config:t}){const{minHeight:i,minWidth:e}=t,{width:r,height:o}=m(n.frontPoints);return r>=e&&o>=i}export{T as getBackPointsByFrontPoints,K as getCuboidAllSideLine,x as getCuboidBasicInfo,ot as getCuboidDragMove,tt as getCuboidHoverRange,H as getCuboidShowingSideLine,lt as getCuboidTextAttributeOffset,A as getFrontPointsByBackPoints,Z as getHighlightLines,$ as getHighlightPoints,F as getMaxExternalQuadrilateral,W as getNewPointsAfterOffset,k as getPlainPointsByDiagonalPoints,m as getPlanePointsBasicInfo,rt as getPointListsByDirection,j as getPointsByBottomLeftPoint,M as getPointsByBottomRightPoint,R as getPointsByIntersection,st as getToggleDirectionButtonOffset,at as isCuboidWithInLimits,N as judgeCuboidLineIsRowOrColumn};
|