@labelbee/lb-annotation 1.14.0-alpha.2 → 1.14.0-alpha.3

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 (187) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +8 -1
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +35 -2
  3. package/dist/_virtual/filterBoxWorker.js +8 -1
  4. package/dist/_virtual/highlightWorker.js +8 -1
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +5 -1
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +5 -1
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +5 -1
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +5 -1
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +5 -1
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +5 -1
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +5 -1
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +5 -1
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +5 -1
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +5 -1
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +5 -7
  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 +5 -12
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +5 -1
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +5 -1
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +5 -1
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +5 -1
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +5 -1
  25. package/dist/constant/annotation.js +127 -1
  26. package/dist/constant/annotationTask.js +30 -1
  27. package/dist/constant/defaultConfig.js +266 -1
  28. package/dist/constant/keyCode.js +38 -1
  29. package/dist/constant/style.js +98 -1
  30. package/dist/constant/tool.js +236 -1
  31. package/dist/core/index.js +150 -1
  32. package/dist/core/pointCloud/OrbitControls.js +665 -1
  33. package/dist/core/pointCloud/PCDLoader.js +260 -2
  34. package/dist/core/pointCloud/annotation.js +215 -1
  35. package/dist/core/pointCloud/cache.js +53 -1
  36. package/dist/core/pointCloud/index.js +991 -5
  37. package/dist/core/pointCloud/matrix.js +138 -1
  38. package/dist/core/pointCloud/segmentation.js +144 -0
  39. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +26 -0
  40. package/dist/core/pointCloud/selector/Sse3dSelector.js +16 -0
  41. package/dist/core/scheduler.js +233 -1
  42. package/dist/core/toolOperation/LineToolOperation.js +1434 -1
  43. package/dist/core/toolOperation/ScribbleTool.js +292 -1
  44. package/dist/core/toolOperation/TextToolOperation.js +131 -1
  45. package/dist/core/toolOperation/ViewOperation.js +556 -1
  46. package/dist/core/toolOperation/basicToolOperation.js +881 -1
  47. package/dist/core/toolOperation/checkOperation.js +208 -1
  48. package/dist/core/toolOperation/cuboidOperation.js +754 -1
  49. package/dist/core/toolOperation/cuboidToggleButtonClass.js +152 -7
  50. package/dist/core/toolOperation/eventListener.js +37 -1
  51. package/dist/core/toolOperation/measureOperation.js +41 -1
  52. package/dist/core/toolOperation/pointCloud2dOperation.js +365 -1
  53. package/dist/core/toolOperation/pointOperation.js +696 -1
  54. package/dist/core/toolOperation/polygonOperation.js +1251 -1
  55. package/dist/core/toolOperation/rectOperation.js +1233 -1
  56. package/dist/core/toolOperation/segmentByRect.js +174 -1
  57. package/dist/core/toolOperation/tagOperation.js +201 -3
  58. package/dist/core/toolOperation/textAttributeClass.js +182 -16
  59. package/dist/index.js +185 -1
  60. package/dist/locales/constants.js +24 -1
  61. package/dist/locales/en_US/message.js +25 -1
  62. package/dist/locales/index.js +19 -1
  63. package/dist/locales/zh_CN/message.js +25 -1
  64. package/dist/newCore/CanvasScheduler.js +35 -1
  65. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  66. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  67. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  68. package/dist/utils/ActionsHistory.js +84 -1
  69. package/dist/utils/ImgUtils.js +23 -1
  70. package/dist/utils/MathUtils.js +385 -2
  71. package/dist/utils/VectorUtils.js +25 -1
  72. package/dist/utils/tool/AttributeUtils.js +218 -1
  73. package/dist/utils/tool/AxisUtils.js +340 -1
  74. package/dist/utils/tool/CanvasUtils.js +62 -1
  75. package/dist/utils/tool/CommonToolUtils.js +174 -1
  76. package/dist/utils/tool/CuboidUtils.js +704 -1
  77. package/dist/utils/tool/DblClickEventListener.js +102 -1
  78. package/dist/utils/tool/DrawUtils.js +492 -3
  79. package/dist/utils/tool/EnhanceCommonToolUtils.js +53 -1
  80. package/dist/utils/tool/ImgPosUtils.js +58 -1
  81. package/dist/utils/tool/LineToolUtils.js +261 -1
  82. package/dist/utils/tool/MarkerUtils.js +56 -1
  83. package/dist/utils/tool/PolygonUtils.js +460 -1
  84. package/dist/utils/tool/RectUtils.js +155 -1
  85. package/dist/utils/tool/RenderDomClass.js +57 -7
  86. package/dist/utils/tool/RenderDomUtils.js +21 -4
  87. package/dist/utils/tool/StyleUtils.js +31 -1
  88. package/dist/utils/tool/TagUtils.js +129 -1
  89. package/dist/utils/tool/UnitUtils.js +12 -1
  90. package/dist/utils/tool/ZoomUtils.js +72 -1
  91. package/dist/utils/tool/polygonTool.js +133 -1
  92. package/dist/utils/uuid.js +26 -1
  93. package/es/_virtual/MathUtilsWorker.js +6 -1
  94. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  95. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  96. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -2
  97. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  98. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  99. package/es/_virtual/filterBoxWorker.js +6 -1
  100. package/es/_virtual/highlightWorker.js +6 -1
  101. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -1
  102. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -1
  103. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -1
  104. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -1
  105. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -1
  106. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -1
  107. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -1
  108. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -1
  109. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -1
  110. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -1
  111. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -5
  112. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -7
  113. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -5
  114. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -5
  115. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -12
  116. package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -1
  117. package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -1
  118. package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -1
  119. package/es/assets/attributeIcon/icon_editLV.svg.js +3 -1
  120. package/es/assets/attributeIcon/icon_editQING.svg.js +3 -1
  121. package/es/constant/annotation.js +113 -1
  122. package/es/constant/annotationTask.js +25 -1
  123. package/es/constant/defaultConfig.js +260 -1
  124. package/es/constant/keyCode.js +36 -1
  125. package/es/constant/style.js +74 -1
  126. package/es/constant/tool.js +220 -1
  127. package/es/core/index.js +148 -1
  128. package/es/core/pointCloud/OrbitControls.js +661 -1
  129. package/es/core/pointCloud/PCDLoader.js +256 -2
  130. package/es/core/pointCloud/annotation.js +211 -1
  131. package/es/core/pointCloud/cache.js +49 -1
  132. package/es/core/pointCloud/index.js +962 -5
  133. package/es/core/pointCloud/matrix.js +109 -1
  134. package/es/core/pointCloud/segmentation.js +120 -0
  135. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +24 -0
  136. package/es/core/pointCloud/selector/Sse3dSelector.js +14 -0
  137. package/es/core/scheduler.js +228 -1
  138. package/es/core/toolOperation/LineToolOperation.js +1421 -1
  139. package/es/core/toolOperation/ScribbleTool.js +290 -1
  140. package/es/core/toolOperation/TextToolOperation.js +129 -1
  141. package/es/core/toolOperation/ViewOperation.js +549 -1
  142. package/es/core/toolOperation/basicToolOperation.js +877 -1
  143. package/es/core/toolOperation/checkOperation.js +206 -1
  144. package/es/core/toolOperation/cuboidOperation.js +752 -1
  145. package/es/core/toolOperation/cuboidToggleButtonClass.js +150 -7
  146. package/es/core/toolOperation/eventListener.js +35 -1
  147. package/es/core/toolOperation/measureOperation.js +39 -1
  148. package/es/core/toolOperation/pointCloud2dOperation.js +359 -1
  149. package/es/core/toolOperation/pointOperation.js +690 -1
  150. package/es/core/toolOperation/polygonOperation.js +1245 -1
  151. package/es/core/toolOperation/rectOperation.js +1228 -1
  152. package/es/core/toolOperation/scribbleTool2.js +249 -0
  153. package/es/core/toolOperation/segmentByRect.js +172 -1
  154. package/es/core/toolOperation/tagOperation.js +199 -3
  155. package/es/core/toolOperation/textAttributeClass.js +180 -16
  156. package/es/index.js +46 -1
  157. package/es/locales/constants.js +22 -1
  158. package/es/locales/en_US/message.js +23 -1
  159. package/es/locales/index.js +17 -1
  160. package/es/locales/zh_CN/message.js +23 -1
  161. package/es/newCore/CanvasScheduler.js +31 -1
  162. package/es/utils/ActionsHistory.js +78 -1
  163. package/es/utils/ImgUtils.js +21 -1
  164. package/es/utils/MathUtils.js +380 -2
  165. package/es/utils/VectorUtils.js +23 -1
  166. package/es/utils/tool/AttributeUtils.js +212 -1
  167. package/es/utils/tool/AxisUtils.js +335 -1
  168. package/es/utils/tool/CanvasUtils.js +60 -1
  169. package/es/utils/tool/CommonToolUtils.js +172 -1
  170. package/es/utils/tool/CuboidUtils.js +680 -1
  171. package/es/utils/tool/DblClickEventListener.js +100 -1
  172. package/es/utils/tool/DrawUtils.js +490 -3
  173. package/es/utils/tool/EnhanceCommonToolUtils.js +48 -1
  174. package/es/utils/tool/ImgPosUtils.js +56 -1
  175. package/es/utils/tool/LineToolUtils.js +255 -1
  176. package/es/utils/tool/MarkerUtils.js +54 -1
  177. package/es/utils/tool/PolygonUtils.js +458 -1
  178. package/es/utils/tool/RectUtils.js +153 -1
  179. package/es/utils/tool/RenderDomClass.js +55 -7
  180. package/es/utils/tool/RenderDomUtils.js +19 -4
  181. package/es/utils/tool/StyleUtils.js +29 -1
  182. package/es/utils/tool/TagUtils.js +127 -1
  183. package/es/utils/tool/UnitUtils.js +10 -1
  184. package/es/utils/tool/ZoomUtils.js +70 -1
  185. package/es/utils/tool/polygonTool.js +126 -1
  186. package/es/utils/uuid.js +24 -1
  187. package/package.json +7 -5
@@ -1,2 +1,260 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils");class PCDLoader extends THREE.Loader{constructor(a){super(a);this.littleEndian=!0}load(a,c,h,g){const i=this,l=new THREE.FileLoader(i.manager);l.setPath(i.path),l.setResponseType("arraybuffer"),l.setRequestHeader(i.requestHeader),l.setWithCredentials(i.withCredentials),l.load(a,function(d){try{c(i.parse(d))}catch(u){g?g(u):console.error(u),i.manager.itemError(a)}},h,g)}parse(a){function c(s,e){const p=s.length,n=new Uint8Array(e);let r=0,t=0,o,w,f;do if(o=s[r++],o<1<<5){if(o++,t+o>e)throw new Error("Output buffer is not large enough");if(r+o>p)throw new Error("Invalid compressed data");do n[t++]=s[r++];while(--o)}else{if(w=o>>5,f=t-((o&31)<<8)-1,r>=p)throw new Error("Invalid compressed data");if(w===7&&(w+=s[r++],r>=p))throw new Error("Invalid compressed data");if(f-=s[r++],t+w+2>e)throw new Error("Output buffer is not large enough");if(f<0)throw new Error("Invalid compressed data");if(f>=t)throw new Error("Invalid compressed data");do n[t++]=n[f++];while(--w+2)}while(r<p);return n}function h(s){const e={},p=s.search(/[\n\r]data\s(\S*)\s/i),n=/[\n\r]data\s(\S*)\s/i.exec(s.slice(p-1));if(e.data=n[1],e.headerLen=n[0].length+p,e.str=s.slice(0,e.headerLen),e.str=e.str.replace(/#.*/gi,""),e.version=/version (.*)/i.exec(e.str),e.fields=/fields (.*)/i.exec(e.str),e.size=/size (.*)/i.exec(e.str),e.type=/type (.*)/i.exec(e.str),e.count=/count (.*)/i.exec(e.str),e.width=/width (.*)/i.exec(e.str),e.height=/height (.*)/i.exec(e.str),e.viewpoint=/viewpoint (.*)/i.exec(e.str),e.points=/points (.*)/i.exec(e.str),e.version!==null&&(e.version=parseFloat(e.version[1])),e.fields=e.fields!==null?e.fields[1].split(" "):[],e.type!==null&&(e.type=e.type[1].split(" ")),e.width!==null&&(e.width=parseInt(e.width[1])),e.height!==null&&(e.height=parseInt(e.height[1])),e.viewpoint!==null&&(e.viewpoint=e.viewpoint[1]),e.points!==null&&(e.points=parseInt(e.points[1],10)),e.points===null&&(e.points=e.width*e.height),e.size!==null&&(e.size=e.size[1].split(" ").map(function(t){return parseInt(t,10)})),e.count!==null)e.count=e.count[1].split(" ").map(function(t){return parseInt(t,10)});else{e.count=[];for(let t=0,o=e.fields.length;t<o;t++)e.count.push(1)}e.offset={};let r=0;for(let t=0,o=e.fields.length;t<o;t++)e.data==="ascii"?e.offset[e.fields[t]]=t:(e.offset[e.fields[t]]=r,r+=e.size[t]*e.count[t]);return e.rowSize=r,e}const g=THREE.LoaderUtils.decodeText(new Uint8Array(a)),i=h(g),l=[],d=[],u=[];if(i.data==="ascii"){const{offset:s}=i,p=g.slice(i.headerLen).split(`
2
- `);for(let n=0,r=p.length;n<r;n++){if(p[n]==="")continue;const t=p[n].split(" ");if(s.x!==void 0&&(l.push(parseFloat(t[s.x])),l.push(parseFloat(t[s.y])),l.push(parseFloat(t[s.z]))),this.genColorByZ){const w=this.genColorByZ(parseFloat(t[s.x]),parseFloat(t[s.y]),parseFloat(t[s.z])).map(f=>f/255);u.push(...w)}s.normal_x!==void 0&&(d.push(parseFloat(t[s.normal_x])),d.push(parseFloat(t[s.normal_y])),d.push(parseFloat(t[s.normal_z])))}}if(i.data==="binary_compressed"){const s=new Uint32Array(a.slice(i.headerLen,i.headerLen+8)),e=s[0],p=s[1],n=c(new Uint8Array(a,i.headerLen+8,e),p),r=new DataView(n.buffer),{offset:t}=i;for(let o=0;o<i.points;o++)if(t.x!==void 0&&(l.push(r.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian)),l.push(r.getFloat32(i.points*t.y+i.size[1]*o,this.littleEndian)),l.push(r.getFloat32(i.points*t.z+i.size[2]*o,this.littleEndian))),t.normal_x!==void 0&&(d.push(r.getFloat32(i.points*t.normal_x+i.size[4]*o,this.littleEndian)),d.push(r.getFloat32(i.points*t.normal_y+i.size[5]*o,this.littleEndian)),d.push(r.getFloat32(i.points*t.normal_z+i.size[6]*o,this.littleEndian))),this.genColorByZ){const f=this.genColorByZ(r.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian),r.getFloat32(i.points*t.y+i.size[0]*o,this.littleEndian),r.getFloat32(i.points*t.z+i.size[0]*o,this.littleEndian)).map(F=>F/255);u.push(...f)}}if(i.data==="binary"){const s=new DataView(a,i.headerLen),{offset:e}=i;for(let p=0,n=0;p<i.points;p++,n+=i.rowSize)if(e.x!==void 0&&(l.push(s.getFloat32(n+e.x,this.littleEndian)),l.push(s.getFloat32(n+e.y,this.littleEndian)),l.push(s.getFloat32(n+e.z,this.littleEndian))),e.normal_x!==void 0&&(d.push(s.getFloat32(n+e.normal_x,this.littleEndian)),d.push(s.getFloat32(n+e.normal_y,this.littleEndian)),d.push(s.getFloat32(n+e.normal_z,this.littleEndian))),this.genColorByZ){const t=this.genColorByZ(s.getFloat32(n+e.x,this.littleEndian),s.getFloat32(n+e.y,this.littleEndian),s.getFloat32(n+e.z,this.littleEndian)).map(o=>o/255);u.push(...t)}}const x=new THREE.BufferGeometry;l.length>0&&x.setAttribute("position",new THREE.Float32BufferAttribute(l,3)),d.length>0&&x.setAttribute("normal",new THREE.Float32BufferAttribute(d,3)),u.length>0&&x.setAttribute("color",new THREE.Float32BufferAttribute(u,3)),x.computeBoundingSphere();const y=new THREE.PointsMaterial({size:.01});return u.length>0?y.vertexColors=!0:y.color.setHex(16777215),new THREE.Points(x,y)}genColorByCoord(a,c,h){return h<=0?[128,128,128]:h<5?[255,0,0]:h<10?[0,255,0]:[0,0,255]}genColorByZ(a,c,h){const g=getIndex(h),i=lbUtils.COLOR_MAP_JET[g];return[i[0],i[1],i[2]]}}function getIndex(m){const a=-7,c=3,h=c-a;return m<a&&(m=a),m>c&&(m=c),Math.floor((m-a)/h*255)}exports.PCDLoader=PCDLoader;
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
+
8
+ class PCDLoader extends THREE.Loader {
9
+ constructor(manager) {
10
+ super(manager);
11
+ this.littleEndian = true;
12
+ }
13
+ load(url, onLoad, onProgress, onError) {
14
+ const scope = this;
15
+ const loader = new THREE.FileLoader(scope.manager);
16
+ loader.setPath(scope.path);
17
+ loader.setResponseType("arraybuffer");
18
+ loader.setRequestHeader(scope.requestHeader);
19
+ loader.setWithCredentials(scope.withCredentials);
20
+ loader.load(url, function(data) {
21
+ try {
22
+ onLoad(scope.parse(data));
23
+ } catch (e) {
24
+ if (onError) {
25
+ onError(e);
26
+ } else {
27
+ console.error(e);
28
+ }
29
+ scope.manager.itemError(url);
30
+ }
31
+ }, onProgress, onError);
32
+ }
33
+ parse(data) {
34
+ function decompressLZF(inData, outLength) {
35
+ const inLength = inData.length;
36
+ const outData = new Uint8Array(outLength);
37
+ let inPtr = 0;
38
+ let outPtr = 0;
39
+ let ctrl;
40
+ let len;
41
+ let ref;
42
+ do {
43
+ ctrl = inData[inPtr++];
44
+ if (ctrl < 1 << 5) {
45
+ ctrl++;
46
+ if (outPtr + ctrl > outLength)
47
+ throw new Error("Output buffer is not large enough");
48
+ if (inPtr + ctrl > inLength)
49
+ throw new Error("Invalid compressed data");
50
+ do {
51
+ outData[outPtr++] = inData[inPtr++];
52
+ } while (--ctrl);
53
+ } else {
54
+ len = ctrl >> 5;
55
+ ref = outPtr - ((ctrl & 31) << 8) - 1;
56
+ if (inPtr >= inLength)
57
+ throw new Error("Invalid compressed data");
58
+ if (len === 7) {
59
+ len += inData[inPtr++];
60
+ if (inPtr >= inLength)
61
+ throw new Error("Invalid compressed data");
62
+ }
63
+ ref -= inData[inPtr++];
64
+ if (outPtr + len + 2 > outLength)
65
+ throw new Error("Output buffer is not large enough");
66
+ if (ref < 0)
67
+ throw new Error("Invalid compressed data");
68
+ if (ref >= outPtr)
69
+ throw new Error("Invalid compressed data");
70
+ do {
71
+ outData[outPtr++] = outData[ref++];
72
+ } while (--len + 2);
73
+ }
74
+ } while (inPtr < inLength);
75
+ return outData;
76
+ }
77
+ function parseHeader(data2) {
78
+ const PCDheader2 = {};
79
+ const result1 = data2.search(/[\n\r]data\s(\S*)\s/i);
80
+ const result2 = /[\n\r]data\s(\S*)\s/i.exec(data2.slice(result1 - 1));
81
+ PCDheader2.data = result2[1];
82
+ PCDheader2.headerLen = result2[0].length + result1;
83
+ PCDheader2.str = data2.slice(0, PCDheader2.headerLen);
84
+ PCDheader2.str = PCDheader2.str.replace(/#.*/gi, "");
85
+ PCDheader2.version = /version (.*)/i.exec(PCDheader2.str);
86
+ PCDheader2.fields = /fields (.*)/i.exec(PCDheader2.str);
87
+ PCDheader2.size = /size (.*)/i.exec(PCDheader2.str);
88
+ PCDheader2.type = /type (.*)/i.exec(PCDheader2.str);
89
+ PCDheader2.count = /count (.*)/i.exec(PCDheader2.str);
90
+ PCDheader2.width = /width (.*)/i.exec(PCDheader2.str);
91
+ PCDheader2.height = /height (.*)/i.exec(PCDheader2.str);
92
+ PCDheader2.viewpoint = /viewpoint (.*)/i.exec(PCDheader2.str);
93
+ PCDheader2.points = /points (.*)/i.exec(PCDheader2.str);
94
+ if (PCDheader2.version !== null)
95
+ PCDheader2.version = parseFloat(PCDheader2.version[1]);
96
+ PCDheader2.fields = PCDheader2.fields !== null ? PCDheader2.fields[1].split(" ") : [];
97
+ if (PCDheader2.type !== null)
98
+ PCDheader2.type = PCDheader2.type[1].split(" ");
99
+ if (PCDheader2.width !== null)
100
+ PCDheader2.width = parseInt(PCDheader2.width[1]);
101
+ if (PCDheader2.height !== null)
102
+ PCDheader2.height = parseInt(PCDheader2.height[1]);
103
+ if (PCDheader2.viewpoint !== null)
104
+ PCDheader2.viewpoint = PCDheader2.viewpoint[1];
105
+ if (PCDheader2.points !== null)
106
+ PCDheader2.points = parseInt(PCDheader2.points[1], 10);
107
+ if (PCDheader2.points === null)
108
+ PCDheader2.points = PCDheader2.width * PCDheader2.height;
109
+ if (PCDheader2.size !== null) {
110
+ PCDheader2.size = PCDheader2.size[1].split(" ").map(function(x) {
111
+ return parseInt(x, 10);
112
+ });
113
+ }
114
+ if (PCDheader2.count !== null) {
115
+ PCDheader2.count = PCDheader2.count[1].split(" ").map(function(x) {
116
+ return parseInt(x, 10);
117
+ });
118
+ } else {
119
+ PCDheader2.count = [];
120
+ for (let i = 0, l = PCDheader2.fields.length; i < l; i++) {
121
+ PCDheader2.count.push(1);
122
+ }
123
+ }
124
+ PCDheader2.offset = {};
125
+ let sizeSum = 0;
126
+ for (let i = 0, l = PCDheader2.fields.length; i < l; i++) {
127
+ if (PCDheader2.data === "ascii") {
128
+ PCDheader2.offset[PCDheader2.fields[i]] = i;
129
+ } else {
130
+ PCDheader2.offset[PCDheader2.fields[i]] = sizeSum;
131
+ sizeSum += PCDheader2.size[i] * PCDheader2.count[i];
132
+ }
133
+ }
134
+ PCDheader2.rowSize = sizeSum;
135
+ return PCDheader2;
136
+ }
137
+ const textData = THREE.LoaderUtils.decodeText(new Uint8Array(data));
138
+ const PCDheader = parseHeader(textData);
139
+ const position = [];
140
+ const normal = [];
141
+ const color = [];
142
+ if (PCDheader.data === "ascii") {
143
+ const {offset} = PCDheader;
144
+ const pcdData = textData.slice(PCDheader.headerLen);
145
+ const lines = pcdData.split("\n");
146
+ for (let i = 0, l = lines.length; i < l; i++) {
147
+ if (lines[i] === "")
148
+ continue;
149
+ const line = lines[i].split(" ");
150
+ if (offset.x !== void 0) {
151
+ position.push(parseFloat(line[offset.x]));
152
+ position.push(parseFloat(line[offset.y]));
153
+ position.push(parseFloat(line[offset.z]));
154
+ }
155
+ if (this.genColorByZ) {
156
+ const pdColor = this.genColorByZ(parseFloat(line[offset.x]), parseFloat(line[offset.y]), parseFloat(line[offset.z]));
157
+ const pdColorUnit8 = pdColor.map((hex) => hex / 255);
158
+ color.push(...pdColorUnit8);
159
+ }
160
+ if (offset.normal_x !== void 0) {
161
+ normal.push(parseFloat(line[offset.normal_x]));
162
+ normal.push(parseFloat(line[offset.normal_y]));
163
+ normal.push(parseFloat(line[offset.normal_z]));
164
+ }
165
+ }
166
+ }
167
+ if (PCDheader.data === "binary_compressed") {
168
+ const sizes = new Uint32Array(data.slice(PCDheader.headerLen, PCDheader.headerLen + 8));
169
+ const compressedSize = sizes[0];
170
+ const decompressedSize = sizes[1];
171
+ const decompressed = decompressLZF(new Uint8Array(data, PCDheader.headerLen + 8, compressedSize), decompressedSize);
172
+ const dataview = new DataView(decompressed.buffer);
173
+ const {offset} = PCDheader;
174
+ for (let i = 0; i < PCDheader.points; i++) {
175
+ if (offset.x !== void 0) {
176
+ position.push(dataview.getFloat32(PCDheader.points * offset.x + PCDheader.size[0] * i, this.littleEndian));
177
+ position.push(dataview.getFloat32(PCDheader.points * offset.y + PCDheader.size[1] * i, this.littleEndian));
178
+ position.push(dataview.getFloat32(PCDheader.points * offset.z + PCDheader.size[2] * i, this.littleEndian));
179
+ }
180
+ if (offset.normal_x !== void 0) {
181
+ normal.push(dataview.getFloat32(PCDheader.points * offset.normal_x + PCDheader.size[4] * i, this.littleEndian));
182
+ normal.push(dataview.getFloat32(PCDheader.points * offset.normal_y + PCDheader.size[5] * i, this.littleEndian));
183
+ normal.push(dataview.getFloat32(PCDheader.points * offset.normal_z + PCDheader.size[6] * i, this.littleEndian));
184
+ }
185
+ if (this.genColorByZ) {
186
+ const pdColor = this.genColorByZ(dataview.getFloat32(PCDheader.points * offset.x + PCDheader.size[0] * i, this.littleEndian), dataview.getFloat32(PCDheader.points * offset.y + PCDheader.size[0] * i, this.littleEndian), dataview.getFloat32(PCDheader.points * offset.z + PCDheader.size[0] * i, this.littleEndian));
187
+ const pdColorUnit8 = pdColor.map((hex) => hex / 255);
188
+ color.push(...pdColorUnit8);
189
+ }
190
+ }
191
+ }
192
+ if (PCDheader.data === "binary") {
193
+ const dataview = new DataView(data, PCDheader.headerLen);
194
+ const {offset} = PCDheader;
195
+ for (let i = 0, row = 0; i < PCDheader.points; i++, row += PCDheader.rowSize) {
196
+ if (offset.x !== void 0) {
197
+ position.push(dataview.getFloat32(row + offset.x, this.littleEndian));
198
+ position.push(dataview.getFloat32(row + offset.y, this.littleEndian));
199
+ position.push(dataview.getFloat32(row + offset.z, this.littleEndian));
200
+ }
201
+ if (offset.normal_x !== void 0) {
202
+ normal.push(dataview.getFloat32(row + offset.normal_x, this.littleEndian));
203
+ normal.push(dataview.getFloat32(row + offset.normal_y, this.littleEndian));
204
+ normal.push(dataview.getFloat32(row + offset.normal_z, this.littleEndian));
205
+ }
206
+ if (this.genColorByZ) {
207
+ const pdColor = this.genColorByZ(dataview.getFloat32(row + offset.x, this.littleEndian), dataview.getFloat32(row + offset.y, this.littleEndian), dataview.getFloat32(row + offset.z, this.littleEndian));
208
+ const pdColorUnit8 = pdColor.map((hex) => hex / 255);
209
+ color.push(...pdColorUnit8);
210
+ }
211
+ }
212
+ }
213
+ const geometry = new THREE.BufferGeometry();
214
+ if (position.length > 0)
215
+ geometry.setAttribute("position", new THREE.Float32BufferAttribute(position, 3));
216
+ if (normal.length > 0)
217
+ geometry.setAttribute("normal", new THREE.Float32BufferAttribute(normal, 3));
218
+ if (color.length > 0)
219
+ geometry.setAttribute("color", new THREE.Float32BufferAttribute(color, 3));
220
+ geometry.computeBoundingSphere();
221
+ const material = new THREE.PointsMaterial({size: 0.01});
222
+ if (color.length > 0) {
223
+ material.vertexColors = true;
224
+ } else {
225
+ material.color.setHex(16777215);
226
+ }
227
+ return new THREE.Points(geometry, material);
228
+ }
229
+ genColorByCoord(x, y, z) {
230
+ if (z <= 0) {
231
+ return [128, 128, 128];
232
+ }
233
+ if (z < 5) {
234
+ return [255, 0, 0];
235
+ }
236
+ if (z < 10) {
237
+ return [0, 255, 0];
238
+ }
239
+ return [0, 0, 255];
240
+ }
241
+ genColorByZ(x, y, z) {
242
+ const index = getIndex(z);
243
+ const color = lbUtils.COLOR_MAP_JET[index];
244
+ return [color[0], color[1], color[2]];
245
+ }
246
+ }
247
+ function getIndex(z) {
248
+ const minZ = -7;
249
+ const maxZ = 3;
250
+ const len = maxZ - minZ;
251
+ if (z < minZ) {
252
+ z = minZ;
253
+ }
254
+ if (z > maxZ) {
255
+ z = maxZ;
256
+ }
257
+ return Math.floor((z - minZ) / len * 255);
258
+ }
259
+
260
+ exports.PCDLoader = PCDLoader;
@@ -1 +1,215 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),scheduler=require("../scheduler.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,e)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,__spreadValues=(i,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(i,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(i,e,t[e]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));const createEmptyImage=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const e=t.getContext("2d");return e?(e.fillStyle="black",e.fillRect(0,0,i.width,i.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:e,pcdPath:a,extraProps:P,config:m,checkMode:v,toolName:d}){this.updateLineList=s=>{const l=s.map(n=>{var o;return __spreadProps(__spreadValues({},n),{pointList:(o=n==null?void 0:n.pointList)==null?void 0:o.map(r=>lbUtils.PointCloudUtils.transferWorld2Canvas(r,this.toolInstance.size))})});this.toolScheduler.updateDataByToolName(tool.EToolName.Line,l)},this.updatePolygonList=(s,l)=>{let n=s.map(o=>{var r;const{polygon2d:C}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(o);return{id:o.id,sourceID:"",pointList:C,isRect:!0,valid:(r=o.valid)!=null?r:!0,attribute:o.attribute}});l&&(n=n.concat(l.map(o=>{var r;return __spreadProps(__spreadValues({},o),{pointList:(r=o==null?void 0:o.pointList)==null?void 0:r.map(C=>lbUtils.PointCloudUtils.transferWorld2Canvas(C,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(tool.EToolName.PointCloudPolygon,n)},this.updatePointList=s=>{const l=s==null?void 0:s.map(n=>{var o;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(n);return __spreadProps(__spreadValues({},r),{id:n.id,sourceID:"",valid:(o=n.valid)!=null?o:!0,attribute:n.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(tool.EToolName.Point,l)};const O=this.getDefaultOrthographic(t),I=createEmptyImage(t),u=new Image;u.src=I;const p=new scheduler.ToolScheduler({container:e,size:t,toolName:d}),f=new CanvasScheduler.CanvasScheduler({container:e}),h=new index.PointCloud({container:e,noAppend:!0,isOrthographicCamera:!0,orthographicParams:O});a&&h.loadPCDFile(a),f.createCanvas(h.renderer.domElement);const g={size:t,config:JSON.stringify(__spreadProps(__spreadValues({},m),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:u,checkMode:v};P&&Object.assign(g,P);let c=[];scheduler.HybridToolUtils.isSingleTool(d)?c=[d]:c=d,c.forEach((s,l)=>{let n;if(s===tool.EToolName.PointCloudPolygon){const o=p.createOperation(s,u,g);o.eventBinding(),o.setPattern(tool.EPolygonPattern.Rect),this.toolInstance=o,this.toolInstance.eventBinding(),this.pointCloud2dOperation=o}else n=p.createOperation(s,u,g);l===c.length-1&&(this.toolInstance||(this.toolInstance=n,this.toolInstance.eventBinding()))}),this.pointCloudInstance=h,this.canvasScheduler=f,this.toolScheduler=p,this.config=m}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const e=createEmptyImage(t),a=new Image;a.src=e,a.onload=()=>{this.toolInstance.setImgNode(a),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),a=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,a)}addLineListOnTopView(t){const e=lbUtils.PointCloudUtils.getLineListFromResultList(t);this.updateLineList(e)}addPointListOnTopView(t){const e=lbUtils.PointCloudUtils.getSphereParamsFromResultList(t);this.updatePointList(e)}updateData(t,e,a){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,a==null?void 0:a.radius),this.addPolygonListOnTopView(e),this.addLineListOnTopView(e),this.addPointListOnTopView(e))}switchToCanvas(t){const e=this.toolScheduler.switchToCanvas(t);return e?(e.eventBinding(),this.toolInstance=e,e):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var lbUtils = require('@labelbee/lb-utils');
6
+ var tool = require('../../constant/tool.js');
7
+ var CanvasScheduler = require('../../newCore/CanvasScheduler.js');
8
+ var index = require('./index.js');
9
+ var scheduler = require('../scheduler.js');
10
+
11
+ var __defProp = Object.defineProperty;
12
+ var __defProps = Object.defineProperties;
13
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
14
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
18
+ var __spreadValues = (a, b) => {
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(b)) {
24
+ if (__propIsEnum.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ }
27
+ return a;
28
+ };
29
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
30
+ const createEmptyImage = (size) => {
31
+ const canvas = document.createElement("canvas");
32
+ canvas.width = size.width;
33
+ canvas.height = size.height;
34
+ const ctx = canvas.getContext("2d");
35
+ if (ctx) {
36
+ ctx.fillStyle = "black";
37
+ ctx.fillRect(0, 0, size.width, size.height);
38
+ return canvas.toDataURL();
39
+ }
40
+ return "";
41
+ };
42
+ class PointCloudAnnotation {
43
+ constructor({size, container, pcdPath, extraProps, config, checkMode, toolName}) {
44
+ this.updateLineList = (lineList) => {
45
+ const list = lineList.map((v) => {
46
+ var _a;
47
+ return __spreadProps(__spreadValues({}, v), {
48
+ pointList: (_a = v == null ? void 0 : v.pointList) == null ? void 0 : _a.map((point) => lbUtils.PointCloudUtils.transferWorld2Canvas(point, this.toolInstance.size))
49
+ });
50
+ });
51
+ this.toolScheduler.updateDataByToolName(tool.EToolName.Line, list);
52
+ };
53
+ this.updatePolygonList = (pointCloudDataList, extraList) => {
54
+ let polygonList = pointCloudDataList.map((v) => {
55
+ var _a;
56
+ const {polygon2d: pointList} = this.pointCloudInstance.getBoxTopPolygon2DCoordinate(v);
57
+ return {
58
+ id: v.id,
59
+ sourceID: "",
60
+ pointList,
61
+ isRect: true,
62
+ valid: (_a = v.valid) != null ? _a : true,
63
+ attribute: v.attribute
64
+ };
65
+ });
66
+ if (extraList) {
67
+ polygonList = polygonList.concat(extraList.map((v) => {
68
+ var _a;
69
+ return __spreadProps(__spreadValues({}, v), {
70
+ pointList: (_a = v == null ? void 0 : v.pointList) == null ? void 0 : _a.map((point) => lbUtils.PointCloudUtils.transferWorld2Canvas(point, this.toolInstance.size))
71
+ });
72
+ }));
73
+ }
74
+ this.toolScheduler.updateDataByToolName(tool.EToolName.PointCloudPolygon, polygonList);
75
+ };
76
+ this.updatePointList = (sphereList) => {
77
+ const pointList = sphereList == null ? void 0 : sphereList.map((v) => {
78
+ var _a;
79
+ const {point2d} = this.pointCloudInstance.getSphereTopPoint2DCoordinate(v);
80
+ return __spreadProps(__spreadValues({}, point2d), {
81
+ id: v.id,
82
+ sourceID: "",
83
+ valid: (_a = v.valid) != null ? _a : true,
84
+ attribute: v.attribute,
85
+ textAttribute: ""
86
+ });
87
+ });
88
+ this.toolScheduler.updateDataByToolName(tool.EToolName.Point, pointList);
89
+ };
90
+ const defaultOrthographic = this.getDefaultOrthographic(size);
91
+ const imgSrc = createEmptyImage(size);
92
+ const image = new Image();
93
+ image.src = imgSrc;
94
+ const toolScheduler = new scheduler.ToolScheduler({container, size, toolName});
95
+ const canvasScheduler = new CanvasScheduler.CanvasScheduler({container});
96
+ const pointCloud = new index.PointCloud({
97
+ container,
98
+ noAppend: true,
99
+ isOrthographicCamera: true,
100
+ orthographicParams: defaultOrthographic
101
+ });
102
+ if (pcdPath) {
103
+ pointCloud.loadPCDFile(pcdPath);
104
+ }
105
+ canvasScheduler.createCanvas(pointCloud.renderer.domElement);
106
+ const defaultProps = {
107
+ size,
108
+ config: JSON.stringify(__spreadProps(__spreadValues({}, config), {attributeConfigurable: true, hideAttribute: true})),
109
+ imgNode: image,
110
+ checkMode
111
+ };
112
+ if (extraProps) {
113
+ Object.assign(defaultProps, extraProps);
114
+ }
115
+ let toolList = [];
116
+ if (scheduler.HybridToolUtils.isSingleTool(toolName)) {
117
+ toolList = [toolName];
118
+ } else {
119
+ toolList = toolName;
120
+ }
121
+ toolList.forEach((tool$1, i) => {
122
+ let toolInstance;
123
+ if (tool$1 === tool.EToolName.PointCloudPolygon) {
124
+ const pointCloudPolygonOperation = toolScheduler.createOperation(tool$1, image, defaultProps);
125
+ pointCloudPolygonOperation.eventBinding();
126
+ pointCloudPolygonOperation.setPattern(tool.EPolygonPattern.Rect);
127
+ this.toolInstance = pointCloudPolygonOperation;
128
+ this.toolInstance.eventBinding();
129
+ this.pointCloud2dOperation = pointCloudPolygonOperation;
130
+ } else {
131
+ toolInstance = toolScheduler.createOperation(tool$1, image, defaultProps);
132
+ }
133
+ if (i === toolList.length - 1) {
134
+ if (!this.toolInstance) {
135
+ this.toolInstance = toolInstance;
136
+ this.toolInstance.eventBinding();
137
+ }
138
+ }
139
+ });
140
+ this.pointCloudInstance = pointCloud;
141
+ this.canvasScheduler = canvasScheduler;
142
+ this.toolScheduler = toolScheduler;
143
+ this.config = config;
144
+ }
145
+ updateConfig(config) {
146
+ this.config = config;
147
+ this.pointCloud2dOperation.setConfig(JSON.stringify(config));
148
+ }
149
+ getDefaultOrthographic(size) {
150
+ return {
151
+ left: -size.width / 2,
152
+ right: size.width / 2,
153
+ top: size.height / 2,
154
+ bottom: -size.height / 2,
155
+ near: 100,
156
+ far: -100
157
+ };
158
+ }
159
+ initSize(size) {
160
+ this.pointCloudInstance.updateTopCamera();
161
+ this.pointCloudInstance.setDefaultControls();
162
+ this.pointCloudInstance.initRenderer();
163
+ this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(size));
164
+ this.pointCloudInstance.render();
165
+ const imgSrc = createEmptyImage(size);
166
+ const image = new Image();
167
+ image.src = imgSrc;
168
+ image.onload = () => {
169
+ this.toolInstance.setImgNode(image);
170
+ this.toolInstance.initImgPos();
171
+ };
172
+ this.pointCloud2dOperation.setCanvasSize(size);
173
+ }
174
+ addPolygonListOnTopView(result) {
175
+ const pointCloudDataList = lbUtils.PointCloudUtils.getBoxParamsFromResultList(result);
176
+ const polygonList = lbUtils.PointCloudUtils.getPolygonListFromResultList(result);
177
+ this.updatePolygonList(pointCloudDataList, polygonList);
178
+ }
179
+ addLineListOnTopView(result) {
180
+ const lineList = lbUtils.PointCloudUtils.getLineListFromResultList(result);
181
+ this.updateLineList(lineList);
182
+ }
183
+ addPointListOnTopView(result) {
184
+ const sphereList = lbUtils.PointCloudUtils.getSphereParamsFromResultList(result);
185
+ this.updatePointList(sphereList);
186
+ }
187
+ updateData(pcdPath, result, config) {
188
+ if (!this.toolInstance || !this.pointCloudInstance) {
189
+ return;
190
+ }
191
+ this.pointCloudInstance.loadPCDFile(pcdPath, config == null ? void 0 : config.radius);
192
+ this.addPolygonListOnTopView(result);
193
+ this.addLineListOnTopView(result);
194
+ this.addPointListOnTopView(result);
195
+ }
196
+ switchToCanvas(toolName) {
197
+ const newInstance = this.toolScheduler.switchToCanvas(toolName);
198
+ if (newInstance) {
199
+ newInstance.eventBinding();
200
+ this.toolInstance = newInstance;
201
+ return newInstance;
202
+ }
203
+ return this.toolInstance;
204
+ }
205
+ initAllPosition() {
206
+ this.pointCloudInstance.updateTopCamera();
207
+ this.pointCloud2dOperation.initPosition();
208
+ }
209
+ clearAllData() {
210
+ this.pointCloudInstance.clearPointCloudAndRender();
211
+ this.pointCloud2dOperation.clearResult();
212
+ }
213
+ }
214
+
215
+ exports.PointCloudAnnotation = PointCloudAnnotation;
@@ -1 +1,53 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PCDLoader=require("./PCDLoader.js");class PointCloudCache{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((s,n)=>{const o=this.pointsMap.get(t),i=this.colorMap.get(t);if(o&&i){s({points:o,color:i});return}if(this.cacheList.length>this.MAX_SIZE){const e=this.cacheList.shift();e&&this.pointsMap.delete(e.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,e=>{const r=e.geometry.attributes.position.array,a=e.geometry.attributes.color.array;this.pointsMap.set(t,r),this.colorMap.set(t,a),s({points:r,color:a})},()=>{},e=>{n(e)})}),this.pcdLoader=new PCDLoader.PCDLoader,this.pointsMap=new Map,this.colorMap=new Map}static getInstance(){return this.instance==null&&(this.instance=new PointCloudCache),this.instance}updateColor(t,s){this.colorMap.set(t,s)}}exports.PointCloudCache=PointCloudCache;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var PCDLoader = require('./PCDLoader.js');
6
+
7
+ class PointCloudCache {
8
+ constructor() {
9
+ this.MAX_SIZE = 50;
10
+ this.cacheList = [];
11
+ this.loadPCDFile = (src) => {
12
+ return new Promise((resolve, reject) => {
13
+ const clonePoints = this.pointsMap.get(src);
14
+ const cloneColor = this.colorMap.get(src);
15
+ if (clonePoints && cloneColor) {
16
+ resolve({points: clonePoints, color: cloneColor});
17
+ return;
18
+ }
19
+ if (this.cacheList.length > this.MAX_SIZE) {
20
+ const firstCacheInfo = this.cacheList.shift();
21
+ if (firstCacheInfo) {
22
+ this.pointsMap.delete(firstCacheInfo.src);
23
+ }
24
+ }
25
+ this.cacheList.push({src});
26
+ this.pcdLoader.load(src, (points) => {
27
+ const pointsArray = points.geometry.attributes.position.array;
28
+ const colorArray = points.geometry.attributes.color.array;
29
+ this.pointsMap.set(src, pointsArray);
30
+ this.colorMap.set(src, colorArray);
31
+ resolve({points: pointsArray, color: colorArray});
32
+ }, () => {
33
+ }, (err) => {
34
+ reject(err);
35
+ });
36
+ });
37
+ };
38
+ this.pcdLoader = new PCDLoader.PCDLoader();
39
+ this.pointsMap = new Map();
40
+ this.colorMap = new Map();
41
+ }
42
+ static getInstance() {
43
+ if (this.instance == null) {
44
+ this.instance = new PointCloudCache();
45
+ }
46
+ return this.instance;
47
+ }
48
+ updateColor(src, color) {
49
+ this.colorMap.set(src, color);
50
+ }
51
+ }
52
+
53
+ exports.PointCloudCache = PointCloudCache;