@labelbee/lb-annotation 1.27.0-alpha.9 → 1.28.0-alpha.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 (47) hide show
  1. package/dist/_virtual/highlightWorker.js +1 -1
  2. package/dist/constant/keyCode.js +1 -1
  3. package/dist/constant/tool.js +1 -1
  4. package/dist/core/pointCloud/OrbitControls.js +1 -1
  5. package/dist/core/pointCloud/index.js +4 -2
  6. package/dist/core/pointCloud/matrix.js +1 -1
  7. package/dist/core/pointCloud/omniCamera.js +1 -1
  8. package/dist/core/toolOperation/ViewOperation.js +1 -1
  9. package/dist/core/toolOperation/basicToolOperation.js +1 -1
  10. package/dist/core/toolOperation/pointCloud2DRectOperation.js +1 -1
  11. package/dist/core/toolOperation/pointOperation.js +1 -1
  12. package/dist/core/toolOperation/polygonOperation.js +1 -1
  13. package/dist/core/toolOperation/rectOperation.js +2 -1
  14. package/dist/core/toolOperation/utils/reCalcRect.js +1 -0
  15. package/dist/types/constant/keyCode.d.ts +1 -0
  16. package/dist/types/constant/tool.d.ts +2 -1
  17. package/dist/types/core/pointCloud/index.d.ts +54 -4
  18. package/dist/types/core/toolOperation/ViewOperation.d.ts +22 -1
  19. package/dist/types/core/toolOperation/basicToolOperation.d.ts +1 -0
  20. package/dist/types/core/toolOperation/pointCloud2DRectOperation.d.ts +10 -2
  21. package/dist/types/core/toolOperation/pointOperation.d.ts +4 -0
  22. package/dist/types/core/toolOperation/polygonOperation.d.ts +2 -0
  23. package/dist/types/core/toolOperation/rectOperation.d.ts +22 -5
  24. package/dist/types/core/toolOperation/utils/reCalcRect.d.ts +9 -0
  25. package/dist/types/utils/MathUtils.d.ts +7 -0
  26. package/dist/types/utils/tool/AxisUtils.d.ts +3 -0
  27. package/dist/types/utils/tool/PolygonUtils.d.ts +13 -0
  28. package/dist/types/utils/tool/RectUtils.d.ts +3 -0
  29. package/dist/utils/MathUtils.js +1 -1
  30. package/dist/utils/tool/PolygonUtils.js +1 -1
  31. package/es/_virtual/highlightWorker.js +1 -1
  32. package/es/constant/keyCode.js +1 -1
  33. package/es/constant/tool.js +1 -1
  34. package/es/core/pointCloud/OrbitControls.js +1 -1
  35. package/es/core/pointCloud/index.js +4 -2
  36. package/es/core/pointCloud/matrix.js +1 -1
  37. package/es/core/pointCloud/omniCamera.js +1 -1
  38. package/es/core/toolOperation/ViewOperation.js +1 -1
  39. package/es/core/toolOperation/basicToolOperation.js +1 -1
  40. package/es/core/toolOperation/pointCloud2DRectOperation.js +1 -1
  41. package/es/core/toolOperation/pointOperation.js +1 -1
  42. package/es/core/toolOperation/polygonOperation.js +1 -1
  43. package/es/core/toolOperation/rectOperation.js +2 -1
  44. package/es/core/toolOperation/utils/reCalcRect.js +1 -0
  45. package/es/utils/MathUtils.js +2 -2
  46. package/es/utils/tool/PolygonUtils.js +1 -1
  47. package/package.json +2 -2
@@ -1 +1 @@
1
- "use strict";var _rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory=require("./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js"),WorkerFactory=_rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory.createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHAodCl7Y29uc3QgZT0tNyxpPTMsbz1pLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5pJiYodD1pKSxNYXRoLmZsb29yKCh0LWUpL28qMjU1KX1mdW5jdGlvbiBoKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBpPTA7aTwyMDtpKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPWgoKTtmdW5jdGlvbiBkKHQsZSxpPTApe2xldCBvPTAscyxhLHIsZjtlPVsuLi5lXSxpPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsdSk9PlsuLi5jLHUueCx1LnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IG49ZS5sZW5ndGg7Zm9yKHM9MTtzPD1uO3MrKylmPWVbcyVuXSx0Lng+TWF0aC5taW4oci54LGYueCkmJnQueDw9TWF0aC5tYXgoci54LGYueCkmJnQueTw9TWF0aC5tYXgoci55LGYueSkmJnIueCE9PWYueCYmKGE9KHQueC1yLngpKihmLnktci55KS8oZi54LXIueCkrci55LChyLnk9PT1mLnl8fHQueTw9YSkmJm8rKykscj1mO3JldHVybiBvJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0OmksYXR0cmlidXRlOm8seDpzLHk6YSx6OnIsY29sb3JMaXN0OmYsdmFsaWQ6bn0pe2lmKGQoe3g6cyx5OmF9LGkpJiZyPj10JiZyPD1lKXJldHVybiBuPT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpmW29dP2Zbb10ucmdiYS5zbGljZSgwLDMpLm1hcCh1PT51LzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOmksY29sb3I6byxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmEsaGlnaGxpZ2h0SW5kZXg6cn09ZS5kYXRhO2xldCBmPTA7Zm9yKGxldCBuPTA7bjxpLmxlbmd0aDtuKz0zKXtjb25zdCBjPWlbbl0sdT1pW24rMV0sZz1pW24rMl0sbT1zLm1hcChsPT5iKHtwb2x5Z29uUG9pbnRMaXN0OmwucG9seWdvblBvaW50TGlzdCx6TWluOmwuek1pbix6TWF4Omwuek1heCx4OmMseTp1LHo6ZyxhdHRyaWJ1dGU6bC5hdHRyaWJ1dGUsY29sb3JMaXN0OmEsdmFsaWQ6bC52YWxpZH0pKS5maWx0ZXIobD0+bCkucG9wKCk7aWYobSl7ZisrO2NvbnN0W2wseSxNXT1tO29bbl09bCxvW24rMV09eSxvW24rMl09TX1lbHNle2NvbnN0IGw9TWF0aC5mbG9vcihuLzMpO2lmKHImJnJbbF09PT0xKW9bbl09MCxvW24rMV09MCxvW24rMl09MDtlbHNle2NvbnN0IHk9cChnKSxNPUNbeV0sW3csSSxfXT1NO29bbl09dy8yNTUsb1tuKzFdPUkvMjU1LG9bbisyXT1fLzI1NX19fXBvc3RNZXNzYWdlKHtwb2ludHM6aSxjb2xvcjpvLG51bTpmfSl9LHguaXNJblBvbHlnb249ZCxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);module.exports=WorkerFactory;
1
+ "use strict";var _rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory=require("./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js"),WorkerFactory=_rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory.createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24ocCl7InVzZSBzdHJpY3QiO2NvbnN0IHY9Wy0xLC0xLC0xXTtsZXQgST0hMTtmdW5jdGlvbiBCKGUpe2NvbnN0IHQ9LTcsbz0zLG49by10O3JldHVybiBlPHQmJihlPXQpLGU+byYmKGU9byksTWF0aC5mbG9vcigoZS10KS9uKjI1NSl9ZnVuY3Rpb24gRSgpe2xldCBlO2NvbnN0IHQ9bmV3IEFycmF5KDI1NikuZmlsbCgiIikubWFwKCgpPT5uZXcgQXJyYXkoMykuZmlsbCgiIikpO2ZvcihsZXQgbz0wO288MjA7bysrKXtmb3IoZT0wO2U8MzI7ZSsrKXRbZV1bMF09MTI4KzQqZSx0W2VdWzFdPTAsdFtlXVsyXT0wO2Zvcih0WzMyXVswXT0yNTUsdFszMl1bMV09MCx0WzMyXVsyXT0wLGU9MDtlPDYzO2UrKyl0WzMzK2VdWzBdPTI1NSx0WzMzK2VdWzFdPTQrNCplLHRbMzMrZV1bMl09MDtmb3IodFs5Nl1bMF09MjU0LHRbOTZdWzFdPTI1NSx0Wzk2XVsyXT0yLGU9MDtlPDYyO2UrKyl0Wzk3K2VdWzBdPTI1MC00KmUsdFs5NytlXVsxXT0yNTUsdFs5NytlXVsyXT02KzQqZTtmb3IodFsxNTldWzBdPTEsdFsxNTldWzFdPTI1NSx0WzE1OV1bMl09MjU0LGU9MDtlPDY0O2UrKyl0WzE2MCtlXVswXT0wLHRbMTYwK2VdWzFdPTI1Mi1lKjQsdFsxNjArZV1bMl09MjU1O2ZvcihlPTA7ZTwzMjtlKyspdFsyMjQrZV1bMF09MCx0WzIyNCtlXVsxXT0wLHRbMjI0K2VdWzJdPTI1Mi00KmV9cmV0dXJuIHR9Y29uc3QgUj1FKCk7ZnVuY3Rpb24gaChlLHQsbz0wKXtsZXQgbj0wLGEseCxpLGw7dD1bLi4udF0sbz09PTEmJih0PWNyZWF0ZVNtb290aEN1cnZlUG9pbnRzKHQucmVkdWNlKCh5LGMpPT5bLi4ueSxjLngsYy55XSxbXSksLjUsITAsU0VHTUVOVF9OVU1CRVIpKSxbaV09dDtjb25zdCB1PXQubGVuZ3RoO2ZvcihhPTE7YTw9dTthKyspbD10W2EldV0sZS54Pk1hdGgubWluKGkueCxsLngpJiZlLng8PU1hdGgubWF4KGkueCxsLngpJiZlLnk8PU1hdGgubWF4KGkueSxsLnkpJiZpLnghPT1sLngmJih4PShlLngtaS54KSoobC55LWkueSkvKGwueC1pLngpK2kueSwoaS55PT09bC55fHxlLnk8PXgpJiZuKyspLGk9bDtyZXR1cm4gbiUyIT0wfWZ1bmN0aW9uIE8oe3pNaW46ZSx6TWF4OnQscG9seWdvblBvaW50TGlzdDpvLGF0dHJpYnV0ZTpuLHg6YSx5OngsejppLGNvbG9yTGlzdDpsLHZhbGlkOnV9KXtpZihoKHt4OmEseTp4fSxvKSYmaT49ZSYmaTw9dClyZXR1cm4gdT09PSExP1sxLDEwMy8yNTUsMTAyLzI1NV06bFtuXT9sW25dLnJnYmEuc2xpY2UoMCwzKS5tYXAoYz0+Yy8yNTUpOlsxLDAsMF19ZnVuY3Rpb24gbShlKXtjb25zdCB0PUIoZSksbz1SW3RdLFtuLGEseF09bztyZXR1cm5bbi8yNTUsYS8yNTUseC8yNTVdfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24odCl7Y29uc3R7cG9zaXRpb246byxjb2xvcjpuLGN1Ym9pZExpc3Q6YSxjb2xvckxpc3Q6eCxoaWdobGlnaHRJbmRleDppfT10LmRhdGE7bGV0e21vZGlmaWVkQm94SWRzOmw9W10scmVzZXRBcmVhczp1PVtdfT10LmRhdGEseT0wO2Z1bmN0aW9uIGMoKXt5Kz0xfWlmKCFvKXJldHVybjtjb25zdCBfPSEhKGk9PW51bGw/dm9pZCAwOmkubGVuZ3RoKTsoX3x8SSkmJihsPVtdLHU9W10pO2NvbnN0IHc9bC5sZW5ndGg/YS5maWx0ZXIocj0+bC5pbmNsdWRlcyhyLmlkKSk6YTtmb3IobGV0IHI9MDtyPG8ubGVuZ3RoO3IrPTMpe2NvbnN0IEM9b1tyXSxMPW9bcisxXSxkPW9bcisyXTtsZXQgZztpZih1Lmxlbmd0aD09PTEmJiFsLmxlbmd0aCloKHt4OkMseTpMfSx1WzBdKT9nPW0oZCk6Zz12O2Vsc2UgaWYodS5sZW5ndGh8fGwubGVuZ3RoKXtsZXQgcz0hMTt3LnNvbWUoZj0+e2NvbnN0IE09Tyh7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDpDLHk6TCx6OmQsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDp4LHZhbGlkOmYudmFsaWR9KTtyZXR1cm4gTT8oYygpLGc9TSxzPSEwLCEwKTohMX0pLCFzJiZ1Lmxlbmd0aCYmKHM9dS5zb21lKGY9Pmgoe3g6Qyx5Okx9LGYpPyhnPW0oZCksITApOiExKSksIXMmJiFfJiYoST9nPW0oZCk6Zz12KX1lbHNlIHcuc29tZShzPT57Y29uc3QgZj1PKHtwb2x5Z29uUG9pbnRMaXN0OnMucG9seWdvblBvaW50TGlzdCx6TWluOnMuek1pbix6TWF4OnMuek1heCx4OkMseTpMLHo6ZCxhdHRyaWJ1dGU6cy5hdHRyaWJ1dGUsY29sb3JMaXN0OngsdmFsaWQ6cy52YWxpZH0pO3JldHVybiBmPyhjKCksZz1mLCEwKTohMX0pO2NvbnN0IEE9cz0+e2NvbnN0IGY9TWF0aC5mbG9vcihzLzMpO3JldHVybiBpJiZpW2ZdPT09MX07aWYoZylpZihnWzBdPT09dlswXSYmQShyKSluW3JdPTAsbltyKzFdPTAsbltyKzJdPTA7ZWxzZXtjb25zdFtzLGYsTV09ZztuW3JdPXMsbltyKzFdPWYsbltyKzJdPU19ZWxzZSBpZihBKHIpKW5bcl09MCxuW3IrMV09MCxuW3IrMl09MDtlbHNle2NvbnN0W3MsZixNXT1tKGQpO25bcl09cyxuW3IrMV09ZixuW3IrMl09TX19ST1fLHBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjpuLG51bTp5fSl9LHAuaXNJblBvbHlnb249aCxPYmplY3QuZGVmaW5lUHJvcGVydHkocCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkscH0oe30pOwoK",null,!1);module.exports=WorkerFactory;
@@ -1 +1 @@
1
- "use strict";var EKeyCode;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.O=79]="O",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.One=49]="One",t[t.Two=50]="Two",t[t.Three=51]="Three",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace",t[t.Minus=189]="Minus",t[t.Equal=187]="Equal"})(EKeyCode||(EKeyCode={}));var EKeyCode$1=EKeyCode;module.exports=EKeyCode$1;
1
+ "use strict";var EKeyCode;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.O=79]="O",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.P=80]="P",t[t.One=49]="One",t[t.Two=50]="Two",t[t.Three=51]="Three",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace",t[t.Minus=189]="Minus",t[t.Equal=187]="Equal"})(EKeyCode||(EKeyCode={}));var EKeyCode$1=EKeyCode;module.exports=EKeyCode$1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const editStepWidth=320;exports.EPointCloudName=void 0,function(o){o.PointCloud="pointCloudTool"}(exports.EPointCloudName||(exports.EPointCloudName={})),exports.EVideoToolName=void 0,function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"}(exports.EVideoToolName||(exports.EVideoToolName={})),exports.EAudioToolName=void 0,function(o){o.AudioTextTool="audioTextTool"}(exports.EAudioToolName||(exports.EAudioToolName={})),exports.EToolType=void 0,function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"}(exports.EToolType||(exports.EToolType={})),exports.EToolName=void 0,function(o){o.Rect="rectTool",o.Tag="tagTool",o.Point="pointTool",o.PointMarker="pointMarkerTool",o.Segmentation="segmentationTool",o.Filter="filterTool",o.Text="textTool",o.Polygon="polygonTool",o.Line="lineTool",o.LineMarker="lineMarkerTool",o.Empty="emptyTool",o.FolderTag="folderTagTool",o.RectTrack="rectTrackTool",o.ScribbleTool="scribbleTool",o.Face="faceTool",o.ClientAttribute="clientAttributeTool",o.OCRRelation="OCRRelationTool",o.SegmentByRect="segmentByRectTool",o.Cuboid="cuboidTool",o.PointCloudPolygon="pointCloudPolygon",o.LLM="LLMTool",o.NLP="NLPTool"}(exports.EToolName||(exports.EToolName={})),exports.ECheckModel=void 0,function(o){o.Check="check"}(exports.ECheckModel||(exports.ECheckModel={})),exports.ERectPattern=void 0,function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"}(exports.ERectPattern||(exports.ERectPattern={}));const TOOL_NAME={[exports.EToolName.Rect]:"\u62C9\u6846",[exports.EToolName.Tag]:"\u6807\u7B7E",[exports.EToolName.Point]:"\u6807\u70B9",[exports.EToolName.PointMarker]:"\u5217\u8868\u6807\u70B9",[exports.EToolName.Segmentation]:"\u524D\u666F\u5206\u5272",[exports.EToolName.Filter]:"\u7B5B\u9009",[exports.EToolName.Text]:"\u6587\u672C",[exports.EToolName.Polygon]:"\u591A\u8FB9\u5F62",[exports.EToolName.Line]:"\u7EBF\u6761",[exports.EToolName.LineMarker]:"\u5217\u8868\u7EBF\u6761",[exports.EToolName.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[exports.EToolName.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[exports.EToolName.Face]:"\u4EBA\u8138106\u5DE5\u5177",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[exports.EToolName.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[exports.EVideoToolName.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[exports.EVideoToolName.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[exports.EVideoToolName.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91",[exports.EToolName.Cuboid]:"\u7ACB\u4F53\u6846",[exports.EToolName.LLM]:"\u5927\u6A21\u578B",[exports.EToolName.NLP]:"NLP\u6807\u6CE8"},TOOL_NAME_EN={[exports.EToolName.Rect]:"Rect",[exports.EToolName.Tag]:"Tag",[exports.EToolName.Point]:"Point",[exports.EToolName.PointMarker]:"PointMarker",[exports.EToolName.Segmentation]:"Segmentation",[exports.EToolName.Filter]:"Filter",[exports.EToolName.Text]:"Text",[exports.EToolName.Polygon]:"Polygon",[exports.EToolName.Line]:"Line",[exports.EToolName.LineMarker]:"LineMarker",[exports.EToolName.FolderTag]:"FolderTag",[exports.EToolName.RectTrack]:"RectTrack",[exports.EToolName.Face]:"Face",[exports.EToolName.ClientAttribute]:"ClientAttribute",[exports.EToolName.OCRRelation]:"OCRRelation",[exports.EToolName.SegmentByRect]:"SegmentByRect",[exports.EVideoToolName.VideoTextTool]:"VideoTextTool",[exports.EVideoToolName.VideoTagTool]:"VideoTagTool",[exports.EVideoToolName.VideoClipTool]:"VideoClipTool",[exports.EPointCloudName.PointCloud]:"PointCloud",[exports.EToolName.Cuboid]:"Cuboid",[exports.EToolName.LLM]:"LLM",[exports.EToolName.NLP]:"NLP"};exports.EDependPattern=void 0,function(o){o[o.noDepend=1]="noDepend",o[o.dependOrigin=2]="dependOrigin",o[o.dependShape=3]="dependShape",o[o.dependLine=4]="dependLine",o[o.dependPolygon=5]="dependPolygon",o[o.dependPreShape=101]="dependPreShape",o[o.dependPreLine=102]="dependPreLine",o[o.dependPrePolygon=103]="dependPrePolygon"}(exports.EDependPattern||(exports.EDependPattern={})),exports.EFilterToolOperation=void 0,function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"}(exports.EFilterToolOperation||(exports.EFilterToolOperation={}));const OPERATION_LIST={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};exports.EAnnotationMode=void 0,function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"}(exports.EAnnotationMode||(exports.EAnnotationMode={})),exports.ELineTypes=void 0,function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"}(exports.ELineTypes||(exports.ELineTypes={})),exports.ELineColor=void 0,function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"}(exports.ELineColor||(exports.ELineColor={})),exports.ESelectedType=void 0,function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"}(exports.ESelectedType||(exports.ESelectedType={})),exports.EDragTarget=void 0,function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"}(exports.EDragTarget||(exports.EDragTarget={})),exports.EDrawPointPattern=void 0,function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"}(exports.EDrawPointPattern||(exports.EDrawPointPattern={})),exports.EPageOperator=void 0,function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"}(exports.EPageOperator||(exports.EPageOperator={})),exports.EAuditStatus=void 0,function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"}(exports.EAuditStatus||(exports.EAuditStatus={})),exports.ETextType=void 0,function(o){o[o.AnyString=0]="AnyString",o[o.Order=1]="Order",o[o.EnglishOnly=2]="EnglishOnly",o[o.NumberOnly=3]="NumberOnly",o[o.CustomFormat=4]="CustomFormat"}(exports.ETextType||(exports.ETextType={}));const TEXT_TYPE={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},TEXT_ATTRIBUTE_MAX_LENGTH=1e3,TEXT_ATTRIBUTE_LINE_HEIGHT=16,DEFAULT_TEXT_MAX_WIDTH=300,DEFAULT_FONT="normal normal 500 14px Arial";exports.EThumbnailOption=void 0,function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"}(exports.EThumbnailOption||(exports.EThumbnailOption={}));const CLIENT_TOOL_HEAD_TYPE={[exports.EPointCloudName.PointCloud]:"sensebeepc",[exports.EToolName.ClientAttribute]:"sensebeepc-EnumAttributeTool",[exports.EToolName.Face]:"sensebeepc-FacePointsLabellingTool",[exports.EToolName.OCRRelation]:"sensebeepc-OCRRelationTool"},CLIENT_TOOL_NAME={[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},SEGMENT_NUMBER=16,edgeAdsorptionScope=10;exports.EPolygonPattern=void 0,function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"}(exports.EPolygonPattern||(exports.EPolygonPattern={})),exports.EScribblePattern=void 0,function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"}(exports.EScribblePattern||(exports.EScribblePattern={})),exports.EOperationMode=void 0,function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"}(exports.EOperationMode||(exports.EOperationMode={})),exports.CLIENT_TOOL_HEAD_TYPE=CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=CLIENT_TOOL_NAME,exports.DEFAULT_FONT=DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=DEFAULT_TEXT_MAX_WIDTH,exports.OPERATION_LIST=OPERATION_LIST,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=TEXT_TYPE,exports.TOOL_NAME=TOOL_NAME,exports.TOOL_NAME_EN=TOOL_NAME_EN,exports.edgeAdsorptionScope=edgeAdsorptionScope,exports.editStepWidth=editStepWidth;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const editStepWidth=320;exports.EPointCloudName=void 0,function(o){o.PointCloud="pointCloudTool"}(exports.EPointCloudName||(exports.EPointCloudName={})),exports.EVideoToolName=void 0,function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"}(exports.EVideoToolName||(exports.EVideoToolName={})),exports.EAudioToolName=void 0,function(o){o.AudioTextTool="audioTextTool"}(exports.EAudioToolName||(exports.EAudioToolName={})),exports.EToolType=void 0,function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"}(exports.EToolType||(exports.EToolType={})),exports.EToolName=void 0,function(o){o.Rect="rectTool",o.Tag="tagTool",o.Point="pointTool",o.PointMarker="pointMarkerTool",o.Segmentation="segmentationTool",o.Filter="filterTool",o.Text="textTool",o.Polygon="polygonTool",o.Line="lineTool",o.LineMarker="lineMarkerTool",o.Empty="emptyTool",o.FolderTag="folderTagTool",o.RectTrack="rectTrackTool",o.ScribbleTool="scribbleTool",o.Face="faceTool",o.ClientAttribute="clientAttributeTool",o.OCRRelation="OCRRelationTool",o.SegmentByRect="segmentByRectTool",o.Cuboid="cuboidTool",o.PointCloudPolygon="pointCloudPolygon",o.LLM="LLMTool",o.NLP="NLPTool",o.LLMMultiWheel="LLMMultiWheelTool"}(exports.EToolName||(exports.EToolName={})),exports.ECheckModel=void 0,function(o){o.Check="check"}(exports.ECheckModel||(exports.ECheckModel={})),exports.ERectPattern=void 0,function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"}(exports.ERectPattern||(exports.ERectPattern={}));const TOOL_NAME={[exports.EToolName.Rect]:"\u62C9\u6846",[exports.EToolName.Tag]:"\u6807\u7B7E",[exports.EToolName.Point]:"\u6807\u70B9",[exports.EToolName.PointMarker]:"\u5217\u8868\u6807\u70B9",[exports.EToolName.Segmentation]:"\u524D\u666F\u5206\u5272",[exports.EToolName.Filter]:"\u7B5B\u9009",[exports.EToolName.Text]:"\u6587\u672C",[exports.EToolName.Polygon]:"\u591A\u8FB9\u5F62",[exports.EToolName.Line]:"\u7EBF\u6761",[exports.EToolName.LineMarker]:"\u5217\u8868\u7EBF\u6761",[exports.EToolName.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[exports.EToolName.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[exports.EToolName.Face]:"\u4EBA\u8138106\u5DE5\u5177",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[exports.EToolName.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[exports.EVideoToolName.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[exports.EVideoToolName.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[exports.EVideoToolName.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91",[exports.EToolName.Cuboid]:"\u7ACB\u4F53\u6846",[exports.EToolName.LLM]:"\u5927\u6A21\u578B",[exports.EToolName.NLP]:"NLP\u6807\u6CE8",[exports.EToolName.LLMMultiWheel]:"\u5927\u6A21\u578B\uFF08\u591A\u8F6E\u5BF9\u8BDD\uFF09"},TOOL_NAME_EN={[exports.EToolName.Rect]:"Rect",[exports.EToolName.Tag]:"Tag",[exports.EToolName.Point]:"Point",[exports.EToolName.PointMarker]:"PointMarker",[exports.EToolName.Segmentation]:"Segmentation",[exports.EToolName.Filter]:"Filter",[exports.EToolName.Text]:"Text",[exports.EToolName.Polygon]:"Polygon",[exports.EToolName.Line]:"Line",[exports.EToolName.LineMarker]:"LineMarker",[exports.EToolName.FolderTag]:"FolderTag",[exports.EToolName.RectTrack]:"RectTrack",[exports.EToolName.Face]:"Face",[exports.EToolName.ClientAttribute]:"ClientAttribute",[exports.EToolName.OCRRelation]:"OCRRelation",[exports.EToolName.SegmentByRect]:"SegmentByRect",[exports.EVideoToolName.VideoTextTool]:"VideoTextTool",[exports.EVideoToolName.VideoTagTool]:"VideoTagTool",[exports.EVideoToolName.VideoClipTool]:"VideoClipTool",[exports.EPointCloudName.PointCloud]:"PointCloud",[exports.EToolName.Cuboid]:"Cuboid",[exports.EToolName.LLM]:"LLM",[exports.EToolName.NLP]:"NLP",[exports.EToolName.LLMMultiWheel]:"LLMMultiWheelTool"};exports.EDependPattern=void 0,function(o){o[o.noDepend=1]="noDepend",o[o.dependOrigin=2]="dependOrigin",o[o.dependShape=3]="dependShape",o[o.dependLine=4]="dependLine",o[o.dependPolygon=5]="dependPolygon",o[o.dependPreShape=101]="dependPreShape",o[o.dependPreLine=102]="dependPreLine",o[o.dependPrePolygon=103]="dependPrePolygon"}(exports.EDependPattern||(exports.EDependPattern={})),exports.EFilterToolOperation=void 0,function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"}(exports.EFilterToolOperation||(exports.EFilterToolOperation={}));const OPERATION_LIST={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};exports.EAnnotationMode=void 0,function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"}(exports.EAnnotationMode||(exports.EAnnotationMode={})),exports.ELineTypes=void 0,function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"}(exports.ELineTypes||(exports.ELineTypes={})),exports.ELineColor=void 0,function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"}(exports.ELineColor||(exports.ELineColor={})),exports.ESelectedType=void 0,function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"}(exports.ESelectedType||(exports.ESelectedType={})),exports.EDragTarget=void 0,function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"}(exports.EDragTarget||(exports.EDragTarget={})),exports.EDrawPointPattern=void 0,function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"}(exports.EDrawPointPattern||(exports.EDrawPointPattern={})),exports.EPageOperator=void 0,function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"}(exports.EPageOperator||(exports.EPageOperator={})),exports.EAuditStatus=void 0,function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"}(exports.EAuditStatus||(exports.EAuditStatus={})),exports.ETextType=void 0,function(o){o[o.AnyString=0]="AnyString",o[o.Order=1]="Order",o[o.EnglishOnly=2]="EnglishOnly",o[o.NumberOnly=3]="NumberOnly",o[o.CustomFormat=4]="CustomFormat"}(exports.ETextType||(exports.ETextType={}));const TEXT_TYPE={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},TEXT_ATTRIBUTE_MAX_LENGTH=1e3,TEXT_ATTRIBUTE_LINE_HEIGHT=16,DEFAULT_TEXT_MAX_WIDTH=300,DEFAULT_FONT="normal normal 500 14px Arial";exports.EThumbnailOption=void 0,function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"}(exports.EThumbnailOption||(exports.EThumbnailOption={}));const CLIENT_TOOL_HEAD_TYPE={[exports.EPointCloudName.PointCloud]:"sensebeepc",[exports.EToolName.ClientAttribute]:"sensebeepc-EnumAttributeTool",[exports.EToolName.Face]:"sensebeepc-FacePointsLabellingTool",[exports.EToolName.OCRRelation]:"sensebeepc-OCRRelationTool"},CLIENT_TOOL_NAME={[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},SEGMENT_NUMBER=16,edgeAdsorptionScope=10;exports.EPolygonPattern=void 0,function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"}(exports.EPolygonPattern||(exports.EPolygonPattern={})),exports.EScribblePattern=void 0,function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"}(exports.EScribblePattern||(exports.EScribblePattern={})),exports.EOperationMode=void 0,function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"}(exports.EOperationMode||(exports.EOperationMode={})),exports.CLIENT_TOOL_HEAD_TYPE=CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=CLIENT_TOOL_NAME,exports.DEFAULT_FONT=DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=DEFAULT_TEXT_MAX_WIDTH,exports.OPERATION_LIST=OPERATION_LIST,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=TEXT_TYPE,exports.TOOL_NAME=TOOL_NAME,exports.TOOL_NAME_EN=TOOL_NAME_EN,exports.edgeAdsorptionScope=edgeAdsorptionScope,exports.editStepWidth=editStepWidth;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),__defProp=Object.defineProperty,__defNormalProp=(y,u,p)=>u in y?__defProp(y,u,{enumerable:!0,configurable:!0,writable:!0,value:p}):y[u]=p,__publicField=(y,u,p)=>(__defNormalProp(y,typeof u!="symbol"?u+"":u,p),p);const _changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"};class OrbitControls extends THREE.EventDispatcher{constructor(u,p){super();__publicField(this,"listenToKeyEvents",t=>{t.addEventListener("keydown",onKeyDown),this._domElementKeyEvents=t}),p===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),p===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=u,this.domElement=p,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new THREE.Vector3,this.minDistance=0,this.maxDistance=Infinity,this.minZoom=0,this.maxZoom=Infinity,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-Infinity,this.maxAzimuthAngle=Infinity,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:THREE.MOUSE.ROTATE,MIDDLE:THREE.MOUSE.DOLLY,RIGHT:THREE.MOUSE.PAN},this.touches={ONE:THREE.TOUCH.ROTATE,TWO:THREE.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(_changeEvent),e.update(),i=a.NONE},this.update=function(){const t=new THREE.Vector3,n=new THREE.Quaternion().setFromUnitVectors(u.up,new THREE.Vector3(0,1,0)),r=n.clone().invert(),c=new THREE.Vector3,l=new THREE.Quaternion,L=2*Math.PI;return function(){const{position:oe}=e.object;t.copy(oe).sub(e.target),t.applyQuaternion(n),s.setFromVector3(t),e.autoRotate&&i===a.NONE&&C(ae()),e.enableDamping?(s.theta+=d.theta*e.dampingFactor,s.phi+=d.phi*e.dampingFactor):(s.theta+=d.theta,s.phi+=d.phi);let h=e.minAzimuthAngle,m=e.maxAzimuthAngle;return isFinite(h)&&isFinite(m)&&(h<-Math.PI?h+=L:h>Math.PI&&(h-=L),m<-Math.PI?m+=L:m>Math.PI&&(m-=L),h<=m?s.theta=Math.max(h,Math.min(m,s.theta)):s.theta=s.theta>(h+m)/2?Math.max(h,s.theta):Math.min(m,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),s.radius*=N,s.radius=Math.max(e.minDistance,Math.min(e.maxDistance,s.radius)),e.enableDamping===!0?e.target.addScaledVector(O,e.dampingFactor):e.target.add(O),t.setFromSpherical(s),t.applyQuaternion(r),oe.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,O.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),O.set(0,0,0)),N=1,S||c.distanceToSquared(e.object.position)>U||8*(1-l.dot(e.object.quaternion))>U?(e.dispatchEvent(_changeEvent),c.copy(e.object.position),l.copy(e.object.quaternion),S=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",ee),e.domElement.removeEventListener("pointerdown",Q),e.domElement.removeEventListener("pointercancel",J),e.domElement.removeEventListener("wheel",$),e.domElement.removeEventListener("pointermove",k),e.domElement.removeEventListener("pointerup",_),e._domElementKeyEvents!==null&&e._domElementKeyEvents.removeEventListener("keydown",Ee)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=a.NONE;const U=1e-6,s=new THREE.Spherical,d=new THREE.Spherical;let N=1;const O=new THREE.Vector3;let S=!1;const f=new THREE.Vector2,b=new THREE.Vector2,P=new THREE.Vector2,E=new THREE.Vector2,g=new THREE.Vector2,T=new THREE.Vector2,M=new THREE.Vector2,w=new THREE.Vector2,D=new THREE.Vector2,o=[],R={};function ae(){return 2*Math.PI/60/60*e.autoRotateSpeed}function j(){return Math.pow(.95,e.zoomSpeed)}function C(t){d.theta-=t}function H(t){d.phi-=t}const V=function(){const t=new THREE.Vector3;return function(r,c){t.setFromMatrixColumn(c,0),t.multiplyScalar(-r),O.add(t)}}(),v=function(){const t=new THREE.Vector3;return function(r,c){e.screenSpacePanning===!0?t.setFromMatrixColumn(c,1):(t.setFromMatrixColumn(c,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(r),O.add(t)}}(),A=function(){const t=new THREE.Vector3;return function(r,c){const l=e.domElement;if(e.object.isPerspectiveCamera){const{position:L}=e.object;t.copy(L).sub(e.target);let x=t.length();x*=Math.tan(e.object.fov/2*Math.PI/180),V(2*r*x/l.clientHeight,e.object.matrix),v(2*c*x/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(V(r*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),v(c*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function I(t){e.object.isPerspectiveCamera?N/=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*t)),e.object.updateProjectionMatrix(),S=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function z(t){e.object.isPerspectiveCamera?N*=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/t)),e.object.updateProjectionMatrix(),S=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Z(t){f.set(t.clientX,t.clientY)}function ie(t){M.set(t.clientX,t.clientY)}function F(t){E.set(t.clientX,t.clientY)}function se(t){b.set(t.clientX,t.clientY),P.subVectors(b,f).multiplyScalar(e.rotateSpeed);const n=e.domElement;C(2*Math.PI*P.x/n.clientHeight),H(2*Math.PI*P.y/n.clientHeight),f.copy(b),e.update()}function re(t){w.set(t.clientX,t.clientY),D.subVectors(w,M),D.y>0?I(j()):D.y<0&&z(j()),M.copy(w),e.update()}function ce(t){g.set(t.clientX,t.clientY),T.subVectors(g,E).multiplyScalar(e.panSpeed),A(T.x,T.y),E.copy(g),e.update()}function le(t){t.deltaY<0?z(j()):t.deltaY>0&&I(j()),e.update()}function ue(t){let n=!1;switch(t.code){case e.keys.UP:A(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:A(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:A(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:A(-e.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),e.update())}function X(){if(o.length===1)f.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);f.set(t,n)}}function K(){if(o.length===1)E.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);E.set(t,n)}}function q(){const t=o[0].pageX-o[1].pageX,n=o[0].pageY-o[1].pageY,r=Math.sqrt(t*t+n*n);M.set(0,r)}function pe(){e.enableZoom&&q(),e.enablePan&&K()}function de(){e.enableZoom&&q(),e.enableRotate&&X()}function W(t){if(o.length==1)b.set(t.pageX,t.pageY);else{const r=Y(t),c=.5*(t.pageX+r.x),l=.5*(t.pageY+r.y);b.set(c,l)}P.subVectors(b,f).multiplyScalar(e.rotateSpeed);const n=e.domElement;C(2*Math.PI*P.x/n.clientHeight),H(2*Math.PI*P.y/n.clientHeight),f.copy(b)}function G(t){if(o.length===1)g.set(t.pageX,t.pageY);else{const n=Y(t),r=.5*(t.pageX+n.x),c=.5*(t.pageY+n.y);g.set(r,c)}T.subVectors(g,E).multiplyScalar(e.panSpeed),A(T.x,T.y),E.copy(g)}function B(t){const n=Y(t),r=t.pageX-n.x,c=t.pageY-n.y,l=Math.sqrt(r*r+c*c);w.set(0,l),D.set(0,Math.pow(w.y/M.y,e.zoomSpeed)),I(D.y),M.copy(w)}function he(t){e.enableZoom&&B(t),e.enablePan&&G(t)}function me(t){e.enableZoom&&B(t),e.enableRotate&&W(t)}function Q(t){e.enabled!==!1&&(o.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",k),e.domElement.addEventListener("pointerup",_)),Oe(t),t.pointerType==="touch"?ge(t):fe(t))}function k(t){e.enabled!==!1&&(t.pointerType==="touch"?ye(t):be(t))}function _(t){te(t),o.length===0&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",k),e.domElement.removeEventListener("pointerup",_)),e.dispatchEvent(_endEvent),i=a.NONE}function J(t){te(t)}function fe(t){let n;switch(t.button){case 0:n=e.mouseButtons.LEFT;break;case 1:n=e.mouseButtons.MIDDLE;break;case 2:n=e.mouseButtons.RIGHT;break;default:n=-1}switch(n){case THREE.MOUSE.DOLLY:if(e.enableZoom===!1)return;ie(t),i=a.DOLLY;break;case THREE.MOUSE.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;F(t),i=a.PAN}else{if(e.enableRotate===!1)return;Z(t),i=a.ROTATE}break;case THREE.MOUSE.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;Z(t),i=a.ROTATE}else{if(e.enablePan===!1)return;F(t),i=a.PAN}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(_startEvent)}function be(t){if(e.enabled!==!1)switch(i){case a.ROTATE:if(e.enableRotate===!1)return;se(t);break;case a.DOLLY:if(e.enableZoom===!1)return;re(t);break;case a.PAN:if(e.enablePan===!1)return;ce(t);break}}function $(t){e.enabled===!1||e.enableZoom===!1||i!==a.NONE||(t.preventDefault(),e.dispatchEvent(_startEvent),le(t),e.dispatchEvent(_endEvent))}function Ee(t){e.enabled===!1||e.enablePan===!1||ue(t)}function ge(t){switch(ne(t),o.length){case 1:switch(e.touches.ONE){case THREE.TOUCH.ROTATE:if(e.enableRotate===!1)return;X(),i=a.TOUCH_ROTATE;break;case THREE.TOUCH.PAN:if(e.enablePan===!1)return;K(),i=a.TOUCH_PAN;break;default:i=a.NONE}break;case 2:switch(e.touches.TWO){case THREE.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;pe(),i=a.TOUCH_DOLLY_PAN;break;case THREE.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;de(),i=a.TOUCH_DOLLY_ROTATE;break;default:i=a.NONE}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(_startEvent)}function ye(t){switch(ne(t),i){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;W(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;G(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;he(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;me(t),e.update();break;default:i=a.NONE}}function ee(t){e.enabled!==!1&&t.preventDefault()}function Oe(t){o.push(t)}function te(t){delete R[t.pointerId];for(let n=0;n<o.length;n++)if(o[n].pointerId==t.pointerId){o.splice(n,1);return}}function ne(t){let n=R[t.pointerId];n===void 0&&(n=new THREE.Vector2,R[t.pointerId]=n),n.set(t.pageX,t.pageY)}function Y(t){const n=t.pointerId===o[0].pointerId?o[1]:o[0];return R[n.pointerId]}e.domElement.addEventListener("contextmenu",ee),e.domElement.addEventListener("pointerdown",Q),e.domElement.addEventListener("pointercancel",J),e.domElement.addEventListener("wheel",$,{passive:!1}),this.update()}}exports.OrbitControls=OrbitControls;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),__defProp=Object.defineProperty,__defNormalProp=(y,u,p)=>u in y?__defProp(y,u,{enumerable:!0,configurable:!0,writable:!0,value:p}):y[u]=p,__publicField=(y,u,p)=>(__defNormalProp(y,typeof u!="symbol"?u+"":u,p),p);const _changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"};class OrbitControls extends THREE.EventDispatcher{constructor(u,p){super();__publicField(this,"listenToKeyEvents",t=>{t.addEventListener("keydown",onKeyDown),this._domElementKeyEvents=t}),p===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),p===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=u,this.domElement=p,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new THREE.Vector3,this.minDistance=0,this.maxDistance=Infinity,this.minZoom=0,this.maxZoom=Infinity,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-Infinity,this.maxAzimuthAngle=Infinity,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:THREE.MOUSE.ROTATE,MIDDLE:THREE.MOUSE.DOLLY,RIGHT:THREE.MOUSE.PAN},this.touches={ONE:THREE.TOUCH.ROTATE,TWO:THREE.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(_changeEvent),e.update(),i=a.NONE},this.update=function(){const t=new THREE.Vector3,n=new THREE.Quaternion().setFromUnitVectors(u.up,new THREE.Vector3(0,1,0)),r=n.clone().invert(),c=new THREE.Vector3,l=new THREE.Quaternion,L=2*Math.PI;return function(){const{position:oe}=e.object;t.copy(oe).sub(e.target),t.applyQuaternion(n),s.setFromVector3(t),e.autoRotate&&i===a.NONE&&C(ae()),e.enableDamping?(s.theta+=h.theta*e.dampingFactor,s.phi+=h.phi*e.dampingFactor):(s.theta+=h.theta,s.phi+=h.phi);let d=e.minAzimuthAngle,m=e.maxAzimuthAngle;return isFinite(d)&&isFinite(m)&&(d<-Math.PI?d+=L:d>Math.PI&&(d-=L),m<-Math.PI?m+=L:m>Math.PI&&(m-=L),d<=m?s.theta=Math.max(d,Math.min(m,s.theta)):s.theta=s.theta>(d+m)/2?Math.max(d,s.theta):Math.min(m,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),s.radius*=N,s.radius=Math.max(e.minDistance,Math.min(e.maxDistance,s.radius)),e.enableDamping===!0?e.target.addScaledVector(O,e.dampingFactor):e.target.add(O),t.setFromSpherical(s),t.applyQuaternion(r),oe.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(h.theta*=1-e.dampingFactor,h.phi*=1-e.dampingFactor,O.multiplyScalar(1-e.dampingFactor)):(h.set(0,0,0),O.set(0,0,0)),N=1,S||c.distanceToSquared(e.object.position)>U||8*(1-l.dot(e.object.quaternion))>U?(e.dispatchEvent(_changeEvent),c.copy(e.object.position),l.copy(e.object.quaternion),S=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",ee),e.domElement.removeEventListener("pointerdown",Q),e.domElement.removeEventListener("pointercancel",J),e.domElement.removeEventListener("wheel",$),e.domElement.removeEventListener("pointermove",I),e.domElement.removeEventListener("pointerup",_),e._domElementKeyEvents!==null&&e._domElementKeyEvents.removeEventListener("keydown",Ee)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=a.NONE;const U=1e-6,s=new THREE.Spherical,h=new THREE.Spherical;let N=1;const O=new THREE.Vector3;let S=!1;const f=new THREE.Vector2,b=new THREE.Vector2,P=new THREE.Vector2,E=new THREE.Vector2,g=new THREE.Vector2,T=new THREE.Vector2,M=new THREE.Vector2,w=new THREE.Vector2,D=new THREE.Vector2,o=[],R={};function ae(){return 2*Math.PI/60/60*e.autoRotateSpeed}function j(){return Math.pow(.95,e.zoomSpeed)}function C(t){h.theta-=t}function H(t){h.phi-=t}const V=function(){const t=new THREE.Vector3;return function(r,c){t.setFromMatrixColumn(c,0),t.multiplyScalar(-r),O.add(t)}}(),v=function(){const t=new THREE.Vector3;return function(r,c){e.screenSpacePanning===!0?t.setFromMatrixColumn(c,1):(t.setFromMatrixColumn(c,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(r),O.add(t)}}(),A=function(){const t=new THREE.Vector3;return function(r,c){const l=e.domElement;if(e.object.isPerspectiveCamera){const{position:L}=e.object;t.copy(L).sub(e.target);let x=t.length();x*=Math.tan(e.object.fov/2*Math.PI/180),V(2*r*x/l.clientHeight,e.object.matrix),v(2*c*x/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(V(r*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),v(c*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function k(t){e.object.isPerspectiveCamera?N/=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*t)),e.object.updateProjectionMatrix(),S=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function z(t){e.object.isPerspectiveCamera?N*=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/t)),e.object.updateProjectionMatrix(),S=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Z(t){f.set(t.clientX,t.clientY)}function ie(t){M.set(t.clientX,t.clientY)}function F(t){E.set(t.clientX,t.clientY)}function se(t){b.set(t.clientX,t.clientY),P.subVectors(b,f).multiplyScalar(e.rotateSpeed);const n=e.domElement;C(2*Math.PI*P.x/n.clientHeight),H(2*Math.PI*P.y/n.clientHeight),f.copy(b),e.update()}function re(t){w.set(t.clientX,t.clientY),D.subVectors(w,M),D.y>0?k(j()):D.y<0&&z(j()),M.copy(w),e.update()}function ce(t){g.set(t.clientX,t.clientY),T.subVectors(g,E).multiplyScalar(e.panSpeed),A(T.x,T.y),E.copy(g),e.update()}function le(t){t.deltaY<0?z(j()):t.deltaY>0&&k(j()),e.update()}function ue(t){let n=!1;switch(t.code){case e.keys.UP:A(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:A(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:A(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:A(-e.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),e.update())}function X(){if(o.length===1)f.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);f.set(t,n)}}function K(){if(o.length===1)E.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);E.set(t,n)}}function q(){const t=o[0].pageX-o[1].pageX,n=o[0].pageY-o[1].pageY,r=Math.sqrt(t*t+n*n);M.set(0,r)}function pe(){e.enableZoom&&q(),e.enablePan&&K()}function he(){e.enableZoom&&q(),e.enableRotate&&X()}function W(t){if(o.length==1)b.set(t.pageX,t.pageY);else{const r=Y(t),c=.5*(t.pageX+r.x),l=.5*(t.pageY+r.y);b.set(c,l)}P.subVectors(b,f).multiplyScalar(e.rotateSpeed);const n=e.domElement;C(2*Math.PI*P.x/n.clientHeight),H(2*Math.PI*P.y/n.clientHeight),f.copy(b)}function G(t){if(o.length===1)g.set(t.pageX,t.pageY);else{const n=Y(t),r=.5*(t.pageX+n.x),c=.5*(t.pageY+n.y);g.set(r,c)}T.subVectors(g,E).multiplyScalar(e.panSpeed),A(T.x,T.y),E.copy(g)}function B(t){const n=Y(t),r=t.pageX-n.x,c=t.pageY-n.y,l=Math.sqrt(r*r+c*c);w.set(0,l),D.set(0,Math.pow(w.y/M.y,e.zoomSpeed)),k(D.y),M.copy(w)}function de(t){e.enableZoom&&B(t),e.enablePan&&G(t)}function me(t){e.enableZoom&&B(t),e.enableRotate&&W(t)}function Q(t){e.enabled!==!1&&(o.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",I),e.domElement.addEventListener("pointerup",_)),Oe(t),t.pointerType==="touch"?ge(t):fe(t))}function I(t){e.enabled!==!1&&(t.pointerType==="touch"?ye(t):be(t))}function _(t){te(t),o.length===0&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",I),e.domElement.removeEventListener("pointerup",_)),e.dispatchEvent(_endEvent),i=a.NONE}function J(t){te(t)}function fe(t){let n;switch(t.button){case 0:n=e.mouseButtons.LEFT;break;case 1:n=e.mouseButtons.MIDDLE;break;case 2:n=e.mouseButtons.RIGHT;break;default:n=-1}switch(n){case THREE.MOUSE.DOLLY:if(e.enableZoom===!1)return;ie(t),i=a.DOLLY;break;case THREE.MOUSE.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;F(t),i=a.PAN}else{if(e.enableRotate===!1)return;Z(t),i=a.ROTATE}break;case THREE.MOUSE.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;Z(t),i=a.ROTATE}else{if(e.enablePan===!1)return;F(t),i=a.PAN}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(_startEvent)}function be(t){if(e.enabled!==!1)switch(i){case a.ROTATE:if(e.enableRotate===!1)return;se(t);break;case a.DOLLY:if(e.enableZoom===!1)return;re(t);break;case a.PAN:if(e.enablePan===!1)return;ce(t);break}}function $(t){e.enabled===!1||e.enableZoom===!1||i!==a.NONE||(t.preventDefault(),e.dispatchEvent(_startEvent),le(t),e.dispatchEvent(_endEvent))}function Ee(t){e.enabled===!1||e.enablePan===!1||ue(t)}function ge(t){switch(ne(t),o.length){case 1:switch(e.touches.ONE){case THREE.TOUCH.ROTATE:if(e.enableRotate===!1)return;X(),i=a.TOUCH_ROTATE;break;case THREE.TOUCH.PAN:if(e.enablePan===!1)return;K(),i=a.TOUCH_PAN;break;default:i=a.NONE}break;case 2:switch(e.touches.TWO){case THREE.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;pe(),i=a.TOUCH_DOLLY_PAN;break;case THREE.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;he(),i=a.TOUCH_DOLLY_ROTATE;break;default:i=a.NONE}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(_startEvent)}function ye(t){switch(ne(t),i){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;W(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;G(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;de(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;me(t),e.update();break;default:i=a.NONE}}function ee(t){e.enabled!==!1&&(t.preventDefault(),e.dispatchEvent({type:"rightClick",originalEvent:t}))}function Oe(t){o.push(t)}function te(t){delete R[t.pointerId];for(let n=0;n<o.length;n++)if(o[n].pointerId==t.pointerId){o.splice(n,1);return}}function ne(t){let n=R[t.pointerId];n===void 0&&(n=new THREE.Vector2,R[t.pointerId]=n),n.set(t.pageX,t.pageY)}function Y(t){const n=t.pointerId===o[0].pointerId?o[1]:o[0];return R[n.pointerId]}e.domElement.addEventListener("contextmenu",ee),e.domElement.addEventListener("pointerdown",Q),e.domElement.addEventListener("pointercancel",J),e.domElement.addEventListener("wheel",$,{passive:!1}),this.update()}}exports.OrbitControls=OrbitControls;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),highlightWorker$1=require("../../_virtual/highlightWorker.js"),filterBoxWorker=require("../../_virtual/filterBoxWorker.js"),polygonTool=require("../../utils/tool/polygonTool.js"),uuid=require("../../utils/uuid.js"),MathUtils=require("../../utils/MathUtils.js"),ImgUtils=require("../../utils/ImgUtils.js"),PCDLoader=require("./PCDLoader.js"),OrbitControls=require("./OrbitControls.js"),cache=require("./cache.js"),matrix=require("./matrix.js"),segmentation=require("./segmentation.js"),index=require("./store/index.js"),index$1=require("./render/index.js"),eventListener=require("../toolOperation/eventListener.js");require("../../constant/tool.js"),require("../scheduler.js");function _interopNamespace(f){if(f&&f.__esModule)return f;var t=Object.create(null);return f&&Object.keys(f).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(f,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return f[e]}})}}),t.default=f,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=(f,t,e)=>t in f?__defProp(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e,__spreadValues=(f,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(f,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(f,e,t[e]);return f},__spreadProps=(f,t)=>__defProps(f,__getOwnPropDescs(t)),__async=(f,t,e)=>new Promise((i,r)=>{var o=l=>{try{s(e.next(l))}catch(n){r(n)}},a=l=>{try{s(e.throw(l))}catch(n){r(n)}},s=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,a);s((e=e.apply(f,t)).next())});const DEFAULT_DISTANCE=30,highlightWorker=new highlightWorker$1({type:"module"});class PointCloud extends eventListener{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:o="#4C4C4C",config:a,isSegment:s,checkMode:l}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.workerLoading=!1,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(n,c="blue")=>{var h;const d=(h=n.id)!=null?h:uuid();this.removeObjectByName(d,"sphere");const{radius:u,widthSegments:m,heightSegments:p}=lbUtils.DEFAULT_SPHERE_PARAMS,{center:g}=n,y=new THREE__namespace.Group,x=new THREE__namespace.SphereGeometry(u,m,p),w=new THREE__namespace.MeshBasicMaterial({color:c}),C=new THREE__namespace.Mesh(x,w);C.position.set(g.x,g.y,g.z),y.add(C),y.name=`sphere${d}`,this.scene.add(y)},this.generateSphere=n=>{const{fill:c}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,c),this.render()},this.generateSpheres=n=>{n.forEach(c=>{const{fill:h}=this.getColorFromConfig(c.attribute);this.addSphereToSense(c,h)}),this.render()},this.addBoxToSense=(n,c=16777215)=>{var h;const d=(h=n.id)!=null?h:uuid();this.removeObjectByName(d,"box");const{center:u,width:m,height:p,depth:g,rotation:y}=n,x=new THREE__namespace.Group,w=new THREE__namespace.BoxGeometry(m,p,g),C=new THREE__namespace.MeshBasicMaterial({color:"blue"}),b=new THREE__namespace.Mesh(w,C),v=new THREE__namespace.BoxHelper(b,c),M=this.generateBoxArrow(n),P=this.generateBoxTrackID(n);P&&x.add(P),x.add(v),x.add(M),u&&x.position.set(u.x,u.y,u.z),y&&x.rotation.set(0,0,y),x.name=`box${d}`,this.scene.add(x)},this.applyCameraTarget=n=>{if(this.camera.type==="OrthographicCamera"&&n){const c=this.getOrthographicCameraTarget(n);this.updateCameraZoom(n.zoom),this.updateCamera(n.position,c)}},this.initShaderMaterial=()=>({vertexShader:`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),highlightWorker$1=require("../../_virtual/highlightWorker.js"),filterBoxWorker=require("../../_virtual/filterBoxWorker.js"),polygonTool=require("../../utils/tool/polygonTool.js"),uuid=require("../../utils/uuid.js"),MathUtils=require("../../utils/MathUtils.js"),ImgUtils=require("../../utils/ImgUtils.js"),PCDLoader=require("./PCDLoader.js"),OrbitControls=require("./OrbitControls.js"),cache=require("./cache.js"),matrix=require("./matrix.js"),segmentation=require("./segmentation.js"),index=require("./store/index.js"),index$1=require("./render/index.js"),eventListener=require("../toolOperation/eventListener.js");require("../../constant/tool.js"),require("../scheduler.js");function _interopNamespace(w){if(w&&w.__esModule)return w;var t=Object.create(null);return w&&Object.keys(w).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(w,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return w[e]}})}}),t.default=w,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=(w,t,e)=>t in w?__defProp(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,__spreadValues=(w,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(w,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(w,e,t[e]);return w},__spreadProps=(w,t)=>__defProps(w,__getOwnPropDescs(t)),__async=(w,t,e)=>new Promise((i,r)=>{var a=l=>{try{s(e.next(l))}catch(d){r(d)}},h=l=>{try{s(e.throw(l))}catch(d){r(d)}},s=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,h);s((e=e.apply(w,t)).next())});const DEFAULT_DISTANCE=30,highlightWorker=new highlightWorker$1({type:"module"});class PointCloud extends eventListener{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:a="#4C4C4C",config:h,isSegment:s,checkMode:l,hiddenText:d=!1}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.workerLoading=!1,this.raycaster=new THREE__namespace.Raycaster,this.pointer=new THREE__namespace.Vector2,this.hiddenText=!1,this.filterBoxWorkerTimer=null,this.highlightColor=16776960,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=o=>{if(!!this.store)switch(o.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=o=>{if(!!this.store)switch(o.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(o,n="blue")=>{var c;const u=(c=o.id)!=null?c:uuid();this.removeObjectByName(u,"sphere");const{radius:p,widthSegments:m,heightSegments:f}=lbUtils.DEFAULT_SPHERE_PARAMS,{center:g}=o,x=new THREE__namespace.Group,y=new THREE__namespace.SphereGeometry(p,m,f),b=new THREE__namespace.MeshBasicMaterial({color:n}),C=new THREE__namespace.Mesh(y,b);C.position.set(g.x,g.y,g.z),x.add(C),x.name=`sphere${u}`,this.scene.add(x)},this.generateSphere=o=>{const{fill:n}=this.getColorFromConfig(o.attribute);this.addSphereToSense(o,n),this.render()},this.generateSpheres=o=>{o.forEach(n=>{const{fill:c}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,c)}),this.render()},this.addBoxToSense=(o,n=16777215)=>{var c;const u=(c=o.id)!=null?c:uuid();this.removeObjectByName(u,"box");const{center:p,width:m,height:f,depth:g,rotation:x}=o,y=new THREE__namespace.Group,b=new THREE__namespace.BoxGeometry(m,f,g),C=new THREE__namespace.MeshBasicMaterial({color:"blue"}),v=new THREE__namespace.Mesh(b,C),B=new THREE__namespace.BoxHelper(v,n),S=this.generateBoxArrow(o),M=this.generateBoxTrackID(o,n);M&&y.add(M);const P=this.generateBoxAttributeLabel(o,n);P&&y.add(P),y.add(B),y.add(S),p&&y.position.set(p.x,p.y,p.z),x&&y.rotation.set(0,0,x),y.name=`box${u}`;const O=new THREE__namespace.BoxGeometry(m,f,g),T=new THREE__namespace.MeshBasicMaterial({visible:!1}),z=new THREE__namespace.Mesh(O,T);y.add(z),y.userData={defaultColor:n,selectedID:u},this.scene.add(y)},this.applyCameraTarget=o=>{if(this.camera.type==="OrthographicCamera"&&o){const n=this.getOrthographicCameraTarget(o);this.updateCameraZoom(o.zoom),this.updateCamera(o.position,n)}},this.initShaderMaterial=()=>({vertexShader:`
2
2
  attribute vec3 dimensions;
3
3
  varying vec3 vDimensions;
4
4
  uniform float pointSize;
@@ -28,4 +28,6 @@
28
28
 
29
29
  // Output the final color
30
30
  gl_FragColor = vec4(color, 1.0);
31
- }`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...n)=>__async(this,[...n],function*(c=this.currentPCDSrc,h){if(!c)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=c;const{points:d,color:u}=yield this.cacheInstance.loadPCDFile(c),m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.BufferAttribute(d,3)),this.isSegment||m.setAttribute("dimensions",new THREE__namespace.BufferAttribute(u,3)),this.initCloudData(d);const p=new THREE__namespace.Points(m);this.renderPointCloud(p,h),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=n=>__async(this,[n],function*({mappingImgList:c,points:h}){const d=c.length===0?[]:yield Promise.all(c.map(p=>ImgUtils.default.load(p.url))),u=c.map((p,g)=>{var y;if(this.cacheInstance.cache2DHighlightIndex.has(p.url))return(y=this.cacheInstance.cache2DHighlightIndex.get(p.url))!=null?y:[];const x=matrix.getHighlightIndexByPoints({points:h,calib:p.calib,width:d[g].width,height:d[g].height});return this.cacheInstance.cache2DHighlightIndex.set(p.url,x),x});return matrix.mergeHighlightList(u)}),this.filterPreResult=(n,c,h)=>__async(this,null,function*(){const{points:d}=yield this.cacheInstance.loadPCDFile(n),u=yield this.cacheInstance.loadIndexMap(n,d);return new Promise(m=>{const p=h.map(g=>{const y=MathUtils.default.calculatePointsInsideBox({indexMap:u,polygon:matrix.getCuboidFromPointCloudBox(g).polygonPointList,zScope:[g.center.z-g.depth/2,g.center.z+g.depth/2],box:g}),x=y>=c.lowerLimitPointsNumInBox;return __spreadProps(__spreadValues({},g),{valid:x,count:y})});m(p)})}),this.loadPCDFileByBox=(n,c,h)=>__async(this,null,function*(){const d=(p,g)=>__async(this,null,function*(){const{width:y=0,height:x=0,depth:w=0}=h!=null?h:{},C=yield this.filterPointsByBox(__spreadProps(__spreadValues({},c),{width:c.width+y,height:c.height+x,depth:c.depth+w}),p,g);if(!C){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=n;const b=new THREE__namespace.Points(C.geometry);b.name=this.pointCloudObjectName,this.scene.add(b),this.render()}),{points:u,color:m}=yield this.cacheInstance.loadPCDFile(n);d(u,m)}),this.generateRange=n=>{const c=this.createRange(n);this.scene.add(c)},this.generateBoxArrow=({width:n})=>{const c=new THREE__namespace.Vector3(1,0,0),h=new THREE__namespace.Vector3(n/2,0,0),d=2,u=16776960,m=new THREE__namespace.ArrowHelper(c,h,d,u);return m.visible=this.showDirection,m},this.generateBoxTrackID=n=>{if(!n.trackID)return;const c=new THREE__namespace.Texture(this.getTextCanvas(n.trackID.toString()));c.needsUpdate=!0;const h=new THREE__namespace.SpriteMaterial({map:c,depthWrite:!1}),d=new THREE__namespace.Sprite(h);return d.scale.set(5,5,5),d.position.set(-n.width/2,0,n.depth/2+.5),d},this.applyZAxisPoints=n=>{this.zAxisLimit=n,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:n,customSize:c})=>{const h=this.scene.getObjectByName(this.pointCloudObjectName);if(!h)return;const d=h.material.uniforms.pointSize.value;n?h.material.uniforms.pointSize.value=Math.min(d*1.2,10):h.material.uniforms.pointSize.value=Math.max(d/1.2,1),c&&(h.material.uniforms.pointSize.value=c,this.pointsMaterialSize=c),h.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=o,this.config=a,this.checkMode=l!=null?l:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,s?this.container:this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance(),s===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new index(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new segmentation.PointCloudSegmentOperation(__spreadValues({dom:this.container,store:this.store},this.eventBus)),this.pointCloudRender=new index$1(__spreadProps(__spreadValues({store:this.store},this.eventBus),{nextTick:this.nextTick})),this.initMsg(),document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup)}orbiterStart(){}orbiterChange(){!this.store||(this.store.orbiting=!0)}orbiterEnd(){!this.store||(this.store.orbiting=!1)}get currentSegmentTool(){var t;return(t=this.segmentOperation)==null?void 0:t.currentToolName}get pointCloudObject(){return this.scene.getObjectByName(this.pointCloudObjectName)}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.on("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.on("clearPointCloud",this.clearPointCloud.bind(this)),this.on("loadPCDFile",this.loadPCDFile.bind(this)))}unbindMsg(){!this.segmentOperation||(this.unbind("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.unbind("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.unbind("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.unbind("clearPointCloud",this.clearPointCloud.bind(this)),this.unbind("loadPCDFile",this.loadPCDFile.bind(this)))}get eventBus(){return{on:this.on.bind(this),emit:this.emit.bind(this),unbind:this.unbind.bind(this)}}get pointCloudDelegate(){return __spreadValues({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode,config:this.config},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new THREE__namespace.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){var e;this.config=t,(e=this.store)==null||e.setConfig(t)}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:o,near:a,far:s}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=o,this.camera.near=a,this.camera.far=s,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:i,z:r}=this.initCameraPosition;t.position.set(e,i,r)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new THREE__namespace.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new THREE__namespace.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}getColorFromConfig(t){return lbUtils.toolStyleConverter.getColorFromConfig({attribute:t},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{})}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=this.getColorFromConfig(i.attribute),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,o=10,a=e.x-i/2-o,s=e.x-i/2+o,l=e.y+r/2+o,n=e.y-r/2-o,c=100,h=-100,d=500/c;return{left:a,right:s,top:l,bottom:n,near:c,far:h,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:o,height:a,depth:s,rotation:l}=t,n=this.getCameraVector(r,l,{width:o,height:a,depth:s},e);return i?(this.updateCamera(i,r),new THREE__namespace.Vector3(i.x,i.y,i.z)):(this.updateCamera(n,r),n)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=lbUtils.DEFAULT_SPHERE_PARAMS,o=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,o,a;if(!e){const s=this.scene.getObjectByName(this.pointCloudObjectName);if(!s)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:a.array}if(window.Worker){const{zMin:s,zMax:l,polygonPointList:n}=matrix.getCuboidFromPointCloudBox(t),c=e;i=i!=null?i:new Float32Array([]);const h={boxParams:t,zMin:s,zMax:l,polygonPointList:n,color:i,position:c};return new Promise(d=>{const u=new filterBoxWorker;u.postMessage(h),u.onmessage=m=>{const{color:p,position:g,num:y}=m.data,x=new THREE__namespace.BufferGeometry;x.setAttribute("position",new THREE__namespace.Float32BufferAttribute(g,3)),x.setAttribute("color",new THREE__namespace.Float32BufferAttribute(p,3)),x.computeBoundingSphere(),u.terminate(),d({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,o=DEFAULT_DISTANCE){let a=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(o);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:a=lbUtils.PerspectiveShiftUtils.backViewMatrix4(o);break;case lbUtils.EPerspectiveView.Left:a=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(o);break;case lbUtils.EPerspectiveView.Right:a=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(o);break;case lbUtils.EPerspectiveView.Top:a=lbUtils.PerspectiveShiftUtils.topViewMatrix4(o);break;case lbUtils.EPerspectiveView.LFT:a=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(o,i);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(o,i);break}const s=this.createThreeMatrix4(a),l=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),n=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(s).applyMatrix4(l).applyMatrix4(c).applyMatrix4(n)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new THREE__namespace.BufferGeometry().setFromPoints(i),o=new THREE__namespace.LineBasicMaterial({color:16711680}),a=new THREE__namespace.Line(r,o);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new THREE__namespace.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],o=t[e+2];this.store.cloudData.set(`${i}@${r}@${o}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return __async(this,null,function*(){return new Promise((e,i)=>{if(this.workerLoading){i(new Error("workerLoading"));return}this.workerLoading=!0,highlightWorker.postMessage(t),highlightWorker.onmessage=r=>{e(r.data),this.workerLoading=!1},highlightWorker.onerror=r=>{i(r),this.workerLoading=!1}})})}highlightOriginPointCloud(t){return __async(this,arguments,function*(e,i=[]){const r=this.scene.getObjectByName(this.pointCloudObjectName);if(!!r)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((o,a)=>{if(window.Worker){const l=(e?[...e]:[]).map(h=>matrix.getCuboidFromPointCloudBox(h)),n=this.getAllAttributeColor(l),c={cuboidList:l,position:r.geometry.attributes.position.array,color:r.geometry.attributes.dimensions.array,colorList:n,highlightIndex:i};this.handleWebworker(c).then(h=>{const{color:d}=h,u=new THREE__namespace.BufferAttribute(d,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||r.geometry.attributes.position.array.length!==d.length){a(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,d),this.highlightPCDSrc=void 0,u.needsUpdate=!0,r.geometry.setAttribute("dimensions",u),r.geometry.attributes.dimensions.needsUpdate=!0,o(d),this.render()}).catch(h=>{a(h)})}})})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new THREE__namespace.Group;t.forEach(i=>{const{center:{x:r,y:o,z:a},width:s,height:l,depth:n,rotation:c}=i,{fill:h}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),d=new THREE__namespace.BoxGeometry(s,l,n),u=new THREE__namespace.MeshBasicMaterial({color:h,transparent:!0,opacity:.2,depthTest:!1});d.rotateZ(c),d.translate(r,o,a);const m=new THREE__namespace.Mesh(d,u);e.add(m);const p=new THREE__namespace.PlaneGeometry(n,l);p.rotateY(Math.PI/2),p.rotateZ(c);const g=new THREE__namespace.Vector3(s/2,0,0),y=new THREE__namespace.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(c);g.applyMatrix4(y),p.translate(r+g.x,o+g.y,a+g.z);const x=new THREE__namespace.MeshBasicMaterial({color:h,side:THREE__namespace.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),w=new THREE__namespace.Mesh(p,x);e.add(w)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((h,d)=>h.z-d.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:h})=>h>r.z+.1);const o=.005,a=Math.floor(e.length*(1-o));e=e.slice(0,a),e.sort((h,d)=>h.x-d.x);const s=Math.floor(e.length*o),l=Math.floor(e.length*(1-o));e=e.slice(s,l),e.sort((h,d)=>h.y-d.y);const n=Math.floor(e.length*o),c=Math.floor(e.length*(1-o));return e=e.slice(n,c),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:l,y:n})=>{t.forEach((c,h)=>{const d=r[h+1],u=MathUtils.default.getFootOfPerpendicular({x:l,y:n},c,d,!1,!0).length;(!i[h]||u<i[h].distance)&&(i[h]={distance:u,point:{x:l,y:n}})})}),r=[t[t.length-1],...t,t[0]];const o=[i[i.length-1],...i],a=t.map((l,n)=>{const c=r[n],h=r[n+1],d=r[n+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:o[n].point,line1:[c,h],p2:o[n+1].point,line2:[h,d]})});return a.some(l=>!(Number.isFinite(l.x)&&Number.isFinite(l.y)))?t:a}getSensesPointZAxisInPolygon(t,e,i){var r,o,a;const s=this.scene.children.find(p=>p.uuid===this.pointsUuid);let l=0,n=0,c=0,h=0,d=[],u=[];const m=((a=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:a.array)||[];for(let p=0;p<m.length;p+=3){const g=m[p],y=m[p+1],x=m[p+2];polygonTool.isInPolygon({x:g,y},t)&&(x||x===0)&&u.push({x:g,y,z:x})}return u.length?(i&&(u=this.filterNoise(u),d=this.getFittedCoordinates(t,u)),u.sort((p,g)=>p.z-g.z),l=u[0].z-.01,n=u[u.length-1].z+.01,h=u.length,e&&(c=u.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:n,minZ:l,count:c,zCount:h,fittedCoordinates:d}):{maxZ:n,minZ:l,count:c,zCount:h,fittedCoordinates:d}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e+a/2,y:i+o/2,z:r-s/2},n={x:e+a/2,y:i+o/2,z:r+s/2},c={x:e-a/2,y:i+o/2,z:r+s/2},h={x:e-a/2,y:i+o/2,z:r-s/2};return[l,n,c,h]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e-a/2,y:i+o/2,z:r+s/2},n={x:e-a/2,y:i+o/2,z:r-s/2},c={x:e-a/2,y:i-o/2,z:r-s/2},h={x:e-a/2,y:i-o/2,z:r+s/2};return[l,n,c,h]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e+a/2,y:i+o/2,z:r+s/2},n={x:e+a/2,y:i-o/2,z:r+s/2},c={x:e-a/2,y:i-o/2,z:r+s/2},h={x:e-a/2,y:i+o/2,z:r+s/2};return[l,n,c,h]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:o}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),s=new THREE__namespace.Matrix4().makeTranslation(e,i,r),l=new THREE__namespace.Matrix4().makeRotationZ(o);return new THREE__namespace.Matrix4().multiply(s).multiply(l).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:o}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const l=i.map(h=>new THREE__namespace.Vector3(h.x,h.y,h.z)).map(h=>h.applyMatrix4(this.sideMatrix)),n=this.containerWidth/r,c=this.containerHeight/o;return{polygon2d:l,zoom:Math.min(n,c)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:o}=t,{radius:a}=lbUtils.DEFAULT_SPHERE_PARAMS,s={center:e,attribute:i,id:r,valid:o,width:a*2,height:a*2,depth:a*2,rotation:0},l=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(s)).premultiply(l).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const c=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),h=this.containerWidth/(a*2),d=this.containerHeight/(a*2);return{point2d:c,zoom:Math.min(h,d)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=lbUtils.DEFAULT_SPHERE_PARAMS,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},o=this.containerWidth/(i*2),a=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(o,a)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,o=this.getPolygonTopPoints(t).map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.getModelTransformationMatrix(t))).map(l=>({x:l.y,y:l.x})).map(l=>({x:-(l.x-this.containerWidth/2),y:-(l.y-this.containerHeight/2)})),a=this.containerWidth/e,s=this.containerHeight/i;return{polygon2d:o,zoom:Math.min(a,s)/2}}getNewBoxBySideUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+a.x,y:s.center.y+a.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:Math.abs(s.width+e),height:s.height,depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxByBackUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+a.x,y:s.center.y+a.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:s.width,height:Math.abs(s.height+e),depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxBySideUpdateByPoints(t,e,i,r){var o;const a=(o=this.sideMatrix)==null?void 0:o.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const s=t.map(g=>new THREE__namespace.Vector3(g.x,g.y,g.z)).map(g=>g.applyMatrix4(a)),[l,n,c,h]=s,d=Math.max(Math.abs(l.x-c.x),Math.abs(l.x-n.x)),m=n.add(h).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:__spreadProps(__spreadValues({},r),{center:{x:r.center.x-m.x,y:r.center.y-m.y,z:r.center.z-i},width:d,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,o=[],{count:a}=r;for(let s=0;s<a;s++){const l=r.getZ(s);o.push(l>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(o,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isFisheyeCalibValid=matrix.isFisheyeCalibValid,exports.isInImage=matrix.isInImage,exports.isMatrixValid=matrix.isMatrixValid,exports.isMatrixValidByArr=matrix.isMatrixValidByArr,exports.lidar2FisheyeImage=matrix.lidar2FisheyeImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.oCamFisheyeTransfer=matrix.oCamFisheyeTransfer,exports.omniCamera11VTransfer=matrix.omniCamera11VTransfer,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.pointListLidar2Img=matrix.pointListLidar2Img,exports.pointMappingLidar2image=matrix.pointMappingLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
31
+ }`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...o)=>__async(this,[...o],function*(n=this.currentPCDSrc,c){if(!n)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=n;const{points:u,color:p}=yield this.cacheInstance.loadPCDFile(n),m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.BufferAttribute(u,3)),this.isSegment||m.setAttribute("dimensions",new THREE__namespace.BufferAttribute(p,3)),this.initCloudData(u);const f=new THREE__namespace.Points(m);this.renderPointCloud(f,c),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=o=>__async(this,[o],function*({mappingImgList:n,points:c}){const u=g=>__async(this,null,function*(){try{return yield ImgUtils.default.load(g)}catch(x){return console.error("Error loading image:",x),null}}),p=n.length===0?[]:(yield Promise.all(n.map(g=>__async(this,null,function*(){let x=yield u(g.url);return!x&&g.fallbackUrl&&(x=yield u(g.fallbackUrl)),x})))).filter(g=>g!==null),m=n.map((g,x)=>{var y;if(this.cacheInstance.cache2DHighlightIndex.has(g.url))return(y=this.cacheInstance.cache2DHighlightIndex.get(g.url))!=null?y:[];const b=matrix.getHighlightIndexByPoints({points:c,calib:g.calib,width:p[x].width,height:p[x].height});return this.cacheInstance.cache2DHighlightIndex.set(g.url,b),b});return matrix.mergeHighlightList(m)}),this.filterPreResult=(o,n,c)=>__async(this,null,function*(){const{points:u}=yield this.cacheInstance.loadPCDFile(o),p=yield this.cacheInstance.loadIndexMap(o,u);return new Promise(m=>{const f=c.map(g=>{const x=MathUtils.default.calculatePointsInsideBox({indexMap:p,polygon:matrix.getCuboidFromPointCloudBox(g).polygonPointList,zScope:[g.center.z-g.depth/2,g.center.z+g.depth/2],box:g}),y=x>=n.lowerLimitPointsNumInBox;return __spreadProps(__spreadValues({},g),{valid:y,count:x})});m(f)})}),this.loadPCDFileByBox=(o,n,c)=>__async(this,null,function*(){const u=(f,g)=>__async(this,null,function*(){const{width:x=0,height:y=0,depth:b=0}=c!=null?c:{},C=yield this.filterPointsByBox(__spreadProps(__spreadValues({},n),{width:n.width+x,height:n.height+y,depth:n.depth+b}),f,g);if(!C){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=o;const v=new THREE__namespace.Points(C.geometry);v.name=this.pointCloudObjectName,this.scene.add(v),this.render()}),{points:p,color:m}=yield this.cacheInstance.loadPCDFile(o);u(p,m)}),this.generateRange=o=>{const n=this.createRange(o);this.scene.add(n)},this.generateBoxArrow=({width:o})=>{const n=new THREE__namespace.Vector3(1,0,0),c=new THREE__namespace.Vector3(o/2,0,0),u=2,p=new THREE__namespace.ArrowHelper(n,c,u,this.highlightColor);return p.visible=this.showDirection,p},this.generateLabel=(o,n,c)=>{const u=this.getTextCanvas(o),p=new THREE__namespace.Texture(u);p.minFilter=THREE__namespace.LinearFilter,p.magFilter=THREE__namespace.LinearFilter,p.needsUpdate=!0;const m=u.width/window.devicePixelRatio,f=u.height/window.devicePixelRatio,g=new THREE__namespace.SpriteMaterial({map:p,depthWrite:!1,color:c}),x=new THREE__namespace.Sprite(g);return x.scale.set(m/n,f/n,1),{sprite:x,canvasWidth:m,canvasHeight:f}},this.generateBoxTrackID=(o,n)=>{if(!o.trackID)return;const{sprite:c}=this.generateLabel(o.trackID.toString(),50,n);return c.position.set(-o.width/2,0,o.depth/2+.5),c},this.generateBoxAttributeLabel=(o,n)=>{if(!o.attribute||this.hiddenText)return;const c=this.findSubAttributeLabel(o,this.config),u=c?`${o.attribute}
32
+ ${c}`:`${o.attribute}`,{sprite:p,canvasHeight:m}=this.generateLabel(u,100,n);return p.position.set(-o.width/2,0,-o.depth/2-m/150),p},this.applyZAxisPoints=o=>{this.zAxisLimit=o,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:o,customSize:n})=>{const c=this.scene.getObjectByName(this.pointCloudObjectName);if(!c)return;const u=c.material.uniforms.pointSize.value;o?c.material.uniforms.pointSize.value=Math.min(u*1.2,10):c.material.uniforms.pointSize.value=Math.max(u/1.2,1),n&&(c.material.uniforms.pointSize.value=n,this.pointsMaterialSize=n),c.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=a,this.config=h,this.checkMode=l!=null?l:!1,this.hiddenText=d,i&&r?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,s?this.container:this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.filterBoxWorker=new filterBoxWorker,this.geometry=new THREE__namespace.BufferGeometry,this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance(),s===!0&&(this.initSegment(),this.isSegment=!0),this.controls.addEventListener("rightClick",o=>{var n,c,u;const p=this.renderer.domElement.getBoundingClientRect(),m=o.originalEvent.clientX-p.left,f=o.originalEvent.clientY-p.top;this.pointer.x=m/p.width*2-1,this.pointer.y=-(f/p.height)*2+1,this.raycaster.setFromCamera(this.pointer,this.camera);const g=[];this.scene.children.forEach(y=>{y instanceof THREE__namespace.Group&&y.children.forEach(b=>{b instanceof THREE__namespace.Mesh?g.push(b):this.updateMaterialColor(b,y.userData.defaultColor)})});const x=this.raycaster.intersectObjects(g,!1);if(x.length>0){const y=x[0].object.parent;y==null||y.children.forEach(b=>{this.updateMaterialColor(b,this.highlightColor)}),(n=this.pipe)==null||n.setNeedUpdateCenter(!1),(c=this.pipe)==null||c.setSelectedIDs(y==null?void 0:y.userData.selectedID)}else(u=this.pipe)==null||u.setSelectedIDs(void 0);this.render()})}setHighlightColor(t){this.scene.children.forEach(e=>{if(!(e instanceof THREE__namespace.Group))return;const i=e.name===`box${t}`?this.highlightColor:e.userData.defaultColor;e.children.forEach(r=>{this.updateMaterialColor(r,i)})}),this.render()}updateMaterialColor(t,e){(t instanceof THREE__namespace.BoxHelper||t instanceof THREE__namespace.Sprite)&&t.material.color.set(e)}setHandlerPipe(t){this.pipe=t}initSegment(){this.store=new index(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new segmentation.PointCloudSegmentOperation(__spreadValues({dom:this.container,store:this.store},this.eventBus)),this.pointCloudRender=new index$1(__spreadProps(__spreadValues({store:this.store},this.eventBus),{nextTick:this.nextTick})),this.initMsg(),document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup)}orbiterStart(){}orbiterChange(){!this.store||(this.store.orbiting=!0)}orbiterEnd(){!this.store||(this.store.orbiting=!1)}get currentSegmentTool(){var t;return(t=this.segmentOperation)==null?void 0:t.currentToolName}get pointCloudObject(){return this.scene.getObjectByName(this.pointCloudObjectName)}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.on("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.on("clearPointCloud",this.clearPointCloud.bind(this)),this.on("loadPCDFile",this.loadPCDFile.bind(this)))}unbindMsg(){!this.segmentOperation||(this.unbind("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.unbind("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.unbind("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.unbind("clearPointCloud",this.clearPointCloud.bind(this)),this.unbind("loadPCDFile",this.loadPCDFile.bind(this)))}get eventBus(){return{on:this.on.bind(this),emit:this.emit.bind(this),unbind:this.unbind.bind(this)}}get pointCloudDelegate(){return __spreadValues({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode,config:this.config},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new THREE__namespace.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){var e;this.config=t,(e=this.store)==null||e.setConfig(t)}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:a,near:h,far:s}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=a,this.camera.near=h,this.camera.far=s,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:i,z:r}=this.initCameraPosition;t.position.set(e,i,r)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new THREE__namespace.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new THREE__namespace.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}getColorFromConfig(t){return lbUtils.toolStyleConverter.getColorFromConfig({attribute:t},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{})}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=this.getColorFromConfig(i.attribute),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,a=10,h=e.x-i/2-a,s=e.x-i/2+a,l=e.y+r/2+a,d=e.y-r/2-a,o=100,n=-100,c=500/o;return{left:h,right:s,top:l,bottom:d,near:o,far:n,zoom:c}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:a,height:h,depth:s,rotation:l}=t,d=this.getCameraVector(r,l,{width:a,height:h,depth:s},e);return i?(this.updateCamera(i,r),new THREE__namespace.Vector3(i.x,i.y,i.z)):(this.updateCamera(d,r),d)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=lbUtils.DEFAULT_SPHERE_PARAMS,a=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(a,i),a}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,a,h;if(!e){const s=this.scene.getObjectByName(this.pointCloudObjectName);if(!s)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(h=(a=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:a.position)==null?void 0:h.array}if(window.Worker){const{zMin:s,zMax:l,polygonPointList:d}=matrix.getCuboidFromPointCloudBox(t),o=e;i=i!=null?i:new Float32Array([]);const n={boxParams:t,zMin:s,zMax:l,polygonPointList:d,color:i,position:o};return this.filterBoxWorker||(this.filterBoxWorker=new filterBoxWorker),new Promise(c=>{var u;(u=this.filterBoxWorker)==null||u.postMessage(n),this.filterBoxWorker.onmessage=p=>{const{color:m,position:f,num:g}=p.data;this.geometry.dispose(),this.geometry.setAttribute("position",new THREE__namespace.Float32BufferAttribute(f,3)),this.geometry.setAttribute("color",new THREE__namespace.Float32BufferAttribute(m,3)),this.geometry.computeBoundingSphere(),this.filterBoxWorkerTimer&&clearTimeout(this.filterBoxWorkerTimer),this.filterBoxWorkerTimer=setTimeout(()=>{this.filterBoxWorker&&(this.filterBoxWorker.terminate(),this.filterBoxWorker=null)},3e3),c({geometry:this.geometry,num:g})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,a=DEFAULT_DISTANCE){let h=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(a);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:h=lbUtils.PerspectiveShiftUtils.backViewMatrix4(a);break;case lbUtils.EPerspectiveView.Left:h=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(a);break;case lbUtils.EPerspectiveView.Right:h=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(a);break;case lbUtils.EPerspectiveView.Top:h=lbUtils.PerspectiveShiftUtils.topViewMatrix4(a);break;case lbUtils.EPerspectiveView.LFT:h=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(a,i);break;case lbUtils.EPerspectiveView.RBT:h=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(a,i);break}const s=this.createThreeMatrix4(h),l=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),d=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),o=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(s).applyMatrix4(l).applyMatrix4(o).applyMatrix4(d)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new THREE__namespace.BufferGeometry().setFromPoints(i),a=new THREE__namespace.LineBasicMaterial({color:16711680}),h=new THREE__namespace.Line(r,a);return h.name=this.rangeObjectName,h}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new THREE__namespace.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],a=t[e+2];this.store.cloudData.set(`${i}@${r}@${a}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return __async(this,null,function*(){return new Promise((e,i)=>{if(this.workerLoading){i(new Error("highlightWorker called repeatedly, new call discarded"));return}this.workerLoading=!0,highlightWorker.postMessage(t),highlightWorker.onmessage=r=>{e(r.data),this.workerLoading=!1},highlightWorker.onerror=r=>{i(r),this.workerLoading=!1}})})}highlightOriginPointCloud(t){return __async(this,arguments,function*(e,i=[],r={modifiedBoxIds:[],resetAreas:[]}){const{modifiedBoxIds:a,resetAreas:h}=r,s=this.scene.getObjectByName(this.pointCloudObjectName);if(!!s)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((l,d)=>{if(window.Worker){const n=(e?[...e]:[]).map(f=>matrix.getCuboidFromPointCloudBox(f)),c=this.getAllAttributeColor(n),u=s.geometry.attributes.position.array,p=s.geometry.attributes.dimensions.array,m={cuboidList:n,position:u,color:p,colorList:c,highlightIndex:i,modifiedBoxIds:a,resetAreas:h};this.handleWebworker(m).then(f=>{const{color:g}=f;let x=g;(a.length||h.length)&&(x=g.map((b,C)=>b===-1?p[C]:b));const y=new THREE__namespace.BufferAttribute(x,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||s.geometry.attributes.position.array.length!==g.length){d(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,x),this.highlightPCDSrc=void 0,y.needsUpdate=!0,s.geometry.setAttribute("dimensions",y),s.geometry.attributes.dimensions.needsUpdate=!0,l(x),this.render()}).catch(f=>{d(f)})}})})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new THREE__namespace.Group;t.forEach(i=>{const{center:{x:r,y:a,z:h},width:s,height:l,depth:d,rotation:o}=i,{fill:n}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),c=new THREE__namespace.BoxGeometry(s,l,d),u=new THREE__namespace.MeshBasicMaterial({color:n,transparent:!0,opacity:.2,depthTest:!1});c.rotateZ(o),c.translate(r,a,h);const p=new THREE__namespace.Mesh(c,u);e.add(p);const m=new THREE__namespace.PlaneGeometry(d,l);m.rotateY(Math.PI/2),m.rotateZ(o);const f=new THREE__namespace.Vector3(s/2,0,0),g=new THREE__namespace.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(o);f.applyMatrix4(g),m.translate(r+f.x,a+f.y,h+f.z);const x=new THREE__namespace.MeshBasicMaterial({color:n,side:THREE__namespace.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),y=new THREE__namespace.Mesh(m,x);e.add(y)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}findSubAttributeLabel(t,e){if(!(t==null?void 0:t.subAttribute)||typeof t.subAttribute!="object"||!e)return"";const{inputList:i}=e;let r="";const a=Object.keys(t.subAttribute);return a.length===0||a.forEach(h=>{const s=i.find(o=>o.value===h);if(!s||!s.subSelected)return;const{key:l,subSelected:d}=s;d.forEach(o=>{var n;const c=(n=t.subAttribute)==null?void 0:n[h];(c==null?void 0:c.includes(o.value))&&(r&&(r+="\u3001"),r+=`${l}:${o.key}`)})}),r}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d"),r=window.devicePixelRatio||1,a=50;if(i){i.font=`${a}px bold`;const h=t.split(`
33
+ `),s=Math.max(...h.map(n=>i.measureText(n).width)),l=Math.ceil(s),d=a*1.5,o=d*h.length;e.width=l*r,e.height=o*r,e.style.width=`${l}px`,e.style.height=`${o}px`,i.scale(r,r),i.font=`${a}px bold`,i.fillStyle="white",i.textAlign="left",i.textBaseline="top",h.forEach((n,c)=>{i.fillText(n,0,c*d)})}return e}updateHiddenTextAndRender(t,e){this.hiddenText=t,this.generateBoxes(e)}filterNoise(t){let e=[...t];e.sort((n,c)=>n.z-c.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:n})=>n>r.z+.1);const a=.005,h=Math.floor(e.length*(1-a));e=e.slice(0,h),e.sort((n,c)=>n.x-c.x);const s=Math.floor(e.length*a),l=Math.floor(e.length*(1-a));e=e.slice(s,l),e.sort((n,c)=>n.y-c.y);const d=Math.floor(e.length*a),o=Math.floor(e.length*(1-a));return e=e.slice(d,o),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:l,y:d})=>{t.forEach((o,n)=>{const c=r[n+1],u=MathUtils.default.getFootOfPerpendicular({x:l,y:d},o,c,!1,!0).length;(!i[n]||u<i[n].distance)&&(i[n]={distance:u,point:{x:l,y:d}})})}),r=[t[t.length-1],...t,t[0]];const a=[i[i.length-1],...i],h=t.map((l,d)=>{const o=r[d],n=r[d+1],c=r[d+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:a[d].point,line1:[o,n],p2:a[d+1].point,line2:[n,c]})});return h.some(l=>!(Number.isFinite(l.x)&&Number.isFinite(l.y)))?t:h}getSensesPointZAxisInPolygon(t,e,i){var r,a,h;const s=this.scene.children.find(m=>m.uuid===this.pointsUuid);let l=0,d=0,o=0,n=0,c=[],u=[];const p=((h=(a=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:a.position)==null?void 0:h.array)||[];for(let m=0;m<p.length;m+=3){const f=p[m],g=p[m+1],x=p[m+2];polygonTool.isInPolygon({x:f,y:g},t)&&(x||x===0)&&u.push({x:f,y:g,z:x})}return u.length?(i&&(u=this.filterNoise(u),c=this.getFittedCoordinates(t,u)),u.sort((m,f)=>m.z-f.z),l=u[0].z-.01,d=u[u.length-1].z+.01,n=u.length,e&&(o=u.filter(({z:m})=>m>=e[0]&&m<=e[1]).length),{maxZ:d,minZ:l,count:o,zCount:n,fittedCoordinates:c}):{maxZ:d,minZ:l,count:o,zCount:n,fittedCoordinates:c}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:a,width:h,depth:s}=t,l={x:e+h/2,y:i+a/2,z:r-s/2},d={x:e+h/2,y:i+a/2,z:r+s/2},o={x:e-h/2,y:i+a/2,z:r+s/2},n={x:e-h/2,y:i+a/2,z:r-s/2};return[l,d,o,n]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:a,width:h,depth:s}=t,l={x:e-h/2,y:i+a/2,z:r+s/2},d={x:e-h/2,y:i+a/2,z:r-s/2},o={x:e-h/2,y:i-a/2,z:r-s/2},n={x:e-h/2,y:i-a/2,z:r+s/2};return[l,d,o,n]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:a,width:h,depth:s}=t,l={x:e+h/2,y:i+a/2,z:r+s/2},d={x:e+h/2,y:i-a/2,z:r+s/2},o={x:e-h/2,y:i-a/2,z:r+s/2},n={x:e-h/2,y:i+a/2,z:r+s/2};return[l,d,o,n]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:a}=t,h=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),s=new THREE__namespace.Matrix4().makeTranslation(e,i,r),l=new THREE__namespace.Matrix4().makeRotationZ(a);return new THREE__namespace.Matrix4().multiply(s).multiply(l).multiply(h)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:a}=t,h=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(h).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const l=i.map(n=>new THREE__namespace.Vector3(n.x,n.y,n.z)).map(n=>n.applyMatrix4(this.sideMatrix)),d=this.containerWidth/r,o=this.containerHeight/a;return{polygon2d:l,zoom:Math.min(d,o)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:a}=t,{radius:h}=lbUtils.DEFAULT_SPHERE_PARAMS,s={center:e,attribute:i,id:r,valid:a,width:h*2,height:h*2,depth:h*2,rotation:0},l=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),d=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(s)).premultiply(l).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=d;const o=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),n=this.containerWidth/(h*2),c=this.containerHeight/(h*2);return{point2d:o,zoom:Math.min(n,c)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=lbUtils.DEFAULT_SPHERE_PARAMS,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},a=this.containerWidth/(i*2),h=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(a,h)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,a=this.getPolygonTopPoints(t).map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.getModelTransformationMatrix(t))).map(l=>({x:l.y,y:l.x})).map(l=>({x:-(l.x-this.containerWidth/2),y:-(l.y-this.containerHeight/2)})),h=this.containerWidth/e,s=this.containerHeight/i;return{polygon2d:a,zoom:Math.min(h,s)/2}}getNewBoxBySideUpdate(t,e,i,r){const a=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),h=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(a);let s=r;return s.center={x:s.center.x+h.x,y:s.center.y+h.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:Math.abs(s.width+e),height:s.height,depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxByBackUpdate(t,e,i,r){const a=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),h=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(a);let s=r;return s.center={x:s.center.x+h.x,y:s.center.y+h.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:s.width,height:Math.abs(s.height+e),depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxBySideUpdateByPoints(t,e,i,r){var a;const h=(a=this.sideMatrix)==null?void 0:a.invert();if(!this.sideMatrix||!h){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const s=t.map(f=>new THREE__namespace.Vector3(f.x,f.y,f.z)).map(f=>f.applyMatrix4(h)),[l,d,o,n]=s,c=Math.max(Math.abs(l.x-o.x),Math.abs(l.x-d.x)),p=d.add(n).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:__spreadProps(__spreadValues({},r),{center:{x:r.center.x-p.x,y:r.center.y-p.y,z:r.center.z-i},width:c,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,a=[],{count:h}=r;for(let s=0;s<h;s++){const l=r.getZ(s);a.push(l>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(a,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isFisheyeCalibValid=matrix.isFisheyeCalibValid,exports.isInImage=matrix.isInImage,exports.isMatrixValid=matrix.isMatrixValid,exports.isMatrixValidByArr=matrix.isMatrixValidByArr,exports.lidar2FisheyeImage=matrix.lidar2FisheyeImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.oCamFisheyeTransfer=matrix.oCamFisheyeTransfer,exports.omniCamera11VTransfer=matrix.omniCamera11VTransfer,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.pointListLidar2Img=matrix.pointListLidar2Img,exports.pointMappingLidar2image=matrix.pointMappingLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),uuid=require("../../utils/uuid.js"),omniCamera=require("./omniCamera.js");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,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,__pow=Math.pow,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function createThreeMatrix4(e){return new THREE__namespace.Matrix4().set(...e)}function transferKitti2Matrix(e,t,r){try{const n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),i=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),o=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),l=createThreeMatrix4(n),f=createThreeMatrix4(i),a=createThreeMatrix4(o);return{composeMatrix4:a.clone().premultiply(f).premultiply(l),PM:l,RM:f,TM:a}}catch(n){console.error(n)}}function rotatePoint(e,t,r){var n;const i=new THREE__namespace.Vector3(e.x,e.y,(n=e==null?void 0:e.z)!=null?n:1),o=new THREE__namespace.Matrix4().makeRotationZ(r),l=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),f=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(f).applyMatrix4(o).applyMatrix4(l)}function isMatrixValid(e,t,r){return!(e.length!==t||e.some(n=>n.length!==r))}const isMatrixValidByArr=(e,t)=>t.some(r=>isMatrixValid(e,r[0],r[1])),isFisheyeCalibValid=e=>{var t;return!!(((t=e.fisheyeDistortion)==null?void 0:t.length)>0&&isMatrixValidByArr(e.P,[[3,4],[4,4]])&&isMatrixValidByArr(e.T,[[3,4],[4,4]]))},oCamFisheyeTransfer=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:r,fisheyeDistortion:n,T:i}=t,o=new THREE__namespace.Vector4(e.x,e.y,e.z),l=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(i)),f=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r)),a=o.applyMatrix4(l),x=__pow(__pow(a.x,2)+__pow(a.y,2),.5),p=Math.atan(a.z/x),s=n.reduce((c,u,y)=>c+u*__pow(p,y),0);return a.x=a.x/x*s,a.y=a.y/x*s,a.z=1,a.applyMatrix4(f)},omniCamera11VTransfer=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:r,fisheyeDistortion:n,T:i}=t,o=omniCamera.transformPointCloudToImage([[e.x,e.y,e.z]],i,r,n);return new THREE__namespace.Vector4(o[0][0],o[0][1],1)},batchPolyval=(e,t)=>{const r=e.length;let n=0;const i=[];for(let o=0;o<e.length;o++)i.push(e[r-o-1]+n*t),n=e[r-o-1]+n*t;return n},kbCamFisheyeTransfer=(e,t)=>{const{P:r,fisheyeDistortion:n}=t,{x:i,y:o,z:l}=e,f=[[r[0][0],r[0][1]],[r[1][0],r[1][1]]],a=r[0][2],x=r[1][2],p=1/Math.hypot(i,o),s=[],h=Math.atan2(Math.hypot(i,o),l),c=batchPolyval(n,h);return s[0]=i*p*c,s[1]=o*p*c,{x:f[0][0]*s[0]+f[0][1]*s[1]+a,y:f[1][0]*s[0]+f[1][1]*s[1]+x}},lidar2FisheyeImage=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.OmniCamera)return oCamFisheyeTransfer(e,t);if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.KannalaBrandt)return kbCamFisheyeTransfer(e,t);if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.OmniCamera11V)return omniCamera11VTransfer(e,t)};function lidar2image(e,t){const n=new THREE__namespace.Vector4(e.x,e.y,e.z).applyMatrix4(t);if(n.z<0)return;const i=1/n.z,o=new THREE__namespace.Matrix4().set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,1);return n.applyMatrix4(o)}function getCuboidFromPointCloudBox(e){const{center:t,width:r,height:n,depth:i,rotation:o}=e,l=[{x:t.x+r/2,y:t.y-n/2},{x:t.x+r/2,y:t.y+n/2},{x:t.x-r/2,y:t.y+n/2},{x:t.x-r/2,y:t.y-n/2}].map(x=>{const p=rotatePoint(x,t,o);return{x:p.x,y:p.y}}),f=t.z+i/2,a=t.z-i/2;return __spreadProps(__spreadValues({},e),{polygonPointList:l,zMax:f,zMin:a})}function sortPoints(e){const t=e.slice();return t.sort((r,n)=>r.x===n.x?n.y-r.y:r.x-n.x),t}function crossProduct(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=r.x-e.x,l=r.y-e.y;return n*l-o*i}function buildConvexHull(e){const t=sortPoints(e),r=[];for(let o=0;o<t.length;o++){for(;r.length>=2&&crossProduct(r[r.length-2],r[r.length-1],t[o])<=0;)r.pop();r.push(t[o])}const n=[];for(let o=t.length-1;o>=0;o--){for(;n.length>=2&&crossProduct(n[n.length-2],n[n.length-1],t[o])<=0;)n.pop();n.push(t[o])}return r.pop(),n.pop(),r.concat(n)}const point3DLidar2Image=(e,t)=>{var r;if(isFisheyeCalibValid(t))return lidar2FisheyeImage(e,t);const{P:n,R:i,T:o}=t,{composeMatrix4:l}=(r=transferKitti2Matrix(n,i,o))!=null?r:{};if(!!l)return lidar2image(e,l)},isInImage=({point:e,calib:t,width:r,height:n})=>{if(!t)return!1;const i=point3DLidar2Image(e,t);return i?i.x>=0&&i.x<=r&&i.y>=0&&i.y<=n:!1},getHighlightIndexByPoints=({points:e,calib:t,width:r,height:n})=>{const i=[];for(let o=0;o<e.length;o+=3){const l=e[o],f=e[o+1],a=e[o+2];isInImage({point:{x:l,y:f,z:a},calib:t,width:r,height:n})?i.push(1):i.push(0)}return i},mergeHighlightList=e=>{if(e.length===0)return[];const t=[];for(let r=0;r<e[0].length;r++){for(let n=0;n<e.length;n++)if(e[n][r]===1){t.push(1);break}t.length===r&&t.push(0)}return t};function pointCloudLidar2image(e,t,r={createRange:!1}){var n;if(!t)return{transferViewData:[],viewRangePointList:[]};const{createRange:i}=r,o=lbUtils.PointCloudUtils.getAllViewData(e),l=isFisheyeCalibValid(t),{P:f,R:a,T:x}=t;let p;if(l===!1){const{composeMatrix4:c}=(n=transferKitti2Matrix(f,a,x))!=null?n:{};if(!c)return;p=c}const s=o.map(c=>({type:c.type,pointList:c.pointList.map(u=>rotatePoint(u,e.center,e.rotation)).map(u=>l?lidar2FisheyeImage(u,t):p&&lidar2image(u,p)).map(u=>{if(!!u)return{id:uuid(),x:u==null?void 0:u.x,y:u==null?void 0:u.y}}).filter(u=>u!==void 0)})).filter(c=>c.pointList.length!==0);s[0]&&s[0].pointList&&l&&(s[0].pointList=s[0].pointList.map(c=>__spreadProps(__spreadValues({},c),{specialEdge:!0})));let h=[];if(s.length===6&&i===!0){const c=s[0].pointList,u=s[1].pointList;h=buildConvexHull([...c,...u])}return{transferViewData:s,viewRangePointList:h}}function pointMappingLidar2image(e,t,r){var n;const i=isFisheyeCalibValid(t),{P:o,R:l,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,l,f))!=null?n:{};if(!s)return;a=s}const x=e.length/3,p={};for(let s=0;s<x;s++){const h={x:e[s*3],y:e[s*3+1],z:e[s*3+2]};let c;if(i?c=lidar2FisheyeImage(h,t):c=a&&lidar2image({x:e[s*3],y:e[s*3+1],z:e[s*3+2]},a),c){const u=Math.floor(c.x),y=Math.floor(c.y);if(u>r.width||y>r.height||u<0||y<0)continue;p[s]={x:u,y}}}return{pcdMapping:p}}function pointListLidar2Img(e,t,r){var n;if(!t||!r)return;const i=isFisheyeCalibValid(t),{P:o,R:l,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,l,f))!=null?n:{};if(!s)return;a=s}const x=[];if(e.forEach(s=>{let h;if(i?h=lidar2FisheyeImage(s,t):h=a&&lidar2image(s,a),h){const{x:c,y:u}=h;x.push({x:c,y:u})}}),x.some(s=>s.x>0&&s.x<r.width&&s.y>0&&s.y<r.height))return x}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=getHighlightIndexByPoints,exports.isFisheyeCalibValid=isFisheyeCalibValid,exports.isInImage=isInImage,exports.isMatrixValid=isMatrixValid,exports.isMatrixValidByArr=isMatrixValidByArr,exports.lidar2FisheyeImage=lidar2FisheyeImage,exports.lidar2image=lidar2image,exports.mergeHighlightList=mergeHighlightList,exports.oCamFisheyeTransfer=oCamFisheyeTransfer,exports.omniCamera11VTransfer=omniCamera11VTransfer,exports.point3DLidar2Image=point3DLidar2Image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.pointListLidar2Img=pointListLidar2Img,exports.pointMappingLidar2image=pointMappingLidar2image,exports.rotatePoint=rotatePoint,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"),omniCamera=require("./omniCamera.js");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,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,__pow=Math.pow,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function createThreeMatrix4(e){return new THREE__namespace.Matrix4().set(...e)}function transferKitti2Matrix(e,t,r){try{const n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),i=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),o=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),l=createThreeMatrix4(n),f=createThreeMatrix4(i),a=createThreeMatrix4(o);return{composeMatrix4:a.clone().premultiply(f).premultiply(l),PM:l,RM:f,TM:a}}catch(n){console.error(n)}}function rotatePoint(e,t,r){var n;const i=new THREE__namespace.Vector3(e.x,e.y,(n=e==null?void 0:e.z)!=null?n:1),o=new THREE__namespace.Matrix4().makeRotationZ(r),l=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),f=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(f).applyMatrix4(o).applyMatrix4(l)}function isMatrixValid(e,t,r){return!(e.length!==t||e.some(n=>n.length!==r))}const isMatrixValidByArr=(e,t)=>t.some(r=>isMatrixValid(e,r[0],r[1])),isFisheyeCalibValid=e=>{var t;return!!(((t=e.fisheyeDistortion)==null?void 0:t.length)>0&&isMatrixValidByArr(e.P,[[3,4],[4,4]])&&isMatrixValidByArr(e.T,[[3,4],[4,4]]))},oCamFisheyeTransfer=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:r,fisheyeDistortion:n,T:i}=t,o=new THREE__namespace.Vector4(e.x,e.y,e.z),l=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(i)),f=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r)),a=o.applyMatrix4(l),x=__pow(__pow(a.x,2)+__pow(a.y,2),.5),p=Math.atan(a.z/x),s=n.reduce((c,u,h)=>c+u*__pow(p,h),0);return a.x=a.x/x*s,a.y=a.y/x*s,a.z=1,a.applyMatrix4(f)},omniCamera11VTransfer=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:r,fisheyeDistortion:n,T:i}=t,o=omniCamera.transformPointCloudToImage([[e.x,e.y,e.z]],i,r,n);return new THREE__namespace.Vector4(o[0][0],o[0][1],1)},kbCamFisheyeTransfer=(e,t)=>{const{P:r,T:n,fisheyeDistortion:i}=t,o=[e.x,e.y,e.z,1],l=n.map(g=>g.reduce((M,v,_)=>M+v*o[_],0)),f=l[0],a=l[1],x=l[2];if(!(x>=.01&&isFinite(x)))return;const p=[[r[0][0],r[0][1]],[r[1][0],r[1][1]]],s=r[0][2],y=r[1][2],c=Math.sqrt(f*f+a*a),u=Math.atan2(c,x),h=u+i.reduce((g,M,v)=>g+M*Math.pow(u,2*v+3),0);let m,d;c!==0?(m=f*h/c,d=a*h/c):(m=0,d=0);const T=p[0][0]*m+p[0][1]*d,P=p[1][0]*m+p[1][1]*d;return{x:T+s,y:P+y}},lidar2FisheyeImage=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.OmniCamera)return oCamFisheyeTransfer(e,t);if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.KannalaBrandt)return kbCamFisheyeTransfer(e,t);if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.OmniCamera11V)return omniCamera11VTransfer(e,t)};function lidar2image(e,t){const n=new THREE__namespace.Vector4(e.x,e.y,e.z).applyMatrix4(t);if(n.z<0)return;const i=1/n.z,o=new THREE__namespace.Matrix4().set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,1);return n.applyMatrix4(o)}function getCuboidFromPointCloudBox(e){const{center:t,width:r,height:n,depth:i,rotation:o}=e,l=[{x:t.x+r/2,y:t.y-n/2},{x:t.x+r/2,y:t.y+n/2},{x:t.x-r/2,y:t.y+n/2},{x:t.x-r/2,y:t.y-n/2}].map(x=>{const p=rotatePoint(x,t,o);return{x:p.x,y:p.y}}),f=t.z+i/2,a=t.z-i/2;return __spreadProps(__spreadValues({},e),{polygonPointList:l,zMax:f,zMin:a})}function sortPoints(e){const t=e.slice();return t.sort((r,n)=>r.x===n.x?n.y-r.y:r.x-n.x),t}function crossProduct(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=r.x-e.x,l=r.y-e.y;return n*l-o*i}function buildConvexHull(e){const t=sortPoints(e),r=[];for(let o=0;o<t.length;o++){for(;r.length>=2&&crossProduct(r[r.length-2],r[r.length-1],t[o])<=0;)r.pop();r.push(t[o])}const n=[];for(let o=t.length-1;o>=0;o--){for(;n.length>=2&&crossProduct(n[n.length-2],n[n.length-1],t[o])<=0;)n.pop();n.push(t[o])}return r.pop(),n.pop(),r.concat(n)}const point3DLidar2Image=(e,t)=>{var r;if(isFisheyeCalibValid(t))return lidar2FisheyeImage(e,t);const{P:n,R:i,T:o}=t,{composeMatrix4:l}=(r=transferKitti2Matrix(n,i,o))!=null?r:{};if(!!l)return lidar2image(e,l)},isInImage=({point:e,calib:t,width:r,height:n})=>{if(!t)return!1;const i=point3DLidar2Image(e,t);return i?i.x>=0&&i.x<=r&&i.y>=0&&i.y<=n:!1},getHighlightIndexByPoints=({points:e,calib:t,width:r,height:n})=>{const i=[];for(let o=0;o<e.length;o+=3){const l=e[o],f=e[o+1],a=e[o+2];isInImage({point:{x:l,y:f,z:a},calib:t,width:r,height:n})?i.push(1):i.push(0)}return i},mergeHighlightList=e=>{if(e.length===0)return[];const t=[];for(let r=0;r<e[0].length;r++){for(let n=0;n<e.length;n++)if(e[n][r]===1){t.push(1);break}t.length===r&&t.push(0)}return t};function pointCloudLidar2image(e,t,r={createRange:!1}){var n;if(!t)return{transferViewData:[],viewRangePointList:[]};const{createRange:i}=r,o=lbUtils.PointCloudUtils.getAllViewData(e),l=isFisheyeCalibValid(t),{P:f,R:a,T:x}=t;let p;if(l===!1){const{composeMatrix4:c}=(n=transferKitti2Matrix(f,a,x))!=null?n:{};if(!c)return;p=c}const s=o.map(c=>({type:c.type,pointList:c.pointList.map(u=>rotatePoint(u,e.center,e.rotation)).map(u=>l?lidar2FisheyeImage(u,t):p&&lidar2image(u,p)).map(u=>{if(!!u)return{id:uuid(),x:u==null?void 0:u.x,y:u==null?void 0:u.y}}).filter(u=>u!==void 0)})).filter(c=>c.pointList.length!==0);s[0]&&s[0].pointList&&(s[0].pointList=s[0].pointList.map(c=>__spreadProps(__spreadValues({},c),{specialEdge:!0})));let y=[];if(s.length===6&&i===!0){const c=s[0].pointList,u=s[1].pointList;y=buildConvexHull([...c,...u])}return{transferViewData:s,viewRangePointList:y}}function pointMappingLidar2image(e,t,r){var n;const i=isFisheyeCalibValid(t),{P:o,R:l,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,l,f))!=null?n:{};if(!s)return;a=s}const x=e.length/3,p={};for(let s=0;s<x;s++){const y={x:e[s*3],y:e[s*3+1],z:e[s*3+2]};let c;if(i?c=lidar2FisheyeImage(y,t):c=a&&lidar2image({x:e[s*3],y:e[s*3+1],z:e[s*3+2]},a),c){const u=Math.floor(c.x),h=Math.floor(c.y);if(u>r.width||h>r.height||u<0||h<0)continue;p[s]={x:u,y:h}}}return{pcdMapping:p}}function pointListLidar2Img(e,t,r){var n;if(!t||!r)return;const i=isFisheyeCalibValid(t),{P:o,R:l,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,l,f))!=null?n:{};if(!s)return;a=s}const x=[];if(e.forEach(s=>{let y;if(i?y=lidar2FisheyeImage(s,t):y=a&&lidar2image(s,a),y){const{x:c,y:u}=y;x.push({x:c,y:u})}}),x.some(s=>s.x>0&&s.x<r.width&&s.y>0&&s.y<r.height))return x}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=getHighlightIndexByPoints,exports.isFisheyeCalibValid=isFisheyeCalibValid,exports.isInImage=isInImage,exports.isMatrixValid=isMatrixValid,exports.isMatrixValidByArr=isMatrixValidByArr,exports.lidar2FisheyeImage=lidar2FisheyeImage,exports.lidar2image=lidar2image,exports.mergeHighlightList=mergeHighlightList,exports.oCamFisheyeTransfer=oCamFisheyeTransfer,exports.omniCamera11VTransfer=omniCamera11VTransfer,exports.point3DLidar2Image=point3DLidar2Image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.pointListLidar2Img=pointListLidar2Img,exports.pointMappingLidar2image=pointMappingLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const math=require("mathjs");function convertMatrix(t){if(t.length!==1||t[0].length!==3)throw new Error("Input matrix must be a 1x3 or 3x1 matrix");return[[t[0][0]],[t[0][1]],[t[0][2]],[1]]}function normOfRows(t){const o=[];for(let e=0;e<t.length;e++){const n=t[e],s=n[0]*n[0]+n[1]*n[1],r=Math.sqrt(s);o.push(r)}return o}function polyVal(t,o){const e=t.length,n=[];for(let s=0;s<o.length;s++){let r=0;for(let i=0;i<t.length;i++)r=t[e-i-1]+r*o[s];n.push(r)}return n}function fisheyeCameraToImage(t,o,e){const n=math.matrix([[o[0][0],o[0][1]],[o[1][0],o[1][1]]]),s=o[0][2],r=o[1][2],i=e,l=normOfRows(t.toArray().map(p=>p.slice(0,2))),u=math.dotDivide(math.ones(math.matrix(l).size()),l),f=math.atan2(math.multiply(-1,t.subset(math.index(math.range(0,math.matrix(t).size()[0]),2))),l),a=polyVal(i,f);let c=math.ones(2,t.size()[0]);const x=math.multiply(t.subset(math.index(math.range(0,t.size()[0]),0)),u*a),h=math.multiply(t.subset(math.index(math.range(0,t.size()[0]),1)),u*a),m=math.matrix([[x,0],[h,0]]);c=math.subset(m,math.index(math.range(0,m.size()[0]),0));const g=math.matrix([s,r]),y=math.multiply(n,c),d=g.reshape([2,1]);return math.transpose(math.add(y,d)).toArray()}function transformPointCloudToImage(t=[],o,e,n){const s=math.matrix(convertMatrix(t)),r=math.matrix(o),i=math.multiply(r,s);return fisheyeCameraToImage(math.transpose(i),e,n)}exports.transformPointCloudToImage=transformPointCloudToImage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var math=require("mathjs");function _interopNamespace(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if(n!=="default"){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var math__namespace=_interopNamespace(math);function convertMatrix(t){if(t.length!==1||t[0].length!==3)throw new Error("Input matrix must be a 1x3 or 3x1 matrix");return[[t[0][0]],[t[0][1]],[t[0][2]],[1]]}function normOfRows(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],r=o[0]*o[0]+o[1]*o[1],s=Math.sqrt(r);e.push(s)}return e}function polyVal(t,e){const n=t.length,o=[];for(let r=0;r<e.length;r++){let s=0;for(let u=0;u<t.length;u++)s=t[n-u-1]+s*e[r];o.push(s)}return o}function fisheyeCameraToImage(t,e,n){const o=math__namespace.matrix([[e[0][0],e[0][1]],[e[1][0],e[1][1]]]),r=e[0][2],s=e[1][2],u=n,i=normOfRows(t.toArray().map(d=>d.slice(0,2))),a=math__namespace.dotDivide(math__namespace.ones(math__namespace.matrix(i).size()),i),m=math__namespace.atan2(math__namespace.multiply(-1,t.subset(math__namespace.index(math__namespace.range(0,math__namespace.matrix(t).size()[0]),2))),i),c=polyVal(u,m);let l=math__namespace.ones(2,t.size()[0]);const g=math__namespace.multiply(t.subset(math__namespace.index(math__namespace.range(0,t.size()[0]),0)),a*c),h=math__namespace.multiply(t.subset(math__namespace.index(math__namespace.range(0,t.size()[0]),1)),a*c),f=math__namespace.matrix([[g,0],[h,0]]);l=math__namespace.subset(f,math__namespace.index(math__namespace.range(0,f.size()[0]),0));const x=math__namespace.matrix([r,s]),p=math__namespace.multiply(o,l),y=x.reshape([2,1]);return math__namespace.transpose(math__namespace.add(p,y)).toArray()}function transformPointCloudToImage(t=[],e,n,o){const r=math__namespace.matrix(convertMatrix(t)),s=math__namespace.matrix(e),u=math__namespace.multiply(s,r);return fisheyeCameraToImage(math__namespace.transpose(u),n,o)}exports.transformPointCloudToImage=transformPointCloudToImage;
@@ -1 +1 @@
1
- "use strict";var lbUtils=require("@labelbee/lb-utils"),_=require("lodash"),rgba=require("color-rgba"),DrawUtils=require("../../utils/tool/DrawUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MathUtils=require("../../utils/MathUtils.js"),RenderDomClass=require("../../utils/tool/RenderDomClass.js"),tool=require("../../constant/tool.js"),annotation=require("../../constant/annotation.js"),ImgUtils=require("../../utils/ImgUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),basicToolOperation=require("./basicToolOperation.js"),matrix=require("../pointCloud/matrix.js");function _interopDefaultLegacy(v){return v&&typeof v=="object"&&"default"in v?v:{default:v}}var ___default=_interopDefaultLegacy(_),rgba__default=_interopDefaultLegacy(rgba),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(v,t,e)=>t in v?__defProp(v,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):v[t]=e,__spreadValues=(v,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(v,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(v,e,t[e]);return v},__spreadProps=(v,t)=>__defProps(v,__getOwnPropDescs(t)),__async=(v,t,e)=>new Promise((i,o)=>{var r=a=>{try{s(e.next(a))}catch(n){o(n)}},c=a=>{try{s(e.throw(a))}catch(n){o(n)}},s=a=>a.done?i(a.value):Promise.resolve(a.value).then(r,c);s((e=e.apply(v,t)).next())});const newScope=3,DEFAULT_RADIUS=3,DEFAULT_STROKE_COLOR="#6371FF";class ViewOperation extends basicToolOperation.BasicToolOperation{constructor(t){super(__spreadProps(__spreadValues({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.connectionPoints=[],this.getHoverRectID=i=>{var o,r;const c=this.getCoordinateUnderZoom(i),s=AxisUtils.default.changePointByZoom(c,1/this.zoom);if(((o=this.annotations)==null?void 0:o.length)<=0||!((r=this.annotations)==null?void 0:r.length))return;let a="",n=Number.MAX_SAFE_INTEGER;for(let h=0;h<this.annotations.length;h++){const l=this.annotations[h];switch(l.type){case"rect":{const d=l.annotation;if(RectUtils.isInRect(c,d,newScope,this.zoom)){const f=d.width*d.height;f<n&&(a=d.id,n=f)}break}case"polygon":{const d=l.annotation;if(PolygonUtils.isInPolygon(s,d.pointList)){const f=PolygonUtils.getPolygonArea(d.pointList);f<n&&(a=d.id,n=f)}break}}}return a};var e;this.style=(e=t.style)!=null?e:{stroke:DEFAULT_STROKE_COLOR,thickness:3},this.annotations=t.annotations,this.loading=!1,this.renderDomInstance=new RenderDomClass({container:this.container,height:this.canvas.height})}clearConnectionPoints(){this.connectionPoints=[],this.render()}checkConnectionPoints(t=this.annotations){var e,i;this.connectPointsStatus&&((i=(e=this.connectPointsStatus).close)==null||i.call(e)),this.emit("connectionPointsStatusUpdate",()=>new Promise(o=>{const{promise:r,close:c}=MathUtils.default.getCollectionPointByAnnotationDataPromise(t);this.connectPointsStatus={close:c},r.then(s=>{this.connectionPoints=s.connectionPoints,this.render(),this.connectPointsStatus=void 0,o({connectionPoints:s.connectionPoints})})}))}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let i=[];e&&(i=[e]),this.emit("onChange","selected",i),this.render()}}setImgNode(t,e={}){super.setImgNode(t,e),this.staticMode&&this.generateStaticImgNode()}generateStaticImgNode(){var t,e;const i=ImgUtils.cropAndEnlarge(this.canvas,(t=this.basicImgInfo)==null?void 0:t.width,(e=this.basicImgInfo)==null?void 0:e.height,1);ImgUtils.default.load(i).then(o=>{this.staticImgNode=o,this.drawStaticImg()})}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,i=this.getHoverRectID(t);if(e!==i){this.mouseHoverID=i;let o=[];i&&(o=[i]),this.emit("onChange","hover",o),this.render()}}updateData(t){return __async(this,null,function*(){if(!___default.default.isEqual(this.annotations,t)&&(this.annotations=t,this.staticMode&&(this.staticImgNode=void 0),this.render(),this.staticMode)){const e=this.zoom,i=this.currentPos;this.initImgPos(),this.generateStaticImgNode();const o=this.staticImgNode;this.staticImgNode=void 0,this.updatePosition({zoom:e,currentPos:i}),this.staticImgNode=o}})}getSpecificStyle(t){const e=___default.default.pick(t,["stroke","thickness","fill","radius"]),i=__spreadValues(__spreadValues({},this.style),e);return i.stroke&&Object.assign(i,{color:i.stroke}),i}getFontStyle(t,e){var i,o;const r=(i=t==null?void 0:t.fontSize)!=null?i:14,c=(o=t==null?void 0:t.fontFamily)!=null?o:"Arial";return __spreadProps(__spreadValues({},annotation.DEFAULT_TEXT_SHADOW),{color:e.stroke,font:`normal normal 600 ${r}px ${c}`})}appendOffset({x:t,y:e}){return{x:t+annotation.DEFAULT_TEXT_OFFSET.offsetX,y:e+annotation.DEFAULT_TEXT_OFFSET.offsetY}}getRenderText(t,e=!1){let i="",o="";return!t||e===!0?{headerText:i,bottomText:o}:((t==null?void 0:t.order)&&(i=`${t.order}`),(t==null?void 0:t.label)&&(i?i=`${i}_${t.label}`:i=`${t.label}`),(t==null?void 0:t.attribute)&&(i?i=`${i} ${t.attribute}`:i=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(o=t==null?void 0:t.textAttribute),{headerText:i,bottomText:o})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}focusPositionByPointList(t){const e=MathUtils.default.calcViewportBoundaries(t),i={x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top},o=lbUtils.ImgPosUtils.getBasicRecPos(this.imgNode,i,this.size,.5);if(o){this.setCurrentPos(o.currentPos),this.setCurrentPosStorage(o.currentPos);const{imgInfo:r}=this,{innerZoom:c}=this.innerPosAndZoom;r&&this.setImgInfo(__spreadProps(__spreadValues({},r),{width:r.width/c*o.innerZoom,height:r.height/c*o.innerZoom})),this.setZoom(o.innerZoom),this.render(),this.renderBasicCanvas()}}renderConnectionPoints(){this.connectionPoints.forEach(t=>{const e=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,e,4,{color:"#fff"}),DrawUtils.drawCircleWithFill(this.canvas,e,2,{color:"#000"})})}getRenderStyle(t){const e=this.getSpecificStyle(t.annotation),i=this.getFontStyle(t.annotation,e);return{style:e,fontStyle:i}}renderLine(t){var e,i,o;if(t.type!=="line")return;const{style:r,fontStyle:c}=this.getRenderStyle(t),s=t.annotation;if(!(((e=s==null?void 0:s.pointList)==null?void 0:e.length)>=2))return;const{lineType:a=tool.ELineTypes.Line}=s,n=AxisUtils.default.changePointListByZoom((i=s==null?void 0:s.pointList)!=null?i:[],this.zoom,this.currentPos),h=__spreadProps(__spreadValues(__spreadValues({},r),this.getReferenceOptions(s==null?void 0:s.isReference)),{lineType:a,strokeColor:r.stroke});let l=[];if(s.showKeyPoint?l=DrawUtils.drawPolygonWithKeyPoint(this.canvas,n,h):l=DrawUtils.drawPolygon(this.canvas,n,h),(s==null?void 0:s.showDirection)===!0&&((o=s==null?void 0:s.pointList)==null?void 0:o.length)>=2){let g=n[0],y=MathUtils.default.getLineCenterPoint([n[0],n[1]]);if(a===tool.ELineTypes.Curve){const u=Math.floor(tool.SEGMENT_NUMBER/2);g=l[u],y=l[u+1]}DrawUtils.drawArrowByCanvas(this.canvas,g,y,{color:r.stroke,thickness:r.thickness}),DrawUtils.drawCircle(this.canvas,n[0],r.thickness+6,{color:r.stroke,thickness:r.thickness})}const{headerText:f,bottomText:p}=this.getRenderText(s,s==null?void 0:s.hiddenText);if(f&&DrawUtils.drawText(this.canvas,this.appendOffset(n[0]),f,c),p){const g=n[n.length-1];DrawUtils.drawText(this.canvas,this.appendOffset({x:g.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:g.y+annotation.TEXT_ATTRIBUTE_OFFSET.y}),p,c)}}renderPolygon(t){var e,i,o,r,c;if(t.type!=="polygon")return;const{style:s,fontStyle:a}=this.getRenderStyle(t),n=t.annotation;if(!(((e=n==null?void 0:n.pointList)==null?void 0:e.length)>=3))return;const{lineType:h=tool.ELineTypes.Line}=n,l=AxisUtils.default.changePointListByZoom((i=n==null?void 0:n.pointList)!=null?i:[],this.zoom,this.currentPos);if(n.id===this.mouseHoverID||s.fill){const u=rgba__default.default((r=(o=s==null?void 0:s.fill)!=null?o:s==null?void 0:s.stroke)!=null?r:DEFAULT_STROKE_COLOR),m=`rgba(${u[0]}, ${u[1]}, ${u[2]},${u[3]*.8})`;DrawUtils.drawPolygonWithFill(this.canvas,l,{color:m,lineType:h})}const d=__spreadProps(__spreadValues(__spreadProps(__spreadValues({},s),{isClose:!0}),this.getReferenceOptions(n==null?void 0:n.isReference)),{lineType:h,strokeColor:s.stroke});let f=[];if(n.showKeyPoint?f=DrawUtils.drawPolygonWithKeyPoint(this.canvas,l,d):f=DrawUtils.drawPolygon(this.canvas,l,d),(n==null?void 0:n.showDirection)===!0&&((c=n==null?void 0:n.pointList)==null?void 0:c.length)>=2){let u=l[0],m=MathUtils.default.getLineCenterPoint([l[0],l[1]]);if(h===tool.ELineTypes.Curve){const P=Math.floor(tool.SEGMENT_NUMBER/2);u=f[P],m=f[P+1]}DrawUtils.drawArrowByCanvas(this.canvas,u,m,{color:s.stroke,thickness:s.thickness}),DrawUtils.drawCircle(this.canvas,l[0],s.thickness+6,{color:s.stroke,thickness:s.thickness})}const{headerText:g,bottomText:y}=this.getRenderText(n,n==null?void 0:n.hiddenText);if(g&&DrawUtils.drawText(this.canvas,this.appendOffset(l[0]),g,a),y){const u=l[l.length-1];DrawUtils.drawText(this.canvas,this.appendOffset({x:u.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:u.y+annotation.TEXT_ATTRIBUTE_OFFSET.y}),y,a)}}renderSingleCuboid(t){var e,i;const{style:o}=this.getRenderStyle(t),r=t.annotation,c=rgba__default.default((i=(e=o==null?void 0:o.fill)!=null?e:o==null?void 0:o.stroke)!=null?i:DEFAULT_STROKE_COLOR),s=`rgba(${c[0]}, ${c[1]}, ${c[2]},${c[3]*.8})`,a=o.stroke,n=AxisUtils.default.changeCuboidByZoom(r,this.zoom,this.currentPos),{headerText:h,bottomText:l}=this.getRenderText(r,r==null?void 0:r.hiddenText);DrawUtils.drawCuboidWithText(this.canvas,n,{strokeColor:a,fillColor:s,thickness:o.thickness},{config:this.config,hiddenText:r==null?void 0:r.hiddenText,headerText:h,bottomText:l})}renderBox3d(t){var e;if(t.type!=="box3d")return;const i=t.annotation,{transferViewData:o}=(e=matrix.pointCloudLidar2image(i,i.calib))!=null?e:{};if(!o)return;const r={fill:"transparent"},c=___default.default.pick(i,["stroke","thickness"]);o.forEach((s,a)=>{const n=__spreadValues(__spreadProps(__spreadValues({},c),{id:`${t.annotation.id}-${a}`,pointList:s.pointList}),r);switch(s.type){case"line":this.renderLine({type:"line",annotation:n});break;case"polygon":this.renderPolygon({type:"polygon",annotation:n});break}})}renderPixelPoints(t){var e;if(t.type!=="pixelPoints")return;const i=t.annotation;if(!this.imgNode){console.error("Need to load after imgLoaded");return}if(!(i.length>0)){console.warn("Empty pixelPoints");return}const o=this.imgNode.src+i.length+t.defaultRGBA,r=(e=this.cacheCanvas)==null?void 0:e[o];if(r){DrawUtils.drawImg(this.canvas,r,{zoom:this.zoom,currentPos:this.currentPos});return}const c={width:this.imgNode.width,height:this.imgNode.height},{ctx:s,canvas:a}=CanvasUtils.createCanvas(c),n=typeof t.pixelSize=="number"?t.pixelSize:13;s&&(i==null?void 0:i.length)>0&&(DrawUtils.drawPixel({canvas:a,points:i,size:c,defaultRGBA:t.defaultRGBA,pixelSize:n}),DrawUtils.drawImg(this.canvas,a,{zoom:this.zoom,currentPos:this.currentPos}),this.cacheCanvas={[o]:a})}render(){try{if(this.staticImgNode||(super.render(),this.loading===!0))return;const t=this.annotations.filter(e=>e.type==="text"&&e.annotation.position==="rt").map(e=>e.annotation);this.renderDomInstance.render(t),this.annotations.forEach(e=>{var i,o,r,c,s;const a=this.getSpecificStyle(e.annotation),n=this.getFontStyle(e.annotation,a);switch(e.type){case"rect":{const h=e.annotation,{hiddenText:l=!1,isReference:d,hiddenRectSize:f=!1}=h,{zoom:p}=this,g=AxisUtils.default.changeRectByZoom(h,this.zoom,this.currentPos),{x:y,y:u,width:m,height:P}=g,x=rgba__default.default((o=(i=a==null?void 0:a.fill)!=null?i:a==null?void 0:a.stroke)!=null?o:DEFAULT_STROKE_COLOR),w=`rgba(${x[0]}, ${x[1]}, ${x[2]},${x[3]*.8})`;(h.id===this.mouseHoverID||a.fill)&&DrawUtils.drawRectWithFill(this.canvas,g,{color:w}),DrawUtils.drawRect(this.canvas,g,__spreadValues(__spreadProps(__spreadValues({},a),{hiddenText:!0}),this.getReferenceOptions(d))),(h==null?void 0:h.isHighlight)&&DrawUtils.drawHighlightFlag({canvas:this.canvas,color:w,position:{x:y-16,y:u-16}});const{headerText:T,bottomText:I}=this.getRenderText(h,h==null?void 0:h.hiddenText);T&&DrawUtils.drawText(this.canvas,{x:y,y:u-6},T,__spreadValues({textMaxWidth:300},n));const b=`${Math.round(m/p)} * ${Math.round(P/p)}`,S=b.length*7;if(!l&&!f&&DrawUtils.drawText(this.canvas,{x:y+m-S,y:u+P+15},b,n),I){const k=20,C=Math.max(20,m-S);DrawUtils.drawText(this.canvas,{x:y,y:u+P+k},h.textAttribute,__spreadValues({textMaxWidth:C},n))}break}case"polygon":{this.renderPolygon(e);break}case"line":{this.renderLine(e);break}case"point":{const h=e.annotation,l=AxisUtils.default.changePointByZoom(h,this.zoom,this.currentPos),d=(r=a.radius)!=null?r:DEFAULT_RADIUS;DrawUtils.drawCircle(this.canvas,l,d,a);const{headerText:f,bottomText:p}=this.getRenderText(h,h==null?void 0:h.hiddenText);f&&DrawUtils.drawText(this.canvas,{x:l.x+d/2,y:l.y-d-4},f,__spreadValues({textAlign:"center"},n)),p&&DrawUtils.drawText(this.canvas,this.appendOffset({x:l.x+d,y:l.y+d+24}),p,n);break}case"text":{const h=e.annotation,{text:l,x:d,y:f,textMaxWidth:p,color:g="white",background:y="rgba(0, 0, 0, 0.6)",lineHeight:u=25,font:m=tool.DEFAULT_FONT,position:P}=h,x=10,w=10,T=AxisUtils.default.changePointByZoom({x:d,y:f},this.zoom,this.currentPos),{width:I,height:b,fontHeight:S=0}=MathUtils.default.getTextArea(this.canvas,h.text,p,m,u);if(P==="rt")break;DrawUtils.drawRectWithFill(this.canvas,{x:T.x,y:T.y,width:I+w*2,height:b+x*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:y}),DrawUtils.drawText(this.canvas,{x:T.x+w,y:T.y+S+x},l,{color:g,lineHeight:u,font:m,textMaxWidth:p});break}case"box3d":{this.renderBox3d(e);break}case"cuboid":{this.renderSingleCuboid(e);break}case"pixelPoints":{this.renderPixelPoints(e);break}default:break}"renderEnhance"in e.annotation&&((s=(c=e.annotation).renderEnhance)==null||s.call(c,{ctx:this.ctx,canvas:this.canvas,currentPos:this.currentPos,zoom:this.zoom,data:e,toolInstance:this}))}),this.renderConnectionPoints()}catch(t){console.error("ViewOperation Render Error",t)}}}module.exports=ViewOperation;
1
+ "use strict";var lbUtils=require("@labelbee/lb-utils"),_=require("lodash"),rgba=require("color-rgba"),DrawUtils=require("../../utils/tool/DrawUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MathUtils=require("../../utils/MathUtils.js"),RenderDomClass=require("../../utils/tool/RenderDomClass.js"),tool=require("../../constant/tool.js"),annotation=require("../../constant/annotation.js"),ImgUtils=require("../../utils/ImgUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),basicToolOperation=require("./basicToolOperation.js"),matrix=require("../pointCloud/matrix.js");function _interopDefaultLegacy(v){return v&&typeof v=="object"&&"default"in v?v:{default:v}}var ___default=_interopDefaultLegacy(_),rgba__default=_interopDefaultLegacy(rgba),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(v,t,e)=>t in v?__defProp(v,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):v[t]=e,__spreadValues=(v,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(v,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(v,e,t[e]);return v},__spreadProps=(v,t)=>__defProps(v,__getOwnPropDescs(t)),__async=(v,t,e)=>new Promise((i,o)=>{var r=a=>{try{n(e.next(a))}catch(s){o(s)}},l=a=>{try{n(e.throw(a))}catch(s){o(s)}},n=a=>a.done?i(a.value):Promise.resolve(a.value).then(r,l);n((e=e.apply(v,t)).next())});const newScope=3,DEFAULT_RADIUS=3,DEFAULT_STROKE_COLOR="#6371FF";class ViewOperation extends basicToolOperation.BasicToolOperation{constructor(t){super(__spreadProps(__spreadValues({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.connectionPoints=[],this.needUpdatePosition=!0,this.posTimer=null,this.convexHullGroup={},this.pointCloudBoxList=[],this.hiddenText=!1,this.renderToolName=void 0,this.getHoverRectID=i=>{var o,r;const l=this.getCoordinateUnderZoom(i),n=AxisUtils.default.changePointByZoom(l,1/this.zoom);if(((o=this.annotations)==null?void 0:o.length)<=0||!((r=this.annotations)==null?void 0:r.length))return;let a="",s=Number.MAX_SAFE_INTEGER;for(let d=0;d<this.annotations.length;d++){const c=this.annotations[d];switch(c.type){case"rect":{const h=c.annotation;if(RectUtils.isInRect(l,h,newScope,this.zoom)){const u=h.width*h.height;u<s&&(a=h.id,s=u)}break}case"polygon":{const h=c.annotation;if(PolygonUtils.isInPolygon(n,h.pointList)){const u=PolygonUtils.getPolygonArea(h.pointList);u<s&&(a=h.id,s=u)}break}}}return a};var e;this.style=(e=t.style)!=null?e:{stroke:DEFAULT_STROKE_COLOR,thickness:3},this.annotations=t.annotations,this.convexHullGroup=PolygonUtils.createConvexHullGroup(t.annotations),this.loading=!1,this.renderDomInstance=new RenderDomClass({container:this.container,height:this.canvas.height}),this.renderToolName=t.renderToolName}clearConnectionPoints(){this.connectionPoints=[],this.render()}checkConnectionPoints(t=this.annotations){var e,i;this.connectPointsStatus&&((i=(e=this.connectPointsStatus).close)==null||i.call(e)),this.emit("connectionPointsStatusUpdate",()=>new Promise(o=>{const{promise:r,close:l}=MathUtils.default.getCollectionPointByAnnotationDataPromise(t);this.connectPointsStatus={close:l},r.then(n=>{this.connectionPoints=n.connectionPoints,this.render(),this.connectPointsStatus=void 0,o({connectionPoints:n.connectionPoints})})}))}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let i=[];e&&(i=[e]),this.emit("onChange","selected",i),this.render()}}setImgNode(t,e={}){super.setImgNode(t,e),this.staticMode&&this.generateStaticImgNode()}generateStaticImgNode(){var t,e;const i=ImgUtils.cropAndEnlarge(this.canvas,(t=this.basicImgInfo)==null?void 0:t.width,(e=this.basicImgInfo)==null?void 0:e.height,1);ImgUtils.default.load(i).then(o=>{this.staticImgNode=o,this.drawStaticImg()})}onRightClick(t){const e=this.getClickTargetId(t);this.needUpdatePosition=!1,this.posTimer&&clearTimeout(this.posTimer),this.emit("onRightClick",{event:t,targetId:e}),this.posTimer=setTimeout(()=>{this.needUpdatePosition=!0},1e3)}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,i=this.getHoverRectID(t);if(e!==i){this.mouseHoverID=i;let o=[];i&&(o=[i]),this.emit("onChange","hover",o),this.render()}}updateData(t){return __async(this,null,function*(){if(!___default.default.isEqual(this.annotations,t)&&(this.annotations=t,this.convexHullGroup=PolygonUtils.createConvexHullGroup(t),this.staticMode&&(this.staticImgNode=void 0),this.render(),this.staticMode)){const e=this.zoom,i=this.currentPos;this.initImgPos(),this.generateStaticImgNode();const o=this.staticImgNode;this.staticImgNode=void 0,this.updatePosition({zoom:e,currentPos:i}),this.staticImgNode=o}})}setPointCloudBoxList(t){this.pointCloudBoxList=t}setHiddenText(t){this.hiddenText=t,this.render()}setConfig(t){this.config=t}getSpecificStyle(t){const e=___default.default.pick(t,["stroke","thickness","fill","radius"]),i=__spreadValues(__spreadValues({},this.style),e);return i.stroke&&Object.assign(i,{color:i.stroke}),i}getFontStyle(t,e){var i,o;const r=(i=t==null?void 0:t.fontSize)!=null?i:14,l=(o=t==null?void 0:t.fontFamily)!=null?o:"Arial";return __spreadProps(__spreadValues({},annotation.DEFAULT_TEXT_SHADOW),{color:e.stroke,font:`normal normal 600 ${r}px ${l}`})}appendOffset({x:t,y:e}){return{x:t+annotation.DEFAULT_TEXT_OFFSET.offsetX,y:e+annotation.DEFAULT_TEXT_OFFSET.offsetY}}getRenderText(t,e=!1){let i="",o="";return!t||e===!0?{headerText:i,bottomText:o}:((t==null?void 0:t.order)&&(i=`${t.order}`),(t==null?void 0:t.label)&&(i?i=`${i}_${t.label}`:i=`${t.label}`),(t==null?void 0:t.attribute)&&(i?i=`${i} ${t.attribute}`:i=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(o=t==null?void 0:t.textAttribute),(t==null?void 0:t.subAttributeText)&&(i+=t==null?void 0:t.subAttributeText),{headerText:i,bottomText:o})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}focusPositionByPointList(t){if(!this.needUpdatePosition)return;const e=MathUtils.default.calcViewportBoundaries(t),i={x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top},o=lbUtils.ImgPosUtils.getBasicRecPos(this.imgNode,i,this.size,.5);if(o){this.setCurrentPos(o.currentPos),this.setCurrentPosStorage(o.currentPos);const{imgInfo:r}=this,{innerZoom:l}=this.innerPosAndZoom;r&&this.setImgInfo(__spreadProps(__spreadValues({},r),{width:r.width/l*o.innerZoom,height:r.height/l*o.innerZoom})),this.setZoom(o.innerZoom),this.render(),this.renderBasicCanvas()}}renderConnectionPoints(){this.connectionPoints.forEach(t=>{const e=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,e,4,{color:"#fff"}),DrawUtils.drawCircleWithFill(this.canvas,e,2,{color:"#000"})})}renderPointCloud3DRectAttribute(){___default.default.chunk(this.annotations,6).forEach(e=>{var i,o;const r=e.find(c=>c.type==="polygon");if(!r)return;const{fontStyle:l}=this.getRenderStyle(r),n=r.annotation,a=(i=this.pointCloudBoxList)==null?void 0:i.find(c=>c.id===n.id);if(!a)return;const s=this.hiddenText?"":`${a==null?void 0:a.trackID} ${a==null?void 0:a.attribute}`,d=AxisUtils.default.changePointListByZoom((o=n==null?void 0:n.pointList)!=null?o:[],this.zoom,this.currentPos);s&&DrawUtils.drawText(this.canvas,this.appendOffset(d[0]),s,l)})}getRenderStyle(t){const e=this.getSpecificStyle(t.annotation),i=this.getFontStyle(t.annotation,e);return{style:e,fontStyle:i}}renderLine(t){var e,i,o;if(t.type!=="line")return;const{style:r,fontStyle:l}=this.getRenderStyle(t),n=t.annotation;if(!(((e=n==null?void 0:n.pointList)==null?void 0:e.length)>=2))return;const{lineType:a=tool.ELineTypes.Line}=n,s=AxisUtils.default.changePointListByZoom((i=n==null?void 0:n.pointList)!=null?i:[],this.zoom,this.currentPos),d=__spreadProps(__spreadValues(__spreadValues({},r),this.getReferenceOptions(n==null?void 0:n.isReference)),{lineType:a,strokeColor:r.stroke});let c=[];if(n.showKeyPoint?c=DrawUtils.drawPolygonWithKeyPoint(this.canvas,s,d):c=DrawUtils.drawPolygon(this.canvas,s,d),(n==null?void 0:n.showDirection)===!0&&((o=n==null?void 0:n.pointList)==null?void 0:o.length)>=2){let g=s[0],p=MathUtils.default.getLineCenterPoint([s[0],s[1]]);if(a===tool.ELineTypes.Curve){const f=Math.floor(tool.SEGMENT_NUMBER/2);g=c[f],p=c[f+1]}DrawUtils.drawArrowByCanvas(this.canvas,g,p,{color:r.stroke,thickness:r.thickness}),DrawUtils.drawCircle(this.canvas,s[0],r.thickness+6,{color:r.stroke,thickness:r.thickness})}const{headerText:u,bottomText:y}=this.getRenderText(n,n==null?void 0:n.hiddenText);if(u&&DrawUtils.drawText(this.canvas,this.appendOffset(s[0]),u,l),y){const g=s[s.length-1];DrawUtils.drawText(this.canvas,this.appendOffset({x:g.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:g.y+annotation.TEXT_ATTRIBUTE_OFFSET.y}),y,l)}}renderPolygon(t){var e,i,o,r,l;if(t.type!=="polygon")return;const{style:n,fontStyle:a}=this.getRenderStyle(t),s=t.annotation;if(!(((e=s==null?void 0:s.pointList)==null?void 0:e.length)>=3))return;const{lineType:d=tool.ELineTypes.Line}=s,c=AxisUtils.default.changePointListByZoom((i=s==null?void 0:s.pointList)!=null?i:[],this.zoom,this.currentPos);if(s.id===this.mouseHoverID||n.fill){const f=rgba__default.default((r=(o=n==null?void 0:n.fill)!=null?o:n==null?void 0:n.stroke)!=null?r:DEFAULT_STROKE_COLOR),m=`rgba(${f[0]}, ${f[1]}, ${f[2]},${f[3]*.8})`;DrawUtils.drawPolygonWithFill(this.canvas,c,{color:m,lineType:d})}const h=__spreadProps(__spreadValues(__spreadProps(__spreadValues({},n),{isClose:!0}),this.getReferenceOptions(s==null?void 0:s.isReference)),{lineType:d,strokeColor:n.stroke});let u=[];if(s.showKeyPoint?u=DrawUtils.drawPolygonWithKeyPoint(this.canvas,c,h):u=DrawUtils.drawPolygon(this.canvas,c,h),(s==null?void 0:s.showDirection)===!0&&((l=s==null?void 0:s.pointList)==null?void 0:l.length)>=2){let f=c[0],m=MathUtils.default.getLineCenterPoint([c[0],c[1]]);if(d===tool.ELineTypes.Curve){const x=Math.floor(tool.SEGMENT_NUMBER/2);f=u[x],m=u[x+1]}DrawUtils.drawArrowByCanvas(this.canvas,f,m,{color:n.stroke,thickness:n.thickness}),DrawUtils.drawCircle(this.canvas,c[0],n.thickness+6,{color:n.stroke,thickness:n.thickness})}const{headerText:g,bottomText:p}=this.getRenderText(s,s==null?void 0:s.hiddenText);if(g&&DrawUtils.drawText(this.canvas,this.appendOffset(c[0]),g,a),p){const f=c[c.length-2];DrawUtils.drawText(this.canvas,this.appendOffset({x:f.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:f.y+annotation.TEXT_ATTRIBUTE_OFFSET.y}),p,a)}}renderSingleCuboid(t){var e,i;const{style:o}=this.getRenderStyle(t),r=t.annotation,l=rgba__default.default((i=(e=o==null?void 0:o.fill)!=null?e:o==null?void 0:o.stroke)!=null?i:DEFAULT_STROKE_COLOR),n=`rgba(${l[0]}, ${l[1]}, ${l[2]},${l[3]*.8})`,a=o.stroke,s=AxisUtils.default.changeCuboidByZoom(r,this.zoom,this.currentPos),{headerText:d,bottomText:c}=this.getRenderText(r,r==null?void 0:r.hiddenText);DrawUtils.drawCuboidWithText(this.canvas,s,{strokeColor:a,fillColor:n,thickness:o.thickness},{config:this.config,hiddenText:r==null?void 0:r.hiddenText,headerText:d,bottomText:c})}renderBox3d(t){var e;if(t.type!=="box3d")return;const i=t.annotation,{transferViewData:o}=(e=matrix.pointCloudLidar2image(i,i.calib))!=null?e:{};if(!o)return;const r={fill:"transparent"},l=___default.default.pick(i,["stroke","thickness"]);o.forEach((n,a)=>{const s=__spreadValues(__spreadProps(__spreadValues({},l),{id:`${t.annotation.id}-${a}`,pointList:n.pointList}),r);switch(n.type){case"line":this.renderLine({type:"line",annotation:s});break;case"polygon":this.renderPolygon({type:"polygon",annotation:s});break}})}renderPixelPoints(t){var e;if(t.type!=="pixelPoints")return;const i=t.annotation;if(!this.imgNode){console.error("Need to load after imgLoaded");return}if(!(i.length>0)){console.warn("Empty pixelPoints");return}const o=this.imgNode.src+i.length+t.defaultRGBA,r=(e=this.cacheCanvas)==null?void 0:e[o];if(r){DrawUtils.drawImg(this.canvas,r,{zoom:this.zoom,currentPos:this.currentPos});return}const l={width:this.imgNode.width,height:this.imgNode.height},{ctx:n,canvas:a}=CanvasUtils.createCanvas(l),s=typeof t.pixelSize=="number"?t.pixelSize:13;n&&(i==null?void 0:i.length)>0&&(DrawUtils.drawPixel({canvas:a,points:i,size:l,defaultRGBA:t.defaultRGBA,pixelSize:s}),DrawUtils.drawImg(this.canvas,a,{zoom:this.zoom,currentPos:this.currentPos}),this.cacheCanvas={[o]:a})}render(){try{if(this.staticImgNode||(super.render(),this.loading===!0))return;const t=this.annotations.filter(e=>e.type==="text"&&e.annotation.position==="rt").map(e=>e.annotation);this.renderDomInstance.render(t),this.annotations.forEach(e=>{var i,o,r,l,n,a,s;const d=this.getSpecificStyle(e.annotation),c=this.getFontStyle(e.annotation,d);switch(e.type){case"rect":{const h=e.annotation,{hiddenText:u=!1,isReference:y,hiddenRectSize:g=!1}=h,{zoom:p}=this,f=AxisUtils.default.changeRectByZoom(h,this.zoom,this.currentPos),{x:m,y:x,width:w,height:b}=f,P=rgba__default.default((o=(i=d==null?void 0:d.fill)!=null?i:d==null?void 0:d.stroke)!=null?o:DEFAULT_STROKE_COLOR),C=`rgba(${P[0]}, ${P[1]}, ${P[2]},${P[3]*.8})`;(h.id===this.mouseHoverID||d.fill)&&DrawUtils.drawRectWithFill(this.canvas,f,{color:C}),DrawUtils.drawRect(this.canvas,f,__spreadValues(__spreadProps(__spreadValues({},d),{hiddenText:!0}),this.getReferenceOptions(y))),(h==null?void 0:h.isHighlight)&&DrawUtils.drawHighlightFlag({canvas:this.canvas,color:C,position:{x:m-16,y:x-16}});const{headerText:S,bottomText:T}=this.getRenderText(h,h==null?void 0:h.hiddenText);S&&DrawUtils.drawText(this.canvas,{x:m,y:x-6},S,__spreadValues({textMaxWidth:300},c));const k=`${Math.round(w/p)} * ${Math.round(b/p)}`,I=k.length*7;if(!u&&!g&&DrawUtils.drawText(this.canvas,{x:m+w-I,y:x+b+15},k,c),T){const R=20,D=Math.max(20,w-I);DrawUtils.drawText(this.canvas,{x:m,y:x+b+R},h.textAttribute,__spreadValues({textMaxWidth:D},c))}break}case"polygon":{this.renderPolygon(e);break}case"line":{this.renderLine(e);break}case"point":{const h=e.annotation,u=AxisUtils.default.changePointByZoom(h,this.zoom,this.currentPos),y=(r=d.radius)!=null?r:DEFAULT_RADIUS;DrawUtils.drawCircle(this.canvas,u,y,d);const{headerText:g,bottomText:p}=this.getRenderText(h,h==null?void 0:h.hiddenText);g&&DrawUtils.drawText(this.canvas,{x:u.x+y/2,y:u.y-y-4},g,__spreadValues({textAlign:"center"},c)),p&&DrawUtils.drawText(this.canvas,this.appendOffset({x:u.x+y,y:u.y+y+24}),p,c);break}case"text":{const h=e.annotation,{text:u,x:y,y:g,textMaxWidth:p,color:f="white",background:m="rgba(0, 0, 0, 0.6)",lineHeight:x=25,font:w=tool.DEFAULT_FONT,position:b,offset:P}=h,C=10,S=10,T=AxisUtils.default.changePointByZoom({x:y,y:g},this.zoom,this.currentPos);P&&(T.x+=(l=P.x)!=null?l:0,T.y+=(n=P.y)!=null?n:0);const{width:k,height:I,fontHeight:R=0}=MathUtils.default.getTextArea(this.canvas,h.text,p,w,x);if(b==="rt")break;DrawUtils.drawRectWithFill(this.canvas,{x:T.x,y:T.y,width:k+S*2,height:I+C*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:m}),DrawUtils.drawText(this.canvas,{x:T.x+S,y:T.y+R+C},u,{color:f,lineHeight:x,font:w,textMaxWidth:p});break}case"box3d":{this.renderBox3d(e);break}case"cuboid":{this.renderSingleCuboid(e);break}case"pixelPoints":{this.renderPixelPoints(e);break}default:break}"renderEnhance"in e.annotation&&((s=(a=e.annotation).renderEnhance)==null||s.call(a,{ctx:this.ctx,canvas:this.canvas,currentPos:this.currentPos,zoom:this.zoom,data:e,toolInstance:this}))}),this.renderConnectionPoints(),this.renderToolName&&this.renderToolName===tool.EPointCloudName.PointCloud&&this.renderPointCloud3DRectAttribute()}catch(t){console.error("ViewOperation Render Error",t)}}getClickTargetId(t){const e=this.getCoordinateUnderZoom(t),i=AxisUtils.default.changePointByZoom(e,1/this.zoom);for(const o in this.convexHullGroup){if(!Object.prototype.hasOwnProperty.call(this.convexHullGroup,o))continue;const r=this.convexHullGroup[o].convexHull;if(PolygonUtils.isInPolygon(i,r))return o}}}module.exports=ViewOperation;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),_=require("lodash"),tool=require("../../constant/tool.js"),MathUtils=require("../../utils/MathUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),LineToolUtils=require("../../utils/tool/LineToolUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),style=require("../../constant/style.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),ActionsHistory=require("../../utils/ActionsHistory.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),DblClickEventListener=require("../../utils/tool/DblClickEventListener.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),RenderDomUtils=require("../../utils/tool/RenderDomUtils.js"),ZoomUtils=require("../../utils/tool/ZoomUtils.js"),eventListener=require("./eventListener.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,t,i)=>t in u?__defProp(u,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[t]=i,__spreadValues=(u,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(u,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(u,i,t[i]);return u},__spreadProps=(u,t)=>__defProps(u,__getOwnPropDescs(t)),__async=(u,t,i)=>new Promise((e,o)=>{var r=n=>{try{a(i.next(n))}catch(l){o(l)}},c=n=>{try{a(i.throw(n))}catch(l){o(l)}},a=n=>n.done?e(n.value):Promise.resolve(n.value).then(r,c);a((i=i.apply(u,t)).next())});const LANGUAGE_MAP={[annotation.ELang.Zh]:"cn",[annotation.ELang.US]:"en"},DEFAULT_ZOOM_INFO={min:.2,max:1e3,ratio:.4};class BasicToolOperation extends eventListener{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.staticMode=!1,this.operationMode=tool.EOperationMode.General,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.zoomInfo=DEFAULT_ZOOM_INFO,this.initImgPos=()=>__async(this,null,function*(){var d,h;if(!this.imgNode)return;const s=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(h=this._imgAttribute)==null?void 0:h.isOriginalSize,{currentPos:m,imgInfo:f,zoom:v}=lbUtils.ImgPosUtils.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,s,g);this.setCurrentPos(m),this.currentPosStorage=m,this.setImgInfo(f),this.setZoom(v),this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",v,m,f)}),this.getCurrentPos=d=>{const{_firstClickCoordinate:h,currentPosStorage:s}=this;try{let g;return h&&s?g={y:s.y+d.y-h.y,x:s.x+d.x-h.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.wheelChangePos=(d,h,s)=>{const{currentPos:g,imgNode:m}=this;if(!m){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&h===-1)return;const f=ZoomUtils.wheelChangePos(m,d,h,g,{zoom:s||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:this.zoomInfo.max,rotate:this.rotate});if(!f)return;const{currentPos:v,ratio:w,zoom:y,imgInfo:P}=f;this.setZoom(y),this.setCurrentPos(v),this.currentPosStorage=v,this.setImgInfo(P),this.zoomInfo.ratio=w,this.emit("renderZoom",y,v,P)},this.zoomChanged=(d,h=annotation.EGrowthMode.Linear)=>{const s=ZoomUtils.zoomChanged(this.zoom,d,h);this.wheelChangePos(this.getGetCenterCoordinate(),s>this.zoom?1:-1,s),this.render(),this.renderBasicCanvas()},this.zoomChangeOnCenter=d=>{this.wheelChangePos(this.getGetCenterCoordinate(),0,d),this.render(),this.renderBasicCanvas()},this.drawStraightLine=(d,h)=>{const{ctx:s}=this;s&&(s.save(),s.lineCap="round",s.lineJoin="round",s.strokeStyle=h.color,s.lineWidth=h.lineWidth,s.globalAlpha=h.globalAlpha,d.forEach((g,m)=>{if(s.beginPath(),m>0){const f=d[m-1];s.save(),s.moveTo(f.x,f.y),s.lineTo(g.x,g.y),s.stroke(),s.restore()}}),s.restore())},this.drawImg=()=>{!this.imgNode||this.hiddenImg===!0||(DrawUtils.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute}),this.drawStaticImg())},this.drawStaticImg=()=>{!this.staticImgNode||!this.staticMode||(this.clearCanvas(),DrawUtils.drawImg(this.canvas,this.staticImgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute}))};var i,e,o,r,c,a,n,l,C,b,I;this.container=t.container,this.config=CommonToolUtils.jsonParser(t.config),this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size,t.isAppend),this.imgNode=t.imgNode,this.staticMode=(i=t.staticMode)!=null?i:!1,this.isImgError=!t.imgNode,this.basicImgInfo={width:(o=(e=t.imgNode)==null?void 0:e.width)!=null?o:0,height:(c=(r=t.imgNode)==null?void 0:r.height)!=null?c:0,valid:!0,rotate:0},this.forbidOperation=(a=t.forbidOperation)!=null?a:!1,this.forbidBasicResultRender=(n=t.forbidBasicResultRender)!=null?n:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.attributeLockList=[],this.history=new ActionsHistory,this.style=(l=t.style)!=null?l:CommonToolUtils.jsonParser(style.styleString),this._imgAttribute=(C=t.imgAttribute)!=null?C:{},this.isHidden=!1,this.dragStatus=annotation.EDragStatus.Wait,this.defaultAttribute=(b=t==null?void 0:t.defaultAttribute)!=null?b:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=(I=t==null?void 0:t.language)!=null?I:annotation.ELang.Zh,lbUtils.i18n.changeLanguage(LANGUAGE_MAP[this.lang]),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new DblClickEventListener(this.container,200),this.coordUtils=new AxisUtils.CoordinateUtils(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo),this.hiddenImg=t.hiddenImg||!1,t.zoomInfo&&(this.zoomInfo=t.zoomInfo)}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?i:0}get valid(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?i:!0}get baseIcon(){return style.BASE_ICON[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}get innerPosAndZoom(){return{innerZoom:this.innerZoom,currentPosStorage:this.currentPosStorage}}get isShowDefaultCursor(){return this.showDefaultCursor}get isMultiMoveMode(){return this.operationMode===tool.EOperationMode.MultiMove}get hasMarkerConfig(){return this.config.markerConfigurable===!0&&this.config.markerList&&this.config.markerList.length>0}setZoom(t){this.zoom=t,this.innerZoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setReferenceData(t){this.referenceData=t}setImgInfo(t){this.imgInfo=t}setCurrentPosStorage(t){this.currentPosStorage=t}setOperationMode(t){this.operationMode=t}recoverOperationMode(){this.operationMode===tool.EOperationMode.MultiMove&&this.setOperationMode(tool.EOperationMode.General)}updatePosition(t){const{zoom:i,currentPos:e}=t;this.setZoom(i),this.setCurrentPos(e),this.currentPosStorage=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t;const i=LANGUAGE_MAP[t];lbUtils.i18n.changeLanguage(i)}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}setCustomCursor(t){this.container.style.cursor=t}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}get pixelRatio(){var t;return CanvasUtils.getPixelRatio((t=this.canvas)==null?void 0:t.getContext("2d"))}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}updateCanvasBasicStyle(t,i,e){const o=this.pixelRatio;t.style.position="absolute",t.width=i.width*o,t.height=i.height*o,t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.left="0",t.style.top="0",t.style.zIndex=`${e} `}createCanvas(t,i=!0){var e,o;const r=this.pixelRatio,c=document.createElement("canvas");this.updateCanvasBasicStyle(c,t,0),this.basicCanvas=c;const a=document.createElement("canvas");this.updateCanvasBasicStyle(a,t,10),i&&(this.container.hasChildNodes()?(this.container.insertBefore(a,this.container.childNodes[0]),this.container.insertBefore(c,this.container.childNodes[0])):(this.container.appendChild(c),this.container.appendChild(a))),this.canvas=a,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(r,r),(o=this.basicCtx)==null||o.scale(r,r),this.ctx&&(this.ctx.imageSmoothingEnabled=!1)}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,i={}){this.imgNode=t,this.setBasicImgInfo(__spreadValues({width:t.width,height:t.height,valid:!0,rotate:0},i)),this.updateZoomInfo(),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof i.valid=="boolean"&&this.setValid(i.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}updateZoomInfo(t=this.imgNode,i=this.size){var e;if(!t||!i)return;const{min:o}=lbUtils.ImgPosUtils.getMinZoomByImgAndSize({canvasSize:i,imgSize:{width:t.width,height:t.height},rotate:this.rotate,zoomRatio:(e=this._imgAttribute)==null?void 0:e.zoomRatio});this.zoomInfo=__spreadProps(__spreadValues({},this.zoomInfo),{min:o})}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.setShowDefaultCursor(t),this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setDefaultAttribute(t){this.defaultAttribute=t}getCoordinateInOrigin(t){const i=this.canvas.getBoundingClientRect();return{x:(t.clientX-i.left-this.currentPos.x)/this.zoom,y:(t.clientY-i.top-this.currentPos.y)/this.zoom}}getTextIconSvg(t=""){var i;return AttributeUtils.default.getTextIconSvg(t,(i=this.config)==null?void 0:i.attributeList,this.config.attributeConfigurable,this.baseIcon)}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}getCoordinateUnderZoom(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left-this.currentPos.x,y:t.clientY-i.top-this.currentPos.y}}getCoordinateUnderZoomByRotate(t){const{x:i,y:e}=this.getCoordinateUnderZoom(t);return this.basicImgInfo.rotate===90?{x:e,y:this.basicImgInfo.height*this.zoom-i}:this.basicImgInfo.rotate===180?{x:this.basicImgInfo.width*this.zoom-i,y:this.basicImgInfo.height*this.zoom-e}:this.basicImgInfo.rotate===270?{x:this.basicImgInfo.width*this.zoom-e,y:i}:{x:i,y:e}}getCoordinateUnderZoomByRotateFromImgPoint(t){const{x:i,y:e}=t;return this.basicImgInfo.rotate===90?{x:(this.basicImgInfo.height-e)*this.zoom+this.currentPos.x,y:i*this.zoom+this.currentPos.y}:this.basicImgInfo.rotate===180?{x:(this.basicImgInfo.width-i)*this.zoom+this.currentPos.x,y:(this.basicImgInfo.height-e)*this.zoom+this.currentPos.y}:this.basicImgInfo.rotate===270?{x:e*this.zoom+this.currentPos.x,y:(this.basicImgInfo.width-i)*this.zoom+this.currentPos.y}:{x:i*this.zoom+this.currentPos.x,y:e*this.zoom+this.currentPos.y}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:i,imgNode:e,_imgAttribute:o,imgInfo:r,dependToolName:c}=this;if(t&&e&&c){let a=t;switch(c){case tool.EToolName.Polygon:case tool.EToolName.Line:{if(t.pointList){const l=MathUtils.default.calcViewportBoundaries(t.pointList);a={x:l.left,y:l.top,width:l.right-l.left,height:l.bottom-l.top}}break}}const n=lbUtils.ImgPosUtils.getBasicRecPos(e,a,i,void 0,o==null?void 0:o.zoomRatio,o==null?void 0:o.isOriginalSize);n&&(this.setCurrentPos(n.currentPos),this.currentPosStorage=this.currentPos,this.setImgInfo(__spreadProps(__spreadValues({},r),{width:r.width/this.innerZoom*n.innerZoom,height:r.height/this.innerZoom*n.innerZoom})),this.setZoom(n.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}clearCursorLine(){this.coord={x:-1,y:-1}}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=i,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);this.isShowCursor&&(this.coord=i);try{if(!i||!_.isNumber(i==null?void 0:i.x)||!_.isNumber(i==null?void 0:i.y))throw new Error("coord error");if(this.coord=i,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const e=this.getCurrentPos(i);this.setCurrentPos(e),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender"),this.emit("dragMove",{currentPos:e,zoom:this.zoom,imgInfo:this.imgInfo})}this.render()}catch(e){console.error(e)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const i=new Date().getTime(),e=this.getCoordinate(t);if(i-this.startTime>1e3||this.isSpaceKey===!0||LineToolUtils.default.calcTwoPointDistance(e,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch((t.keyCode===keyCode.Alt||t.keyCode===keyCode.A)&&t.preventDefault(),t.keyCode){case keyCode.Space:this.isSpaceKey=!0,t.preventDefault();break;case keyCode.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case keyCode.Space:this.isSpaceKey=!1;break}}exportCustomData(){return{}}onWheel(t,i=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const e=this.getCoordinate(t),o=t.deltaY||t.wheelDelta;let r=0;o>0&&this.zoom>this.zoomInfo.min&&(r=-1),o<0&&this.zoom<this.zoomInfo.max&&(r=1),this.wheelChangePos(e,r),this.emit("dependRender"),i&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(i=>(i=this.style.lineColor[0])!=null?i:"")()){if(!this.ctx||this.forbidCursorLine||this.forbidOperation)return;const{x:i,y:e}=this.coord;DrawUtils.drawLine(this.canvas,{x:0,y:e},{x:1e4,y:e},{color:t}),DrawUtils.drawLine(this.canvas,{x:i,y:0},{x:i,y:1e4},{color:t}),DrawUtils.drawCircleWithFill(this.canvas,{x:i,y:e},1,{color:"white"})}setSize(t){var i;this.size=t,this.updateZoomInfo(),this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init(),((i=this.basicImgInfo)==null?void 0:i.valid)===!1&&this.renderInvalidPage())}setImgAttribute(t){const i=this._imgAttribute;if(this._imgAttribute=t,(i==null?void 0:i.zoomRatio)!==t.zoomRatio||i.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,i){this.dependToolName=t,this.coordUtils.setDependInfo(t,i)}filterCacheContext(){}setAttributeLockList(t){this.attributeLockList=t,this.filterCacheContext(),this.render()}setConfig(t){this.config=CommonToolUtils.jsonParser(t)}setDataInjectionAtCreation(t){this.dataInjectionAtCreation=t}setRenderEnhance(t){this.renderEnhance=t}setCustomRenderStyle(t){this.customRenderStyle=t}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.NoRotateNotice,this.lang)),!1;const t=MathUtils.default.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",i=this.config){return lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:i,style:this.style})}getLineColor(t=""){var i,e,o,r,c,a,n,l;if(((i=this.config)==null?void 0:i.attributeConfigurable)===!0){const I=AttributeUtils.default.getAttributeIndex(t,(o=(e=this.config)==null?void 0:e.attributeList)!=null?o:[])+1;return((a=(c=(r=this.config)==null?void 0:r.attributeList)==null?void 0:c.find(h=>h.value===t))==null?void 0:a.color)?(l=(n=lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:this.config}))==null?void 0:n.valid)==null?void 0:l.stroke:this.style.attributeLineColor?this.style.attributeLineColor[I]:""}const{color:C,lineColor:b}=this.style;return C&&b?b[C]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=RenderDomUtils.renderInvalidPage(this.container,this.size,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(!this.forbidBasicResultRender&&this.basicResult&&this.dependToolName)switch(this.dependToolName){case tool.EToolName.Rect:{DrawUtils.drawRect(this.basicCanvas,AxisUtils.default.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case tool.EToolName.Polygon:{DrawUtils.drawPolygonWithFillAndLine(this.basicCanvas,AxisUtils.default.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case tool.EToolName.Line:{DrawUtils.drawLineWithPointList(this.basicCanvas,AxisUtils.default.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}exports.BasicToolOperation=BasicToolOperation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),_=require("lodash"),tool=require("../../constant/tool.js"),MathUtils=require("../../utils/MathUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),LineToolUtils=require("../../utils/tool/LineToolUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),style=require("../../constant/style.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),ActionsHistory=require("../../utils/ActionsHistory.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),DblClickEventListener=require("../../utils/tool/DblClickEventListener.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),RenderDomUtils=require("../../utils/tool/RenderDomUtils.js"),ZoomUtils=require("../../utils/tool/ZoomUtils.js"),eventListener=require("./eventListener.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,t,i)=>t in u?__defProp(u,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[t]=i,__spreadValues=(u,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(u,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(u,i,t[i]);return u},__spreadProps=(u,t)=>__defProps(u,__getOwnPropDescs(t)),__async=(u,t,i)=>new Promise((e,o)=>{var n=r=>{try{a(i.next(r))}catch(l){o(l)}},c=r=>{try{a(i.throw(r))}catch(l){o(l)}},a=r=>r.done?e(r.value):Promise.resolve(r.value).then(n,c);a((i=i.apply(u,t)).next())});const LANGUAGE_MAP={[annotation.ELang.Zh]:"cn",[annotation.ELang.US]:"en"},DEFAULT_ZOOM_INFO={min:.2,max:1e3,ratio:.4};class BasicToolOperation extends eventListener{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.staticMode=!1,this.operationMode=tool.EOperationMode.General,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.zoomInfo=DEFAULT_ZOOM_INFO,this.initImgPos=()=>__async(this,null,function*(){var d,h;if(!this.imgNode)return;const s=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(h=this._imgAttribute)==null?void 0:h.isOriginalSize,{currentPos:m,imgInfo:f,zoom:v}=lbUtils.ImgPosUtils.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,s,g);this.setCurrentPos(m),this.currentPosStorage=m,this.setImgInfo(f),this.setZoom(v),this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",v,m,f)}),this.getCurrentPos=d=>{const{_firstClickCoordinate:h,currentPosStorage:s}=this;try{let g;return h&&s?g={y:s.y+d.y-h.y,x:s.x+d.x-h.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.wheelChangePos=(d,h,s)=>{const{currentPos:g,imgNode:m}=this;if(!m){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&h===-1)return;const f=ZoomUtils.wheelChangePos(m,d,h,g,{zoom:s||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:this.zoomInfo.max,rotate:this.rotate});if(!f)return;const{currentPos:v,ratio:w,zoom:y,imgInfo:P}=f;this.setZoom(y),this.setCurrentPos(v),this.currentPosStorage=v,this.setImgInfo(P),this.zoomInfo.ratio=w,this.emit("renderZoom",y,v,P)},this.zoomChanged=(d,h=annotation.EGrowthMode.Linear)=>{const s=ZoomUtils.zoomChanged(this.zoom,d,h);this.wheelChangePos(this.getGetCenterCoordinate(),s>this.zoom?1:-1,s),this.render(),this.renderBasicCanvas()},this.zoomChangeOnCenter=d=>{this.wheelChangePos(this.getGetCenterCoordinate(),0,d),this.render(),this.renderBasicCanvas()},this.drawStraightLine=(d,h)=>{const{ctx:s}=this;s&&(s.save(),s.lineCap="round",s.lineJoin="round",s.strokeStyle=h.color,s.lineWidth=h.lineWidth,s.globalAlpha=h.globalAlpha,d.forEach((g,m)=>{if(s.beginPath(),m>0){const f=d[m-1];s.save(),s.moveTo(f.x,f.y),s.lineTo(g.x,g.y),s.stroke(),s.restore()}}),s.restore())},this.drawImg=()=>{!this.imgNode||this.hiddenImg===!0||(DrawUtils.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute}),this.drawStaticImg())},this.drawStaticImg=()=>{!this.staticImgNode||!this.staticMode||(this.clearCanvas(),DrawUtils.drawImg(this.canvas,this.staticImgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute}))};var i,e,o,n,c,a,r,l,C,b,I;this.container=t.container,this.config=CommonToolUtils.jsonParser(t.config),this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size,t.isAppend),this.imgNode=t.imgNode,this.staticMode=(i=t.staticMode)!=null?i:!1,this.isImgError=!t.imgNode,this.basicImgInfo={width:(o=(e=t.imgNode)==null?void 0:e.width)!=null?o:0,height:(c=(n=t.imgNode)==null?void 0:n.height)!=null?c:0,valid:!0,rotate:0},this.forbidOperation=(a=t.forbidOperation)!=null?a:!1,this.forbidBasicResultRender=(r=t.forbidBasicResultRender)!=null?r:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.attributeLockList=[],this.history=new ActionsHistory,this.style=(l=t.style)!=null?l:CommonToolUtils.jsonParser(style.styleString),this._imgAttribute=(C=t.imgAttribute)!=null?C:{},this.isHidden=!1,this.dragStatus=annotation.EDragStatus.Wait,this.defaultAttribute=(b=t==null?void 0:t.defaultAttribute)!=null?b:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=(I=t==null?void 0:t.language)!=null?I:annotation.ELang.Zh,lbUtils.i18n.changeLanguage(LANGUAGE_MAP[this.lang]),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.onRightClick=this.onRightClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new DblClickEventListener(this.container,200),this.coordUtils=new AxisUtils.CoordinateUtils(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo),this.hiddenImg=t.hiddenImg||!1,t.zoomInfo&&(this.zoomInfo=t.zoomInfo)}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?i:0}get valid(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?i:!0}get baseIcon(){return style.BASE_ICON[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}get innerPosAndZoom(){return{innerZoom:this.innerZoom,currentPosStorage:this.currentPosStorage}}get isShowDefaultCursor(){return this.showDefaultCursor}get isMultiMoveMode(){return this.operationMode===tool.EOperationMode.MultiMove}get hasMarkerConfig(){return this.config.markerConfigurable===!0&&this.config.markerList&&this.config.markerList.length>0}setZoom(t){this.zoom=t,this.innerZoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setReferenceData(t){this.referenceData=t}setImgInfo(t){this.imgInfo=t}setCurrentPosStorage(t){this.currentPosStorage=t}setOperationMode(t){this.operationMode=t}recoverOperationMode(){this.operationMode===tool.EOperationMode.MultiMove&&this.setOperationMode(tool.EOperationMode.General)}updatePosition(t){const{zoom:i,currentPos:e}=t;this.setZoom(i),this.setCurrentPos(e),this.currentPosStorage=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t;const i=LANGUAGE_MAP[t];lbUtils.i18n.changeLanguage(i)}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}setCustomCursor(t){this.container.style.cursor=t}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}get pixelRatio(){var t;return CanvasUtils.getPixelRatio((t=this.canvas)==null?void 0:t.getContext("2d"))}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}updateCanvasBasicStyle(t,i,e){const o=this.pixelRatio;t.style.position="absolute",t.width=i.width*o,t.height=i.height*o,t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.left="0",t.style.top="0",t.style.zIndex=`${e} `}createCanvas(t,i=!0){var e,o;const n=this.pixelRatio,c=document.createElement("canvas");this.updateCanvasBasicStyle(c,t,0),this.basicCanvas=c;const a=document.createElement("canvas");this.updateCanvasBasicStyle(a,t,10),i&&(this.container.hasChildNodes()?(this.container.insertBefore(a,this.container.childNodes[0]),this.container.insertBefore(c,this.container.childNodes[0])):(this.container.appendChild(c),this.container.appendChild(a))),this.canvas=a,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(n,n),(o=this.basicCtx)==null||o.scale(n,n),this.ctx&&(this.ctx.imageSmoothingEnabled=!1)}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,i={}){this.imgNode=t,this.setBasicImgInfo(__spreadValues({width:t.width,height:t.height,valid:!0,rotate:0},i)),this.updateZoomInfo(),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof i.valid=="boolean"&&this.setValid(i.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}updateZoomInfo(t=this.imgNode,i=this.size){var e;if(!t||!i)return;const{min:o}=lbUtils.ImgPosUtils.getMinZoomByImgAndSize({canvasSize:i,imgSize:{width:t.width,height:t.height},rotate:this.rotate,zoomRatio:(e=this._imgAttribute)==null?void 0:e.zoomRatio});this.zoomInfo=__spreadProps(__spreadValues({},this.zoomInfo),{min:o})}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.setShowDefaultCursor(t),this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setDefaultAttribute(t){this.defaultAttribute=t}getCoordinateInOrigin(t){const i=this.canvas.getBoundingClientRect();return{x:(t.clientX-i.left-this.currentPos.x)/this.zoom,y:(t.clientY-i.top-this.currentPos.y)/this.zoom}}getTextIconSvg(t=""){var i;return AttributeUtils.default.getTextIconSvg(t,(i=this.config)==null?void 0:i.attributeList,this.config.attributeConfigurable,this.baseIcon)}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}getCoordinateUnderZoom(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left-this.currentPos.x,y:t.clientY-i.top-this.currentPos.y}}getCoordinateUnderZoomByRotate(t){const{x:i,y:e}=this.getCoordinateUnderZoom(t);return this.basicImgInfo.rotate===90?{x:e,y:this.basicImgInfo.height*this.zoom-i}:this.basicImgInfo.rotate===180?{x:this.basicImgInfo.width*this.zoom-i,y:this.basicImgInfo.height*this.zoom-e}:this.basicImgInfo.rotate===270?{x:this.basicImgInfo.width*this.zoom-e,y:i}:{x:i,y:e}}getCoordinateUnderZoomByRotateFromImgPoint(t){const{x:i,y:e}=t;return this.basicImgInfo.rotate===90?{x:(this.basicImgInfo.height-e)*this.zoom+this.currentPos.x,y:i*this.zoom+this.currentPos.y}:this.basicImgInfo.rotate===180?{x:(this.basicImgInfo.width-i)*this.zoom+this.currentPos.x,y:(this.basicImgInfo.height-e)*this.zoom+this.currentPos.y}:this.basicImgInfo.rotate===270?{x:e*this.zoom+this.currentPos.x,y:(this.basicImgInfo.width-i)*this.zoom+this.currentPos.y}:{x:i*this.zoom+this.currentPos.x,y:e*this.zoom+this.currentPos.y}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:i,imgNode:e,_imgAttribute:o,imgInfo:n,dependToolName:c}=this;if(t&&e&&c){let a=t;switch(c){case tool.EToolName.Polygon:case tool.EToolName.Line:{if(t.pointList){const l=MathUtils.default.calcViewportBoundaries(t.pointList);a={x:l.left,y:l.top,width:l.right-l.left,height:l.bottom-l.top}}break}}const r=lbUtils.ImgPosUtils.getBasicRecPos(e,a,i,void 0,o==null?void 0:o.zoomRatio,o==null?void 0:o.isOriginalSize);r&&(this.setCurrentPos(r.currentPos),this.currentPosStorage=this.currentPos,this.setImgInfo(__spreadProps(__spreadValues({},n),{width:n.width/this.innerZoom*r.innerZoom,height:n.height/this.innerZoom*r.innerZoom})),this.setZoom(r.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}clearCursorLine(){this.coord={x:-1,y:-1}}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=i,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);this.isShowCursor&&(this.coord=i);try{if(!i||!_.isNumber(i==null?void 0:i.x)||!_.isNumber(i==null?void 0:i.y))throw new Error("coord error");if(this.coord=i,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const e=this.getCurrentPos(i);this.setCurrentPos(e),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender"),this.emit("dragMove",{currentPos:e,zoom:this.zoom,imgInfo:this.imgInfo})}this.render()}catch(e){console.error(e)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const i=new Date().getTime(),e=this.getCoordinate(t);if(i-this.startTime>1e3||this.isSpaceKey===!0||LineToolUtils.default.calcTwoPointDistance(e,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,t.button===2&&this.onRightClick(t),this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onRightClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch((t.keyCode===keyCode.Alt||t.keyCode===keyCode.A)&&t.preventDefault(),t.keyCode){case keyCode.Space:this.isSpaceKey=!0,t.preventDefault();break;case keyCode.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case keyCode.Space:this.isSpaceKey=!1;break}}exportCustomData(){return{}}onWheel(t,i=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const e=this.getCoordinate(t),o=t.deltaY||t.wheelDelta;let n=0;o>0&&this.zoom>this.zoomInfo.min&&(n=-1),o<0&&this.zoom<this.zoomInfo.max&&(n=1),this.wheelChangePos(e,n),this.emit("dependRender"),i&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(i=>(i=this.style.lineColor[0])!=null?i:"")()){if(!this.ctx||this.forbidCursorLine||this.forbidOperation)return;const{x:i,y:e}=this.coord;DrawUtils.drawLine(this.canvas,{x:0,y:e},{x:1e4,y:e},{color:t}),DrawUtils.drawLine(this.canvas,{x:i,y:0},{x:i,y:1e4},{color:t}),DrawUtils.drawCircleWithFill(this.canvas,{x:i,y:e},1,{color:"white"})}setSize(t){var i;this.size=t,this.updateZoomInfo(),this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init(),((i=this.basicImgInfo)==null?void 0:i.valid)===!1&&this.renderInvalidPage())}setImgAttribute(t){const i=this._imgAttribute;if(this._imgAttribute=t,(i==null?void 0:i.zoomRatio)!==t.zoomRatio||i.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,i){this.dependToolName=t,this.coordUtils.setDependInfo(t,i)}filterCacheContext(){}setAttributeLockList(t){this.attributeLockList=t,this.filterCacheContext(),this.render()}setConfig(t){this.config=CommonToolUtils.jsonParser(t)}setDataInjectionAtCreation(t){this.dataInjectionAtCreation=t}setRenderEnhance(t){this.renderEnhance=t}setCustomRenderStyle(t){this.customRenderStyle=t}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.NoRotateNotice,this.lang)),!1;const t=MathUtils.default.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",i=this.config){return lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:i,style:this.style})}getLineColor(t=""){var i,e,o,n,c,a,r,l;if(((i=this.config)==null?void 0:i.attributeConfigurable)===!0){const I=AttributeUtils.default.getAttributeIndex(t,(o=(e=this.config)==null?void 0:e.attributeList)!=null?o:[])+1;return((a=(c=(n=this.config)==null?void 0:n.attributeList)==null?void 0:c.find(h=>h.value===t))==null?void 0:a.color)?(l=(r=lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:this.config}))==null?void 0:r.valid)==null?void 0:l.stroke:this.style.attributeLineColor?this.style.attributeLineColor[I]:""}const{color:C,lineColor:b}=this.style;return C&&b?b[C]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=RenderDomUtils.renderInvalidPage(this.container,this.size,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(!this.forbidBasicResultRender&&this.basicResult&&this.dependToolName)switch(this.dependToolName){case tool.EToolName.Rect:{DrawUtils.drawRect(this.basicCanvas,AxisUtils.default.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case tool.EToolName.Polygon:{DrawUtils.drawPolygonWithFillAndLine(this.basicCanvas,AxisUtils.default.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case tool.EToolName.Line:{DrawUtils.drawLineWithPointList(this.basicCanvas,AxisUtils.default.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}exports.BasicToolOperation=BasicToolOperation;
@@ -1 +1 @@
1
- "use strict";var keyCode=require("../../constant/keyCode.js"),rectOperation=require("./rectOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));class PointCloud2DRectOperation extends rectOperation.RectOperation{constructor(e){super(e);this.checkMode=e.checkMode}createNewDrawingRect(e,t){this.checkMode||super.createNewDrawingRect(e,t)}deleteSelectedRect(){this.checkMode||this.emit("deleteSelectedRects",this.selectedRects)}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||(this.setSelectedRectID(this.drawingRect.id),this.emit("afterAddingDrawingRect",__spreadValues({},this.selectedRect)))}setSelectedRectID(e){this.checkMode||super.setSelectedRectID(e)}onKeyDown(e){if(!(this.checkMode||e.keyCode!==keyCode.Delete))return super.onKeyDown(e),!0}renderDrawingRect(e,t=this.zoom,c=!1){super.renderDrawingRect((e==null?void 0:e.boxID)?e:__spreadProps(__spreadValues({},e),{lineDash:[3]}),t,c)}}module.exports=PointCloud2DRectOperation;
1
+ "use strict";var keyCode=require("../../constant/keyCode.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),rectOperation=require("./rectOperation.js"),reCalcRect=require("./utils/reCalcRect.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));class PointCloud2DRectOperation extends rectOperation.RectOperation{constructor(e){super(e);this.highLightRectList=[],this.checkMode=e.checkMode,this.highLightRectList=[]}setHighLightRectList(e){this.highLightRectList=e}createNewDrawingRect(e,t){this.checkMode||super.createNewDrawingRect(e,t)}deleteSelectedRect(e){if(this.checkMode)return;const{selectedRects:t}=this;t.length&&e.stopPropagation(),this.emit("deleteSelectedRects",t)}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||(this.setSelectedRectID(this.drawingRect.id),this.emit("afterAddingDrawingRect",__spreadValues({},this.selectedRect)))}setSelectedRectID(e){this.checkMode||super.setSelectedRectID(e)}onKeyDown(e){if(this.checkMode||![keyCode.Delete,keyCode.R].includes(e.keyCode))return;super.onKeyDown(e);const{keyCode:t,ctrlKey:i,altKey:s,shiftKey:c,metaKey:n}=e;switch(t){case keyCode.R:{if(i||s||c||n)return;this.resizeRect();break}}return!0}renderDrawingRect(e,t=this.zoom,i=!1,s=!1){const c=(e==null?void 0:e.boxID)||(e==null?void 0:e.lineDash);super.renderDrawingRect(c?e:__spreadProps(__spreadValues({},e),{lineDash:[3]}),t,i,s)}renderPointCloud2DHighlight(){const{renderEnhance:e={}}=this;this.highLightRectList&&this.highLightRectList.forEach(t=>{this.renderDrawingRect(t,this.zoom,!1,!0),e.selectedRender&&e.selectedRender(this.canvas,AxisUtils.default.changeRectByZoom(t,this.zoom,this.currentPos),this.getRenderStyle(t))})}resizeRect(e=100,t=100){var i;if(!this.imgNode||!((i=this.selectedRects)==null?void 0:i.length)||e<=0||t<=0||this.selectedRects[0].width<=e&&this.selectedRects[0].height<=t)return;const{width:s,height:c}=this.basicImgInfo,n={width:s,height:c,x:0,y:0},h=reCalcRect(this.selectedRects[0],n,e,t);h.noChange||(this.setRectList(this.rectList.map(o=>this.selectedIDs.includes(o.id)?__spreadValues(__spreadValues({},o),h):o),!0),this.render(),this.updateDragResult())}rightMouseUp(e){const t=super.rightMouseUp(e),i=(t==null?void 0:t.boxID)||(t==null?void 0:t.extId);return this.emit("onRightClick",{event:e,targetId:i,id:t==null?void 0:t.id}),t}}module.exports=PointCloud2DRectOperation;