@labelbee/lb-annotation 1.28.0-alpha.3 → 1.28.0-alpha.30

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/tool.js +1 -1
  3. package/dist/core/pointCloud/annotation.js +1 -1
  4. package/dist/core/pointCloud/index.js +4 -4
  5. package/dist/core/pointCloud/matrix.js +1 -1
  6. package/dist/core/scheduler.js +1 -1
  7. package/dist/core/toolOperation/basicToolOperation.js +1 -1
  8. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -1
  9. package/dist/core/toolOperation/pointOperation.js +1 -1
  10. package/dist/core/toolOperation/polygonOperation.js +1 -1
  11. package/dist/core/toolOperation/rectOperation.js +2 -2
  12. package/dist/index.js +1 -1
  13. package/dist/types/constant/tool.d.ts +7 -0
  14. package/dist/types/core/pointCloud/QuadTree25D.d.ts +78 -0
  15. package/dist/types/core/pointCloud/annotation.d.ts +4 -3
  16. package/dist/types/core/pointCloud/index.d.ts +17 -8
  17. package/dist/types/core/scheduler.d.ts +1 -1
  18. package/dist/types/core/toolOperation/ScribbleTool.d.ts +1 -9
  19. package/dist/types/core/toolOperation/basicToolOperation.d.ts +8 -1
  20. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +19 -0
  21. package/dist/types/core/toolOperation/pointOperation.d.ts +1 -0
  22. package/dist/types/core/toolOperation/polygonOperation.d.ts +17 -13
  23. package/dist/types/core/toolOperation/rectOperation.d.ts +14 -4
  24. package/dist/types/utils/tool/AxisUtils.d.ts +3 -27
  25. package/dist/utils/tool/AxisUtils.js +1 -1
  26. package/dist/utils/tool/DrawUtils.js +1 -1
  27. package/dist/utils/tool/PolygonUtils.js +1 -1
  28. package/dist/utils/tool/TagUtils.js +1 -1
  29. package/dist/utils/tool/polygonTool.js +1 -1
  30. package/es/_virtual/highlightWorker.js +1 -1
  31. package/es/constant/tool.js +1 -1
  32. package/es/core/pointCloud/annotation.js +1 -1
  33. package/es/core/pointCloud/index.js +4 -4
  34. package/es/core/pointCloud/matrix.js +1 -1
  35. package/es/core/scheduler.js +1 -1
  36. package/es/core/toolOperation/basicToolOperation.js +1 -1
  37. package/es/core/toolOperation/pointCloud2dOperation.js +1 -1
  38. package/es/core/toolOperation/pointOperation.js +1 -1
  39. package/es/core/toolOperation/polygonOperation.js +1 -1
  40. package/es/core/toolOperation/rectOperation.js +2 -2
  41. package/es/index.js +1 -1
  42. package/es/utils/tool/AxisUtils.js +1 -1
  43. package/es/utils/tool/DrawUtils.js +3 -3
  44. package/es/utils/tool/PolygonUtils.js +1 -1
  45. package/es/utils/tool/TagUtils.js +1 -1
  46. package/es/utils/tool/polygonTool.js +1 -1
  47. package/package.json +4 -4
@@ -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("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24ocCl7InVzZSBzdHJpY3QiO2NvbnN0IHY9Wy0xLC0xLC0xXTtsZXQgST0hMTtmdW5jdGlvbiBCKGUpe2NvbnN0IHQ9LTcsbz0zLG49by10O3JldHVybiBlPHQmJihlPXQpLGU+byYmKGU9byksTWF0aC5mbG9vcigoZS10KS9uKjI1NSl9ZnVuY3Rpb24gRSgpe2xldCBlO2NvbnN0IHQ9bmV3IEFycmF5KDI1NikuZmlsbCgiIikubWFwKCgpPT5uZXcgQXJyYXkoMykuZmlsbCgiIikpO2ZvcihsZXQgbz0wO288MjA7bysrKXtmb3IoZT0wO2U8MzI7ZSsrKXRbZV1bMF09MTI4KzQqZSx0W2VdWzFdPTAsdFtlXVsyXT0wO2Zvcih0WzMyXVswXT0yNTUsdFszMl1bMV09MCx0WzMyXVsyXT0wLGU9MDtlPDYzO2UrKyl0WzMzK2VdWzBdPTI1NSx0WzMzK2VdWzFdPTQrNCplLHRbMzMrZV1bMl09MDtmb3IodFs5Nl1bMF09MjU0LHRbOTZdWzFdPTI1NSx0Wzk2XVsyXT0yLGU9MDtlPDYyO2UrKyl0Wzk3K2VdWzBdPTI1MC00KmUsdFs5NytlXVsxXT0yNTUsdFs5NytlXVsyXT02KzQqZTtmb3IodFsxNTldWzBdPTEsdFsxNTldWzFdPTI1NSx0WzE1OV1bMl09MjU0LGU9MDtlPDY0O2UrKyl0WzE2MCtlXVswXT0wLHRbMTYwK2VdWzFdPTI1Mi1lKjQsdFsxNjArZV1bMl09MjU1O2ZvcihlPTA7ZTwzMjtlKyspdFsyMjQrZV1bMF09MCx0WzIyNCtlXVsxXT0wLHRbMjI0K2VdWzJdPTI1Mi00KmV9cmV0dXJuIHR9Y29uc3QgUj1FKCk7ZnVuY3Rpb24gaChlLHQsbz0wKXtsZXQgbj0wLGEseCxpLGw7dD1bLi4udF0sbz09PTEmJih0PWNyZWF0ZVNtb290aEN1cnZlUG9pbnRzKHQucmVkdWNlKCh5LGMpPT5bLi4ueSxjLngsYy55XSxbXSksLjUsITAsU0VHTUVOVF9OVU1CRVIpKSxbaV09dDtjb25zdCB1PXQubGVuZ3RoO2ZvcihhPTE7YTw9dTthKyspbD10W2EldV0sZS54Pk1hdGgubWluKGkueCxsLngpJiZlLng8PU1hdGgubWF4KGkueCxsLngpJiZlLnk8PU1hdGgubWF4KGkueSxsLnkpJiZpLnghPT1sLngmJih4PShlLngtaS54KSoobC55LWkueSkvKGwueC1pLngpK2kueSwoaS55PT09bC55fHxlLnk8PXgpJiZuKyspLGk9bDtyZXR1cm4gbiUyIT0wfWZ1bmN0aW9uIE8oe3pNaW46ZSx6TWF4OnQscG9seWdvblBvaW50TGlzdDpvLGF0dHJpYnV0ZTpuLHg6YSx5OngsejppLGNvbG9yTGlzdDpsLHZhbGlkOnV9KXtpZihoKHt4OmEseTp4fSxvKSYmaT49ZSYmaTw9dClyZXR1cm4gdT09PSExP1sxLDEwMy8yNTUsMTAyLzI1NV06bFtuXT9sW25dLnJnYmEuc2xpY2UoMCwzKS5tYXAoYz0+Yy8yNTUpOlsxLDAsMF19ZnVuY3Rpb24gbShlKXtjb25zdCB0PUIoZSksbz1SW3RdLFtuLGEseF09bztyZXR1cm5bbi8yNTUsYS8yNTUseC8yNTVdfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24odCl7Y29uc3R7cG9zaXRpb246byxjb2xvcjpuLGN1Ym9pZExpc3Q6YSxjb2xvckxpc3Q6eCxoaWdobGlnaHRJbmRleDppfT10LmRhdGE7bGV0e21vZGlmaWVkQm94SWRzOmw9W10scmVzZXRBcmVhczp1PVtdfT10LmRhdGEseT0wO2Z1bmN0aW9uIGMoKXt5Kz0xfWlmKCFvKXJldHVybjtjb25zdCBfPSEhKGk9PW51bGw/dm9pZCAwOmkubGVuZ3RoKTsoX3x8SSkmJihsPVtdLHU9W10pO2NvbnN0IHc9bC5sZW5ndGg/YS5maWx0ZXIocj0+bC5pbmNsdWRlcyhyLmlkKSk6YTtmb3IobGV0IHI9MDtyPG8ubGVuZ3RoO3IrPTMpe2NvbnN0IEM9b1tyXSxMPW9bcisxXSxkPW9bcisyXTtsZXQgZztpZih1Lmxlbmd0aD09PTEmJiFsLmxlbmd0aCloKHt4OkMseTpMfSx1WzBdKT9nPW0oZCk6Zz12O2Vsc2UgaWYodS5sZW5ndGh8fGwubGVuZ3RoKXtsZXQgcz0hMTt3LnNvbWUoZj0+e2NvbnN0IE09Tyh7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDpDLHk6TCx6OmQsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDp4LHZhbGlkOmYudmFsaWR9KTtyZXR1cm4gTT8oYygpLGc9TSxzPSEwLCEwKTohMX0pLCFzJiZ1Lmxlbmd0aCYmKHM9dS5zb21lKGY9Pmgoe3g6Qyx5Okx9LGYpPyhnPW0oZCksITApOiExKSksIXMmJiFfJiYoST9nPW0oZCk6Zz12KX1lbHNlIHcuc29tZShzPT57Y29uc3QgZj1PKHtwb2x5Z29uUG9pbnRMaXN0OnMucG9seWdvblBvaW50TGlzdCx6TWluOnMuek1pbix6TWF4OnMuek1heCx4OkMseTpMLHo6ZCxhdHRyaWJ1dGU6cy5hdHRyaWJ1dGUsY29sb3JMaXN0OngsdmFsaWQ6cy52YWxpZH0pO3JldHVybiBmPyhjKCksZz1mLCEwKTohMX0pO2NvbnN0IEE9cz0+e2NvbnN0IGY9TWF0aC5mbG9vcihzLzMpO3JldHVybiBpJiZpW2ZdPT09MX07aWYoZylpZihnWzBdPT09dlswXSYmQShyKSluW3JdPTAsbltyKzFdPTAsbltyKzJdPTA7ZWxzZXtjb25zdFtzLGYsTV09ZztuW3JdPXMsbltyKzFdPWYsbltyKzJdPU19ZWxzZSBpZihBKHIpKW5bcl09MCxuW3IrMV09MCxuW3IrMl09MDtlbHNle2NvbnN0W3MsZixNXT1tKGQpO25bcl09cyxuW3IrMV09ZixuW3IrMl09TX19ST1fLHBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjpuLG51bTp5fSl9LHAuaXNJblBvbHlnb249aCxPYmplY3QuZGVmaW5lUHJvcGVydHkocCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkscH0oe30pOwoK",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("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24odyl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHEoaSx0KXtjb25zdHtwb2x5Z29uUG9pbnRMaXN0OmUsek1pbjpuLHpNYXg6cixhdHRyaWJ1dGU6Yyx2YWxpZDpzLGlkOmh9PWk7bGV0IGw9SW5maW5pdHksbT0tSW5maW5pdHksZj1JbmZpbml0eSxkPS1JbmZpbml0eTtjb25zdCB1PWUubGVuZ3RoO2ZvcihsZXQgYT0wO2E8dTthKyspe2NvbnN0e3gseTpYfT1lW2FdO2w9eDxsP3g6bCxtPXg+bT94Om0sZj1YPGY/WDpmLGQ9WD5kP1g6ZH1sZXQgbztpZihzPT09ITEpbz1bMSwuNDAzOSwuNF07ZWxzZSBpZih0JiZ0W2NdKXtjb25zdHtyZ2JhOmF9PXRbY107bz1bYVswXS8yNTUsYVsxXS8yNTUsYVsyXS8yNTVdfWVsc2Ugbz1bMSwwLDBdO3JldHVybntpZDpoLG1pblg6bCxtYXhYOm0sbWluWTpmLG1heFk6ZCx6TWluOm4sek1heDpyLHdpZHRoOm0tbCxoZWlnaHQ6ZC1mLGRlcHRoOnItbixjZW50ZXJYOihsK20pKi41LGNlbnRlclk6KGYrZCkqLjUsY2VudGVyWjoobityKSouNSxwb2x5Z29uUG9pbnRMaXN0OmUsY29sb3JJbmZvOm8sYXR0cmlidXRlOmMsdmFsaWQ6c319ZnVuY3Rpb24gRShpKXtpZighaXx8aS5sZW5ndGg9PT0wKXJldHVybnttaW5YOjAsbWF4WDoxLG1pblk6MCxtYXhZOjEsbWluWjowLG1heFo6MSx3aWR0aDoxLGhlaWdodDoxLGRlcHRoOjF9O2xldCB0PUluZmluaXR5LGU9LUluZmluaXR5LG49SW5maW5pdHkscj0tSW5maW5pdHksYz1JbmZpbml0eSxzPS1JbmZpbml0eTtjb25zdCBoPWkubGVuZ3RoO2ZvcihsZXQgdT0wO3U8aDt1Kz0zKXtjb25zdCBvPWlbdV0sYT1pW3UrMV0seD1pW3UrMl07bzx0JiYodD1vKSxvPmUmJihlPW8pLGE8biYmKG49YSksYT5yJiYocj1hKSx4PGMmJihjPXgpLHg+cyYmKHM9eCl9Y29uc3QgbD1NYXRoLm1heChlLXQsci1uKSouMDEsbT1lLXQrbCoyLGY9ci1uK2wqMixkPXMtYztyZXR1cm57bWluWDp0LWwsbWF4WDplK2wsbWluWTpuLWwsbWF4WTpyK2wsbWluWjpjLG1heFo6cyx3aWR0aDptLGhlaWdodDpmLGRlcHRoOmQsY2VudGVyWDoodCtlKSouNSxjZW50ZXJZOihuK3IpKi41fX1jbGFzcyBae2NvbnN0cnVjdG9yKHQsZT0xNixuPTYscj0wKXt0aGlzLm1pblg9dC5taW5YLHRoaXMubWF4WD10Lm1heFgsdGhpcy5taW5ZPXQubWluWSx0aGlzLm1heFk9dC5tYXhZLHRoaXMubWluWj10Lm1pblp8fC1JbmZpbml0eSx0aGlzLm1heFo9dC5tYXhafHxJbmZpbml0eSx0aGlzLndpZHRoPXQud2lkdGh8fHRoaXMubWF4WC10aGlzLm1pblgsdGhpcy5oZWlnaHQ9dC5oZWlnaHR8fHRoaXMubWF4WS10aGlzLm1pblksdGhpcy5jZW50ZXJYPXQuY2VudGVyWHx8KHRoaXMubWluWCt0aGlzLm1heFgpKi41LHRoaXMuY2VudGVyWT10LmNlbnRlcll8fCh0aGlzLm1pblkrdGhpcy5tYXhZKSouNSx0aGlzLmNhcGFjaXR5PWUsdGhpcy5tYXhMZXZlbD1uLHRoaXMubGV2ZWw9cix0aGlzLmN1Ym9pZHM9W10sdGhpcy5kaXZpZGVkPSExLHRoaXMuY2hpbGRyZW49bnVsbCx0aGlzLnBvaW50Q291bnQ9MH1jb250YWluc1BvaW50KHQsZSxuKXtyZXR1cm4odC10aGlzLm1pblgpKih0aGlzLm1heFgtdCk+PTAmJihlLXRoaXMubWluWSkqKHRoaXMubWF4WS1lKT49MCYmKG4tdGhpcy5taW5aKSoodGhpcy5tYXhaLW4pPj0wfWludGVyc2VjdHNDdWJvaWQodCl7cmV0dXJuISh0Lm1heFg8dGhpcy5taW5YfHx0Lm1pblg+dGhpcy5tYXhYfHx0Lm1heFk8dGhpcy5taW5ZfHx0Lm1pblk+dGhpcy5tYXhZfHx0LnpNYXg8dGhpcy5taW5afHx0LnpNaW4+dGhpcy5tYXhaKX1zdWJkaXZpZGUoKXtpZih0aGlzLmRpdmlkZWQpcmV0dXJuO2NvbnN0IHQ9dGhpcy53aWR0aCouNSxlPXRoaXMuaGVpZ2h0Ki41LG49dGhpcy5sZXZlbCsxO3RoaXMuY2hpbGRyZW49W25ldyBaKHttaW5YOnRoaXMubWluWCxtYXhYOnRoaXMuY2VudGVyWCxtaW5ZOnRoaXMubWluWSxtYXhZOnRoaXMuY2VudGVyWSxtaW5aOnRoaXMubWluWixtYXhaOnRoaXMubWF4Wix3aWR0aDp0LGhlaWdodDplfSx0aGlzLmNhcGFjaXR5LHRoaXMubWF4TGV2ZWwsbiksbmV3IFooe21pblg6dGhpcy5jZW50ZXJYLG1heFg6dGhpcy5tYXhYLG1pblk6dGhpcy5taW5ZLG1heFk6dGhpcy5jZW50ZXJZLG1pblo6dGhpcy5taW5aLG1heFo6dGhpcy5tYXhaLHdpZHRoOnQsaGVpZ2h0OmV9LHRoaXMuY2FwYWNpdHksdGhpcy5tYXhMZXZlbCxuKSxuZXcgWih7bWluWDp0aGlzLm1pblgsbWF4WDp0aGlzLmNlbnRlclgsbWluWTp0aGlzLmNlbnRlclksbWF4WTp0aGlzLm1heFksbWluWjp0aGlzLm1pblosbWF4Wjp0aGlzLm1heFosd2lkdGg6dCxoZWlnaHQ6ZX0sdGhpcy5jYXBhY2l0eSx0aGlzLm1heExldmVsLG4pLG5ldyBaKHttaW5YOnRoaXMuY2VudGVyWCxtYXhYOnRoaXMubWF4WCxtaW5ZOnRoaXMuY2VudGVyWSxtYXhZOnRoaXMubWF4WSxtaW5aOnRoaXMubWluWixtYXhaOnRoaXMubWF4Wix3aWR0aDp0LGhlaWdodDplfSx0aGlzLmNhcGFjaXR5LHRoaXMubWF4TGV2ZWwsbildLHRoaXMuZGl2aWRlZD0hMDtjb25zdCByPXRoaXMuY3Vib2lkcy5sZW5ndGg7Zm9yKGxldCBjPTA7YzxyO2MrKyl7Y29uc3Qgcz10aGlzLmN1Ym9pZHNbY107Zm9yKGxldCBoPTA7aDw0O2grKyl0aGlzLmNoaWxkcmVuW2hdLmludGVyc2VjdHNDdWJvaWQocykmJnRoaXMuY2hpbGRyZW5baF0uaW5zZXJ0KHMpfXRoaXMubGV2ZWw+MCYmKHRoaXMuY3Vib2lkcz1bXSl9aW5zZXJ0KHQpe2lmKCF0aGlzLmludGVyc2VjdHNDdWJvaWQodCkpcmV0dXJuITE7aWYodGhpcy5kaXZpZGVkKXtsZXQgZT0hMTtmb3IobGV0IG49MDtuPDQ7bisrKXRoaXMuY2hpbGRyZW5bbl0uaW5zZXJ0KHQpJiYoZT0hMCk7cmV0dXJuIHRoaXMubGV2ZWw9PT0wJiZ0aGlzLmN1Ym9pZHMucHVzaCh0KSxlfXJldHVybiB0aGlzLmN1Ym9pZHMucHVzaCh0KSx0aGlzLnBvaW50Q291bnQrKyx0aGlzLnBvaW50Q291bnQ+dGhpcy5jYXBhY2l0eSYmdGhpcy5sZXZlbDx0aGlzLm1heExldmVsJiZ0aGlzLnN1YmRpdmlkZSgpLCEwfV9maW5kQ3Vib2lkQ29udGFpbmluZ1BvaW50KHQsZSxuKXtjb25zdCByPXRoaXMuY3Vib2lkcy5sZW5ndGg7Zm9yKGxldCBjPTA7YzxyO2MrKyl7Y29uc3Qgcz10aGlzLmN1Ym9pZHNbY107aWYobjxzLnpNaW58fG4+cy56TWF4fHx0PHMubWluWHx8dD5zLm1heFh8fGU8cy5taW5ZfHxlPnMubWF4WSljb250aW51ZTtjb25zdCBoPXMucG9seWdvblBvaW50TGlzdDtsZXQgbD0hMTtmb3IobGV0IG09MCxmPWgubGVuZ3RoLTE7bTxoLmxlbmd0aDtmPW0rKyl7Y29uc3QgZD1oW21dLngsdT1oW21dLnksbz1oW2ZdLngsYT1oW2ZdLnk7dT5lIT1hPmUmJnQ8KG8tZCkqKGUtdSkvKGEtdSkrZCYmKGw9IWwpfWlmKGwpcmV0dXJue2N1Ym9pZDpzLGNvbG9ySW5mbzpzLmNvbG9ySW5mb319cmV0dXJuIG51bGx9cXVlcnlQb2ludCh0KXtjb25zdHt4OmUseTpuLHo6cn09dDtpZihlPHRoaXMubWluWHx8ZT50aGlzLm1heFh8fG48dGhpcy5taW5ZfHxuPnRoaXMubWF4WXx8cjx0aGlzLm1pblp8fHI+dGhpcy5tYXhaKXJldHVybiBudWxsO2lmKCF0aGlzLmRpdmlkZWQpcmV0dXJuIHRoaXMuX2ZpbmRDdWJvaWRDb250YWluaW5nUG9pbnQoZSxuLHIpO2NvbnN0IGM9KG48dGhpcy5jZW50ZXJZPzA6MikrKGU8dGhpcy5jZW50ZXJYPzA6MSk7bGV0IHM9dGhpcy5jaGlsZHJlbltjXS5xdWVyeVBvaW50KHQpO2lmKCFzKWZvcihsZXQgaD0wO2g8NCYmIShoIT09YyYmKHM9dGhpcy5jaGlsZHJlbltoXS5xdWVyeVBvaW50KHQpLHMpKTtoKyspO3JldHVybiFzJiZ0aGlzLmxldmVsPT09MCYmKHM9dGhpcy5fZmluZEN1Ym9pZENvbnRhaW5pbmdQb2ludChlLG4scikpLHN9Y2xlYXIoKXtpZih0aGlzLmN1Ym9pZHM9W10sdGhpcy5wb2ludENvdW50PTAsdGhpcy5kaXZpZGVkKXtmb3IobGV0IHQ9MDt0PDQ7dCsrKXRoaXMuY2hpbGRyZW5bdF0mJnRoaXMuY2hpbGRyZW5bdF0uY2xlYXIoKTt0aGlzLmRpdmlkZWQ9ITEsdGhpcy5jaGlsZHJlbj1udWxsfX19Y29uc3QgTT1bLTEsLTEsLTFdO2xldCBiPSExLEM9bnVsbDtjb25zdCBJPW5ldyBNYXA7ZnVuY3Rpb24gTyhpKXtjb25zdCB0PS03LGU9MyxuPWUtdDtyZXR1cm4gaTx0JiYoaT10KSxpPmUmJihpPWUpLE1hdGguZmxvb3IoKGktdCkvbioyNTUpfWZ1bmN0aW9uIF8oKXtsZXQgaTtjb25zdCB0PW5ldyBBcnJheSgyNTYpLmZpbGwoIiIpLm1hcCgoKT0+bmV3IEFycmF5KDMpLmZpbGwoIiIpKTtmb3IoaT0wO2k8MzI7aSsrKXRbaV1bMF09MTI4KzQqaSx0W2ldWzFdPTAsdFtpXVsyXT0wO2Zvcih0WzMyXVswXT0yNTUsdFszMl1bMV09MCx0WzMyXVsyXT0wLGk9MDtpPDYzO2krKyl0WzMzK2ldWzBdPTI1NSx0WzMzK2ldWzFdPTQrNCppLHRbMzMraV1bMl09MDtmb3IodFs5Nl1bMF09MjU0LHRbOTZdWzFdPTI1NSx0Wzk2XVsyXT0yLGk9MDtpPDYyO2krKyl0Wzk3K2ldWzBdPTI1MC00KmksdFs5NytpXVsxXT0yNTUsdFs5NytpXVsyXT02KzQqaTtmb3IodFsxNTldWzBdPTEsdFsxNTldWzFdPTI1NSx0WzE1OV1bMl09MjU0LGk9MDtpPDY0O2krKyl0WzE2MCtpXVswXT0wLHRbMTYwK2ldWzFdPTI1Mi1pKjQsdFsxNjAraV1bMl09MjU1O2ZvcihpPTA7aTwzMjtpKyspdFsyMjQraV1bMF09MCx0WzIyNCtpXVsxXT0wLHRbMjI0K2ldWzJdPTI1Mi00Kmk7cmV0dXJuIHR9Y29uc3QgQT1fKCk7ZnVuY3Rpb24gTChpLHQsZT0wKXtsZXQgbj0wLHIsYyxzLGg7ZT09PTEmJih0PWNyZWF0ZVNtb290aEN1cnZlUG9pbnRzKHQucmVkdWNlKChtLGYpPT5bLi4ubSxmLngsZi55XSxbXSksLjUsITAsU0VHTUVOVF9OVU1CRVIpKSxbc109dDtjb25zdCBsPXQubGVuZ3RoO2ZvcihyPTE7cjw9bDtyKyspaD10W3IlbF0saS54Pk1hdGgubWluKHMueCxoLngpJiZpLng8PU1hdGgubWF4KHMueCxoLngpJiZpLnk8PU1hdGgubWF4KHMueSxoLnkpJiZzLnghPT1oLngmJihjPShpLngtcy54KSooaC55LXMueSkvKGgueC1zLngpK3MueSwocy55PT09aC55fHxpLnk8PWMpJiZuKyspLHM9aDtyZXR1cm4gbiUyIT0wfWZ1bmN0aW9uIHAoaSl7Y29uc3QgdD1NYXRoLnJvdW5kKGkqMWUzKS8xZTM7aWYoSS5oYXModCkpcmV0dXJuIEkuZ2V0KHQpO2NvbnN0IGU9TyhpKSxuPUFbZV0sW3IsYyxzXT1uLGg9W3IvMjU1LGMvMjU1LHMvMjU1XTtyZXR1cm4gSS5zZXQodCxoKSxofXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24odCl7Y29uc3R7cG9zaXRpb246ZSxjb2xvcjpuLGN1Ym9pZExpc3Q6cixjb2xvckxpc3Q6YyxoaWdobGlnaHRJbmRleDpzfT10LmRhdGE7bGV0e21vZGlmaWVkQm94SWRzOmg9W10scmVzZXRBcmVhczpsPVtdfT10LmRhdGE7SS5jbGVhcigpO2xldCBtPTA7ZnVuY3Rpb24gZigpe20rPTF9aWYoIWUpcmV0dXJuO2NvbnN0IGQ9ISEocz09bnVsbD92b2lkIDA6cy5sZW5ndGgpOyhkfHxiKSYmKGg9W10sbD1bXSk7Y29uc3QgdT1oLmxlbmd0aD9yLmZpbHRlcihvPT5oLmluY2x1ZGVzKG8uaWQpKTpyO2lmKEMpQy5jbGVhcigpO2Vsc2V7Y29uc3Qgbz1FKGUpO0M9bmV3IFoobywzMiw2KX11LmZvckVhY2gobz0+e2NvbnN0IGE9cShvLGMpO0MuaW5zZXJ0KGEpfSk7Zm9yKGxldCBvPTA7bzxlLmxlbmd0aDtvKz0zKXtjb25zdCBhPWVbb10seD1lW28rMV0sWD1lW28rMl07bGV0IFk7aWYobC5sZW5ndGg9PT0xJiYhaC5sZW5ndGgpTCh7eDphLHk6eH0sbFswXSk/WT1wKFgpOlk9TTtlbHNlIGlmKGwubGVuZ3RofHxoLmxlbmd0aCl7bGV0IGc9ITE7Y29uc3QgeT1DLnF1ZXJ5UG9pbnQoe3g6YSx5OngsejpYfSk7eSYmKGYoKSxZPXkuY29sb3JJbmZvLGc9ITApLCFnJiZsLmxlbmd0aCYmKGc9bC5zb21lKHY9Pkwoe3g6YSx5Onh9LHYpPyhZPXAoWCksITApOiExKSksIWcmJiFkJiYoYj9ZPXAoWCk6WT1NKX1lbHNle2NvbnN0IGc9Qy5xdWVyeVBvaW50KHt4OmEseTp4LHo6WH0pO2cmJihmKCksWT1nLmNvbG9ySW5mbyl9Y29uc3QgUD1nPT57Y29uc3QgeT1NYXRoLmZsb29yKGcvMyk7cmV0dXJuIHMmJnNbeV09PT0xfTtpZihZKWlmKFlbMF09PT1NWzBdJiZQKG8pKW5bb109MCxuW28rMV09MCxuW28rMl09MDtlbHNle2NvbnN0W2cseSx2XT1ZO25bb109ZyxuW28rMV09eSxuW28rMl09dn1lbHNlIGlmKFAobykpbltvXT0wLG5bbysxXT0wLG5bbysyXT0wO2Vsc2V7Y29uc3RbZyx5LHZdPXAoWCk7bltvXT1nLG5bbysxXT15LG5bbysyXT12fX1iPWQscG9zdE1lc3NhZ2Uoe3BvaW50czplLGNvbG9yOm4sbnVtOm19KX0sdy5pc0luUG9seWdvbj1MLE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh3LCJfX2VzTW9kdWxlIix7dmFsdWU6ITB9KSx3fSh7fSk7Cgo=",null,!1);module.exports=WorkerFactory;
@@ -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",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
+ "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={}));const RECT_TOOL_MODE_NAME="rect_tool_mode";exports.ERectToolModeType=void 0,function(o){o.ThreePoints="three_points",o.TwoPoints="two_points"}(exports.ERectToolModeType||(exports.ERectToolModeType={})),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.RECT_TOOL_MODE_NAME=RECT_TOOL_MODE_NAME,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 lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),scheduler=require("../scheduler.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));const createEmptyImage=n=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const e=t.getContext("2d");return e?(e.fillStyle="black",e.fillRect(0,0,n.width,n.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:e,pcdPath:s,extraProps:P,config:m,checkMode:I,toolName:u,proxyMode:v}){this.updateLineList=a=>{const l=(a!=null?a:[]).map(i=>{var o;const r=(o=i.pointList)==null?void 0:o.map(d=>__spreadValues({i:d},lbUtils.PointCloudUtils.transferWorld2Canvas(d,this.toolInstance.size)));return __spreadProps(__spreadValues({},i),{pointList:r})});this.toolScheduler.updateDataByToolName(tool.EToolName.Line,l)},this.updatePolygonList=(a,l)=>{let i=a.map(o=>{var r;const{polygon2d:d}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(o);return{id:o.id,sourceID:"",pointList:d,isRect:!0,valid:(r=o.valid)!=null?r:!0,attribute:o.attribute,trackID:o==null?void 0:o.trackID}});l&&(i=i.concat(l.map(o=>{var r;return __spreadProps(__spreadValues({},o),{pointList:(r=o==null?void 0:o.pointList)==null?void 0:r.map(d=>lbUtils.PointCloudUtils.transferWorld2Canvas(d,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(tool.EToolName.PointCloudPolygon,i)},this.updatePointList=a=>{const l=a==null?void 0:a.map(i=>{var o;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(i);return __spreadProps(__spreadValues({},r),{id:i.id,sourceID:"",valid:(o=i.valid)!=null?o:!0,attribute:i.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(tool.EToolName.Point,l)};const L=lbUtils.PointCloudUtils.getDefaultOrthographicParams(t),O=createEmptyImage(t),c=new Image;c.src=O;const h=new scheduler.ToolScheduler({container:e,size:t,toolName:u,proxyMode:v}),f=new CanvasScheduler.CanvasScheduler({container:e}),g=new index.PointCloud({container:e,noAppend:!0,isOrthographicCamera:!0,orthographicParams:L});s&&g.loadPCDFile(s),f.createCanvas(g.renderer.domElement);const C={size:t,config:JSON.stringify(__spreadProps(__spreadValues({},m),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:c,checkMode:I};P&&Object.assign(C,P);let p=[];scheduler.HybridToolUtils.isSingleTool(u)?p=[u]:p=u,p.forEach((a,l)=>{let i;if(a===tool.EToolName.PointCloudPolygon){const o=h.createOperation(a,c,C);o.eventBinding(),o.setPattern(tool.EPolygonPattern.Rect),this.toolInstance=o,this.toolInstance.eventBinding(),this.pointCloud2dOperation=o}else i=h.createOperation(a,c,__spreadProps(__spreadValues({},C),{textConfigurable:!1}));l===p.length-1&&(this.toolInstance||(this.toolInstance=i,this.toolInstance.eventBinding()))}),this.pointCloudInstance=g,this.canvasScheduler=f,this.toolScheduler=h,this.config=m}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}updateAttributeList(t){this.config=__spreadProps(__spreadValues({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(t)}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.toolScheduler.setSize(t),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(lbUtils.PointCloudUtils.getDefaultOrthographicParams(t)),this.pointCloudInstance.render();const e=createEmptyImage(t),s=new Image;s.src=e,s.onload=()=>{this.toolInstance.setImgNode(s),this.toolInstance.initImgPos()}}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),s=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,s)}addLineListOnTopView(t){const e=lbUtils.PointCloudUtils.getLineListFromResultList(t);this.updateLineList(e)}addPointListOnTopView(t){const e=lbUtils.PointCloudUtils.getSphereParamsFromResultList(t);this.updatePointList(e)}updateData(t,e,s){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,s==null?void 0:s.radius),this.addPolygonListOnTopView(e),this.addLineListOnTopView(e),this.addPointListOnTopView(e))}switchToCanvas(t){const e=this.toolScheduler.switchToCanvas(t);return e?(this.toolInstance.eventUnbinding(),e.eventBinding(),this.toolInstance=e,e):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),scheduler=require("../scheduler.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));const createEmptyImage=n=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const e=t.getContext("2d");return e?(e.fillStyle="black",e.fillRect(0,0,n.width,n.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:e,pcdPath:s,extraProps:m,config:f,checkMode:v,toolName:u,proxyMode:L,view:O}){this.updateLineList=a=>{const d=(a!=null?a:[]).map(l=>{var o;const i=(o=l.pointList)==null?void 0:o.map(r=>__spreadValues({i:r},lbUtils.PointCloudUtils.transferWorld2Canvas(r,this.toolInstance.size)));return __spreadProps(__spreadValues({},l),{pointList:i})});this.toolScheduler.updateDataByToolName(tool.EToolName.Line,d)},this.updatePolygonList=(a,d,l=!0)=>{let o=a.map(i=>{var r;const{polygon2d:P}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(i);return{id:i.id,sourceID:"",pointList:P,isRect:!0,valid:(r=i.valid)!=null?r:!0,attribute:i.attribute,trackID:i==null?void 0:i.trackID}});d&&(o=o.concat(d.map(i=>{var r;return __spreadProps(__spreadValues({},i),{pointList:(r=i==null?void 0:i.pointList)==null?void 0:r.map(P=>lbUtils.PointCloudUtils.transferWorld2Canvas(P,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(tool.EToolName.PointCloudPolygon,o,l)},this.updatePointList=(a,d=!0)=>{const l=a==null?void 0:a.map(o=>{var i;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(o);return __spreadProps(__spreadValues({},r),{id:o.id,sourceID:"",valid:(i=o.valid)!=null?i:!0,attribute:o.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(tool.EToolName.Point,l,d)};const y=lbUtils.PointCloudUtils.getDefaultOrthographicParams(t),S=createEmptyImage(t),c=new Image;c.src=S;const h=new scheduler.ToolScheduler({container:e,size:t,toolName:u,proxyMode:L}),I=new CanvasScheduler.CanvasScheduler({container:e}),g=new index.PointCloud({container:e,noAppend:!0,isOrthographicCamera:!0,orthographicParams:y,view:O});s&&g.loadPCDFile(s),I.createCanvas(g.renderer.domElement);const C={size:t,config:JSON.stringify(__spreadProps(__spreadValues({},f),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:c,checkMode:v};m&&Object.assign(C,m);let p=[];scheduler.HybridToolUtils.isSingleTool(u)?p=[u]:p=u,p.forEach((a,d)=>{let l;if(a===tool.EToolName.PointCloudPolygon){const o=h.createOperation(a,c,C);o.eventBinding(),o.setPattern(tool.EPolygonPattern.Rect),this.toolInstance=o,this.toolInstance.eventBinding(),this.pointCloud2dOperation=o}else l=h.createOperation(a,c,__spreadProps(__spreadValues({},C),{textConfigurable:!1}));d===p.length-1&&(this.toolInstance||(this.toolInstance=l,this.toolInstance.eventBinding()))}),this.pointCloudInstance=g,this.canvasScheduler=I,this.toolScheduler=h,this.config=f}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}updateAttributeList(t){this.config=__spreadProps(__spreadValues({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(t)}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.toolScheduler.setSize(t),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(lbUtils.PointCloudUtils.getDefaultOrthographicParams(t)),this.pointCloudInstance.render();const e=createEmptyImage(t),s=new Image;s.src=e,s.onload=()=>{this.toolInstance.setImgNode(s),this.toolInstance.initImgPos()}}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),s=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,s)}addLineListOnTopView(t){const e=lbUtils.PointCloudUtils.getLineListFromResultList(t);this.updateLineList(e)}addPointListOnTopView(t){const e=lbUtils.PointCloudUtils.getSphereParamsFromResultList(t);this.updatePointList(e)}updateData(t,e,s){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,s==null?void 0:s.radius),this.addPolygonListOnTopView(e),this.addLineListOnTopView(e),this.addPointListOnTopView(e))}switchToCanvas(t){const e=this.toolScheduler.switchToCanvas(t);return e?(this.toolInstance.eventUnbinding(),e.eventBinding(),this.toolInstance=e,e):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
@@ -1,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(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:`
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(b){if(b&&b.__esModule)return b;var t=Object.create(null);return b&&Object.keys(b).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(b,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return b[e]}})}}),t.default=b,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=(b,t,e)=>t in b?__defProp(b,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):b[t]=e,__spreadValues=(b,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(b,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(b,e,t[e]);return b},__spreadProps=(b,t)=>__defProps(b,__getOwnPropDescs(t)),__async=(b,t,e)=>new Promise((i,r)=>{var s=c=>{try{o(e.next(c))}catch(d){r(d)}},h=c=>{try{o(e.throw(c))}catch(d){r(d)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,h);o((e=e.apply(b,t)).next())});const DEFAULT_DISTANCE=30;let highlightWorker=null;class PointCloud extends eventListener{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:s="#4C4C4C",config:h,isSegment:o,checkMode:c,hiddenText:d=!1,view:g=""}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.tipScopeObjectName="tipScope",this.highlightGroupName="highlightBoxes",this.cacheTipScopeList=[],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.highlightColor=16776960,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,a="blue")=>{var l;const u=(l=n.id)!=null?l:uuid();this.removeObjectByName(u,"sphere");const{radius:p,widthSegments:f,heightSegments:w}=lbUtils.DEFAULT_SPHERE_PARAMS,{center:m}=n,y=new THREE__namespace.Group,x=new THREE__namespace.SphereGeometry(p,f,w),C=new THREE__namespace.MeshBasicMaterial({color:a}),v=new THREE__namespace.Mesh(x,C);v.position.set(m.x,m.y,m.z),y.add(v),y.name=`sphere${u}`,this.scene.add(y)},this.generateSphere=n=>{const{fill:a}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,a),this.render()},this.generateSpheres=n=>{n.forEach(a=>{const{fill:l}=this.getColorFromConfig(a.attribute);this.addSphereToSense(a,l)}),this.render()},this.addBoxToSense=(n,a=16777215)=>{var l;const u=(l=n.id)!=null?l:uuid();this.removeObjectByName(u,"box");const{center:p,width:f,height:w,depth:m,rotation:y}=n,x=new THREE__namespace.Group,C=new THREE__namespace.BoxGeometry(f,w,m),v=new THREE__namespace.MeshBasicMaterial({color:"blue"}),M=new THREE__namespace.Mesh(C,v),B=new THREE__namespace.BoxHelper(M,a),O=this.generateBoxArrow(n),P=this.generateBoxTrackID(n,a);P&&x.add(P);const S=this.generateBoxAttributeLabel(n,a);S&&x.add(S),x.add(B),x.add(O),p&&x.position.set(p.x,p.y,p.z),y&&x.rotation.set(0,0,y),x.name=`box${u}`;const L=new THREE__namespace.BoxGeometry(f,w,m),T=new THREE__namespace.MeshBasicMaterial({visible:!1}),z=new THREE__namespace.Mesh(L,T);x.add(z),x.userData={defaultColor:a,selectedID:u},this.scene.add(x)},this.applyCameraTarget=n=>{if(this.camera.type==="OrthographicCamera"&&n){const a=this.getOrthographicCameraTarget(n);this.updateCameraZoom(n.zoom),this.updateCamera(n.position,a)}},this.initShaderMaterial=()=>({vertexShader:`
2
2
  attribute vec3 dimensions;
3
3
  varying vec3 vDimensions;
4
4
  uniform float pointSize;
@@ -28,6 +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=(...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=t&&e.name===`box${t}`?this.highlightColor:e.userData.defaultColor;e.children.forEach(r=>{this.updateMaterialColor(r,i)})})}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;
31
+ }`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...n)=>__async(this,[...n],function*(a=this.currentPCDSrc,l,u){if(!a||this.workerLoading)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=a;const{points:p,color:f}=yield this.cacheInstance.loadPCDFile(a),w=new THREE__namespace.BufferGeometry;w.setAttribute("position",new THREE__namespace.BufferAttribute(p,3)),this.isSegment||w.setAttribute("dimensions",new THREE__namespace.BufferAttribute(f,3)),this.initCloudData(p);const m=new THREE__namespace.Points(w);this.renderPointCloud(m,l,u),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=n=>__async(this,[n],function*({mappingImgList:a,points:l}){const u=m=>__async(this,null,function*(){try{return yield ImgUtils.default.load(m)}catch(y){return console.error("Error loading image:",y),null}}),p=a.length===0?[]:(yield Promise.all(a.map(m=>__async(this,null,function*(){let y=yield u(m.url);return!y&&m.fallbackUrl&&(y=yield u(m.fallbackUrl)),y})))).filter(m=>m!==null),f=a.map((m,y)=>{var x;if(this.cacheInstance.cache2DHighlightIndex.has(m.url))return(x=this.cacheInstance.cache2DHighlightIndex.get(m.url))!=null?x:[];const C=matrix.getHighlightIndexByPoints({points:l,calib:m.calib,width:p[y].width,height:p[y].height});return this.cacheInstance.cache2DHighlightIndex.set(m.url,C),C});return matrix.mergeHighlightList(f)}),this.filterPreResult=(n,a,l)=>__async(this,null,function*(){const{points:u}=yield this.cacheInstance.loadPCDFile(n),p=yield this.cacheInstance.loadIndexMap(n,u);return new Promise(f=>{const w=l.map(m=>{const y=MathUtils.default.calculatePointsInsideBox({indexMap:p,polygon:matrix.getCuboidFromPointCloudBox(m).polygonPointList,zScope:[m.center.z-m.depth/2,m.center.z+m.depth/2],box:m}),x=y>=a.lowerLimitPointsNumInBox;return __spreadProps(__spreadValues({},m),{valid:x,count:y})});f(w)})}),this.loadPCDFileByBox=(n,a,l)=>__async(this,null,function*(){const u=(w,m)=>__async(this,null,function*(){const{width:y=0,height:x=0,depth:C=0}=l!=null?l:{},v=yield this.filterPointsByBox(__spreadProps(__spreadValues({},a),{width:a.width+y,height:a.height+x,depth:a.depth+C}),w,m);if(!v){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=n;const M=new THREE__namespace.Points(v.geometry);M.name=this.pointCloudObjectName,this.scene.add(M),this.render()}),{points:p,color:f}=yield this.cacheInstance.loadPCDFile(n);u(p,f)}),this.generateRange=n=>{const a=this.createRange(n);this.scene.add(a)},this.generateTipScopeList=n=>{this.cacheTipScopeList.forEach((a,l)=>{this.removeObjectByName(this.tipScopeObjectName+l)}),n.forEach((a,l)=>{const u=this.createTipScope(a,l);u&&this.scene.add(u)}),this.cacheTipScopeList=n},this.generateBoxArrow=({width:n})=>{const a=new THREE__namespace.Vector3(1,0,0),l=new THREE__namespace.Vector3(n/2,0,0),u=2,p=new THREE__namespace.ArrowHelper(a,l,u,this.highlightColor);return p.visible=this.showDirection,p},this.generateLabel=(n,a,l)=>{const u=this.getTextCanvas(n),p=new THREE__namespace.Texture(u);p.minFilter=THREE__namespace.LinearFilter,p.magFilter=THREE__namespace.LinearFilter,p.needsUpdate=!0;const f=u.width/window.devicePixelRatio,w=u.height/window.devicePixelRatio,m=new THREE__namespace.SpriteMaterial({map:p,depthWrite:!1,color:l}),y=new THREE__namespace.Sprite(m);return y.scale.set(f/a,w/a,1),{sprite:y,canvasWidth:f,canvasHeight:w}},this.generateBoxTrackID=(n,a)=>{if(!n.trackID)return;const{sprite:l}=this.generateLabel(n.trackID.toString(),50,a);return l.position.set(-n.width/2,0,n.depth/2+.5),l},this.generateBoxAttributeLabel=(n,a)=>{if(!n.attribute||this.hiddenText)return;const l=this.findSubAttributeLabel(n,this.config),u=l?`${n.attribute}
32
+ ${l}`:`${n.attribute}`,{sprite:p,canvasHeight:f}=this.generateLabel(u,100,a);return p.position.set(-n.width/2,0,-n.depth/2-f/150),p},this.applyZAxisPoints=n=>{this.zAxisLimit=n,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:n,customSize:a})=>{const l=this.scene.getObjectByName(this.pointCloudObjectName);if(!l)return;const u=l.material.uniforms.pointSize.value;n?l.material.uniforms.pointSize.value=Math.min(u*1.2,10):l.material.uniforms.pointSize.value=Math.max(u/1.2,1),a&&(l.material.uniforms.pointSize.value=a,this.pointsMaterialSize=a),l.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=h,this.checkMode=c!=null?c:!1,this.hiddenText=d,this.view=g,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,o?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(),o===!0&&(this.initSegment(),this.isSegment=!0),this.controls.addEventListener("rightClick",n=>{var a,l,u;const p=this.renderer.domElement.getBoundingClientRect(),f=n.originalEvent.clientX-p.left,w=n.originalEvent.clientY-p.top;this.pointer.x=f/p.width*2-1,this.pointer.y=-(w/p.height)*2+1,this.raycaster.setFromCamera(this.pointer,this.camera);const m=[];this.scene.children.forEach(x=>{x instanceof THREE__namespace.Group&&x.children.forEach(C=>{C instanceof THREE__namespace.Mesh?m.push(C):this.updateMaterialColor(C,x.userData.defaultColor)})});const y=this.raycaster.intersectObjects(m,!1);if(y.length>0){const x=y[0].object.parent;x==null||x.children.forEach(C=>{this.updateMaterialColor(C,this.highlightColor)}),(a=this.pipe)==null||a.setNeedUpdateCenter(!1),(l=this.pipe)==null||l.setSelectedIDs(x==null?void 0:x.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=t&&e.name===`box${t}`?this.highlightColor:e.userData.defaultColor;e.children.forEach(r=>{this.updateMaterialColor(r,i)})})}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:s,near:h,far:o}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=s,this.camera.near=h,this.camera.far=o,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,s=10,h=e.x-i/2-s,o=e.x-i/2+s,c=e.y+r/2+s,d=e.y-r/2-s,g=100,n=-100,a=500/g;return{left:h,right:o,top:c,bottom:d,near:g,far:n,zoom:a}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:s,height:h,depth:o,rotation:c}=t,d=this.getCameraVector(r,c,{width:s,height:h,depth:o},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,s=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(s,i),s}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,s,h;if(!e){const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(h=(s=(r=o==null?void 0:o.geometry)==null?void 0:r.attributes)==null?void 0:s.position)==null?void 0:h.array}if(window.Worker){const{zMin:o,zMax:c,polygonPointList:d}=matrix.getCuboidFromPointCloudBox(t),g=e;i=i!=null?i:new Float32Array([]);const n={boxParams:t,zMin:o,zMax:c,polygonPointList:d,color:i,position:g};return this.filterBoxWorker||(this.filterBoxWorker=new filterBoxWorker),new Promise(a=>{var l;(l=this.filterBoxWorker)==null||l.postMessage(n),this.filterBoxWorker.onmessage=u=>{const{color:p,position:f,num:w}=u.data;this.geometry.dispose(),this.geometry.setAttribute("position",new THREE__namespace.Float32BufferAttribute(f,3)),this.geometry.setAttribute("color",new THREE__namespace.Float32BufferAttribute(p,3)),this.geometry.computeBoundingSphere(),this.filterBoxWorker&&(this.filterBoxWorker.terminate(),this.filterBoxWorker=null),a({geometry:this.geometry,num:w})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,s=DEFAULT_DISTANCE){let h=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(s);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:h=lbUtils.PerspectiveShiftUtils.backViewMatrix4(s);break;case lbUtils.EPerspectiveView.Left:h=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(s);break;case lbUtils.EPerspectiveView.Right:h=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(s);break;case lbUtils.EPerspectiveView.Top:h=lbUtils.PerspectiveShiftUtils.topViewMatrix4(s);break;case lbUtils.EPerspectiveView.LFT:h=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(s,i);break;case lbUtils.EPerspectiveView.RBT:h=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(s,i);break}const o=this.createThreeMatrix4(h),c=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),d=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),g=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(o).applyMatrix4(c).applyMatrix4(g).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),s=new THREE__namespace.LineBasicMaterial({color:16711680}),h=new THREE__namespace.Line(r,s);return h.name=this.rangeObjectName,h}createTipScope(t,e){this.removeObjectByName(this.tipScopeObjectName+e);let i=null;const{scopeType:r,range:s}=t;if(r==="circle"){const o=new THREE__namespace.EllipseCurve(0,0,Number(s.radius),Number(s.radius),0,2*Math.PI,!1,0).getPoints(50),c=new THREE__namespace.BufferGeometry().setFromPoints(o),d=new THREE__namespace.LineBasicMaterial({color:16711680});i=new THREE__namespace.Line(c,d)}else if(r==="rect"){const{top:h=0,bottom:o=0,left:c=0,right:d=0}=s,g=c,n=-d,a=h,l=-o,u=new THREE__namespace.Shape;u.moveTo(a,g),u.lineTo(l,g),u.lineTo(l,n),u.lineTo(a,n),u.lineTo(a,g);const p=new THREE__namespace.BufferGeometry().setFromPoints(u.getPoints()),f=new THREE__namespace.LineBasicMaterial({color:16711680});i=new THREE__namespace.Line(p,f)}return i?(i.name=this.tipScopeObjectName+e,i):null}renderPointCloud(t,e,i){if(this.clearPointCloud(),this.workerLoading)return;t.name=this.pointCloudObjectName;const r=new THREE__namespace.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),i&&this.generateTipScopeList(i),this.pointsUuid=t.uuid,t.material=r,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],s=t[e+2];this.store.cloudData.set(`${i}@${r}@${s}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return __async(this,null,function*(){return new Promise((e,i)=>{highlightWorker&&(highlightWorker.terminate(),highlightWorker=null),highlightWorker=new highlightWorker$1({type:"module"}),highlightWorker.postMessage(t),highlightWorker.onmessage=r=>{e(r.data),highlightWorker==null||highlightWorker.terminate(),highlightWorker=null},highlightWorker.onerror=r=>{i(r)}})})}highlightOriginPointCloud(t){return __async(this,arguments,function*(e,i=[],r={modifiedBoxIds:[],resetAreas:[]}){if(this.workerLoading)return;this.workerLoading=!0;const{modifiedBoxIds:s,resetAreas:h}=r,o=this.scene.getObjectByName(this.pointCloudObjectName);if(!!o)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((c,d)=>{if(window.Worker){const n=(e?[...e]:[]).map(f=>matrix.getCuboidFromPointCloudBox(f)),a=this.getAllAttributeColor(n),l=o.geometry.attributes.position.array,u=o.geometry.attributes.dimensions.array,p={cuboidList:n,position:l,color:u,colorList:a,highlightIndex:i,modifiedBoxIds:s,resetAreas:h};this.handleWebworker(p).then(f=>{const{color:w}=f;if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||o.geometry.attributes.position.array.length!==w.length){d(new Error("Error Path"));return}let m=w;(s.length||h.length)&&(m=w.map((C,v)=>C===-1?u[v]:C));const y=new THREE__namespace.BufferAttribute(m,3);this.highlightPCDSrc=void 0,y.needsUpdate=!0,o.geometry.setAttribute("dimensions",y),o.geometry.attributes.dimensions.needsUpdate=!0;const x={color:m,view:this.view,currentPCDSrc:this.currentPCDSrc};c(x),this.workerLoading=!1,this.render()}).catch(f=>{this.workerLoading=!1,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:s,z:h},width:o,height:c,depth:d,rotation:g}=i,{fill:n}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),a=new THREE__namespace.BoxGeometry(o,c,d),l=new THREE__namespace.MeshBasicMaterial({color:n,transparent:!0,opacity:.2,depthTest:!1});a.rotateZ(g),a.translate(r,s,h);const u=new THREE__namespace.Mesh(a,l);e.add(u);const p=new THREE__namespace.PlaneGeometry(d,c);p.rotateY(Math.PI/2),p.rotateZ(g);const f=new THREE__namespace.Vector3(o/2,0,0),w=new THREE__namespace.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(g);f.applyMatrix4(w),p.translate(r+f.x,s+f.y,h+f.z);const m=new THREE__namespace.MeshBasicMaterial({color:n,side:THREE__namespace.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),y=new THREE__namespace.Mesh(p,m);e.add(y)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t,e=""){if(e&&e!==this.currentPCDSrc)return;const i=this.scene.getObjectByName(this.pointCloudObjectName);if(i){const r=new THREE__namespace.BufferAttribute(t,3);i.geometry.setAttribute("dimensions",r),i.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 s=Object.keys(t.subAttribute);return s.length===0||s.forEach(h=>{const o=i.find(n=>n.value===h);if(!o||!o.subSelected)return;const{key:c,subSelected:d}=o,g=[];d.forEach(n=>{var a;const l=(a=t.subAttribute)==null?void 0:a[h],u=Array.isArray(l)?l:l==null?void 0:l.split(";");(u==null?void 0:u.includes(n.value))&&g.push(n.key)}),g.length>0&&(r&&(r+="\u3001"),r+=`${c}:${g.join("\u3001")}`)}),r}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d"),r=window.devicePixelRatio||1,s=50;if(i){i.font=`${s}px bold`;const h=t.split(`
33
+ `),o=Math.max(...h.map(n=>i.measureText(n).width)),c=Math.ceil(o),d=s*1.5,g=d*h.length;e.width=c*r,e.height=g*r,e.style.width=`${c}px`,e.style.height=`${g}px`,i.scale(r,r),i.font=`${s}px bold`,i.fillStyle="white",i.textAlign="left",i.textBaseline="top",h.forEach((n,a)=>{i.fillText(n,0,a*d)})}return e}updateHiddenTextAndRender(t,e){this.hiddenText=t,this.generateBoxes(e)}filterNoise(t){let e=[...t];e.sort((n,a)=>n.z-a.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:n})=>n>r.z+.1);const s=.005,h=Math.floor(e.length*(1-s));e=e.slice(0,h),e.sort((n,a)=>n.x-a.x);const o=Math.floor(e.length*s),c=Math.floor(e.length*(1-s));e=e.slice(o,c),e.sort((n,a)=>n.y-a.y);const d=Math.floor(e.length*s),g=Math.floor(e.length*(1-s));return e=e.slice(d,g),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:c,y:d})=>{t.forEach((g,n)=>{const a=r[n+1],l=MathUtils.default.getFootOfPerpendicular({x:c,y:d},g,a,!1,!0).length;(!i[n]||l<i[n].distance)&&(i[n]={distance:l,point:{x:c,y:d}})})}),r=[t[t.length-1],...t,t[0]];const s=[i[i.length-1],...i],h=t.map((c,d)=>{const g=r[d],n=r[d+1],a=r[d+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:s[d].point,line1:[g,n],p2:s[d+1].point,line2:[n,a]})});return h.some(c=>!(Number.isFinite(c.x)&&Number.isFinite(c.y)))?t:h}getSensesPointZAxisInPolygon(t,e,i){var r,s,h;const o=this.scene.children.find(p=>p.uuid===this.pointsUuid);let c=0,d=0,g=0,n=0,a=[],l=[];const u=((h=(s=(r=o==null?void 0:o.geometry)==null?void 0:r.attributes)==null?void 0:s.position)==null?void 0:h.array)||[];for(let p=0;p<u.length;p+=3){const f=u[p],w=u[p+1],m=u[p+2];polygonTool.isInPolygon({x:f,y:w},t)&&(m||m===0)&&l.push({x:f,y:w,z:m})}return l.length?(i&&(l=this.filterNoise(l),a=this.getFittedCoordinates(t,l)),l.sort((p,f)=>p.z-f.z),c=l[0].z-.01,d=l[l.length-1].z+.01,n=l.length,e&&(g=l.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:d,minZ:c,count:g,zCount:n,fittedCoordinates:a}):{maxZ:d,minZ:c,count:g,zCount:n,fittedCoordinates:a}}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:s,width:h,depth:o}=t,c={x:e+h/2,y:i+s/2,z:r-o/2},d={x:e+h/2,y:i+s/2,z:r+o/2},g={x:e-h/2,y:i+s/2,z:r+o/2},n={x:e-h/2,y:i+s/2,z:r-o/2};return[c,d,g,n]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:s,width:h,depth:o}=t,c={x:e-h/2,y:i+s/2,z:r+o/2},d={x:e-h/2,y:i+s/2,z:r-o/2},g={x:e-h/2,y:i-s/2,z:r-o/2},n={x:e-h/2,y:i-s/2,z:r+o/2};return[c,d,g,n]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:s,width:h,depth:o}=t,c={x:e+h/2,y:i+s/2,z:r+o/2},d={x:e+h/2,y:i-s/2,z:r+o/2},g={x:e-h/2,y:i-s/2,z:r+o/2},n={x:e-h/2,y:i+s/2,z:r+o/2};return[c,d,g,n]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:s}=t,h=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),o=new THREE__namespace.Matrix4().makeTranslation(e,i,r),c=new THREE__namespace.Matrix4().makeRotationZ(s);return new THREE__namespace.Matrix4().multiply(o).multiply(c).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:s}=t,h=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),o=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(h).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=o;const c=i.map(n=>new THREE__namespace.Vector3(n.x,n.y,n.z)).map(n=>n.applyMatrix4(this.sideMatrix)),d=this.containerWidth/r,g=this.containerHeight/s;return{polygon2d:c,zoom:Math.min(d,g)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:s}=t,{radius:h}=lbUtils.DEFAULT_SPHERE_PARAMS,o={center:e,attribute:i,id:r,valid:s,width:h*2,height:h*2,depth:h*2,rotation:0},c=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),d=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(o)).premultiply(c).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=d;const g=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),n=this.containerWidth/(h*2),a=this.containerHeight/(h*2);return{point2d:g,zoom:Math.min(n,a)/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)},s=this.containerWidth/(i*2),h=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(s,h)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,s=this.getPolygonTopPoints(t).map(c=>new THREE__namespace.Vector3(c.x,c.y,c.z)).map(c=>c.applyMatrix4(this.getModelTransformationMatrix(t))).map(c=>({x:c.y,y:c.x})).map(c=>({x:-(c.x-this.containerWidth/2),y:-(c.y-this.containerHeight/2)})),h=this.containerWidth/e,o=this.containerHeight/i;return{polygon2d:s,zoom:Math.min(h,o)/2}}getNewBoxBySideUpdate(t,e,i,r){const s=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),h=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(s);let o=r;return o.center={x:o.center.x+h.x,y:o.center.y+h.y,z:o.center.z-t.z},o=__spreadProps(__spreadValues({},o),{width:Math.abs(o.width+e),height:o.height,depth:Math.abs(o.depth+i)}),{newBoxParams:o}}getNewBoxByBackUpdate(t,e,i,r){const s=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),h=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(s);let o=r;return o.center={x:o.center.x+h.x,y:o.center.y+h.y,z:o.center.z-t.z},o=__spreadProps(__spreadValues({},o),{width:o.width,height:Math.abs(o.height+e),depth:Math.abs(o.depth+i)}),{newBoxParams:o}}getNewBoxBySideUpdateByPoints(t,e,i,r){var s;const h=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!h){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const o=t.map(f=>new THREE__namespace.Vector3(f.x,f.y,f.z)).map(f=>f.applyMatrix4(h)),[c,d,g,n]=o,a=Math.max(Math.abs(c.x-g.x),Math.abs(c.x-d.x)),u=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-u.x,y:r.center.y-u.y,z:r.center.z-i},width:a,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,s=[],{count:h}=r;for(let o=0;o<h;o++){const c=r.getZ(o);s.push(c>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(s,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,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
+ "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),c=createThreeMatrix4(n),f=createThreeMatrix4(i),a=createThreeMatrix4(o);return{composeMatrix4:a.clone().premultiply(f).premultiply(c),PM:c,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),c=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(c)}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),c=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(i)),f=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r)),a=o.applyMatrix4(c),x=__pow(__pow(a.x,2)+__pow(a.y,2),.5),p=Math.atan(a.z/x),s=n.reduce((l,u,h)=>l+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],c=n.map(v=>v.reduce((w,P,T)=>w+P*o[T],0)),f=c[0],a=c[1],x=c[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],m=r[1][2],l=Math.sqrt(f*f+a*a),u=Math.atan2(l,x),h=u+i.reduce((v,w,P)=>v+w*Math.pow(u,2*P+3),0);let y,g;l!==0?(y=f*h/l,g=a*h/l):(y=0,g=0);const M=p[0][0]*y+p[0][1]*g,d=p[1][0]*y+p[1][1]*g;return{x:M+s,y:d+m}},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,c=[{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:c,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,c=r.y-e.y;return n*c-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:c}=(r=transferKitti2Matrix(n,i,o))!=null?r:{};if(!!c)return lidar2image(e,c)},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 c=e[o],f=e[o+1],a=e[o+2];isInImage({point:{x:c,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),c=isFisheyeCalibValid(t),{P:f,R:a,T:x}=t;let p;if(c===!1){const l=f.map(d=>[...d]);if(l.length!==3)throw new Error(`Invalid P matrix: Expected 3 rows, got ${l.length}`);if(new Set(l.map(d=>d.length)).size!==1)throw new Error("Invalid P matrix: Inconsistent column counts between rows");const h=l[0].length;if(h!==3&&h!==4)throw new Error(`Invalid P matrix: Expected 3 or 4 columns, got ${h}`);let y=l;h===3&&(y=l.map(d=>[...d.map(Number),0]));const g=y,{composeMatrix4:M}=(n=transferKitti2Matrix(g,a,x))!=null?n:{};if(!M)return;p=M}const s=o.map(l=>({type:l.type,pointList:l.pointList.map(u=>rotatePoint(u,e.center,e.rotation)).map(u=>c?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(l=>l.pointList.length!==0);s[0]&&s[0].pointList&&(s[0].pointList=s[0].pointList.map(l=>__spreadProps(__spreadValues({},l),{specialEdge:!0})));let m=[];if(s.length===6&&i===!0){const l=s[0].pointList,u=s[1].pointList;m=buildConvexHull([...l,...u])}return{transferViewData:s,viewRangePointList:m}}function pointMappingLidar2image(e,t,r){var n;const i=isFisheyeCalibValid(t),{P:o,R:c,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,c,f))!=null?n:{};if(!s)return;a=s}const x=e.length/3,p={};for(let s=0;s<x;s++){const m={x:e[s*3],y:e[s*3+1],z:e[s*3+2]};let l;if(i?l=lidar2FisheyeImage(m,t):l=a&&lidar2image({x:e[s*3],y:e[s*3+1],z:e[s*3+2]},a),l){const u=Math.floor(l.x),h=Math.floor(l.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:c,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,c,f))!=null?n:{};if(!s)return;a=s}const x=[];if(e.forEach(s=>{let m;if(i?m=lidar2FisheyeImage(s,t):m=a&&lidar2image(s,a),m){const{x:l,y:u}=m;x.push({x:l,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});var defaultConfig=require("../constant/defaultConfig.js"),EnhanceCommonToolUtils=require("../utils/tool/EnhanceCommonToolUtils.js"),basicToolOperation=require("./toolOperation/basicToolOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,o)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o,__spreadValues=(i,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(i,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(i,o,t[o]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));const createEmptyImage=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const o=t.getContext("2d");return o?(o.fillStyle="transparent",o.fillRect(0,0,i.width,i.height),t.toDataURL()):""},arraySwap=(i,t,o)=>{const e=i[t];return i[t]=i[o],i[o]=e,i},_HybridToolUtils=class{static isSingleTool(i){return!this.isHybridTool(i)}static isHybridTool(i){return Array.isArray(i)}};let HybridToolUtils=_HybridToolUtils;HybridToolUtils.getTopToolName=i=>_HybridToolUtils.isHybridTool(i)?i[i.length-1]:i;class ToolScheduler{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var o,e;this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(o=t.config)!=null?o:JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(t.toolName))),this.style=(e=t.style)!=null?e:defaultConfig.styleDefaultConfig,this.proxyMode=t.proxyMode,this.onWheel=this.onWheel.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.init()}setImgNode(t,o){this.toolOperationList.forEach(e=>{e.setImgNode(t,o)})}setImgAttribute(t){this.toolOperationList.forEach(o=>{o.setImgAttribute(t)})}syncAllAttributeListInConfig(t){this.toolOperationList.forEach(o=>{const e=__spreadProps(__spreadValues({},o.config),{attributeList:t});o.setConfig(JSON.stringify(e))})}setSize(t){t.width&&t.height&&this.toolOperationDom.forEach(o=>{o.style.width=`${t.width}px`,o.style.height=`${t.height}px`}),this.toolOperationList.forEach(o=>{o.setSize(t)})}syncPosition(t,o,e,n){this.toolOperationList.forEach(a=>{n!==a&&(a.setCurrentPos(t),a.setZoom(o),a.setImgInfo(e),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,o;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((o=this.imgNode)==null?void 0:o.height)||this.size.height}}createDom(){const{width:t,height:o}=this.defaultSize,e=window.document.createElement("div");e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width=`${t}px`,e.style.height=`${o}px`;const n=this.toolOperationList.length+1;return e.style.zIndex=`${n}`,e}getEmptyImage(t,o){const e=createEmptyImage({width:t,height:o}),n=new Image;return n.src=e,n}createOperation(t,o,e){var n;const{width:a,height:l}=this.defaultSize,r=this.createDom(),c=this.getEmptyImage(a,l),h={container:r,size:this.size,config:(n=this==null?void 0:this.config)!=null?n:"{}",drawOutSideTarget:!1,style:this.style,imgNode:o||c,hiddenImg:!!t};e&&Object.assign(h,e);let s;if(!t)s=new basicToolOperation.BasicToolOperation(h),r.style.zIndex="0",s.init();else{const p=EnhanceCommonToolUtils.getCurrentOperation(t);if(!p)return;s=new p(h)}return s==null||s.init(),s.canvas.id=t!=null?t:"basicCanvas",s.historyDisabled=!0,s.on("dragMove",({currentPos:p,zoom:d,imgInfo:u})=>{this.syncPosition(p,d,u,s)}),s.on("renderZoom",(p,d,u)=>{p&&d&&this.syncPosition(d,p,u,s)}),t?(this.container.appendChild(r),this.toolOperationList.push(s),this.toolOperationNameList.push(t),this.toolOperationDom.push(r),s):(this.container.insertBefore(r,this.container.childNodes[0]),this.toolOperationList.unshift(s),this.toolOperationDom.unshift(r),s)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,o=t-1,e=t-2,n=this.toolOperationDom[o],a=this.toolOperationDom[e];if(!(!a||!n))return n.style.zIndex=`${o-1}`,a.style.zIndex=`${o}`,this.toolOperationList[o].clearActiveStatus(),this.toolOperationList[o].clearCursorLine(),this.toolOperationList[o].render(),this.toolOperationList=arraySwap(this.toolOperationList,o,e),this.toolOperationDom=arraySwap(this.toolOperationDom,o,e),this.toolOperationList[o]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var o,e,n,a;const l=this.toolOperationNameList.indexOf(t);if(l<0||this.toolOperationList.length<1||l>this.toolOperationDom.length-1)return;const r=this.toolOperationDom.length-1,c=this.toolOperationDom[l],h=this.toolOperationDom[r];if(!c||!h)return;const s=h.style.zIndex;return h.style.zIndex=`${c.style.zIndex}`,c.style.zIndex=`${s}`,(e=(o=this.toolOperationList[r]).clearActiveStatus)==null||e.call(o),(a=(n=this.toolOperationList[r]).clearCursorLine)==null||a.call(n),this.toolOperationList[r].render(),this.toolOperationList=arraySwap(this.toolOperationList,r,l),this.toolOperationDom=arraySwap(this.toolOperationDom,r,l),this.toolOperationNameList=arraySwap(this.toolOperationNameList,r,l),this.toolOperationList[r]}updateDataByToolName(t,o){const e=this.toolOperationNameList.indexOf(t);e>=0&&this.toolOperationList[e].setResult(o)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var o;(o=t.clearActiveStatus)==null||o.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[],this.eventBinding()}destroy(){this.destroyAllLayer(),this.eventUnBinding()}eventBinding(){this.proxyMode&&(this.container.addEventListener("wheel",this.onWheel),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp))}eventUnBinding(){this.proxyMode&&(this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp))}onWheel(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onWheel(t)}}onMouseDown(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseDown(t)}}onMouseMove(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseMove(t)}}onMouseUp(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseUp(t)}}getCurrentToolName(){return this.toolOperationNameList[this.toolOperationNameList.length-1]}}exports.HybridToolUtils=HybridToolUtils,exports.ToolScheduler=ToolScheduler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var defaultConfig=require("../constant/defaultConfig.js"),EnhanceCommonToolUtils=require("../utils/tool/EnhanceCommonToolUtils.js"),basicToolOperation=require("./toolOperation/basicToolOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,o)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o,__spreadValues=(i,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(i,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(i,o,t[o]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));const createEmptyImage=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const o=t.getContext("2d");return o?(o.fillStyle="transparent",o.fillRect(0,0,i.width,i.height),t.toDataURL()):""},arraySwap=(i,t,o)=>{const e=i[t];return i[t]=i[o],i[o]=e,i},_HybridToolUtils=class{static isSingleTool(i){return!this.isHybridTool(i)}static isHybridTool(i){return Array.isArray(i)}};let HybridToolUtils=_HybridToolUtils;HybridToolUtils.getTopToolName=i=>_HybridToolUtils.isHybridTool(i)?i[i.length-1]:i;class ToolScheduler{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var o,e;this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(o=t.config)!=null?o:JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(t.toolName))),this.style=(e=t.style)!=null?e:defaultConfig.styleDefaultConfig,this.proxyMode=t.proxyMode,this.onWheel=this.onWheel.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.init()}setImgNode(t,o){this.toolOperationList.forEach(e=>{e.setImgNode(t,o)})}setImgAttribute(t){this.toolOperationList.forEach(o=>{o.setImgAttribute(t)})}syncAllAttributeListInConfig(t){this.toolOperationList.forEach(o=>{const e=__spreadProps(__spreadValues({},o.config),{attributeList:t});o.setConfig(JSON.stringify(e))})}setSize(t){t.width&&t.height&&this.toolOperationDom.forEach(o=>{o.style.width=`${t.width}px`,o.style.height=`${t.height}px`}),this.toolOperationList.forEach(o=>{o.setSize(t)})}syncPosition(t,o,e,s){this.toolOperationList.forEach(r=>{s!==r&&(r.setCurrentPos(t),r.setZoom(o),r.setImgInfo(e),r.renderBasicCanvas(),r.render())})}get defaultSize(){var t,o;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((o=this.imgNode)==null?void 0:o.height)||this.size.height}}createDom(){const{width:t,height:o}=this.defaultSize,e=window.document.createElement("div");e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width=`${t}px`,e.style.height=`${o}px`;const s=this.toolOperationList.length+1;return e.style.zIndex=`${s}`,e}getEmptyImage(t,o){const e=createEmptyImage({width:t,height:o}),s=new Image;return s.src=e,s}createOperation(t,o,e){var s;const{width:r,height:l}=this.defaultSize,a=this.createDom(),c=this.getEmptyImage(r,l),h={container:a,size:this.size,config:(s=this==null?void 0:this.config)!=null?s:"{}",drawOutSideTarget:!1,style:this.style,imgNode:o||c,hiddenImg:!!t};e&&Object.assign(h,e);let n;if(!t)n=new basicToolOperation.BasicToolOperation(h),a.style.zIndex="0",n.init();else{const p=EnhanceCommonToolUtils.getCurrentOperation(t);if(!p)return;n=new p(h)}return n==null||n.init(),n.canvas.id=t!=null?t:"basicCanvas",n.historyDisabled=!0,n.on("dragMove",({currentPos:p,zoom:d,imgInfo:u})=>{this.syncPosition(p,d,u,n)}),n.on("renderZoom",(p,d,u)=>{p&&d&&this.syncPosition(d,p,u,n)}),t?(this.container.appendChild(a),this.toolOperationList.push(n),this.toolOperationNameList.push(t),this.toolOperationDom.push(a),n):(this.container.insertBefore(a,this.container.childNodes[0]),this.toolOperationList.unshift(n),this.toolOperationDom.unshift(a),n)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,o=t-1,e=t-2,s=this.toolOperationDom[o],r=this.toolOperationDom[e];if(!(!r||!s))return s.style.zIndex=`${o-1}`,r.style.zIndex=`${o}`,this.toolOperationList[o].clearActiveStatus(),this.toolOperationList[o].clearCursorLine(),this.toolOperationList[o].render(),this.toolOperationList=arraySwap(this.toolOperationList,o,e),this.toolOperationDom=arraySwap(this.toolOperationDom,o,e),this.toolOperationList[o]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var o,e,s,r;const l=this.toolOperationNameList.indexOf(t);if(l<0||this.toolOperationList.length<1||l>this.toolOperationDom.length-1)return;const a=this.toolOperationDom.length-1,c=this.toolOperationDom[l],h=this.toolOperationDom[a];if(!c||!h)return;const n=h.style.zIndex;return h.style.zIndex=`${c.style.zIndex}`,c.style.zIndex=`${n}`,(e=(o=this.toolOperationList[a]).clearActiveStatus)==null||e.call(o),(r=(s=this.toolOperationList[a]).clearCursorLine)==null||r.call(s),this.toolOperationList[a].render(),this.toolOperationList=arraySwap(this.toolOperationList,a,l),this.toolOperationDom=arraySwap(this.toolOperationDom,a,l),this.toolOperationNameList=arraySwap(this.toolOperationNameList,a,l),this.toolOperationList[a]}updateDataByToolName(t,o,e=!0){const s=this.toolOperationNameList.indexOf(t);s>=0&&this.toolOperationList[s].setResult(o,e)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var o;(o=t.clearActiveStatus)==null||o.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[],this.eventBinding()}destroy(){this.destroyAllLayer(),this.eventUnBinding()}eventBinding(){this.proxyMode&&(this.container.addEventListener("wheel",this.onWheel),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp))}eventUnBinding(){this.proxyMode&&(this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp))}onWheel(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onWheel(t)}}onMouseDown(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseDown(t)}}onMouseMove(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseMove(t)}}onMouseUp(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseUp(t)}}getCurrentToolName(){return this.toolOperationNameList[this.toolOperationNameList.length-1]}}exports.HybridToolUtils=HybridToolUtils,exports.ToolScheduler=ToolScheduler;
@@ -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 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
+ "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,s)=>{var a=n=>{try{l(i.next(n))}catch(r){s(r)}},h=n=>{try{l(i.throw(n))}catch(r){s(r)}},l=n=>n.done?e(n.value):Promise.resolve(n.value).then(a,h);l((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.isOffscreenCanvas=!1,this.initImgPos=()=>__async(this,null,function*(){var d,c;if(!this.imgNode)return;const o=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(c=this._imgAttribute)==null?void 0:c.isOriginalSize,{currentPos:m,imgInfo:f,zoom:v}=lbUtils.ImgPosUtils.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,o,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:c,currentPosStorage:o}=this;try{let g;return c&&o?g={y:o.y+d.y-c.y,x:o.x+d.x-c.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.moveAnimationFrameId=null,this.wheelChangePos=(d,c,o)=>{const{currentPos:g,imgNode:m}=this;if(!m){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&c===-1)return;const f=ZoomUtils.wheelChangePos(m,d,c,g,{zoom:o||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,c=annotation.EGrowthMode.Linear)=>{const o=ZoomUtils.zoomChanged(this.zoom,d,c);this.wheelChangePos(this.getGetCenterCoordinate(),o>this.zoom?1:-1,o),this.render(),this.renderBasicCanvas()},this.zoomChangeOnCenter=d=>{this.wheelChangePos(this.getGetCenterCoordinate(),0,d),this.render(),this.renderBasicCanvas()},this.drawStraightLine=(d,c)=>{const{ctx:o}=this;o&&(o.save(),o.lineCap="round",o.lineJoin="round",o.strokeStyle=c.color,o.lineWidth=c.lineWidth,o.globalAlpha=c.globalAlpha,d.forEach((g,m)=>{if(o.beginPath(),m>0){const f=d[m-1];o.save(),o.moveTo(f.x,f.y),o.lineTo(g.x,g.y),o.stroke(),o.restore()}}),o.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,s,a,h,l,n,r,C,b,I;this.isOffscreenCanvas=!!t.isOffscreenCanvas,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:(s=(e=t.imgNode)==null?void 0:e.width)!=null?s:0,height:(h=(a=t.imgNode)==null?void 0:a.height)!=null?h:0,valid:!0,rotate:0},this.forbidOperation=(l=t.forbidOperation)!=null?l:!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=(r=t.style)!=null?r: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.optimizeMouseMove=this.optimizeMouseMove.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,300),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 offscreenCtx(){var t;return(t=this.offscreenCanvas)==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 s=this.pixelRatio;t.style.position="absolute",t.width=i.width*s,t.height=i.height*s,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,s,a;const h=this.pixelRatio,l=document.createElement("canvas");this.updateCanvasBasicStyle(l,t,0),this.basicCanvas=l;const n=document.createElement("canvas");this.updateCanvasBasicStyle(n,t,10);let r;this.isOffscreenCanvas&&(r=document.createElement("canvas"),this.updateCanvasBasicStyle(r,t,20),this.offscreenCanvas=r),i&&(this.container.hasChildNodes()?(this.isOffscreenCanvas&&r&&this.container.insertBefore(r,this.container.childNodes[0]),this.container.insertBefore(n,this.container.childNodes[0]),this.container.insertBefore(l,this.container.childNodes[0])):(this.container.appendChild(l),this.container.appendChild(n),this.isOffscreenCanvas&&r&&this.container.appendChild(r))),this.canvas=n,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(h,h),(s=this.basicCtx)==null||s.scale(h,h),(a=this.offscreenCtx)==null||a.scale(h,h),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.offscreenCanvas&&this.container.contains(this.offscreenCanvas)&&this.container.removeChild(this.offscreenCanvas),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:s}=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:s})}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:s,imgInfo:a,dependToolName:h}=this;if(t&&e&&h){let l=t;switch(h){case tool.EToolName.Polygon:case tool.EToolName.Line:{if(t.pointList){const r=MathUtils.default.calcViewportBoundaries(t.pointList);l={x:r.left,y:r.top,width:r.right-r.left,height:r.bottom-r.top}}break}}const n=lbUtils.ImgPosUtils.getBasicRecPos(e,l,i,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);n&&(this.setCurrentPos(n.currentPos),this.currentPosStorage=this.currentPos,this.setImgInfo(__spreadProps(__spreadValues({},a),{width:a.width/this.innerZoom*n.innerZoom,height:a.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)}clearOffscreenCanvas(){var t;(t=this.offscreenCtx)==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.optimizeMouseMove),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.optimizeMouseMove),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}}optimizeMouseMove(t){this.moveAnimationFrameId||(this.moveAnimationFrameId=requestAnimationFrame(()=>{this.onMouseMove(t),this.moveAnimationFrameId=null}))}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,i=!0){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);this.isShowCursor&&(this.coord=e);try{if(!e||!_.isNumber(e==null?void 0:e.x)||!_.isNumber(e==null?void 0:e.y))throw new Error("coord error");if(this.coord=e,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const s=this.getCurrentPos(e);this.setCurrentPos(s),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender"),this.emit("dragMove",{currentPos:s,zoom:this.zoom,imgInfo:this.imgInfo})}i&&this.render()}catch(s){console.error(s)}}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),s=t.deltaY||t.wheelDelta;let a=0;s>0&&this.zoom>this.zoomInfo.min&&(a=-1),s<0&&this.zoom<this.zoomInfo.max&&(a=1),this.wheelChangePos(e,a),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,s,a,h,l,n,r;if(((i=this.config)==null?void 0:i.attributeConfigurable)===!0){const I=AttributeUtils.default.getAttributeIndex(t,(s=(e=this.config)==null?void 0:e.attributeList)!=null?s:[])+1;return((l=(h=(a=this.config)==null?void 0:a.attributeList)==null?void 0:h.find(c=>c.value===t))==null?void 0:l.color)?(r=(n=lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:this.config}))==null?void 0:n.valid)==null?void 0:r.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 _=require("lodash"),lbUtils=require("@labelbee/lb-utils"),annotation=require("../../constant/annotation.js"),tool=require("../../constant/tool.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),defaultConfig=require("../../constant/defaultConfig.js"),polygonOperation=require("./polygonOperation.js"),basicToolOperation=require("./basicToolOperation.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));class PointCloud2dOperation extends polygonOperation{constructor(t){super(t);this.highlightAttributeList=[],this.rightMouseUp=o=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.selection.setSelectedIDs(this.hoverID,o.ctrlKey),this.emit("setSelectedIDs",this.selection.selectedIDs);const a=(d=this.polygonList.find(u=>u.id===this.hoverID))==null?void 0:d.attribute;a&&a!==this.defaultAttribute&&this.emit("syncAttribute",a)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=o=>{var d;if(o){const a=this.getPointCloudLineColor(o),u=AxisUtils.default.changePointListByZoom(o.pointList,this.zoom,this.currentPos);DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,u,{fillColor:"transparent",strokeColor:a,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(d=this.config)==null?void 0:d.lineType}),o.isRect===!0&&this.showDirectionLine===!0&&(this.renderRectPolygonDirection(u),_.isNumber(o==null?void 0:o.trackID)&&(o==null?void 0:o.trackID)>=0&&this.renderdrawTrackID(o))}},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygonList:o}=this.dragInfo;if(this.selectedIDs.length>0){const d=[];this.polygonList.forEach(a=>{if(this.selectedIDs.includes(a.id)){const u=o.find(c=>c.id===a.id);u&&d.push({newPolygon:a,originPolygon:u})}}),this.emit("updatePolygonByDrag",d)}}};var e,i,s,l,r,h;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(s=CommonToolUtils.jsonParser(t.config))!=null?s:{},this.hideAttributes=[],this.checkMode=(l=t.checkMode)!=null?l:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=__spreadProps(__spreadValues({},defaultConfig.polygonConfig),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(h=(r=this.pointCloudConfig)==null?void 0:r.attributeList)!=null?h:[]})}get getSelectedIDs(){return this.selectedIDs}get enableDrag(){return Boolean(this.selectedIDs.length>0&&this.dragInfo)}get visiblePolygonList(){return this.polygonList.filter(t=>!this.hideAttributes.includes(t.attribute))}setHiddenAttributes(t){this.hideAttributes=t}setConfig(t){var e;const i=CommonToolUtils.jsonParser(t);this.pointCloudConfig=i,this.config=__spreadProps(__spreadValues({},this.config),{attributeList:(e=i==null?void 0:i.attributeList)!=null?e:[]})}dragMouseDown(t){this.checkMode||super.dragMouseDown(t)}deletePolygon(t){this.checkMode||super.deletePolygons(t?[t]:void 0)}deletePolygonPoint(t){this.checkMode||super.deletePolygonPoint(t)}setSelectedIDs(t){this.selection.hardSetSelectedIDs(t),this.selectedIDs.length<2&&this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selection.setSelectedIDs(),this.emit("deleteSelectedIDs")}get selectedPolygons(){return PolygonUtils.getPolygonByIDs(this.polygonList,this.selectedIDs)}updateSelectedPolygonsPoints(t){var e,i;if(this.selectedPolygons&&((e=this.selectedPolygons)==null?void 0:e.length)>0){const s=___default.default.cloneDeep(this.selectedPolygons),l=[];(i=this.selectedPolygons)==null||i.forEach((r,h)=>{r.pointList=r.pointList.map(o=>{var d,a;const{x:u,y:c}=o;return __spreadProps(__spreadValues({},o),{x:u+((d=t.x)!=null?d:0),y:c+((a=t.y)!=null?a:0)})}),l.push({originPolygon:s[h],newPolygon:r})}),this.emit("updateResult"),this.emit("updatePolygonByDrag",l),this.render(),this.history.pushHistory(this.polygonList)}}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t){return t.valid===!1?lbUtils.INVALID_COLOR:lbUtils.toolStyleConverter.getColorFromConfig({attribute:t.attribute},__spreadProps(__spreadValues({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.visiblePolygonList)==null||t.forEach(e=>{var i,s,l;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const r=this.getPointCloudLineColor(e),h=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos),o=this.highlightAttributeList.includes(e.attribute);DrawUtils.drawPolygonWithFillAndLine(this.canvas,h,{fillColor:o?r:"transparent",strokeColor:r,pointColor:"white",thickness:(s=(i=this.style)==null?void 0:i.width)!=null?s:2,lineCap:"round",isClose:!0,lineType:(l=this.config)==null?void 0:l.lineType}),_.isNumber(e==null?void 0:e.trackID)&&(e==null?void 0:e.trackID)>=0&&this.renderdrawTrackID(e),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(h)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderdrawTrackID(t){const e=AxisUtils.default.changePointListByZoom(t.pointList,this.zoom,this.currentPos),i=e[e.length-1],s=t==null?void 0:t.trackID;DrawUtils.drawText(this.canvas,i,`${s}`,__spreadValues({textAlign:"center",color:"white"},annotation.DEFAULT_TEXT_OFFSET))}renderRectPolygonDirection(t){t.length<2||DrawUtils.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===tool.EPolygonPattern.Rect?t.isRect===!0:this.pattern===tool.EPolygonPattern.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),l=this.currentPolygonListByPattern.map(r=>__spreadProps(__spreadValues({},r),{pointList:AxisUtils.default.changePointListByZoom(r.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,l,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=annotation.ESortDirection.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(s=>{var l,r,h,o;return __spreadProps(__spreadValues({},s),{x:(r=(l=s.pointList[0])==null?void 0:l.x)!=null?r:0,y:(o=(h=s.pointList[0])==null?void 0:h.y)!=null?o:0})}),i=CommonToolUtils.getNextSelectedRectID(e,t,this.selectedID);if(i)return this.setSelectedIDs([i.id]),this.render(),[i.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}updateTextAttribute(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributeInstance)==null||e.changeSelected()),t||(i=this._textAttributeInstance)==null||i.clearTextAttribute()}setSelectedID(t){this.updateTextAttribute(t),this.selection.setSelectedIDs(t),this.render()}addPointInDrawing(t){this.forbidAddNew||super.addPointInDrawing(t)}setCanvasSize(t){var e,i;const s=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(s,s),(i=this.basicCtx)==null||i.scale(s,s),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1,i){if(e){super.setPolygonValidAndRender(t,i);return}this.emit("validUpdate",t)}onMouseDown(t){if(basicToolOperation.BasicToolOperation.prototype.onMouseDown.call(this,t)||this.forbidMouseOperation||t.ctrlKey===!0||t.button!==0)return;if(this.selectedIDs.length<2)return super.onMouseDown(t);const e=this.getCoordinateUnderZoom(t);this.dragInfo={dragStartCoord:e,dragTarget:annotation.EDragTarget.Plane,initPointList:[],changePointIndex:[0],originPolygon:this.selectedPolygon,dragPrevCoord:e,originPolygonList:this.polygonList,selectedPolygons:this.selectedPolygons}}setResultAndSelectedID(t,e){this.setPolygonList(t),this.setSelectedIDs([e])}setHighlightAttribute(t){this.highlightAttributeList=[t],this.render()}}module.exports=PointCloud2dOperation;
1
+ "use strict";var _=require("lodash"),lbUtils=require("@labelbee/lb-utils"),annotation=require("../../constant/annotation.js"),tool=require("../../constant/tool.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),defaultConfig=require("../../constant/defaultConfig.js"),MathUtils=require("../../utils/MathUtils.js"),polygonOperation=require("./polygonOperation.js"),basicToolOperation=require("./basicToolOperation.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,t,e)=>t in l?__defProp(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,__spreadValues=(l,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(l,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(l,e,t[e]);return l},__spreadProps=(l,t)=>__defProps(l,__getOwnPropDescs(t));class PointCloud2dOperation extends polygonOperation{constructor(t){super(t);this.highlightAttributeList=[],this.rightMouseUp=o=>{var a,d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.selection.setSelectedIDs(this.hoverID,o.ctrlKey),this.emit("setSelectedIDs",this.selection.selectedIDs);const h=(a=this.polygonList.find(c=>c.id===this.hoverID))==null?void 0:a.attribute;((d=this.selection.selectedIDs)==null?void 0:d.length)===1&&h&&h!==this.defaultAttribute&&this.emit("syncAttribute",h)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=o=>{var a;if(o){const d=this.getPointCloudLineColor(o),h=AxisUtils.default.changePointListByZoom(o.pointList,this.zoom,this.currentPos);DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,h,{fillColor:"transparent",strokeColor:d,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(a=this.config)==null?void 0:a.lineType}),o.isRect===!0&&this.showDirectionLine===!0&&(this.renderRectPolygonDirection(h),_.isNumber(o==null?void 0:o.trackID)&&(o==null?void 0:o.trackID)>=0&&this.renderdrawTrackID(o))}},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygonList:o}=this.dragInfo;if(this.selectedIDs.length>0){const a=[];this.polygonList.forEach(d=>{if(this.selectedIDs.includes(d.id)){const h=o.find(c=>c.id===d.id);h&&a.push({newPolygon:d,originPolygon:h})}}),this.emit("updatePolygonByDrag",a)}}};var e,i,s,r,n,u;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(s=CommonToolUtils.jsonParser(t.config))!=null?s:{},this.hideAttributes=[],this.checkMode=(r=t.checkMode)!=null?r:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=__spreadProps(__spreadValues({},defaultConfig.polygonConfig),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(u=(n=this.pointCloudConfig)==null?void 0:n.attributeList)!=null?u:[]})}get getSelectedIDs(){return this.selectedIDs}get enableDrag(){return Boolean(this.selectedIDs.length>0&&this.dragInfo)}get visiblePolygonList(){return this.polygonList.filter(t=>!this.hideAttributes.includes(t.attribute))}get lastStepByThreePointsMode(){return this.pattern===tool.EPolygonPattern.Rect&&this.drawingPointList.length===2}get lastStepByTwoPointsMode(){return this.pattern===tool.EPolygonPattern.Rect&&this.rectToolMode===tool.ERectToolModeType.TwoPoints&&this.drawingPointList.length===1}setHiddenAttributes(t){this.hideAttributes=t}setConfig(t){var e;const i=CommonToolUtils.jsonParser(t);this.pointCloudConfig=i,this.config=__spreadProps(__spreadValues({},this.config),{attributeList:(e=i==null?void 0:i.attributeList)!=null?e:[]})}dragMouseDown(t){this.checkMode||super.dragMouseDown(t)}deletePolygon(t){this.checkMode||super.deletePolygons(t?[t]:void 0)}deletePolygonPoint(t){this.checkMode||super.deletePolygonPoint(t)}setSelectedIDs(t){this.selection.hardSetSelectedIDs(t),this.selectedIDs.length<2&&this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selection.setSelectedIDs(),this.emit("deleteSelectedIDs")}get selectedPolygons(){return PolygonUtils.getPolygonByIDs(this.polygonList,this.selectedIDs)}updateSelectedPolygonsPoints(t){var e,i;if(this.selectedPolygons&&((e=this.selectedPolygons)==null?void 0:e.length)>0){const s=___default.default.cloneDeep(this.selectedPolygons),r=[];(i=this.selectedPolygons)==null||i.forEach((n,u)=>{n.pointList=n.pointList.map(o=>{var a,d;const{x:h,y:c}=o;return __spreadProps(__spreadValues({},o),{x:h+((a=t.x)!=null?a:0),y:c+((d=t.y)!=null?d:0)})}),r.push({originPolygon:s[u],newPolygon:n})}),this.emit("updateResult"),this.emit("updatePolygonByDrag",r),this.render(),this.history.pushHistory(this.polygonList)}}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t){return t.valid===!1?lbUtils.INVALID_COLOR:lbUtils.toolStyleConverter.getColorFromConfig({attribute:t.attribute},__spreadProps(__spreadValues({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.visiblePolygonList)==null||t.forEach(e=>{var i,s,r;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const n=this.getPointCloudLineColor(e),u=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos),o=this.highlightAttributeList.includes(e.attribute);DrawUtils.drawPolygonWithFillAndLine(this.canvas,u,{fillColor:o?n:"transparent",strokeColor:n,pointColor:"white",thickness:(s=(i=this.style)==null?void 0:i.width)!=null?s:2,lineCap:"round",isClose:!0,lineType:(r=this.config)==null?void 0:r.lineType}),_.isNumber(e==null?void 0:e.trackID)&&(e==null?void 0:e.trackID)>=0&&this.renderdrawTrackID(e),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(u)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderdrawTrackID(t){var e,i;if(!((e=t==null?void 0:t.pointList)==null?void 0:e.length))return;const s=t.pointList[t.pointList.length-1],r=AxisUtils.default.changePointByZoom(s,this.zoom,this.currentPos),n=((i=t==null?void 0:t.trackID)==null?void 0:i.toString())||"";DrawUtils.drawText(this.canvas,r,n,__spreadValues({textAlign:"center",color:"white"},annotation.DEFAULT_TEXT_OFFSET))}renderRectPolygonDirection(t){t.length<2||DrawUtils.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===tool.EPolygonPattern.Rect?t.isRect===!0:this.pattern===tool.EPolygonPattern.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),r=this.currentPolygonListByPattern.map(n=>__spreadProps(__spreadValues({},n),{pointList:AxisUtils.default.changePointListByZoom(n.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,r,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=annotation.ESortDirection.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(s=>{var r,n,u,o;return __spreadProps(__spreadValues({},s),{x:(n=(r=s.pointList[0])==null?void 0:r.x)!=null?n:0,y:(o=(u=s.pointList[0])==null?void 0:u.y)!=null?o:0})}),i=CommonToolUtils.getNextSelectedRectID(e,t,this.selectedID);if(i)return this.setSelectedIDs([i.id]),this.render(),[i.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}updateTextAttribute(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributeInstance)==null||e.changeSelected()),t||(i=this._textAttributeInstance)==null||i.clearTextAttribute()}setSelectedID(t){this.updateTextAttribute(t),this.selection.setSelectedIDs(t),this.render()}addPointInDrawing(t){this.forbidAddNew||(this.rectToolMode=localStorage.getItem(tool.RECT_TOOL_MODE_NAME),super.addPointInDrawing(t))}setCanvasSize(t){var e,i;const s=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(s,s),(i=this.basicCtx)==null||i.scale(s,s),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1,i){if(e){super.setPolygonValidAndRender(t,i);return}this.emit("validUpdate",t)}onMouseDown(t){if(basicToolOperation.BasicToolOperation.prototype.onMouseDown.call(this,t)||this.forbidMouseOperation||t.ctrlKey===!0||t.button!==0)return;if(this.selectedIDs.length<2)return super.onMouseDown(t);const e=this.getCoordinateUnderZoom(t);this.dragInfo={dragStartCoord:e,dragTarget:annotation.EDragTarget.Plane,initPointList:[],changePointIndex:[0],originPolygon:this.selectedPolygon,dragPrevCoord:e,originPolygonList:this.polygonList,selectedPolygons:this.selectedPolygons}}setResultAndSelectedID(t,e){this.setPolygonList(t),this.setSelectedIDs([e])}setHighlightAttribute(t){this.highlightAttributeList=[t],this.render()}createRectByTwoPointsMode(t,e){const i=t[0],s=[...t],r=e.x>i.x&&e.y>i.y,n=e.x<i.x&&e.y<i.y;return r||n?s.push({x:i.x,y:e.y},e,{x:e.x,y:i.y}):s.push({x:e.x,y:i.y},e,{x:i.x,y:e.y}),s}addPointInDrawingHook(t){return this.lastStepByThreePointsMode||this.lastStepByTwoPointsMode?(this.drawingPointList=this.getPointListByRectDrawing(t,this.drawingPointList).value,this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(this.drawingPointList)?(this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.ForbiddenCreationOutsideBoundary,this.lang)}`),this.drawingPointList=[],{continue:!1}):(this.addDrawingPointToPolygonList(!0),{continue:!1})):{continue:!0}}renderPolygonHook(t){return this.lastStepByTwoPointsMode&&DrawUtils.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]}),{continue:!0}}getPointListByRectDrawing(t,e){let i;return this.lastStepByThreePointsMode?i=MathUtils.default.getRectangleByRightAngle(t,e):this.lastStepByTwoPointsMode&&(i=this.createRectByTwoPointsMode(e,t)),{continue:!0,value:i}}}module.exports=PointCloud2dOperation;