@labelbee/lb-annotation 1.13.0 → 1.13.1

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.
Files changed (27) hide show
  1. package/dist/core/pointCloud/index.js +2 -2
  2. package/dist/types/core/pointCloud/index.d.ts +8 -3
  3. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  4. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  5. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  6. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  7. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -0
  8. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -0
  9. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -0
  10. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -0
  11. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -0
  12. package/es/core/pointCloud/index.js +2 -2
  13. package/es/core/pointCloud/render/index.js +131 -0
  14. package/es/core/pointCloud/segmentation.js +95 -0
  15. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +23 -0
  16. package/es/core/pointCloud/selector/Sse3dSelector.js +15 -0
  17. package/es/core/pointCloud/selector/circleSelector.js +39 -0
  18. package/es/core/pointCloud/selector/lassoSelector.js +22 -0
  19. package/es/core/pointCloud/selector/selector.js +16 -0
  20. package/es/core/pointCloud/store/fsm.js +41 -0
  21. package/es/core/pointCloud/store/index.js +376 -0
  22. package/es/core/toolOperation/Selection.js +101 -0
  23. package/es/core/toolOperation/cuboidOperation.js +752 -0
  24. package/es/core/toolOperation/cuboidToggleButtonClass.js +174 -0
  25. package/es/core/toolOperation/scribbleTool2.js +249 -0
  26. package/es/utils/tool/CuboidUtils.js +680 -0
  27. package/package.json +3 -3
@@ -0,0 +1,680 @@
1
+ import { cloneDeep } from 'lodash';
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-annotation",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Annotation tool collection",
5
5
  "keywords": [
6
6
  "annotation",
@@ -92,11 +92,11 @@
92
92
  "typescript": "^4.2.3"
93
93
  },
94
94
  "dependencies": {
95
- "@labelbee/lb-utils": "^1.6.0",
95
+ "@labelbee/lb-utils": "^1.6.1",
96
96
  "@turf/turf": "5.1.6",
97
97
  "color-rgba": "^2.3.0",
98
98
  "lodash": "^4.17.20",
99
99
  "three": ">=0.141.0"
100
100
  },
101
- "gitHead": "9be3cbf1aa9560340678721703ab9c137b9d91f5"
101
+ "gitHead": "c95b85c66f2aa6de4a53a2745765c043e7ab113d"
102
102
  }