@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.
Files changed (189) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +1 -8
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
  3. package/dist/_virtual/filterBoxWorker.js +1 -8
  4. package/dist/_virtual/highlightWorker.js +1 -8
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
  17. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
  18. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
  19. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -5
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
  25. package/dist/constant/annotation.js +1 -127
  26. package/dist/constant/annotationTask.js +1 -30
  27. package/dist/constant/defaultConfig.js +1 -266
  28. package/dist/constant/keyCode.js +1 -38
  29. package/dist/constant/style.js +1 -98
  30. package/dist/constant/tool.js +1 -236
  31. package/dist/core/index.js +1 -150
  32. package/dist/core/pointCloud/OrbitControls.js +1 -665
  33. package/dist/core/pointCloud/PCDLoader.js +2 -260
  34. package/dist/core/pointCloud/annotation.js +1 -215
  35. package/dist/core/pointCloud/cache.js +1 -53
  36. package/dist/core/pointCloud/index.js +5 -991
  37. package/dist/core/pointCloud/matrix.js +1 -138
  38. package/dist/core/scheduler.js +1 -233
  39. package/dist/core/toolOperation/LineToolOperation.js +1 -1434
  40. package/dist/core/toolOperation/ScribbleTool.js +1 -292
  41. package/dist/core/toolOperation/TextToolOperation.js +1 -131
  42. package/dist/core/toolOperation/ViewOperation.js +1 -556
  43. package/dist/core/toolOperation/basicToolOperation.js +1 -881
  44. package/dist/core/toolOperation/checkOperation.js +1 -208
  45. package/dist/core/toolOperation/cuboidOperation.js +1 -754
  46. package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
  47. package/dist/core/toolOperation/eventListener.js +1 -37
  48. package/dist/core/toolOperation/measureOperation.js +1 -41
  49. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
  50. package/dist/core/toolOperation/pointOperation.js +1 -696
  51. package/dist/core/toolOperation/polygonOperation.js +1 -1251
  52. package/dist/core/toolOperation/rectOperation.js +1 -1233
  53. package/dist/core/toolOperation/segmentByRect.js +1 -174
  54. package/dist/core/toolOperation/tagOperation.js +3 -201
  55. package/dist/core/toolOperation/textAttributeClass.js +16 -182
  56. package/dist/index.js +1 -185
  57. package/dist/locales/constants.js +1 -24
  58. package/dist/locales/en_US/message.js +1 -25
  59. package/dist/locales/index.js +1 -19
  60. package/dist/locales/zh_CN/message.js +1 -25
  61. package/dist/newCore/CanvasScheduler.js +1 -35
  62. package/dist/types/core/pointCloud/index.d.ts +2 -2
  63. package/dist/utils/ActionsHistory.js +1 -84
  64. package/dist/utils/ImgUtils.js +1 -23
  65. package/dist/utils/MathUtils.js +2 -385
  66. package/dist/utils/VectorUtils.js +1 -25
  67. package/dist/utils/tool/AttributeUtils.js +1 -218
  68. package/dist/utils/tool/AxisUtils.js +1 -340
  69. package/dist/utils/tool/CanvasUtils.js +1 -62
  70. package/dist/utils/tool/CommonToolUtils.js +1 -174
  71. package/dist/utils/tool/CuboidUtils.js +1 -704
  72. package/dist/utils/tool/DblClickEventListener.js +1 -102
  73. package/dist/utils/tool/DrawUtils.js +3 -492
  74. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
  75. package/dist/utils/tool/ImgPosUtils.js +1 -58
  76. package/dist/utils/tool/LineToolUtils.js +1 -261
  77. package/dist/utils/tool/MarkerUtils.js +1 -56
  78. package/dist/utils/tool/PolygonUtils.js +1 -460
  79. package/dist/utils/tool/RectUtils.js +1 -155
  80. package/dist/utils/tool/RenderDomClass.js +7 -57
  81. package/dist/utils/tool/RenderDomUtils.js +4 -21
  82. package/dist/utils/tool/StyleUtils.js +1 -31
  83. package/dist/utils/tool/TagUtils.js +1 -129
  84. package/dist/utils/tool/UnitUtils.js +1 -12
  85. package/dist/utils/tool/ZoomUtils.js +1 -72
  86. package/dist/utils/tool/polygonTool.js +1 -133
  87. package/dist/utils/uuid.js +1 -26
  88. package/es/_virtual/MathUtilsWorker.js +1 -6
  89. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
  90. package/es/_virtual/filterBoxWorker.js +1 -6
  91. package/es/_virtual/highlightWorker.js +1 -6
  92. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
  93. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
  94. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
  95. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
  96. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
  97. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
  98. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
  99. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
  100. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
  101. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
  102. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
  103. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
  104. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
  105. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
  106. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
  107. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
  108. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
  109. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
  110. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
  111. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
  112. package/es/constant/annotation.js +1 -113
  113. package/es/constant/annotationTask.js +1 -25
  114. package/es/constant/defaultConfig.js +1 -260
  115. package/es/constant/keyCode.js +1 -36
  116. package/es/constant/style.js +1 -74
  117. package/es/constant/tool.js +1 -220
  118. package/es/core/index.js +1 -148
  119. package/es/core/pointCloud/OrbitControls.js +1 -661
  120. package/es/core/pointCloud/PCDLoader.js +2 -256
  121. package/es/core/pointCloud/annotation.js +1 -211
  122. package/es/core/pointCloud/cache.js +1 -49
  123. package/es/core/pointCloud/index.js +5 -962
  124. package/es/core/pointCloud/matrix.js +1 -109
  125. package/es/core/scheduler.js +1 -228
  126. package/es/core/toolOperation/LineToolOperation.js +1 -1421
  127. package/es/core/toolOperation/ScribbleTool.js +1 -290
  128. package/es/core/toolOperation/TextToolOperation.js +1 -129
  129. package/es/core/toolOperation/ViewOperation.js +1 -549
  130. package/es/core/toolOperation/basicToolOperation.js +1 -877
  131. package/es/core/toolOperation/checkOperation.js +1 -206
  132. package/es/core/toolOperation/cuboidOperation.js +1 -752
  133. package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
  134. package/es/core/toolOperation/eventListener.js +1 -35
  135. package/es/core/toolOperation/measureOperation.js +1 -39
  136. package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
  137. package/es/core/toolOperation/pointOperation.js +1 -690
  138. package/es/core/toolOperation/polygonOperation.js +1 -1245
  139. package/es/core/toolOperation/rectOperation.js +1 -1228
  140. package/es/core/toolOperation/segmentByRect.js +1 -172
  141. package/es/core/toolOperation/tagOperation.js +3 -199
  142. package/es/core/toolOperation/textAttributeClass.js +16 -180
  143. package/es/index.js +1 -46
  144. package/es/locales/constants.js +1 -22
  145. package/es/locales/en_US/message.js +1 -23
  146. package/es/locales/index.js +1 -17
  147. package/es/locales/zh_CN/message.js +1 -23
  148. package/es/newCore/CanvasScheduler.js +1 -31
  149. package/es/utils/ActionsHistory.js +1 -78
  150. package/es/utils/ImgUtils.js +1 -21
  151. package/es/utils/MathUtils.js +2 -380
  152. package/es/utils/VectorUtils.js +1 -23
  153. package/es/utils/tool/AttributeUtils.js +1 -212
  154. package/es/utils/tool/AxisUtils.js +1 -335
  155. package/es/utils/tool/CanvasUtils.js +1 -60
  156. package/es/utils/tool/CommonToolUtils.js +1 -172
  157. package/es/utils/tool/CuboidUtils.js +1 -680
  158. package/es/utils/tool/DblClickEventListener.js +1 -100
  159. package/es/utils/tool/DrawUtils.js +3 -490
  160. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
  161. package/es/utils/tool/ImgPosUtils.js +1 -56
  162. package/es/utils/tool/LineToolUtils.js +1 -255
  163. package/es/utils/tool/MarkerUtils.js +1 -54
  164. package/es/utils/tool/PolygonUtils.js +1 -458
  165. package/es/utils/tool/RectUtils.js +1 -153
  166. package/es/utils/tool/RenderDomClass.js +7 -55
  167. package/es/utils/tool/RenderDomUtils.js +4 -19
  168. package/es/utils/tool/StyleUtils.js +1 -29
  169. package/es/utils/tool/TagUtils.js +1 -127
  170. package/es/utils/tool/UnitUtils.js +1 -10
  171. package/es/utils/tool/ZoomUtils.js +1 -70
  172. package/es/utils/tool/polygonTool.js +1 -126
  173. package/es/utils/uuid.js +1 -24
  174. package/package.json +3 -4
  175. package/LICENSE +0 -203
  176. package/dist/core/pointCloud/segmentation.js +0 -144
  177. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
  178. package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
  179. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  180. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  181. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  182. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
  183. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
  184. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  185. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
  186. package/es/core/pointCloud/segmentation.js +0 -120
  187. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
  188. package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
  189. package/es/core/toolOperation/scribbleTool2.js +0 -249
@@ -1,138 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var THREE = require('three');
6
- var lbUtils = require('@labelbee/lb-utils');
7
- var uuid = require('../../utils/uuid.js');
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
28
-
29
- var __defProp = Object.defineProperty;
30
- var __defProps = Object.defineProperties;
31
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
32
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
33
- var __hasOwnProp = Object.prototype.hasOwnProperty;
34
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
35
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
36
- var __spreadValues = (a, b) => {
37
- for (var prop in b || (b = {}))
38
- if (__hasOwnProp.call(b, prop))
39
- __defNormalProp(a, prop, b[prop]);
40
- if (__getOwnPropSymbols)
41
- for (var prop of __getOwnPropSymbols(b)) {
42
- if (__propIsEnum.call(b, prop))
43
- __defNormalProp(a, prop, b[prop]);
44
- }
45
- return a;
46
- };
47
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
48
- function createThreeMatrix4(matrix4) {
49
- return new THREE__namespace.Matrix4().set(...matrix4);
50
- }
51
- function transferKitti2Matrix(P, R, T) {
52
- const PMA = lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(P);
53
- const RMA = lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(R);
54
- const TMA = lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(T);
55
- const PM = createThreeMatrix4(PMA);
56
- const RM = createThreeMatrix4(RMA);
57
- const TM = createThreeMatrix4(TMA);
58
- return {
59
- composeMatrix4: TM.clone().premultiply(RM).premultiply(PM),
60
- PM,
61
- RM,
62
- TM
63
- };
64
- }
65
- function rotatePoint(points, centerPoint, rotationZ) {
66
- var _a;
67
- const pointVector = new THREE__namespace.Vector3(points.x, points.y, (_a = points == null ? void 0 : points.z) != null ? _a : 1);
68
- const Rz = new THREE__namespace.Matrix4().makeRotationZ(rotationZ);
69
- const TFrom = new THREE__namespace.Matrix4().makeTranslation(centerPoint.x, centerPoint.y, centerPoint.z);
70
- const TBack = new THREE__namespace.Matrix4().makeTranslation(-centerPoint.x, -centerPoint.y, -centerPoint.z);
71
- return pointVector.clone().applyMatrix4(TBack).applyMatrix4(Rz).applyMatrix4(TFrom);
72
- }
73
- function lidar2image(point, composeMatrix4) {
74
- const vector = new THREE__namespace.Vector4(point.x, point.y, point.z);
75
- const newV = vector.applyMatrix4(composeMatrix4);
76
- if (newV.z < 0) {
77
- return void 0;
78
- }
79
- const z = 1 / newV.z;
80
- const fixMatrix4 = new THREE__namespace.Matrix4().set(z, 0, 0, 0, 0, z, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
81
- return newV.applyMatrix4(fixMatrix4);
82
- }
83
- function getCuboidFromPointCloudBox(boxParams) {
84
- const {center, width, height, depth, rotation} = boxParams;
85
- const polygonPointList = [
86
- {
87
- x: center.x + width / 2,
88
- y: center.y - height / 2
89
- },
90
- {
91
- x: center.x + width / 2,
92
- y: center.y + height / 2
93
- },
94
- {
95
- x: center.x - width / 2,
96
- y: center.y + height / 2
97
- },
98
- {
99
- x: center.x - width / 2,
100
- y: center.y - height / 2
101
- }
102
- ].map((v) => {
103
- const vector = rotatePoint(v, center, rotation);
104
- return {
105
- x: vector.x,
106
- y: vector.y
107
- };
108
- });
109
- const zMax = center.z + depth / 2;
110
- const zMin = center.z - depth / 2;
111
- return __spreadProps(__spreadValues({}, boxParams), {
112
- polygonPointList,
113
- zMax,
114
- zMin
115
- });
116
- }
117
- function pointCloudLidar2image(boxParams, cameraMatrix) {
118
- const allViewData = lbUtils.PointCloudUtils.getAllViewData(boxParams);
119
- const {P, R, T} = cameraMatrix;
120
- const {composeMatrix4} = transferKitti2Matrix(P, R, T);
121
- const transferViewData = allViewData.map((viewData) => ({
122
- type: viewData.type,
123
- pointList: viewData.pointList.map((point) => rotatePoint(point, boxParams.center, boxParams.rotation)).map((point) => lidar2image(point, composeMatrix4)).map((point) => {
124
- if (!point) {
125
- return void 0;
126
- }
127
- return {id: uuid(), x: point == null ? void 0 : point.x, y: point == null ? void 0 : point.y};
128
- }).filter((v) => v !== void 0)
129
- })).filter((v) => v.pointList.length !== 0);
130
- return transferViewData;
131
- }
132
-
133
- exports.createThreeMatrix4 = createThreeMatrix4;
134
- exports.getCuboidFromPointCloudBox = getCuboidFromPointCloudBox;
135
- exports.lidar2image = lidar2image;
136
- exports.pointCloudLidar2image = pointCloudLidar2image;
137
- exports.rotatePoint = rotatePoint;
138
- exports.transferKitti2Matrix = transferKitti2Matrix;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),uuid=require("../../utils/uuid.js");function _interopNamespace(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return r[e]}})}}),t.default=r,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,e)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues=(r,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(r,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(r,e,t[e]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));function createThreeMatrix4(r){return new THREE__namespace.Matrix4().set(...r)}function transferKitti2Matrix(r,t,e){const i=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),a=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),l=createThreeMatrix4(i),c=createThreeMatrix4(a),s=createThreeMatrix4(n);return{composeMatrix4:s.clone().premultiply(c).premultiply(l),PM:l,RM:c,TM:s}}function rotatePoint(r,t,e){var i;const a=new THREE__namespace.Vector3(r.x,r.y,(i=r==null?void 0:r.z)!=null?i:1),n=new THREE__namespace.Matrix4().makeRotationZ(e),l=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return a.clone().applyMatrix4(c).applyMatrix4(n).applyMatrix4(l)}function lidar2image(r,t){const i=new THREE__namespace.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(i.z<0)return;const a=1/i.z,n=new THREE__namespace.Matrix4().set(a,0,0,0,0,a,0,0,0,0,a,0,0,0,0,1);return i.applyMatrix4(n)}function getCuboidFromPointCloudBox(r){const{center:t,width:e,height:i,depth:a,rotation:n}=r,l=[{x:t.x+e/2,y:t.y-i/2},{x:t.x+e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y-i/2}].map(o=>{const u=rotatePoint(o,t,n);return{x:u.x,y:u.y}}),c=t.z+a/2,s=t.z-a/2;return __spreadProps(__spreadValues({},r),{polygonPointList:l,zMax:c,zMin:s})}function pointCloudLidar2image(r,t){const e=lbUtils.PointCloudUtils.getAllViewData(r),{P:i,R:a,T:n}=t,{composeMatrix4:l}=transferKitti2Matrix(i,a,n);return e.map(s=>({type:s.type,pointList:s.pointList.map(o=>rotatePoint(o,r.center,r.rotation)).map(o=>lidar2image(o,l)).map(o=>{if(!!o)return{id:uuid(),x:o==null?void 0:o.x,y:o==null?void 0:o.y}}).filter(o=>o!==void 0)})).filter(s=>s.pointList.length!==0)}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.lidar2image=lidar2image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
@@ -1,233 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var defaultConfig = require('../constant/defaultConfig.js');
6
- var EnhanceCommonToolUtils = require('../utils/tool/EnhanceCommonToolUtils.js');
7
- var basicToolOperation = require('./toolOperation/basicToolOperation.js');
8
-
9
- const createEmptyImage = (size) => {
10
- const canvas = document.createElement("canvas");
11
- canvas.width = size.width;
12
- canvas.height = size.height;
13
- const ctx = canvas.getContext("2d");
14
- if (ctx) {
15
- ctx.fillStyle = "transparent";
16
- ctx.fillRect(0, 0, size.width, size.height);
17
- return canvas.toDataURL();
18
- }
19
- return "";
20
- };
21
- const arraySwap = (array, index1, index2) => {
22
- const a = array[index1];
23
- array[index1] = array[index2];
24
- array[index2] = a;
25
- return array;
26
- };
27
- const _HybridToolUtils = class {
28
- static isSingleTool(toolName) {
29
- return !this.isHybridTool(toolName);
30
- }
31
- static isHybridTool(toolName) {
32
- return Array.isArray(toolName);
33
- }
34
- };
35
- let HybridToolUtils = _HybridToolUtils;
36
- HybridToolUtils.getTopToolName = (toolName) => {
37
- return _HybridToolUtils.isHybridTool(toolName) ? toolName[toolName.length - 1] : toolName;
38
- };
39
- class ToolScheduler {
40
- constructor(props) {
41
- this.toolOperationList = [];
42
- this.toolOperationDom = [];
43
- this.toolOperationNameList = [];
44
- var _a, _b;
45
- this.init();
46
- this.container = props.container;
47
- this.size = props.size;
48
- this.imgNode = props.imgNode;
49
- this.config = (_a = props.config) != null ? _a : JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(props.toolName)));
50
- this.style = (_b = props.style) != null ? _b : defaultConfig.styleDefaultConfig;
51
- }
52
- setImgNode(imgNode, basicImgInfo) {
53
- this.toolOperationList.forEach((toolInstance) => {
54
- toolInstance.setImgNode(imgNode, basicImgInfo);
55
- });
56
- }
57
- setImgAttribute(imgAttribute) {
58
- this.toolOperationList.forEach((toolInstance) => {
59
- toolInstance.setImgAttribute(imgAttribute);
60
- });
61
- }
62
- setSize(size) {
63
- this.toolOperationList.forEach((toolInstance) => {
64
- toolInstance.setSize(size);
65
- });
66
- }
67
- syncPosition(currentPos, zoom, imgInfo, currentToolInstance) {
68
- this.toolOperationList.forEach((toolInstance) => {
69
- if (currentToolInstance === toolInstance) {
70
- return;
71
- }
72
- toolInstance.setCurrentPos(currentPos);
73
- toolInstance.setZoom(zoom);
74
- toolInstance.setImgInfo(imgInfo);
75
- toolInstance.renderBasicCanvas();
76
- toolInstance.render();
77
- });
78
- }
79
- get defaultSize() {
80
- var _a, _b;
81
- return {
82
- width: ((_a = this.imgNode) == null ? void 0 : _a.width) || this.size.width,
83
- height: ((_b = this.imgNode) == null ? void 0 : _b.height) || this.size.height
84
- };
85
- }
86
- createDom() {
87
- const {width, height} = this.defaultSize;
88
- const dom = window.document.createElement("div");
89
- dom.style.position = "absolute";
90
- dom.style.left = "0";
91
- dom.style.top = "0";
92
- dom.style.width = `${width}px`;
93
- dom.style.height = `${height}px`;
94
- const zIndex = this.toolOperationList.length + 1;
95
- dom.style.zIndex = `${zIndex}`;
96
- return dom;
97
- }
98
- getEmptyImage(width, height) {
99
- const imgSrc = createEmptyImage({width, height});
100
- const emptyImgNode = new Image();
101
- emptyImgNode.src = imgSrc;
102
- return emptyImgNode;
103
- }
104
- createOperation(tool, imgNode, config) {
105
- var _a;
106
- const {width, height} = this.defaultSize;
107
- const dom = this.createDom();
108
- const emptyImgNode = this.getEmptyImage(width, height);
109
- const defaultData = {
110
- container: dom,
111
- size: this.size,
112
- config: (_a = this == null ? void 0 : this.config) != null ? _a : "{}",
113
- drawOutSideTarget: false,
114
- style: this.style,
115
- imgNode: imgNode || emptyImgNode,
116
- hiddenImg: !!tool
117
- };
118
- if (config) {
119
- Object.assign(defaultData, config);
120
- }
121
- let toolInstance;
122
- if (!tool) {
123
- toolInstance = new basicToolOperation.BasicToolOperation(defaultData);
124
- dom.style.zIndex = "0";
125
- toolInstance.init();
126
- } else {
127
- const ToolOperation = EnhanceCommonToolUtils.getCurrentOperation(tool);
128
- if (!ToolOperation) {
129
- return;
130
- }
131
- toolInstance = new ToolOperation(defaultData);
132
- }
133
- toolInstance == null ? void 0 : toolInstance.init();
134
- toolInstance.canvas.id = tool != null ? tool : "basicCanvas";
135
- toolInstance.on("dragMove", ({currentPos, zoom, imgInfo}) => {
136
- this.syncPosition(currentPos, zoom, imgInfo, toolInstance);
137
- });
138
- toolInstance.on("renderZoom", (zoom, currentPos, imgInfo) => {
139
- if (zoom && currentPos) {
140
- this.syncPosition(currentPos, zoom, imgInfo, toolInstance);
141
- }
142
- });
143
- if (!tool) {
144
- this.container.insertBefore(dom, this.container.childNodes[0]);
145
- this.toolOperationList.unshift(toolInstance);
146
- this.toolOperationDom.unshift(dom);
147
- return toolInstance;
148
- }
149
- this.container.appendChild(dom);
150
- this.toolOperationList.push(toolInstance);
151
- this.toolOperationNameList.push(tool);
152
- this.toolOperationDom.push(dom);
153
- return toolInstance;
154
- }
155
- switchLastTwoCanvas() {
156
- if (this.toolOperationDom.length < 3) {
157
- console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");
158
- return;
159
- }
160
- const len = this.toolOperationDom.length;
161
- const lastOneIndex = len - 1;
162
- const last2SecondIndex = len - 2;
163
- const lastOneDom = this.toolOperationDom[lastOneIndex];
164
- const last2SecondDom = this.toolOperationDom[last2SecondIndex];
165
- if (!last2SecondDom || !lastOneDom) {
166
- return;
167
- }
168
- lastOneDom.style.zIndex = `${lastOneIndex - 1}`;
169
- last2SecondDom.style.zIndex = `${lastOneIndex}`;
170
- this.toolOperationList[lastOneIndex].clearActiveStatus();
171
- this.toolOperationList[lastOneIndex].clearCursorLine();
172
- this.toolOperationList[lastOneIndex].render();
173
- this.toolOperationList = arraySwap(this.toolOperationList, lastOneIndex, last2SecondIndex);
174
- this.toolOperationDom = arraySwap(this.toolOperationDom, lastOneIndex, last2SecondIndex);
175
- return this.toolOperationList[lastOneIndex];
176
- }
177
- getFirstToolOperation() {
178
- if (this.toolOperationList.length > 1) {
179
- return this.toolOperationList[1];
180
- }
181
- return this.toolOperationList[0];
182
- }
183
- switchToCanvas(toolName) {
184
- var _a, _b, _c, _d;
185
- const chosenIndex = this.toolOperationNameList.indexOf(toolName);
186
- if (chosenIndex < 0 || this.toolOperationList.length < 1 || chosenIndex > this.toolOperationDom.length - 1) {
187
- return;
188
- }
189
- const lastOneIndex = this.toolOperationDom.length - 1;
190
- const chosenDom = this.toolOperationDom[chosenIndex];
191
- const lastOneDom = this.toolOperationDom[lastOneIndex];
192
- if (!chosenDom || !lastOneDom) {
193
- return;
194
- }
195
- const temp = lastOneDom.style.zIndex;
196
- lastOneDom.style.zIndex = `${chosenDom.style.zIndex}`;
197
- chosenDom.style.zIndex = `${temp}`;
198
- (_b = (_a = this.toolOperationList[lastOneIndex]).clearActiveStatus) == null ? void 0 : _b.call(_a);
199
- (_d = (_c = this.toolOperationList[lastOneIndex]).clearCursorLine) == null ? void 0 : _d.call(_c);
200
- this.toolOperationList[lastOneIndex].render();
201
- this.toolOperationList = arraySwap(this.toolOperationList, lastOneIndex, chosenIndex);
202
- this.toolOperationDom = arraySwap(this.toolOperationDom, lastOneIndex, chosenIndex);
203
- this.toolOperationNameList = arraySwap(this.toolOperationNameList, lastOneIndex, chosenIndex);
204
- return this.toolOperationList[lastOneIndex];
205
- }
206
- updateDataByToolName(toolName, result) {
207
- const operationIndex = this.toolOperationNameList.indexOf(toolName);
208
- if (operationIndex >= 0) {
209
- const operationInstance = this.toolOperationList[operationIndex];
210
- operationInstance.setResult(result);
211
- }
212
- }
213
- clearStatusAndResult() {
214
- this.toolOperationList.forEach((toolInstance) => {
215
- var _a;
216
- (_a = toolInstance.clearActiveStatus) == null ? void 0 : _a.call(toolInstance);
217
- toolInstance.clearResult();
218
- });
219
- }
220
- destroyAllLayer() {
221
- this.toolOperationList.forEach((toolInstance) => {
222
- toolInstance.destroyCanvas();
223
- this.init();
224
- });
225
- }
226
- init() {
227
- this.toolOperationList = [];
228
- this.toolOperationDom = [];
229
- }
230
- }
231
-
232
- exports.HybridToolUtils = HybridToolUtils;
233
- exports.ToolScheduler = ToolScheduler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var defaultConfig=require("../constant/defaultConfig.js"),EnhanceCommonToolUtils=require("../utils/tool/EnhanceCommonToolUtils.js"),basicToolOperation=require("./toolOperation/basicToolOperation.js");const createEmptyImage=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");return i?(i.fillStyle="transparent",i.fillRect(0,0,e.width,e.height),t.toDataURL()):""},arraySwap=(e,t,i)=>{const o=e[t];return e[t]=e[i],e[i]=o,e},_HybridToolUtils=class{static isSingleTool(e){return!this.isHybridTool(e)}static isHybridTool(e){return Array.isArray(e)}};let HybridToolUtils=_HybridToolUtils;HybridToolUtils.getTopToolName=e=>_HybridToolUtils.isHybridTool(e)?e[e.length-1]:e;class ToolScheduler{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var i,o;this.init(),this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(i=t.config)!=null?i:JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(t.toolName))),this.style=(o=t.style)!=null?o:defaultConfig.styleDefaultConfig}setImgNode(t,i){this.toolOperationList.forEach(o=>{o.setImgNode(t,i)})}setImgAttribute(t){this.toolOperationList.forEach(i=>{i.setImgAttribute(t)})}setSize(t){this.toolOperationList.forEach(i=>{i.setSize(t)})}syncPosition(t,i,o,s){this.toolOperationList.forEach(a=>{s!==a&&(a.setCurrentPos(t),a.setZoom(i),a.setImgInfo(o),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,i;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((i=this.imgNode)==null?void 0:i.height)||this.size.height}}createDom(){const{width:t,height:i}=this.defaultSize,o=window.document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.width=`${t}px`,o.style.height=`${i}px`;const s=this.toolOperationList.length+1;return o.style.zIndex=`${s}`,o}getEmptyImage(t,i){const o=createEmptyImage({width:t,height:i}),s=new Image;return s.src=o,s}createOperation(t,i,o){var s;const{width:a,height:l}=this.defaultSize,r=this.createDom(),d=this.getEmptyImage(a,l),h={container:r,size:this.size,config:(s=this==null?void 0:this.config)!=null?s:"{}",drawOutSideTarget:!1,style:this.style,imgNode:i||d,hiddenImg:!!t};o&&Object.assign(h,o);let n;if(!t)n=new basicToolOperation.BasicToolOperation(h),r.style.zIndex="0",n.init();else{const c=EnhanceCommonToolUtils.getCurrentOperation(t);if(!c)return;n=new c(h)}return n==null||n.init(),n.canvas.id=t!=null?t:"basicCanvas",n.on("dragMove",({currentPos:c,zoom:p,imgInfo:u})=>{this.syncPosition(c,p,u,n)}),n.on("renderZoom",(c,p,u)=>{c&&p&&this.syncPosition(p,c,u,n)}),t?(this.container.appendChild(r),this.toolOperationList.push(n),this.toolOperationNameList.push(t),this.toolOperationDom.push(r),n):(this.container.insertBefore(r,this.container.childNodes[0]),this.toolOperationList.unshift(n),this.toolOperationDom.unshift(r),n)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,i=t-1,o=t-2,s=this.toolOperationDom[i],a=this.toolOperationDom[o];if(!(!a||!s))return s.style.zIndex=`${i-1}`,a.style.zIndex=`${i}`,this.toolOperationList[i].clearActiveStatus(),this.toolOperationList[i].clearCursorLine(),this.toolOperationList[i].render(),this.toolOperationList=arraySwap(this.toolOperationList,i,o),this.toolOperationDom=arraySwap(this.toolOperationDom,i,o),this.toolOperationList[i]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var i,o,s,a;const l=this.toolOperationNameList.indexOf(t);if(l<0||this.toolOperationList.length<1||l>this.toolOperationDom.length-1)return;const r=this.toolOperationDom.length-1,d=this.toolOperationDom[l],h=this.toolOperationDom[r];if(!d||!h)return;const n=h.style.zIndex;return h.style.zIndex=`${d.style.zIndex}`,d.style.zIndex=`${n}`,(o=(i=this.toolOperationList[r]).clearActiveStatus)==null||o.call(i),(a=(s=this.toolOperationList[r]).clearCursorLine)==null||a.call(s),this.toolOperationList[r].render(),this.toolOperationList=arraySwap(this.toolOperationList,r,l),this.toolOperationDom=arraySwap(this.toolOperationDom,r,l),this.toolOperationNameList=arraySwap(this.toolOperationNameList,r,l),this.toolOperationList[r]}updateDataByToolName(t,i){const o=this.toolOperationNameList.indexOf(t);o>=0&&this.toolOperationList[o].setResult(i)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var i;(i=t.clearActiveStatus)==null||i.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[]}}exports.HybridToolUtils=HybridToolUtils,exports.ToolScheduler=ToolScheduler;