@labelbee/lb-annotation 1.17.1 → 1.18.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGcodCl7Y29uc3QgZT0tNyxvPTMsaT1vLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5vJiYodD1vKSxNYXRoLmZsb29yKCh0LWUpL2kqMjU1KX1mdW5jdGlvbiBwKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBvPTA7bzwyMDtvKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPXAoKTtmdW5jdGlvbiBtKHQsZSxvPTApe2xldCBpPTAscyxhLHIsbjtlPVsuLi5lXSxvPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsbCk9PlsuLi5jLGwueCxsLnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IHU9ZS5sZW5ndGg7Zm9yKHM9MTtzPD11O3MrKyluPWVbcyV1XSx0Lng+TWF0aC5taW4oci54LG4ueCkmJnQueDw9TWF0aC5tYXgoci54LG4ueCkmJnQueTw9TWF0aC5tYXgoci55LG4ueSkmJnIueCE9PW4ueCYmKGE9KHQueC1yLngpKihuLnktci55KS8obi54LXIueCkrci55LChyLnk9PT1uLnl8fHQueTw9YSkmJmkrKykscj1uO3JldHVybiBpJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0Om8sYXR0cmlidXRlOmkseDpzLHk6YSx6OnIsY29sb3JMaXN0Om4sdmFsaWQ6dX0pe2lmKG0oe3g6cyx5OmF9LG8pJiZyPj10JiZyPD1lKXJldHVybiB1PT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpuW2ldP25baV0ucmdiYS5zbGljZSgwLDMpLm1hcChsPT5sLzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOm8sY29sb3I6aSxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmF9PWUuZGF0YTtsZXQgcj0wO2ZvcihsZXQgbj0wO248by5sZW5ndGg7bis9Myl7Y29uc3QgdT1vW25dLGM9b1tuKzFdLGw9b1tuKzJdLGQ9cy5tYXAoZj0+Yih7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDp1LHk6Yyx6OmwsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDphLHZhbGlkOmYudmFsaWR9KSkuZmlsdGVyKGY9PmYpLnBvcCgpO2lmKGQpe3IrKztjb25zdFtmLHksTV09ZDtpW25dPWYsaVtuKzFdPXksaVtuKzJdPU19ZWxzZXtjb25zdCBmPWcobCkseT1DW2ZdLFtNLHcsX109eTtpW25dPU0vMjU1LGlbbisxXT13LzI1NSxpW24rMl09Xy8yNTV9fXBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjppLG51bTpyfSl9LHguaXNJblBvbHlnb249bSxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",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("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHAodCl7Y29uc3QgZT0tNyxpPTMsbz1pLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5pJiYodD1pKSxNYXRoLmZsb29yKCh0LWUpL28qMjU1KX1mdW5jdGlvbiBoKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBpPTA7aTwyMDtpKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPWgoKTtmdW5jdGlvbiBkKHQsZSxpPTApe2xldCBvPTAscyxhLHIsZjtlPVsuLi5lXSxpPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsdSk9PlsuLi5jLHUueCx1LnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IG49ZS5sZW5ndGg7Zm9yKHM9MTtzPD1uO3MrKylmPWVbcyVuXSx0Lng+TWF0aC5taW4oci54LGYueCkmJnQueDw9TWF0aC5tYXgoci54LGYueCkmJnQueTw9TWF0aC5tYXgoci55LGYueSkmJnIueCE9PWYueCYmKGE9KHQueC1yLngpKihmLnktci55KS8oZi54LXIueCkrci55LChyLnk9PT1mLnl8fHQueTw9YSkmJm8rKykscj1mO3JldHVybiBvJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0OmksYXR0cmlidXRlOm8seDpzLHk6YSx6OnIsY29sb3JMaXN0OmYsdmFsaWQ6bn0pe2lmKGQoe3g6cyx5OmF9LGkpJiZyPj10JiZyPD1lKXJldHVybiBuPT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpmW29dP2Zbb10ucmdiYS5zbGljZSgwLDMpLm1hcCh1PT51LzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOmksY29sb3I6byxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmEsaGlnaGxpZ2h0SW5kZXg6cn09ZS5kYXRhO2xldCBmPTA7Zm9yKGxldCBuPTA7bjxpLmxlbmd0aDtuKz0zKXtjb25zdCBjPWlbbl0sdT1pW24rMV0sZz1pW24rMl0sbT1zLm1hcChsPT5iKHtwb2x5Z29uUG9pbnRMaXN0OmwucG9seWdvblBvaW50TGlzdCx6TWluOmwuek1pbix6TWF4Omwuek1heCx4OmMseTp1LHo6ZyxhdHRyaWJ1dGU6bC5hdHRyaWJ1dGUsY29sb3JMaXN0OmEsdmFsaWQ6bC52YWxpZH0pKS5maWx0ZXIobD0+bCkucG9wKCk7aWYobSl7ZisrO2NvbnN0W2wseSxNXT1tO29bbl09bCxvW24rMV09eSxvW24rMl09TX1lbHNle2NvbnN0IGw9TWF0aC5mbG9vcihuLzMpO2lmKHImJnJbbF09PT0xKW9bbl09MCxvW24rMV09MCxvW24rMl09MDtlbHNle2NvbnN0IHk9cChnKSxNPUNbeV0sW3csSSxfXT1NO29bbl09dy8yNTUsb1tuKzFdPUkvMjU1LG9bbisyXT1fLzI1NX19fXBvc3RNZXNzYWdlKHtwb2ludHM6aSxjb2xvcjpvLG51bTpmfSl9LHguaXNJblBvbHlnb249ZCxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);module.exports=WorkerFactory;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PCDLoader=require("./PCDLoader.js");class PointCloudCache{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((s,n)=>{const o=this.pointsMap.get(t),i=this.colorMap.get(t);if(o&&i){s({points:o,color:i});return}if(this.cacheList.length>this.MAX_SIZE){const e=this.cacheList.shift();e&&this.pointsMap.delete(e.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,e=>{const r=e.geometry.attributes.position.array,a=e.geometry.attributes.color.array;this.pointsMap.set(t,r),this.colorMap.set(t,a),s({points:r,color:a})},()=>{},e=>{n(e)})}),this.pcdLoader=new PCDLoader.PCDLoader,this.pointsMap=new Map,this.colorMap=new Map}static getInstance(){return this.instance==null&&(this.instance=new PointCloudCache),this.instance}updateColor(t,s){this.colorMap.set(t,s)}}exports.PointCloudCache=PointCloudCache;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PCDLoader=require("./PCDLoader.js");class PointCloudCache{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((i,n)=>{const s=this.pointsMap.get(t),o=this.colorMap.get(t);if(s&&o){i({points:s,color:o});return}if(this.cacheList.length>this.MAX_SIZE){const e=this.cacheList.shift();e&&this.pointsMap.delete(e.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,e=>{const a=e.geometry.attributes.position.array,r=e.geometry.attributes.color.array;this.pointsMap.set(t,a),this.colorMap.set(t,r),i({points:a,color:r})},()=>{},e=>{n(e)})}),this.pcdLoader=new PCDLoader.PCDLoader,this.pointsMap=new Map,this.colorMap=new Map,this.cache2DHighlightIndex=new Map}static getInstance(){return this.instance==null&&(this.instance=new PointCloudCache),this.instance}updateColor(t,i){this.colorMap.set(t,i)}clearCache2DHighlightIndex(){this.cache2DHighlightIndex.clear()}}exports.PointCloudCache=PointCloudCache;
@@ -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"),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(g){if(g&&g.__esModule)return g;var t=Object.create(null);return g&&Object.keys(g).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(g,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return g[e]}})}}),t.default=g,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=(g,t,e)=>t in g?__defProp(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,__spreadValues=(g,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(g,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(g,e,t[e]);return g},__spreadProps=(g,t)=>__defProps(g,__getOwnPropDescs(t)),__async=(g,t,e)=>new Promise((i,r)=>{var s=h=>{try{n(e.next(h))}catch(o){r(o)}},a=h=>{try{n(e.throw(h))}catch(o){r(o)}},n=h=>h.done?i(h.value):Promise.resolve(h.value).then(s,a);n((e=e.apply(g,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:s="#4C4C4C",config:a,isSegment:n,checkMode:h}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,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,c="blue")=>{var l;const d=(l=o.id)!=null?l:uuid();this.removeObjectByName(d,"sphere");const{radius:u,widthSegments:m,heightSegments:p}=lbUtils.DEFAULT_SPHERE_PARAMS,{center:f}=o,y=new THREE__namespace.Group,x=new THREE__namespace.SphereGeometry(u,m,p),b=new THREE__namespace.MeshBasicMaterial({color:c}),w=new THREE__namespace.Mesh(x,b);w.position.set(f.x,f.y,f.z),y.add(w),y.name=`sphere${d}`,this.scene.add(y)},this.generateSphere=o=>{const{fill:c}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:o.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(o,c),this.render()},this.generateSpheres=o=>{o.forEach(c=>{const{fill:l}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:c.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(c,l)}),this.render()},this.addBoxToSense=(o,c=16777215)=>{var l;const d=(l=o.id)!=null?l:uuid();this.removeObjectByName(d,"box");const{center:u,width:m,height:p,depth:f,rotation:y}=o,x=new THREE__namespace.Group,b=new THREE__namespace.BoxGeometry(m,p,f),w=new THREE__namespace.MeshBasicMaterial({color:"blue"}),C=new THREE__namespace.Mesh(b,w),P=new THREE__namespace.BoxHelper(C,c),M=this.generateBoxArrow(o),v=this.generateBoxTrackID(o);v&&x.add(v),x.add(P),x.add(M),u&&x.position.set(u.x,u.y,u.z),y&&x.rotation.set(0,0,y),x.name=`box${d}`,this.scene.add(x)},this.applyCameraTarget=o=>{if(this.camera.type==="OrthographicCamera"&&o){const c=this.getOrthographicCameraTarget(o);this.updateCameraZoom(o.zoom),this.updateCamera(o.position,c)}},this.initShaderMaterial=()=>({vertexShader:`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),highlightWorker$1=require("../../_virtual/highlightWorker.js"),filterBoxWorker=require("../../_virtual/filterBoxWorker.js"),polygonTool=require("../../utils/tool/polygonTool.js"),uuid=require("../../utils/uuid.js"),MathUtils=require("../../utils/MathUtils.js"),ImgUtils=require("../../utils/ImgUtils.js"),PCDLoader=require("./PCDLoader.js"),OrbitControls=require("./OrbitControls.js"),cache=require("./cache.js"),matrix=require("./matrix.js"),segmentation=require("./segmentation.js"),index=require("./store/index.js"),index$1=require("./render/index.js"),eventListener=require("../toolOperation/eventListener.js");require("../../constant/tool.js"),require("../scheduler.js");function _interopNamespace(f){if(f&&f.__esModule)return f;var t=Object.create(null);return f&&Object.keys(f).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(f,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return f[e]}})}}),t.default=f,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(f,t,e)=>t in f?__defProp(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e,__spreadValues=(f,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(f,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(f,e,t[e]);return f},__spreadProps=(f,t)=>__defProps(f,__getOwnPropDescs(t)),__async=(f,t,e)=>new Promise((i,r)=>{var o=l=>{try{n(e.next(l))}catch(s){r(s)}},h=l=>{try{n(e.throw(l))}catch(s){r(s)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,h);n((e=e.apply(f,t)).next())});const DEFAULT_DISTANCE=30,highlightWorker=new highlightWorker$1({type:"module"});class PointCloud extends eventListener{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:o="#4C4C4C",config:h,isSegment:n,checkMode:l}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=s=>{if(!!this.store)switch(s.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=s=>{if(!!this.store)switch(s.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(s,a="blue")=>{var c;const d=(c=s.id)!=null?c:uuid();this.removeObjectByName(d,"sphere");const{radius:p,widthSegments:m,heightSegments:u}=lbUtils.DEFAULT_SPHERE_PARAMS,{center:g}=s,y=new THREE__namespace.Group,x=new THREE__namespace.SphereGeometry(p,m,u),w=new THREE__namespace.MeshBasicMaterial({color:a}),b=new THREE__namespace.Mesh(x,w);b.position.set(g.x,g.y,g.z),y.add(b),y.name=`sphere${d}`,this.scene.add(y)},this.generateSphere=s=>{const{fill:a}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:s.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(s,a),this.render()},this.generateSpheres=s=>{s.forEach(a=>{const{fill:c}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:a.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(a,c)}),this.render()},this.addBoxToSense=(s,a=16777215)=>{var c;const d=(c=s.id)!=null?c:uuid();this.removeObjectByName(d,"box");const{center:p,width:m,height:u,depth:g,rotation:y}=s,x=new THREE__namespace.Group,w=new THREE__namespace.BoxGeometry(m,u,g),b=new THREE__namespace.MeshBasicMaterial({color:"blue"}),C=new THREE__namespace.Mesh(w,b),P=new THREE__namespace.BoxHelper(C,a),M=this.generateBoxArrow(s),v=this.generateBoxTrackID(s);v&&x.add(v),x.add(P),x.add(M),p&&x.position.set(p.x,p.y,p.z),y&&x.rotation.set(0,0,y),x.name=`box${d}`,this.scene.add(x)},this.applyCameraTarget=s=>{if(this.camera.type==="OrthographicCamera"&&s){const a=this.getOrthographicCameraTarget(s);this.updateCameraZoom(s.zoom),this.updateCamera(s.position,a)}},this.initShaderMaterial=()=>({vertexShader:`
2
2
  attribute vec3 dimensions;
3
3
  varying vec3 vDimensions;
4
4
  uniform float pointSize;
@@ -28,4 +28,4 @@
28
28
 
29
29
  // Output the final color
30
30
  gl_FragColor = vec4(color, 1.0);
31
- }`,uniforms:{pointSize:{value:1.2}}}),this.loadPCDFile=(...o)=>__async(this,[...o],function*(c=this.currentPCDSrc,l){if(!c)return;this.clearPointCloud(),this.currentPCDSrc=c;const{points:d,color:u}=yield this.cacheInstance.loadPCDFile(c),m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.BufferAttribute(d,3)),this.isSegment||m.setAttribute("dimensions",new THREE__namespace.BufferAttribute(u,3)),this.initCloudData(d);const p=new THREE__namespace.Points(m);this.renderPointCloud(p,l)}),this.loadPCDFileByBox=(o,c,l)=>__async(this,null,function*(){const d=(p,f)=>__async(this,null,function*(){const{width:y=0,height:x=0,depth:b=0}=l!=null?l:{},w=yield this.filterPointsByBox(__spreadProps(__spreadValues({},c),{width:c.width+y,height:c.height+x,depth:c.depth+b}),p,f);if(!w){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=o;const C=new THREE__namespace.Points(w.geometry);C.name=this.pointCloudObjectName,this.scene.add(C),this.render()}),{points:u,color:m}=yield this.cacheInstance.loadPCDFile(o);d(u,m)}),this.generateRange=o=>{const c=this.createRange(o);this.scene.add(c)},this.generateBoxArrow=({width:o})=>{const c=new THREE__namespace.Vector3(1,0,0),l=new THREE__namespace.Vector3(o/2,0,0),d=2,u=16776960,m=new THREE__namespace.ArrowHelper(c,l,d,u);return m.visible=this.showDirection,m},this.generateBoxTrackID=o=>{if(!o.trackID)return;const c=new THREE__namespace.Texture(this.getTextCanvas(o.trackID.toString()));c.needsUpdate=!0;const l=new THREE__namespace.SpriteMaterial({map:c,depthWrite:!1}),d=new THREE__namespace.Sprite(l);return d.scale.set(5,5,5),d.position.set(-o.width/2,0,o.depth/2+.5),d},this.applyZAxisPoints=o=>{this.zAxisLimit=o,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:o,customSize:c})=>{const l=this.scene.getObjectByName(this.pointCloudObjectName);if(!l)return;const d=l.material.uniforms.pointSize.value;o?l.material.uniforms.pointSize.value=Math.min(d*1.2,10):l.material.uniforms.pointSize.value=Math.max(d/1.2,1),c&&(l.material.uniforms.pointSize.value=c,this.pointsMaterialSize=c),l.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,this.checkMode=h!=null?h:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,n?this.container:this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance(),n===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new index(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new segmentation.PointCloudSegmentOperation({dom:this.container,store:this.store}),this.pointCloudRender=new index$1(__spreadProps(__spreadValues({store:this.store},this.eventBus),{nextTick:this.nextTick,config:this.config})),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}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.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("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},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){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:s,near:a,far:n}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=s,this.camera.near=a,this.camera.far=n,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()}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,s=10,a=e.x-i/2-s,n=e.x-i/2+s,h=e.y+r/2+s,o=e.y-r/2-s,c=100,l=-100,d=500/c;return{left:a,right:n,top:h,bottom:o,near:c,far:l,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:s,height:a,depth:n,rotation:h}=t,o=this.getCameraVector(r,h,{width:s,height:a,depth:n},e);return i?(this.updateCamera(i,r),new THREE__namespace.Vector3(i.x,i.y,i.z)):(this.updateCamera(o,r),o)}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,a;if(!e){const n=this.scene.getObjectByName(this.pointCloudObjectName);if(!n)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:n,zMax:h,polygonPointList:o}=matrix.getCuboidFromPointCloudBox(t),c=e;i=i!=null?i:new Float32Array([]);const l={boxParams:t,zMin:n,zMax:h,polygonPointList:o,color:i,position:c};return new Promise(d=>{const u=new filterBoxWorker;u.postMessage(l),u.onmessage=m=>{const{color:p,position:f,num:y}=m.data,x=new THREE__namespace.BufferGeometry;x.setAttribute("position",new THREE__namespace.Float32BufferAttribute(f,3)),x.setAttribute("color",new THREE__namespace.Float32BufferAttribute(p,3)),x.computeBoundingSphere(),u.terminate(),d({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,s=DEFAULT_DISTANCE){let a=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(s);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:a=lbUtils.PerspectiveShiftUtils.backViewMatrix4(s);break;case lbUtils.EPerspectiveView.Left:a=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(s);break;case lbUtils.EPerspectiveView.Right:a=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(s);break;case lbUtils.EPerspectiveView.Top:a=lbUtils.PerspectiveShiftUtils.topViewMatrix4(s);break;case lbUtils.EPerspectiveView.LFT:a=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(s,i);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(s,i);break}const n=this.createThreeMatrix4(a),h=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),o=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(n).applyMatrix4(h).applyMatrix4(c).applyMatrix4(o)}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}),a=new THREE__namespace.Line(r,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new THREE__namespace.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],s=t[e+2];this.store.cloudData.set(`${i}@${r}@${s}`,{visible:!1})}this.store.setOriginPoints(t)}}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((i,r)=>{if(window.Worker){const a=(t?[...t]:[]).map(o=>matrix.getCuboidFromPointCloudBox(o)),n=this.getAllAttributeColor(a),h={cuboidList:a,position:e.geometry.attributes.position.array,color:e.geometry.attributes.dimensions.array,colorList:n};highlightWorker.postMessage(h),highlightWorker.onmessage=o=>{const{color:c}=o.data,l=new THREE__namespace.BufferAttribute(c,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||e.geometry.attributes.position.array.length!==c.length){r(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,c),this.highlightPCDSrc=void 0,l.needsUpdate=!0,e.geometry.setAttribute("dimensions",l),e.geometry.attributes.dimensions.needsUpdate=!0,i(c),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((l,d)=>l.z-d.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:l})=>l>r.z+.1);const s=.005,a=Math.floor(e.length*(1-s));e=e.slice(0,a),e.sort((l,d)=>l.x-d.x);const n=Math.floor(e.length*s),h=Math.floor(e.length*(1-s));e=e.slice(n,h),e.sort((l,d)=>l.y-d.y);const o=Math.floor(e.length*s),c=Math.floor(e.length*(1-s));return e=e.slice(o,c),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:n,y:h})=>{t.forEach((o,c)=>{const l=r[c+1],d=MathUtils.default.getFootOfPerpendicular({x:n,y:h},o,l,!1,!0).length;(!i[c]||d<i[c].distance)&&(i[c]={distance:d,point:{x:n,y:h}})})}),r=[t[t.length-1],...t,t[0]];const s=[i[i.length-1],...i];return t.map((n,h)=>{const o=r[h],c=r[h+1],l=r[h+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:s[h].point,line1:[o,c],p2:s[h+1].point,line2:[c,l]})})}getSensesPointZAxisInPolygon(t,e,i){var r,s,a;const n=this.scene.children.find(p=>p.uuid===this.pointsUuid);let h=0,o=0,c=0,l=0,d=[],u=[];const m=((a=(s=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:s.position)==null?void 0:a.array)||[];for(let p=0;p<m.length;p+=3){const f=m[p],y=m[p+1],x=m[p+2];polygonTool.isInPolygon({x:f,y},t)&&(x||x===0)&&u.push({x:f,y,z:x})}return u.length?(i&&(u=this.filterNoise(u),d=this.getFittedCoordinates(t,u)),u.sort((p,f)=>p.z-f.z),h=u[0].z-.01,o=u[u.length-1].z+.01,l=u.length,e&&(c=u.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:o,minZ:h,count:c,zCount:l,fittedCoordinates:d}):{maxZ:o,minZ:h,count:c,zCount:l,fittedCoordinates:d}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:s,width:a,depth:n}=t,h={x:e+a/2,y:i+s/2,z:r-n/2},o={x:e+a/2,y:i+s/2,z:r+n/2},c={x:e-a/2,y:i+s/2,z:r+n/2},l={x:e-a/2,y:i+s/2,z:r-n/2};return[h,o,c,l]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:s,width:a,depth:n}=t,h={x:e-a/2,y:i+s/2,z:r+n/2},o={x:e-a/2,y:i+s/2,z:r-n/2},c={x:e-a/2,y:i-s/2,z:r-n/2},l={x:e-a/2,y:i-s/2,z:r+n/2};return[h,o,c,l]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:s,width:a,depth:n}=t,h={x:e+a/2,y:i+s/2,z:r+n/2},o={x:e+a/2,y:i-s/2,z:r+n/2},c={x:e-a/2,y:i-s/2,z:r+n/2},l={x:e-a/2,y:i+s/2,z:r+n/2};return[h,o,c,l]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:s}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),n=new THREE__namespace.Matrix4().makeTranslation(e,i,r),h=new THREE__namespace.Matrix4().makeRotationZ(s);return new THREE__namespace.Matrix4().multiply(n).multiply(h).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:s}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const h=i.map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.sideMatrix)),o=this.containerWidth/r,c=this.containerHeight/s;return{polygon2d:h,zoom:Math.min(o,c)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:s}=t,{radius:a}=lbUtils.DEFAULT_SPHERE_PARAMS,n={center:e,attribute:i,id:r,valid:s,width:a*2,height:a*2,depth:a*2,rotation:0},h=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),o=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(n)).premultiply(h).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=o;const c=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),l=this.containerWidth/(a*2),d=this.containerHeight/(a*2);return{point2d:c,zoom:Math.min(l,d)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=lbUtils.DEFAULT_SPHERE_PARAMS,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},s=this.containerWidth/(i*2),a=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(s,a)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,s=this.getPolygonTopPoints(t).map(h=>new THREE__namespace.Vector3(h.x,h.y,h.z)).map(h=>h.applyMatrix4(this.getModelTransformationMatrix(t))).map(h=>({x:h.y,y:h.x})).map(h=>({x:-(h.x-this.containerWidth/2),y:-(h.y-this.containerHeight/2)})),a=this.containerWidth/e,n=this.containerHeight/i;return{polygon2d:s,zoom:Math.min(a,n)/2}}getNewBoxBySideUpdate(t,e,i,r){const s=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(s);let n=r;return n.center={x:n.center.x+a.x,y:n.center.y+a.y,z:n.center.z-t.z},n=__spreadProps(__spreadValues({},n),{width:Math.abs(n.width+e),height:n.height,depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxByBackUpdate(t,e,i,r){const s=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(s);let n=r;return n.center={x:n.center.x+a.x,y:n.center.y+a.y,z:n.center.z-t.z},n=__spreadProps(__spreadValues({},n),{width:n.width,height:Math.abs(n.height+e),depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxBySideUpdateByPoints(t,e,i,r){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const n=t.map(f=>new THREE__namespace.Vector3(f.x,f.y,f.z)).map(f=>f.applyMatrix4(a)),[h,o,c,l]=n,d=Math.max(Math.abs(h.x-c.x),Math.abs(h.x-o.x)),m=o.add(l).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:__spreadProps(__spreadValues({},r),{center:{x:r.center.x-m.x,y:r.center.y-m.y,z:r.center.z-i},width:d,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,s=[],{count:a}=r;for(let n=0;n<a;n++){const h=r.getZ(n);s.push(h>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.lidar2image=matrix.lidar2image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
31
+ }`,uniforms:{pointSize:{value:1.2}}}),this.loadPCDFile=(...s)=>__async(this,[...s],function*(a=this.currentPCDSrc,c){if(!a)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=a;const{points:d,color:p}=yield this.cacheInstance.loadPCDFile(a),m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.BufferAttribute(d,3)),this.isSegment||m.setAttribute("dimensions",new THREE__namespace.BufferAttribute(p,3)),this.initCloudData(d);const u=new THREE__namespace.Points(m);this.renderPointCloud(u,c)}),this.getHighlightIndexByMappingImgList=s=>__async(this,[s],function*({mappingImgList:a,points:c}){const d=yield Promise.all(a.map(u=>ImgUtils.load(u.url))),p=a.map((u,g)=>{var y;if(this.cacheInstance.cache2DHighlightIndex.has(u.url))return(y=this.cacheInstance.cache2DHighlightIndex.get(u.url))!=null?y:[];const x=matrix.getHighlightIndexByPoints({points:c,calib:u.calib,width:d[g].width,height:d[g].height});return this.cacheInstance.cache2DHighlightIndex.set(u.url,x),x});return matrix.mergeHighlightList(p)}),this.loadPCDFileByBox=(s,a,c)=>__async(this,null,function*(){const d=(u,g)=>__async(this,null,function*(){const{width:y=0,height:x=0,depth:w=0}=c!=null?c:{},b=yield this.filterPointsByBox(__spreadProps(__spreadValues({},a),{width:a.width+y,height:a.height+x,depth:a.depth+w}),u,g);if(!b){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=s;const C=new THREE__namespace.Points(b.geometry);C.name=this.pointCloudObjectName,this.scene.add(C),this.render()}),{points:p,color:m}=yield this.cacheInstance.loadPCDFile(s);d(p,m)}),this.generateRange=s=>{const a=this.createRange(s);this.scene.add(a)},this.generateBoxArrow=({width:s})=>{const a=new THREE__namespace.Vector3(1,0,0),c=new THREE__namespace.Vector3(s/2,0,0),d=2,p=16776960,m=new THREE__namespace.ArrowHelper(a,c,d,p);return m.visible=this.showDirection,m},this.generateBoxTrackID=s=>{if(!s.trackID)return;const a=new THREE__namespace.Texture(this.getTextCanvas(s.trackID.toString()));a.needsUpdate=!0;const c=new THREE__namespace.SpriteMaterial({map:a,depthWrite:!1}),d=new THREE__namespace.Sprite(c);return d.scale.set(5,5,5),d.position.set(-s.width/2,0,s.depth/2+.5),d},this.applyZAxisPoints=s=>{this.zAxisLimit=s,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:s,customSize:a})=>{const c=this.scene.getObjectByName(this.pointCloudObjectName);if(!c)return;const d=c.material.uniforms.pointSize.value;s?c.material.uniforms.pointSize.value=Math.min(d*1.2,10):c.material.uniforms.pointSize.value=Math.max(d/1.2,1),a&&(c.material.uniforms.pointSize.value=a,this.pointsMaterialSize=a),c.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=o,this.config=h,this.checkMode=l!=null?l:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,n?this.container:this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance(),n===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new index(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new segmentation.PointCloudSegmentOperation({dom:this.container,store:this.store}),this.pointCloudRender=new index$1(__spreadProps(__spreadValues({store:this.store},this.eventBus),{nextTick:this.nextTick,config:this.config})),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("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("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},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){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:o,near:h,far:n}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=o,this.camera.near=h,this.camera.far=n,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()}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,o=10,h=e.x-i/2-o,n=e.x-i/2+o,l=e.y+r/2+o,s=e.y-r/2-o,a=100,c=-100,d=500/a;return{left:h,right:n,top:l,bottom:s,near:a,far:c,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:o,height:h,depth:n,rotation:l}=t,s=this.getCameraVector(r,l,{width:o,height:h,depth:n},e);return i?(this.updateCamera(i,r),new THREE__namespace.Vector3(i.x,i.y,i.z)):(this.updateCamera(s,r),s)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=lbUtils.DEFAULT_SPHERE_PARAMS,o=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,o,h;if(!e){const n=this.scene.getObjectByName(this.pointCloudObjectName);if(!n)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(h=(o=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:h.array}if(window.Worker){const{zMin:n,zMax:l,polygonPointList:s}=matrix.getCuboidFromPointCloudBox(t),a=e;i=i!=null?i:new Float32Array([]);const c={boxParams:t,zMin:n,zMax:l,polygonPointList:s,color:i,position:a};return new Promise(d=>{const p=new filterBoxWorker;p.postMessage(c),p.onmessage=m=>{const{color:u,position:g,num:y}=m.data,x=new THREE__namespace.BufferGeometry;x.setAttribute("position",new THREE__namespace.Float32BufferAttribute(g,3)),x.setAttribute("color",new THREE__namespace.Float32BufferAttribute(u,3)),x.computeBoundingSphere(),p.terminate(),d({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,o=DEFAULT_DISTANCE){let h=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(o);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:h=lbUtils.PerspectiveShiftUtils.backViewMatrix4(o);break;case lbUtils.EPerspectiveView.Left:h=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(o);break;case lbUtils.EPerspectiveView.Right:h=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(o);break;case lbUtils.EPerspectiveView.Top:h=lbUtils.PerspectiveShiftUtils.topViewMatrix4(o);break;case lbUtils.EPerspectiveView.LFT:h=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(o,i);break;case lbUtils.EPerspectiveView.RBT:h=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(o,i);break}const n=this.createThreeMatrix4(h),l=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),s=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),a=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(n).applyMatrix4(l).applyMatrix4(a).applyMatrix4(s)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new THREE__namespace.BufferGeometry().setFromPoints(i),o=new THREE__namespace.LineBasicMaterial({color:16711680}),h=new THREE__namespace.Line(r,o);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],o=t[e+2];this.store.cloudData.set(`${i}@${r}@${o}`,{visible:!1})}this.store.setOriginPoints(t)}}highlightOriginPointCloud(t,e=[]){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!!i)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((r,o)=>{if(window.Worker){const n=(t?[...t]:[]).map(a=>matrix.getCuboidFromPointCloudBox(a)),l=this.getAllAttributeColor(n),s={cuboidList:n,position:i.geometry.attributes.position.array,color:i.geometry.attributes.dimensions.array,colorList:l,highlightIndex:e};highlightWorker.postMessage(s),highlightWorker.onmessage=a=>{const{color:c}=a.data,d=new THREE__namespace.BufferAttribute(c,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||i.geometry.attributes.position.array.length!==c.length){o(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,c),this.highlightPCDSrc=void 0,d.needsUpdate=!0,i.geometry.setAttribute("dimensions",d),i.geometry.attributes.dimensions.needsUpdate=!0,r(c),this.render()}}})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new THREE__namespace.Group;t.forEach(i=>{const{center:{x:r,y:o,z:h},width:n,height:l,depth:s,rotation:a}=i,{fill:c}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),d=new THREE__namespace.BoxGeometry(n,l,s),p=new THREE__namespace.MeshBasicMaterial({color:c,transparent:!0,opacity:.2,depthTest:!1});d.rotateZ(a),d.translate(r,o,h);const m=new THREE__namespace.Mesh(d,p);e.add(m);const u=new THREE__namespace.PlaneGeometry(s,l);u.rotateY(Math.PI/2),u.rotateZ(a);const g=new THREE__namespace.Vector3(n/2,0,0),y=new THREE__namespace.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(a);g.applyMatrix4(y),u.translate(r+g.x,o+g.y,h+g.z);const x=new THREE__namespace.MeshBasicMaterial({color:c,side:THREE__namespace.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),w=new THREE__namespace.Mesh(u,x);e.add(w)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((c,d)=>c.z-d.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:c})=>c>r.z+.1);const o=.005,h=Math.floor(e.length*(1-o));e=e.slice(0,h),e.sort((c,d)=>c.x-d.x);const n=Math.floor(e.length*o),l=Math.floor(e.length*(1-o));e=e.slice(n,l),e.sort((c,d)=>c.y-d.y);const s=Math.floor(e.length*o),a=Math.floor(e.length*(1-o));return e=e.slice(s,a),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:n,y:l})=>{t.forEach((s,a)=>{const c=r[a+1],d=MathUtils.default.getFootOfPerpendicular({x:n,y:l},s,c,!1,!0).length;(!i[a]||d<i[a].distance)&&(i[a]={distance:d,point:{x:n,y:l}})})}),r=[t[t.length-1],...t,t[0]];const o=[i[i.length-1],...i];return t.map((n,l)=>{const s=r[l],a=r[l+1],c=r[l+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:o[l].point,line1:[s,a],p2:o[l+1].point,line2:[a,c]})})}getSensesPointZAxisInPolygon(t,e,i){var r,o,h;const n=this.scene.children.find(u=>u.uuid===this.pointsUuid);let l=0,s=0,a=0,c=0,d=[],p=[];const m=((h=(o=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:h.array)||[];for(let u=0;u<m.length;u+=3){const g=m[u],y=m[u+1],x=m[u+2];polygonTool.isInPolygon({x:g,y},t)&&(x||x===0)&&p.push({x:g,y,z:x})}return p.length?(i&&(p=this.filterNoise(p),d=this.getFittedCoordinates(t,p)),p.sort((u,g)=>u.z-g.z),l=p[0].z-.01,s=p[p.length-1].z+.01,c=p.length,e&&(a=p.filter(({z:u})=>u>=e[0]&&u<=e[1]).length),{maxZ:s,minZ:l,count:a,zCount:c,fittedCoordinates:d}):{maxZ:s,minZ:l,count:a,zCount:c,fittedCoordinates:d}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:o,width:h,depth:n}=t,l={x:e+h/2,y:i+o/2,z:r-n/2},s={x:e+h/2,y:i+o/2,z:r+n/2},a={x:e-h/2,y:i+o/2,z:r+n/2},c={x:e-h/2,y:i+o/2,z:r-n/2};return[l,s,a,c]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:o,width:h,depth:n}=t,l={x:e-h/2,y:i+o/2,z:r+n/2},s={x:e-h/2,y:i+o/2,z:r-n/2},a={x:e-h/2,y:i-o/2,z:r-n/2},c={x:e-h/2,y:i-o/2,z:r+n/2};return[l,s,a,c]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:o,width:h,depth:n}=t,l={x:e+h/2,y:i+o/2,z:r+n/2},s={x:e+h/2,y:i-o/2,z:r+n/2},a={x:e-h/2,y:i-o/2,z:r+n/2},c={x:e-h/2,y:i+o/2,z:r+n/2};return[l,s,a,c]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:o}=t,h=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),n=new THREE__namespace.Matrix4().makeTranslation(e,i,r),l=new THREE__namespace.Matrix4().makeRotationZ(o);return new THREE__namespace.Matrix4().multiply(n).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:o}=t,h=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(h).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const l=i.map(c=>new THREE__namespace.Vector3(c.x,c.y,c.z)).map(c=>c.applyMatrix4(this.sideMatrix)),s=this.containerWidth/r,a=this.containerHeight/o;return{polygon2d:l,zoom:Math.min(s,a)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:o}=t,{radius:h}=lbUtils.DEFAULT_SPHERE_PARAMS,n={center:e,attribute:i,id:r,valid:o,width:h*2,height:h*2,depth:h*2,rotation:0},l=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(n)).premultiply(l).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const a=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),c=this.containerWidth/(h*2),d=this.containerHeight/(h*2);return{point2d:a,zoom:Math.min(c,d)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=lbUtils.DEFAULT_SPHERE_PARAMS,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},o=this.containerWidth/(i*2),h=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(o,h)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,o=this.getPolygonTopPoints(t).map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.getModelTransformationMatrix(t))).map(l=>({x:l.y,y:l.x})).map(l=>({x:-(l.x-this.containerWidth/2),y:-(l.y-this.containerHeight/2)})),h=this.containerWidth/e,n=this.containerHeight/i;return{polygon2d:o,zoom:Math.min(h,n)/2}}getNewBoxBySideUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),h=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(o);let n=r;return n.center={x:n.center.x+h.x,y:n.center.y+h.y,z:n.center.z-t.z},n=__spreadProps(__spreadValues({},n),{width:Math.abs(n.width+e),height:n.height,depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxByBackUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),h=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(o);let n=r;return n.center={x:n.center.x+h.x,y:n.center.y+h.y,z:n.center.z-t.z},n=__spreadProps(__spreadValues({},n),{width:n.width,height:Math.abs(n.height+e),depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxBySideUpdateByPoints(t,e,i,r){var o;const h=(o=this.sideMatrix)==null?void 0:o.invert();if(!this.sideMatrix||!h){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const n=t.map(g=>new THREE__namespace.Vector3(g.x,g.y,g.z)).map(g=>g.applyMatrix4(h)),[l,s,a,c]=n,d=Math.max(Math.abs(l.x-a.x),Math.abs(l.x-s.x)),m=s.add(c).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:__spreadProps(__spreadValues({},r),{center:{x:r.center.x-m.x,y:r.center.y-m.y,z:r.center.z-i},width:d,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,o=[],{count:h}=r;for(let n=0;n<h;n++){const l=r.getZ(n);o.push(l>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(o,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isInImage=matrix.isInImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.point2dTo3D=matrix.point2dTo3D,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,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");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 o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{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,__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){const o=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),i=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),s=createThreeMatrix4(o),l=createThreeMatrix4(i),c=createThreeMatrix4(n);return{composeMatrix4:c.clone().premultiply(l).premultiply(s),PM:s,RM:l,TM:c}}function rotatePoint(e,t,r){var o;const i=new THREE__namespace.Vector3(e.x,e.y,(o=e==null?void 0:e.z)!=null?o:1),n=new THREE__namespace.Matrix4().makeRotationZ(r),s=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),l=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(l).applyMatrix4(n).applyMatrix4(s)}function lidar2image(e,t){const o=new THREE__namespace.Vector4(e.x,e.y,e.z).applyMatrix4(t);if(o.z<0)return;const i=1/o.z,n=new THREE__namespace.Matrix4().set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,1);return o.applyMatrix4(n)}function getCuboidFromPointCloudBox(e){const{center:t,width:r,height:o,depth:i,rotation:n}=e,s=[{x:t.x+r/2,y:t.y-o/2},{x:t.x+r/2,y:t.y+o/2},{x:t.x-r/2,y:t.y+o/2},{x:t.x-r/2,y:t.y-o/2}].map(u=>{const x=rotatePoint(u,t,n);return{x:x.x,y:x.y}}),l=t.z+i/2,c=t.z-i/2;return __spreadProps(__spreadValues({},e),{polygonPointList:s,zMax:l,zMin:c})}function sortPoints(e){const t=e.slice();return t.sort((r,o)=>r.x===o.x?o.y-r.y:r.x-o.x),t}function crossProduct(e,t,r){const o=t.x-e.x,i=t.y-e.y,n=r.x-e.x,s=r.y-e.y;return o*s-n*i}function buildConvexHull(e){const t=sortPoints(e),r=[];for(let n=0;n<t.length;n++){for(;r.length>=2&&crossProduct(r[r.length-2],r[r.length-1],t[n])<=0;)r.pop();r.push(t[n])}const o=[];for(let n=t.length-1;n>=0;n--){for(;o.length>=2&&crossProduct(o[o.length-2],o[o.length-1],t[n])<=0;)o.pop();o.push(t[n])}return r.pop(),o.pop(),r.concat(o)}function pointCloudLidar2image(e,t,r={createRange:!1}){const{createRange:o}=r,i=lbUtils.PointCloudUtils.getAllViewData(e),{P:n,R:s,T:l}=t,{composeMatrix4:c}=transferKitti2Matrix(n,s,l),u=i.map(p=>({type:p.type,pointList:p.pointList.map(a=>rotatePoint(a,e.center,e.rotation)).map(a=>lidar2image(a,c)).map(a=>{if(!!a)return{id:uuid(),x:a==null?void 0:a.x,y:a==null?void 0:a.y}}).filter(a=>a!==void 0)})).filter(p=>p.pointList.length!==0);let x=[];if(u.length===6&&o===!0){const p=u[0].pointList,a=u[1].pointList;x=buildConvexHull([...p,...a])}return{transferViewData:u,viewRangePointList:x}}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.lidar2image=lidar2image,exports.pointCloudLidar2image=pointCloudLidar2image,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");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,__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){const n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),i=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),o=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),s=createThreeMatrix4(n),c=createThreeMatrix4(i),l=createThreeMatrix4(o);return{composeMatrix4:l.clone().premultiply(c).premultiply(s),PM:s,RM:c,TM:l}}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),s=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(c).applyMatrix4(o).applyMatrix4(s)}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,s=[{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(u=>{const x=rotatePoint(u,t,o);return{x:x.x,y:x.y}}),c=t.z+i/2,l=t.z-i/2;return __spreadProps(__spreadValues({},e),{polygonPointList:s,zMax:c,zMin:l})}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,s=r.y-e.y;return n*s-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)=>{const{P:r,R:n,T:i}=t,{composeMatrix4:o}=transferKitti2Matrix(r,n,i);return lidar2image(e,o)},point2dTo3D=(e,t)=>{const{P:r,R:n,T:i}=t,{composeMatrix4:o}=transferKitti2Matrix(r,n,i);return new THREE__namespace.Vector4(e.x,e.y,e.z).applyMatrix4(o.invert())},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 s=e[o],c=e[o+1],l=e[o+2];isInImage({point:{x:s,y:c,z:l},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}){const{createRange:n}=r,i=lbUtils.PointCloudUtils.getAllViewData(e),{P:o,R:s,T:c}=t,{composeMatrix4:l}=transferKitti2Matrix(o,s,c),u=i.map(p=>({type:p.type,pointList:p.pointList.map(a=>rotatePoint(a,e.center,e.rotation)).map(a=>lidar2image(a,l)).map(a=>{if(!!a)return{id:uuid(),x:a==null?void 0:a.x,y:a==null?void 0:a.y}}).filter(a=>a!==void 0)})).filter(p=>p.pointList.length!==0);let x=[];if(u.length===6&&n===!0){const p=u[0].pointList,a=u[1].pointList;x=buildConvexHull([...p,...a])}return{transferViewData:u,viewRangePointList:x}}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=getHighlightIndexByPoints,exports.isInImage=isInImage,exports.lidar2image=lidar2image,exports.mergeHighlightList=mergeHighlightList,exports.point2dTo3D=point2dTo3D,exports.point3DLidar2Image=point3DLidar2Image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
@@ -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.rightMouseUp=s=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.selection.setSelectedIDs(this.hoverID,s.ctrlKey),this.emit("setSelectedIDs",this.selection.selectedIDs);const a=(d=this.polygonList.find(h=>h.id===this.hoverID))==null?void 0:d.attribute;a&&a!==this.defaultAttribute&&this.emit("syncAttribute",a)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=s=>{var d;if(s){const a=this.getPointCloudLineColor(s),h=AxisUtils.default.changePointListByZoom(s.pointList,this.zoom,this.currentPos);DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,h,{fillColor:"transparent",strokeColor:a,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(d=this.config)==null?void 0:d.lineType}),s.isRect===!0&&this.showDirectionLine===!0&&(this.renderRectPolygonDirection(h),(s==null?void 0:s.trackID)&&this.renderdrawTrackID(s))}},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygonList:s}=this.dragInfo;if(this.selectedIDs.length>0){const d=[];this.polygonList.forEach(a=>{if(this.selectedIDs.includes(a.id)){const h=s.find(u=>u.id===a.id);h&&d.push({newPolygon:a,originPolygon:h})}}),this.emit("updatePolygonByDrag",d)}}};var e,i,o,l,r,c;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=CommonToolUtils.jsonParser(t.config))!=null?o:{},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:(c=(r=this.pointCloudConfig)==null?void 0:r.attributeList)!=null?c:[]})}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 o=___default.default.cloneDeep(this.selectedPolygons),l=[];(i=this.selectedPolygons)==null||i.forEach((r,c)=>{r.pointList=r.pointList.map(s=>{var d,a;const{x:h,y:u}=s;return __spreadProps(__spreadValues({},s),{x:h+((d=t.x)!=null?d:0),y:u+((a=t.y)!=null?a:0)})}),l.push({originPolygon:o[c],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,o,l;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const r=this.getPointCloudLineColor(e),c=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,c,{fillColor:"transparent",strokeColor:r,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(l=this.config)==null?void 0:l.lineType}),(e==null?void 0:e.trackID)&&this.renderdrawTrackID(e),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(c)}))}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],o=t==null?void 0:t.trackID;DrawUtils.drawText(this.canvas,i,`${o}`,__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(o=>{var l,r,c,s;return __spreadProps(__spreadValues({},o),{x:(r=(l=o.pointList[0])==null?void 0:l.x)!=null?r:0,y:(s=(c=o.pointList[0])==null?void 0:c.y)!=null?s: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 o=this.selectedID;t!==o&&o&&((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 o=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(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);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])}}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"),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),(o==null?void 0:o.trackID)&&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}),(e==null?void 0:e.trackID)&&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){if(e){super.setPolygonValidAndRender(t);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;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.lidar2image=matrix.lidar2image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isInImage=matrix.isInImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.point2dTo3D=matrix.point2dTo3D,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
@@ -11,6 +11,7 @@ export declare class PointCloudCache {
11
11
  private colorMap;
12
12
  private cacheList;
13
13
  private static instance;
14
+ cache2DHighlightIndex: Map<string, number[]>;
14
15
  private constructor();
15
16
  static getInstance(): PointCloudCache;
16
17
  /**
@@ -23,4 +24,8 @@ export declare class PointCloudCache {
23
24
  points: Float32Array;
24
25
  color: Float32Array;
25
26
  }>;
27
+ /**
28
+ * Clear all cache2dHighlightIndex.
29
+ */
30
+ clearCache2DHighlightIndex(): void;
26
31
  }
@@ -4,7 +4,7 @@
4
4
  * @author Ron <ron.f.luo@gmail.com>
5
5
  */
6
6
  import * as THREE from 'three';
7
- import { TMatrix4Tuple, EPerspectiveView, IVolume, IPointCloudBox, IPointCloudSphere, I3DSpaceCoord, IPointCloudConfig } from '@labelbee/lb-utils';
7
+ import { TMatrix4Tuple, EPerspectiveView, IVolume, IPointCloudBox, IPointCloudSphere, I3DSpaceCoord, IPointCloudConfig, ICalib } from '@labelbee/lb-utils';
8
8
  import { OrthographicCamera, PerspectiveCamera } from 'three';
9
9
  import { IPolygonPoint } from '@/types/tool/polygon';
10
10
  import { PCDLoader } from './PCDLoader';
@@ -64,6 +64,7 @@ export declare class PointCloud extends EventListener {
64
64
  private backgroundColor;
65
65
  private pointCloudObjectName;
66
66
  private rangeObjectName;
67
+ private highlightGroupName;
67
68
  private cacheInstance;
68
69
  private showDirection;
69
70
  private currentPCDSrc?;
@@ -84,6 +85,7 @@ export declare class PointCloud extends EventListener {
84
85
  orbiterChange(): void;
85
86
  orbiterEnd(): void;
86
87
  get currentSegmentTool(): "LassoSelector" | "CircleSelector" | undefined;
88
+ get pointCloudObject(): THREE.Points<THREE.BufferGeometry, THREE.Material | THREE.Material[]>;
87
89
  initMsg(): void;
88
90
  unbindMsg(): void;
89
91
  nextTick: () => void;
@@ -230,12 +232,30 @@ export declare class PointCloud extends EventListener {
230
232
  * @param radius Render the range of circle
231
233
  */
232
234
  loadPCDFile: (src?: string | undefined, radius?: number) => Promise<void>;
235
+ /**
236
+ * Highlight PointCloud by MappingImgList.
237
+ * @param param0
238
+ * @returns
239
+ */
240
+ getHighlightIndexByMappingImgList: ({ mappingImgList, points, }: {
241
+ mappingImgList: Array<{
242
+ url: string;
243
+ calib: ICalib;
244
+ }>;
245
+ points: ArrayLike<number>;
246
+ }) => Promise<number[]>;
233
247
  /**
234
248
  * It needs to be updated after load PointCloud's data.
235
249
  * @param boxParams
236
250
  * @returns
237
251
  */
238
- highlightOriginPointCloud(pointCloudBoxList?: IPointCloudBox[]): Promise<THREE.BufferAttribute[] | undefined> | undefined;
252
+ highlightOriginPointCloud(pointCloudBoxList?: IPointCloudBox[], highlightIndex?: number[]): Promise<THREE.BufferAttribute[] | undefined> | undefined;
253
+ /**
254
+ * Clean all highlightBox
255
+ */
256
+ clearHighlightBoxes(): void;
257
+ clearHighlightBoxesAndRender(): void;
258
+ highlightBoxes(boxes: IPointCloudBox[]): void;
239
259
  updateColor(color: any[]): void;
240
260
  /**
241
261
  * Load PCD File by box
@@ -2,7 +2,7 @@
2
2
  * The set of Matrix multiplication
3
3
  */
4
4
  import * as THREE from 'three';
5
- import { TMatrix4Tuple, IPointCloudBox, I3DSpaceCoord, TMatrix14Tuple, TMatrix13Tuple, IPolygonPoint } from '@labelbee/lb-utils';
5
+ import { TMatrix4Tuple, IPointCloudBox, I3DSpaceCoord, TMatrix14Tuple, TMatrix13Tuple, IPolygonPoint, ICalib } from '@labelbee/lb-utils';
6
6
  export declare function createThreeMatrix4(matrix4: TMatrix4Tuple): THREE.Matrix4;
7
7
  /**
8
8
  * Transfer the Kitti format (defined by array) to Three Matrix (flatten array)
@@ -49,6 +49,34 @@ export declare function getCuboidFromPointCloudBox(boxParams: IPointCloudBox): {
49
49
  height: number;
50
50
  depth: number;
51
51
  };
52
+ export declare const point3DLidar2Image: (point: {
53
+ x: number;
54
+ y: number;
55
+ z: number;
56
+ }, cameraMatrix: ICalib) => THREE.Vector4 | undefined;
57
+ export declare const point2dTo3D: (point: {
58
+ x: number;
59
+ y: number;
60
+ z: number;
61
+ }, cameraMatrix: ICalib) => THREE.Vector4;
62
+ export declare const isInImage: ({ point, calib, width, height, }: {
63
+ point: I3DSpaceCoord;
64
+ calib: ICalib;
65
+ width: number;
66
+ height: number;
67
+ }) => boolean;
68
+ export declare const getHighlightIndexByPoints: ({ points, calib, width, height, }: {
69
+ points: ArrayLike<number>;
70
+ calib: ICalib;
71
+ width: number;
72
+ height: number;
73
+ }) => number[];
74
+ /**
75
+ * Merge numberList between 1 and 0.
76
+ * @param indexList
77
+ * @returns
78
+ */
79
+ export declare const mergeHighlightList: (indexList: number[][]) => number[];
52
80
  export declare function pointCloudLidar2image(boxParams: IPointCloudBox, cameraMatrix: {
53
81
  P: [TMatrix14Tuple, TMatrix14Tuple, TMatrix14Tuple];
54
82
  R: [TMatrix13Tuple, TMatrix13Tuple, TMatrix13Tuple];
@@ -13,6 +13,7 @@ declare class PointCloud2dOperation extends PolygonOperation {
13
13
  forbidAddNew: boolean;
14
14
  pointCloudConfig: IPointCloudConfig;
15
15
  private checkMode;
16
+ private highlightAttributeList;
16
17
  constructor(props: IPolygonOperationProps & IPointCloud2dOperationProps);
17
18
  get getSelectedIDs(): string[];
18
19
  get enableDrag(): boolean;
@@ -106,6 +107,7 @@ declare class PointCloud2dOperation extends PolygonOperation {
106
107
  */
107
108
  setResultAndSelectedID(polygonList: IPolygonData[], selectedID: string): void;
108
109
  emitUpdatePolygonByDrag: () => void;
110
+ setHighlightAttribute(attribute: string): void;
109
111
  }
110
112
  export default PointCloud2dOperation;
111
113
  export { IPointCloud2dOperationProps };
@@ -1 +1 @@
1
- import{createBase64WorkerFactory as d}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var s=d("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGcodCl7Y29uc3QgZT0tNyxvPTMsaT1vLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5vJiYodD1vKSxNYXRoLmZsb29yKCh0LWUpL2kqMjU1KX1mdW5jdGlvbiBwKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBvPTA7bzwyMDtvKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPXAoKTtmdW5jdGlvbiBtKHQsZSxvPTApe2xldCBpPTAscyxhLHIsbjtlPVsuLi5lXSxvPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsbCk9PlsuLi5jLGwueCxsLnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IHU9ZS5sZW5ndGg7Zm9yKHM9MTtzPD11O3MrKyluPWVbcyV1XSx0Lng+TWF0aC5taW4oci54LG4ueCkmJnQueDw9TWF0aC5tYXgoci54LG4ueCkmJnQueTw9TWF0aC5tYXgoci55LG4ueSkmJnIueCE9PW4ueCYmKGE9KHQueC1yLngpKihuLnktci55KS8obi54LXIueCkrci55LChyLnk9PT1uLnl8fHQueTw9YSkmJmkrKykscj1uO3JldHVybiBpJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0Om8sYXR0cmlidXRlOmkseDpzLHk6YSx6OnIsY29sb3JMaXN0Om4sdmFsaWQ6dX0pe2lmKG0oe3g6cyx5OmF9LG8pJiZyPj10JiZyPD1lKXJldHVybiB1PT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpuW2ldP25baV0ucmdiYS5zbGljZSgwLDMpLm1hcChsPT5sLzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOm8sY29sb3I6aSxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmF9PWUuZGF0YTtsZXQgcj0wO2ZvcihsZXQgbj0wO248by5sZW5ndGg7bis9Myl7Y29uc3QgdT1vW25dLGM9b1tuKzFdLGw9b1tuKzJdLGQ9cy5tYXAoZj0+Yih7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDp1LHk6Yyx6OmwsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDphLHZhbGlkOmYudmFsaWR9KSkuZmlsdGVyKGY9PmYpLnBvcCgpO2lmKGQpe3IrKztjb25zdFtmLHksTV09ZDtpW25dPWYsaVtuKzFdPXksaVtuKzJdPU19ZWxzZXtjb25zdCBmPWcobCkseT1DW2ZdLFtNLHcsX109eTtpW25dPU0vMjU1LGlbbisxXT13LzI1NSxpW24rMl09Xy8yNTV9fXBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjppLG51bTpyfSl9LHguaXNJblBvbHlnb249bSxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);export{s as default};
1
+ import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var d=b("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHAodCl7Y29uc3QgZT0tNyxpPTMsbz1pLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5pJiYodD1pKSxNYXRoLmZsb29yKCh0LWUpL28qMjU1KX1mdW5jdGlvbiBoKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBpPTA7aTwyMDtpKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPWgoKTtmdW5jdGlvbiBkKHQsZSxpPTApe2xldCBvPTAscyxhLHIsZjtlPVsuLi5lXSxpPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsdSk9PlsuLi5jLHUueCx1LnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IG49ZS5sZW5ndGg7Zm9yKHM9MTtzPD1uO3MrKylmPWVbcyVuXSx0Lng+TWF0aC5taW4oci54LGYueCkmJnQueDw9TWF0aC5tYXgoci54LGYueCkmJnQueTw9TWF0aC5tYXgoci55LGYueSkmJnIueCE9PWYueCYmKGE9KHQueC1yLngpKihmLnktci55KS8oZi54LXIueCkrci55LChyLnk9PT1mLnl8fHQueTw9YSkmJm8rKykscj1mO3JldHVybiBvJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0OmksYXR0cmlidXRlOm8seDpzLHk6YSx6OnIsY29sb3JMaXN0OmYsdmFsaWQ6bn0pe2lmKGQoe3g6cyx5OmF9LGkpJiZyPj10JiZyPD1lKXJldHVybiBuPT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpmW29dP2Zbb10ucmdiYS5zbGljZSgwLDMpLm1hcCh1PT51LzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOmksY29sb3I6byxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmEsaGlnaGxpZ2h0SW5kZXg6cn09ZS5kYXRhO2xldCBmPTA7Zm9yKGxldCBuPTA7bjxpLmxlbmd0aDtuKz0zKXtjb25zdCBjPWlbbl0sdT1pW24rMV0sZz1pW24rMl0sbT1zLm1hcChsPT5iKHtwb2x5Z29uUG9pbnRMaXN0OmwucG9seWdvblBvaW50TGlzdCx6TWluOmwuek1pbix6TWF4Omwuek1heCx4OmMseTp1LHo6ZyxhdHRyaWJ1dGU6bC5hdHRyaWJ1dGUsY29sb3JMaXN0OmEsdmFsaWQ6bC52YWxpZH0pKS5maWx0ZXIobD0+bCkucG9wKCk7aWYobSl7ZisrO2NvbnN0W2wseSxNXT1tO29bbl09bCxvW24rMV09eSxvW24rMl09TX1lbHNle2NvbnN0IGw9TWF0aC5mbG9vcihuLzMpO2lmKHImJnJbbF09PT0xKW9bbl09MCxvW24rMV09MCxvW24rMl09MDtlbHNle2NvbnN0IHk9cChnKSxNPUNbeV0sW3csSSxfXT1NO29bbl09dy8yNTUsb1tuKzFdPUkvMjU1LG9bbisyXT1fLzI1NX19fXBvc3RNZXNzYWdlKHtwb2ludHM6aSxjb2xvcjpvLG51bTpmfSl9LHguaXNJblBvbHlnb249ZCxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);export{d as default};
@@ -1 +1 @@
1
- import{PCDLoader as h}from"./PCDLoader.js";class i{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((s,c)=>{const e=this.pointsMap.get(t),a=this.colorMap.get(t);if(e&&a){s({points:e,color:a});return}if(this.cacheList.length>this.MAX_SIZE){const o=this.cacheList.shift();o&&this.pointsMap.delete(o.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,o=>{const n=o.geometry.attributes.position.array,r=o.geometry.attributes.color.array;this.pointsMap.set(t,n),this.colorMap.set(t,r),s({points:n,color:r})},()=>{},o=>{c(o)})}),this.pcdLoader=new h,this.pointsMap=new Map,this.colorMap=new Map}static getInstance(){return this.instance==null&&(this.instance=new i),this.instance}updateColor(t,s){this.colorMap.set(t,s)}}export{i as PointCloudCache};
1
+ import{PCDLoader as r}from"./PCDLoader.js";class e{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((s,c)=>{const o=this.pointsMap.get(t),a=this.colorMap.get(t);if(o&&a){s({points:o,color:a});return}if(this.cacheList.length>this.MAX_SIZE){const i=this.cacheList.shift();i&&this.pointsMap.delete(i.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,i=>{const h=i.geometry.attributes.position.array,n=i.geometry.attributes.color.array;this.pointsMap.set(t,h),this.colorMap.set(t,n),s({points:h,color:n})},()=>{},i=>{c(i)})}),this.pcdLoader=new r,this.pointsMap=new Map,this.colorMap=new Map,this.cache2DHighlightIndex=new Map}static getInstance(){return this.instance==null&&(this.instance=new e),this.instance}updateColor(t,s){this.colorMap.set(t,s)}clearCache2DHighlightIndex(){this.cache2DHighlightIndex.clear()}}export{e as PointCloudCache};
@@ -1,4 +1,4 @@
1
- import*as c from"three";import{toolStyleConverter as O,PerspectiveShiftUtils as v,EPerspectiveView as C,PointCloudUtils as N,DEFAULT_SPHERE_PARAMS as z}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import F from"../../_virtual/filterBoxWorker.js";import{isInPolygon as R}from"../../utils/tool/polygonTool.js";import A from"../../utils/uuid.js";import W from"../../utils/MathUtils.js";import{PCDLoader as Z}from"./PCDLoader.js";import{OrbitControls as U}from"./OrbitControls.js";import{PointCloudCache as H}from"./cache.js";import{getCuboidFromPointCloudBox as k}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import{PointCloudSegmentOperation as G}from"./segmentation.js";import $ from"./store/index.js";import X from"./render/index.js";import Y from"../toolOperation/eventListener.js";import"../../constant/tool.js";import"../scheduler.js";var q=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,j=(w,t,e)=>t in w?q(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,b=(w,t)=>{for(var e in t||(t={}))J.call(t,e)&&j(w,e,t[e]);if(_)for(var e of _(t))tt.call(t,e)&&j(w,e,t[e]);return w},P=(w,t)=>K(w,Q(t)),T=(w,t,e)=>new Promise((i,r)=>{var s=l=>{try{n(e.next(l))}catch(o){r(o)}},a=l=>{try{n(e.throw(l))}catch(o){r(o)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,a);n((e=e.apply(w,t)).next())});const et=30,L=new V({type:"module"});class it extends Y{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:s="#4C4C4C",config:a,isSegment:n,checkMode:l}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,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,h="blue")=>{var d;const u=(d=o.id)!=null?d:A();this.removeObjectByName(u,"sphere");const{radius:m,widthSegments:g,heightSegments:p}=z,{center:f}=o,x=new c.Group,y=new c.SphereGeometry(m,g,p),S=new c.MeshBasicMaterial({color:h}),M=new c.Mesh(y,S);M.position.set(f.x,f.y,f.z),x.add(M),x.name=`sphere${u}`,this.scene.add(x)},this.generateSphere=o=>{const{fill:h}=O.getColorFromConfig({attribute:o.attribute},P(b({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(o,h),this.render()},this.generateSpheres=o=>{o.forEach(h=>{const{fill:d}=O.getColorFromConfig({attribute:h.attribute},P(b({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(h,d)}),this.render()},this.addBoxToSense=(o,h=16777215)=>{var d;const u=(d=o.id)!=null?d:A();this.removeObjectByName(u,"box");const{center:m,width:g,height:p,depth:f,rotation:x}=o,y=new c.Group,S=new c.BoxGeometry(g,p,f),M=new c.MeshBasicMaterial({color:"blue"}),B=new c.Mesh(S,M),I=new c.BoxHelper(B,h),E=this.generateBoxArrow(o),D=this.generateBoxTrackID(o);D&&y.add(D),y.add(I),y.add(E),m&&y.position.set(m.x,m.y,m.z),x&&y.rotation.set(0,0,x),y.name=`box${u}`,this.scene.add(y)},this.applyCameraTarget=o=>{if(this.camera.type==="OrthographicCamera"&&o){const h=this.getOrthographicCameraTarget(o);this.updateCameraZoom(o.zoom),this.updateCamera(o.position,h)}},this.initShaderMaterial=()=>({vertexShader:`
1
+ import*as a from"three";import{toolStyleConverter as z,PerspectiveShiftUtils as B,EPerspectiveView as b,PointCloudUtils as E,DEFAULT_SPHERE_PARAMS as O}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import F from"../../_virtual/filterBoxWorker.js";import{isInPolygon as H}from"../../utils/tool/polygonTool.js";import I from"../../utils/uuid.js";import R from"../../utils/MathUtils.js";import W from"../../utils/ImgUtils.js";import{PCDLoader as Z}from"./PCDLoader.js";import{OrbitControls as U}from"./OrbitControls.js";import{PointCloudCache as G}from"./cache.js";import{getCuboidFromPointCloudBox as A,getHighlightIndexByPoints as $,mergeHighlightList as Y}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isInImage,lidar2image,mergeHighlightList,point2dTo3D,point3DLidar2Image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import{PointCloudSegmentOperation as X}from"./segmentation.js";import q from"./store/index.js";import K from"./render/index.js";import Q from"../toolOperation/eventListener.js";import"../../constant/tool.js";import"../scheduler.js";var J=Object.defineProperty,tt=Object.defineProperties,et=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,k=(w,t,e)=>t in w?J(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,C=(w,t)=>{for(var e in t||(t={}))it.call(t,e)&&k(w,e,t[e]);if(j)for(var e of j(t))rt.call(t,e)&&k(w,e,t[e]);return w},M=(w,t)=>tt(w,et(t)),D=(w,t,e)=>new Promise((i,r)=>{var o=d=>{try{n(e.next(d))}catch(s){r(s)}},c=d=>{try{n(e.throw(d))}catch(s){r(s)}},n=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,c);n((e=e.apply(w,t)).next())});const nt=30,L=new V({type:"module"});class ot extends Q{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:o="#4C4C4C",config:c,isSegment:n,checkMode:d}){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.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=s=>{if(!!this.store)switch(s.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=s=>{if(!!this.store)switch(s.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(s,h="blue")=>{var l;const u=(l=s.id)!=null?l:I();this.removeObjectByName(u,"sphere");const{radius:p,widthSegments:f,heightSegments:m}=O,{center:g}=s,y=new a.Group,x=new a.SphereGeometry(p,f,m),P=new a.MeshBasicMaterial({color:h}),v=new a.Mesh(x,P);v.position.set(g.x,g.y,g.z),y.add(v),y.name=`sphere${u}`,this.scene.add(y)},this.generateSphere=s=>{const{fill:h}=z.getColorFromConfig({attribute:s.attribute},M(C({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(s,h),this.render()},this.generateSpheres=s=>{s.forEach(h=>{const{fill:l}=z.getColorFromConfig({attribute:h.attribute},M(C({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(h,l)}),this.render()},this.addBoxToSense=(s,h=16777215)=>{var l;const u=(l=s.id)!=null?l:I();this.removeObjectByName(u,"box");const{center:p,width:f,height:m,depth:g,rotation:y}=s,x=new a.Group,P=new a.BoxGeometry(f,m,g),v=new a.MeshBasicMaterial({color:"blue"}),S=new a.Mesh(P,v),_=new a.BoxHelper(S,h),N=this.generateBoxArrow(s),T=this.generateBoxTrackID(s);T&&x.add(T),x.add(_),x.add(N),p&&x.position.set(p.x,p.y,p.z),y&&x.rotation.set(0,0,y),x.name=`box${u}`,this.scene.add(x)},this.applyCameraTarget=s=>{if(this.camera.type==="OrthographicCamera"&&s){const h=this.getOrthographicCameraTarget(s);this.updateCameraZoom(s.zoom),this.updateCamera(s.position,h)}},this.initShaderMaterial=()=>({vertexShader:`
2
2
  attribute vec3 dimensions;
3
3
  varying vec3 vDimensions;
4
4
  uniform float pointSize;
@@ -28,4 +28,4 @@ import*as c from"three";import{toolStyleConverter as O,PerspectiveShiftUtils as
28
28
 
29
29
  // Output the final color
30
30
  gl_FragColor = vec4(color, 1.0);
31
- }`,uniforms:{pointSize:{value:1.2}}}),this.loadPCDFile=(...o)=>T(this,[...o],function*(h=this.currentPCDSrc,d){if(!h)return;this.clearPointCloud(),this.currentPCDSrc=h;const{points:u,color:m}=yield this.cacheInstance.loadPCDFile(h),g=new c.BufferGeometry;g.setAttribute("position",new c.BufferAttribute(u,3)),this.isSegment||g.setAttribute("dimensions",new c.BufferAttribute(m,3)),this.initCloudData(u);const p=new c.Points(g);this.renderPointCloud(p,d)}),this.loadPCDFileByBox=(o,h,d)=>T(this,null,function*(){const u=(p,f)=>T(this,null,function*(){const{width:x=0,height:y=0,depth:S=0}=d!=null?d:{},M=yield this.filterPointsByBox(P(b({},h),{width:h.width+x,height:h.height+y,depth:h.depth+S}),p,f);if(!M){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=o;const B=new c.Points(M.geometry);B.name=this.pointCloudObjectName,this.scene.add(B),this.render()}),{points:m,color:g}=yield this.cacheInstance.loadPCDFile(o);u(m,g)}),this.generateRange=o=>{const h=this.createRange(o);this.scene.add(h)},this.generateBoxArrow=({width:o})=>{const h=new c.Vector3(1,0,0),d=new c.Vector3(o/2,0,0),u=2,m=16776960,g=new c.ArrowHelper(h,d,u,m);return g.visible=this.showDirection,g},this.generateBoxTrackID=o=>{if(!o.trackID)return;const h=new c.Texture(this.getTextCanvas(o.trackID.toString()));h.needsUpdate=!0;const d=new c.SpriteMaterial({map:h,depthWrite:!1}),u=new c.Sprite(d);return u.scale.set(5,5,5),u.position.set(-o.width/2,0,o.depth/2+.5),u},this.applyZAxisPoints=o=>{this.zAxisLimit=o,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:o,customSize:h})=>{const d=this.scene.getObjectByName(this.pointCloudObjectName);if(!d)return;const u=d.material.uniforms.pointSize.value;o?d.material.uniforms.pointSize.value=Math.min(u*1.2,10):d.material.uniforms.pointSize.value=Math.max(u/1.2,1),h&&(d.material.uniforms.pointSize.value=h,this.pointsMaterialSize=h),d.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,this.checkMode=l!=null?l:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new U(this.camera,n?this.container:this.renderer.domElement),this.pcdLoader=new Z,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=H.getInstance(),n===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new $(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 G({dom:this.container,store:this.store}),this.pointCloudRender=new X(P(b({store:this.store},this.eventBus),{nextTick:this.nextTick,config:this.config})),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}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.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("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 b({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new c.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:s,near:a,far:n}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=s,this.camera.near=a,this.camera.far=n,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 c.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 c.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=O.getColorFromConfig({attribute:i.attribute},P(b({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,s=10,a=e.x-i/2-s,n=e.x-i/2+s,l=e.y+r/2+s,o=e.y-r/2-s,h=100,d=-100,u=500/h;return{left:a,right:n,top:l,bottom:o,near:h,far:d,zoom:u}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:s,height:a,depth:n,rotation:l}=t,o=this.getCameraVector(r,l,{width:s,height:a,depth:n},e);return i?(this.updateCamera(i,r),new c.Vector3(i.x,i.y,i.z)):(this.updateCamera(o,r),o)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=z,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 c.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 c.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new c.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,s,a;if(!e){const n=this.scene.getObjectByName(this.pointCloudObjectName);if(!n)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:n,zMax:l,polygonPointList:o}=k(t),h=e;i=i!=null?i:new Float32Array([]);const d={boxParams:t,zMin:n,zMax:l,polygonPointList:o,color:i,position:h};return new Promise(u=>{const m=new F;m.postMessage(d),m.onmessage=g=>{const{color:p,position:f,num:x}=g.data,y=new c.BufferGeometry;y.setAttribute("position",new c.Float32BufferAttribute(f,3)),y.setAttribute("color",new c.Float32BufferAttribute(p,3)),y.computeBoundingSphere(),m.terminate(),u({geometry:y,num:x})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=C.Front,s=et){let a=v.frontViewMatrix4(s);switch(r){case C.Front:break;case C.Back:a=v.backViewMatrix4(s);break;case C.Left:a=v.leftViewMatrix4(s);break;case C.Right:a=v.rightViewMatrix4(s);break;case C.Top:a=v.topViewMatrix4(s);break;case C.LFT:a=v.leftFrontTopViewMatrix4(s,i);break;case C.RBT:a=v.rightBackTopViewMatrix4(s,i);break}const n=this.createThreeMatrix4(a),l=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),o=new c.Matrix4().makeTranslation(t.x,t.y,t.z),h=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(n).applyMatrix4(l).applyMatrix4(h).applyMatrix4(o)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new c.BufferGeometry().setFromPoints(i),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(r,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new c.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],s=t[e+2];this.store.cloudData.set(`${i}@${r}@${s}`,{visible:!1})}this.store.setOriginPoints(t)}}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((i,r)=>{if(window.Worker){const a=(t?[...t]:[]).map(o=>k(o)),n=this.getAllAttributeColor(a),l={cuboidList:a,position:e.geometry.attributes.position.array,color:e.geometry.attributes.dimensions.array,colorList:n};L.postMessage(l),L.onmessage=o=>{const{color:h}=o.data,d=new c.BufferAttribute(h,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||e.geometry.attributes.position.array.length!==h.length){r(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,h),this.highlightPCDSrc=void 0,d.needsUpdate=!0,e.geometry.setAttribute("dimensions",d),e.geometry.attributes.dimensions.needsUpdate=!0,i(h),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new c.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((d,u)=>d.z-u.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:d})=>d>r.z+.1);const s=.005,a=Math.floor(e.length*(1-s));e=e.slice(0,a),e.sort((d,u)=>d.x-u.x);const n=Math.floor(e.length*s),l=Math.floor(e.length*(1-s));e=e.slice(n,l),e.sort((d,u)=>d.y-u.y);const o=Math.floor(e.length*s),h=Math.floor(e.length*(1-s));return e=e.slice(o,h),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:n,y:l})=>{t.forEach((o,h)=>{const d=r[h+1],u=W.getFootOfPerpendicular({x:n,y:l},o,d,!1,!0).length;(!i[h]||u<i[h].distance)&&(i[h]={distance:u,point:{x:n,y:l}})})}),r=[t[t.length-1],...t,t[0]];const s=[i[i.length-1],...i];return t.map((n,l)=>{const o=r[l],h=r[l+1],d=r[l+2];return N.getIntersectionBySlope({p1:s[l].point,line1:[o,h],p2:s[l+1].point,line2:[h,d]})})}getSensesPointZAxisInPolygon(t,e,i){var r,s,a;const n=this.scene.children.find(p=>p.uuid===this.pointsUuid);let l=0,o=0,h=0,d=0,u=[],m=[];const g=((a=(s=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:s.position)==null?void 0:a.array)||[];for(let p=0;p<g.length;p+=3){const f=g[p],x=g[p+1],y=g[p+2];R({x:f,y:x},t)&&(y||y===0)&&m.push({x:f,y:x,z:y})}return m.length?(i&&(m=this.filterNoise(m),u=this.getFittedCoordinates(t,m)),m.sort((p,f)=>p.z-f.z),l=m[0].z-.01,o=m[m.length-1].z+.01,d=m.length,e&&(h=m.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:o,minZ:l,count:h,zCount:d,fittedCoordinates:u}):{maxZ:o,minZ:l,count:h,zCount:d,fittedCoordinates:u}}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 c.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 c.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:a,depth:n}=t,l={x:e+a/2,y:i+s/2,z:r-n/2},o={x:e+a/2,y:i+s/2,z:r+n/2},h={x:e-a/2,y:i+s/2,z:r+n/2},d={x:e-a/2,y:i+s/2,z:r-n/2};return[l,o,h,d]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:s,width:a,depth:n}=t,l={x:e-a/2,y:i+s/2,z:r+n/2},o={x:e-a/2,y:i+s/2,z:r-n/2},h={x:e-a/2,y:i-s/2,z:r-n/2},d={x:e-a/2,y:i-s/2,z:r+n/2};return[l,o,h,d]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:s,width:a,depth:n}=t,l={x:e+a/2,y:i+s/2,z:r+n/2},o={x:e+a/2,y:i-s/2,z:r+n/2},h={x:e-a/2,y:i-s/2,z:r+n/2},d={x:e-a/2,y:i+s/2,z:r+n/2};return[l,o,h,d]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-i,-r),n=new c.Matrix4().makeTranslation(e,i,r),l=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(n).multiply(l).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,C.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,C.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case C.Left:return this.getPolygonSidePoints(t);case C.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:s}=t,a=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const l=i.map(d=>new c.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.sideMatrix)),o=this.containerWidth/r,h=this.containerHeight/s;return{polygon2d:l,zoom:Math.min(o,h)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:s}=t,{radius:a}=z,n={center:e,attribute:i,id:r,valid:s,width:a*2,height:a*2,depth:a*2,rotation:0},l=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),o=new c.Matrix4().premultiply(this.getModelTransformationMatrix(n)).premultiply(l).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=o;const h=new c.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),d=this.containerWidth/(a*2),u=this.containerHeight/(a*2);return{point2d:h,zoom:Math.min(d,u)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=z,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},s=this.containerWidth/(i*2),a=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(s,a)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,s=this.getPolygonTopPoints(t).map(l=>new c.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.getModelTransformationMatrix(t))).map(l=>({x:l.y,y:l.x})).map(l=>({x:-(l.x-this.containerWidth/2),y:-(l.y-this.containerHeight/2)})),a=this.containerWidth/e,n=this.containerHeight/i;return{polygon2d:s,zoom:Math.min(a,n)/2}}getNewBoxBySideUpdate(t,e,i,r){const s=new c.Matrix4().makeRotationZ(r.rotation),a=new c.Vector3(-t.x,0,0).applyMatrix4(s);let n=r;return n.center={x:n.center.x+a.x,y:n.center.y+a.y,z:n.center.z-t.z},n=P(b({},n),{width:Math.abs(n.width+e),height:n.height,depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxByBackUpdate(t,e,i,r){const s=new c.Matrix4().makeRotationZ(r.rotation),a=new c.Vector3(0,-t.x,0).applyMatrix4(s);let n=r;return n.center={x:n.center.x+a.x,y:n.center.y+a.y,z:n.center.z-t.z},n=P(b({},n),{width:n.width,height:Math.abs(n.height+e),depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxBySideUpdateByPoints(t,e,i,r){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const n=t.map(f=>new c.Vector3(f.x,f.y,f.z)).map(f=>f.applyMatrix4(a)),[l,o,h,d]=n,u=Math.max(Math.abs(l.x-h.x),Math.abs(l.x-o.x)),g=o.add(d).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:P(b({},r),{center:{x:r.center.x-g.x,y:r.center.y-g.y,z:r.center.z-i},width:u,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:a}=r;for(let n=0;n<a;n++){const l=r.getZ(n);s.push(l>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{it as PointCloud};
31
+ }`,uniforms:{pointSize:{value:1.2}}}),this.loadPCDFile=(...s)=>D(this,[...s],function*(h=this.currentPCDSrc,l){if(!h)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=h;const{points:u,color:p}=yield this.cacheInstance.loadPCDFile(h),f=new a.BufferGeometry;f.setAttribute("position",new a.BufferAttribute(u,3)),this.isSegment||f.setAttribute("dimensions",new a.BufferAttribute(p,3)),this.initCloudData(u);const m=new a.Points(f);this.renderPointCloud(m,l)}),this.getHighlightIndexByMappingImgList=s=>D(this,[s],function*({mappingImgList:h,points:l}){const u=yield Promise.all(h.map(m=>W.load(m.url))),p=h.map((m,g)=>{var y;if(this.cacheInstance.cache2DHighlightIndex.has(m.url))return(y=this.cacheInstance.cache2DHighlightIndex.get(m.url))!=null?y:[];const x=$({points:l,calib:m.calib,width:u[g].width,height:u[g].height});return this.cacheInstance.cache2DHighlightIndex.set(m.url,x),x});return Y(p)}),this.loadPCDFileByBox=(s,h,l)=>D(this,null,function*(){const u=(m,g)=>D(this,null,function*(){const{width:y=0,height:x=0,depth:P=0}=l!=null?l:{},v=yield this.filterPointsByBox(M(C({},h),{width:h.width+y,height:h.height+x,depth:h.depth+P}),m,g);if(!v){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=s;const S=new a.Points(v.geometry);S.name=this.pointCloudObjectName,this.scene.add(S),this.render()}),{points:p,color:f}=yield this.cacheInstance.loadPCDFile(s);u(p,f)}),this.generateRange=s=>{const h=this.createRange(s);this.scene.add(h)},this.generateBoxArrow=({width:s})=>{const h=new a.Vector3(1,0,0),l=new a.Vector3(s/2,0,0),u=2,p=16776960,f=new a.ArrowHelper(h,l,u,p);return f.visible=this.showDirection,f},this.generateBoxTrackID=s=>{if(!s.trackID)return;const h=new a.Texture(this.getTextCanvas(s.trackID.toString()));h.needsUpdate=!0;const l=new a.SpriteMaterial({map:h,depthWrite:!1}),u=new a.Sprite(l);return u.scale.set(5,5,5),u.position.set(-s.width/2,0,s.depth/2+.5),u},this.applyZAxisPoints=s=>{this.zAxisLimit=s,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:s,customSize:h})=>{const l=this.scene.getObjectByName(this.pointCloudObjectName);if(!l)return;const u=l.material.uniforms.pointSize.value;s?l.material.uniforms.pointSize.value=Math.min(u*1.2,10):l.material.uniforms.pointSize.value=Math.max(u/1.2,1),h&&(l.material.uniforms.pointSize.value=h,this.pointsMaterialSize=h),l.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new a.WebGLRenderer({antialias:!0}),this.backgroundColor=o,this.config=c,this.checkMode=d!=null?d:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new a.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new a.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new a.Scene,this.controls=new U(this.camera,n?this.container:this.renderer.domElement),this.pcdLoader=new Z,this.axesHelper=new a.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=G.getInstance(),n===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new q(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 X({dom:this.container,store:this.store}),this.pointCloudRender=new K(M(C({store:this.store},this.eventBus),{nextTick:this.nextTick,config:this.config})),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("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("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 C({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new a.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:o,near:c,far:n}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=o,this.camera.near=c,this.camera.far=n,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 a.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 a.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=z.getColorFromConfig({attribute:i.attribute},M(C({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,o=10,c=e.x-i/2-o,n=e.x-i/2+o,d=e.y+r/2+o,s=e.y-r/2-o,h=100,l=-100,u=500/h;return{left:c,right:n,top:d,bottom:s,near:h,far:l,zoom:u}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:o,height:c,depth:n,rotation:d}=t,s=this.getCameraVector(r,d,{width:o,height:c,depth:n},e);return i?(this.updateCamera(i,r),new a.Vector3(i.x,i.y,i.z)):(this.updateCamera(s,r),s)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=O,o=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new a.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 a.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new a.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,o,c;if(!e){const n=this.scene.getObjectByName(this.pointCloudObjectName);if(!n)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(c=(o=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:c.array}if(window.Worker){const{zMin:n,zMax:d,polygonPointList:s}=A(t),h=e;i=i!=null?i:new Float32Array([]);const l={boxParams:t,zMin:n,zMax:d,polygonPointList:s,color:i,position:h};return new Promise(u=>{const p=new F;p.postMessage(l),p.onmessage=f=>{const{color:m,position:g,num:y}=f.data,x=new a.BufferGeometry;x.setAttribute("position",new a.Float32BufferAttribute(g,3)),x.setAttribute("color",new a.Float32BufferAttribute(m,3)),x.computeBoundingSphere(),p.terminate(),u({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=b.Front,o=nt){let c=B.frontViewMatrix4(o);switch(r){case b.Front:break;case b.Back:c=B.backViewMatrix4(o);break;case b.Left:c=B.leftViewMatrix4(o);break;case b.Right:c=B.rightViewMatrix4(o);break;case b.Top:c=B.topViewMatrix4(o);break;case b.LFT:c=B.leftFrontTopViewMatrix4(o,i);break;case b.RBT:c=B.rightBackTopViewMatrix4(o,i);break}const n=this.createThreeMatrix4(c),d=new a.Matrix4().makeTranslation(-t.x,-t.y,-t.z),s=new a.Matrix4().makeTranslation(t.x,t.y,t.z),h=new a.Matrix4().makeRotationZ(e);return new a.Vector3(t.x,t.y,t.z).clone().applyMatrix4(n).applyMatrix4(d).applyMatrix4(h).applyMatrix4(s)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new a.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new a.BufferGeometry().setFromPoints(i),o=new a.LineBasicMaterial({color:16711680}),c=new a.Line(r,o);return c.name=this.rangeObjectName,c}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new a.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],o=t[e+2];this.store.cloudData.set(`${i}@${r}@${o}`,{visible:!1})}this.store.setOriginPoints(t)}}highlightOriginPointCloud(t,e=[]){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!!i)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((r,o)=>{if(window.Worker){const n=(t?[...t]:[]).map(h=>A(h)),d=this.getAllAttributeColor(n),s={cuboidList:n,position:i.geometry.attributes.position.array,color:i.geometry.attributes.dimensions.array,colorList:d,highlightIndex:e};L.postMessage(s),L.onmessage=h=>{const{color:l}=h.data,u=new a.BufferAttribute(l,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||i.geometry.attributes.position.array.length!==l.length){o(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,l),this.highlightPCDSrc=void 0,u.needsUpdate=!0,i.geometry.setAttribute("dimensions",u),i.geometry.attributes.dimensions.needsUpdate=!0,r(l),this.render()}}})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new a.Group;t.forEach(i=>{const{center:{x:r,y:o,z:c},width:n,height:d,depth:s,rotation:h}=i,{fill:l}=z.getColorFromConfig({attribute:i.attribute},M(C({},this.config),{attributeConfigurable:!0}),{}),u=new a.BoxGeometry(n,d,s),p=new a.MeshBasicMaterial({color:l,transparent:!0,opacity:.2,depthTest:!1});u.rotateZ(h),u.translate(r,o,c);const f=new a.Mesh(u,p);e.add(f);const m=new a.PlaneGeometry(s,d);m.rotateY(Math.PI/2),m.rotateZ(h);const g=new a.Vector3(n/2,0,0),y=new a.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(h);g.applyMatrix4(y),m.translate(r+g.x,o+g.y,c+g.z);const x=new a.MeshBasicMaterial({color:l,side:a.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),P=new a.Mesh(m,x);e.add(P)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new a.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((l,u)=>l.z-u.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:l})=>l>r.z+.1);const o=.005,c=Math.floor(e.length*(1-o));e=e.slice(0,c),e.sort((l,u)=>l.x-u.x);const n=Math.floor(e.length*o),d=Math.floor(e.length*(1-o));e=e.slice(n,d),e.sort((l,u)=>l.y-u.y);const s=Math.floor(e.length*o),h=Math.floor(e.length*(1-o));return e=e.slice(s,h),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:n,y:d})=>{t.forEach((s,h)=>{const l=r[h+1],u=R.getFootOfPerpendicular({x:n,y:d},s,l,!1,!0).length;(!i[h]||u<i[h].distance)&&(i[h]={distance:u,point:{x:n,y:d}})})}),r=[t[t.length-1],...t,t[0]];const o=[i[i.length-1],...i];return t.map((n,d)=>{const s=r[d],h=r[d+1],l=r[d+2];return E.getIntersectionBySlope({p1:o[d].point,line1:[s,h],p2:o[d+1].point,line2:[h,l]})})}getSensesPointZAxisInPolygon(t,e,i){var r,o,c;const n=this.scene.children.find(m=>m.uuid===this.pointsUuid);let d=0,s=0,h=0,l=0,u=[],p=[];const f=((c=(o=(r=n==null?void 0:n.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:c.array)||[];for(let m=0;m<f.length;m+=3){const g=f[m],y=f[m+1],x=f[m+2];H({x:g,y},t)&&(x||x===0)&&p.push({x:g,y,z:x})}return p.length?(i&&(p=this.filterNoise(p),u=this.getFittedCoordinates(t,p)),p.sort((m,g)=>m.z-g.z),d=p[0].z-.01,s=p[p.length-1].z+.01,l=p.length,e&&(h=p.filter(({z:m})=>m>=e[0]&&m<=e[1]).length),{maxZ:s,minZ:d,count:h,zCount:l,fittedCoordinates:u}):{maxZ:s,minZ:d,count:h,zCount:l,fittedCoordinates:u}}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 a.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 a.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:o,width:c,depth:n}=t,d={x:e+c/2,y:i+o/2,z:r-n/2},s={x:e+c/2,y:i+o/2,z:r+n/2},h={x:e-c/2,y:i+o/2,z:r+n/2},l={x:e-c/2,y:i+o/2,z:r-n/2};return[d,s,h,l]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:o,width:c,depth:n}=t,d={x:e-c/2,y:i+o/2,z:r+n/2},s={x:e-c/2,y:i+o/2,z:r-n/2},h={x:e-c/2,y:i-o/2,z:r-n/2},l={x:e-c/2,y:i-o/2,z:r+n/2};return[d,s,h,l]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:o,width:c,depth:n}=t,d={x:e+c/2,y:i+o/2,z:r+n/2},s={x:e+c/2,y:i-o/2,z:r+n/2},h={x:e-c/2,y:i-o/2,z:r+n/2},l={x:e-c/2,y:i+o/2,z:r+n/2};return[d,s,h,l]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:o}=t,c=new a.Matrix4().makeTranslation(-e,-i,-r),n=new a.Matrix4().makeTranslation(e,i,r),d=new a.Matrix4().makeRotationZ(o);return new a.Matrix4().multiply(n).multiply(d).multiply(c)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,b.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,b.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case b.Left:return this.getPolygonSidePoints(t);case b.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:o}=t,c=new a.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new a.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(c).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const d=i.map(l=>new a.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.sideMatrix)),s=this.containerWidth/r,h=this.containerHeight/o;return{polygon2d:d,zoom:Math.min(s,h)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:o}=t,{radius:c}=O,n={center:e,attribute:i,id:r,valid:o,width:c*2,height:c*2,depth:c*2,rotation:0},d=new a.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new a.Matrix4().premultiply(this.getModelTransformationMatrix(n)).premultiply(d).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const h=new a.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),l=this.containerWidth/(c*2),u=this.containerHeight/(c*2);return{point2d:h,zoom:Math.min(l,u)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=O,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},o=this.containerWidth/(i*2),c=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(o,c)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,o=this.getPolygonTopPoints(t).map(d=>new a.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.getModelTransformationMatrix(t))).map(d=>({x:d.y,y:d.x})).map(d=>({x:-(d.x-this.containerWidth/2),y:-(d.y-this.containerHeight/2)})),c=this.containerWidth/e,n=this.containerHeight/i;return{polygon2d:o,zoom:Math.min(c,n)/2}}getNewBoxBySideUpdate(t,e,i,r){const o=new a.Matrix4().makeRotationZ(r.rotation),c=new a.Vector3(-t.x,0,0).applyMatrix4(o);let n=r;return n.center={x:n.center.x+c.x,y:n.center.y+c.y,z:n.center.z-t.z},n=M(C({},n),{width:Math.abs(n.width+e),height:n.height,depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxByBackUpdate(t,e,i,r){const o=new a.Matrix4().makeRotationZ(r.rotation),c=new a.Vector3(0,-t.x,0).applyMatrix4(o);let n=r;return n.center={x:n.center.x+c.x,y:n.center.y+c.y,z:n.center.z-t.z},n=M(C({},n),{width:n.width,height:Math.abs(n.height+e),depth:Math.abs(n.depth+i)}),{newBoxParams:n}}getNewBoxBySideUpdateByPoints(t,e,i,r){var o;const c=(o=this.sideMatrix)==null?void 0:o.invert();if(!this.sideMatrix||!c){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const n=t.map(g=>new a.Vector3(g.x,g.y,g.z)).map(g=>g.applyMatrix4(c)),[d,s,h,l]=n,u=Math.max(Math.abs(d.x-h.x),Math.abs(d.x-s.x)),f=s.add(l).applyMatrix3(new a.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new a.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new a.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:M(C({},r),{center:{x:r.center.x-f.x,y:r.center.y-f.y,z:r.center.z-i},width:u,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,o=[],{count:c}=r;for(let n=0;n<c;n++){const d=r.getZ(n);o.push(d>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new a.Float32BufferAttribute(o,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{ot as PointCloud};
@@ -1 +1 @@
1
- import*as c from"three";import{MatrixUtils as d,PointCloudUtils as _}from"@labelbee/lb-utils";import P from"../../utils/uuid.js";var z=Object.defineProperty,O=Object.defineProperties,T=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,h=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,V=(e,t)=>{for(var r in t||(t={}))L.call(t,r)&&h(e,r,t[r]);if(M)for(var r of M(t))R.call(t,r)&&h(e,r,t[r]);return e},H=(e,t)=>O(e,T(t));function f(e){return new c.Matrix4().set(...e)}function g(e,t,r){const o=d.transferMatrix34FromKitti2Three(e),i=d.transferMatrix33FromKitti2Three(t),n=d.transferMatrix34FromKitti2Three(r),a=f(o),l=f(i),u=f(n);return{composeMatrix4:u.clone().premultiply(l).premultiply(a),PM:a,RM:l,TM:u}}function m(e,t,r){var o;const i=new c.Vector3(e.x,e.y,(o=e==null?void 0:e.z)!=null?o:1),n=new c.Matrix4().makeRotationZ(r),a=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(l).applyMatrix4(n).applyMatrix4(a)}function v(e,t){const o=new c.Vector4(e.x,e.y,e.z).applyMatrix4(t);if(o.z<0)return;const i=1/o.z,n=new c.Matrix4().set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,1);return o.applyMatrix4(n)}function b(e){const{center:t,width:r,height:o,depth:i,rotation:n}=e,a=[{x:t.x+r/2,y:t.y-o/2},{x:t.x+r/2,y:t.y+o/2},{x:t.x-r/2,y:t.y+o/2},{x:t.x-r/2,y:t.y-o/2}].map(p=>{const y=m(p,t,n);return{x:y.x,y:y.y}}),l=t.z+i/2,u=t.z-i/2;return H(V({},e),{polygonPointList:a,zMax:l,zMin:u})}function j(e){const t=e.slice();return t.sort((r,o)=>r.x===o.x?o.y-r.y:r.x-o.x),t}function w(e,t,r){const o=t.x-e.x,i=t.y-e.y,n=r.x-e.x,a=r.y-e.y;return o*a-n*i}function C(e){const t=j(e),r=[];for(let n=0;n<t.length;n++){for(;r.length>=2&&w(r[r.length-2],r[r.length-1],t[n])<=0;)r.pop();r.push(t[n])}const o=[];for(let n=t.length-1;n>=0;n--){for(;o.length>=2&&w(o[o.length-2],o[o.length-1],t[n])<=0;)o.pop();o.push(t[n])}return r.pop(),o.pop(),r.concat(o)}function F(e,t,r={createRange:!1}){const{createRange:o}=r,i=_.getAllViewData(e),{P:n,R:a,T:l}=t,{composeMatrix4:u}=g(n,a,l),p=i.map(x=>({type:x.type,pointList:x.pointList.map(s=>m(s,e.center,e.rotation)).map(s=>v(s,u)).map(s=>{if(!!s)return{id:P(),x:s==null?void 0:s.x,y:s==null?void 0:s.y}}).filter(s=>s!==void 0)})).filter(x=>x.pointList.length!==0);let y=[];if(p.length===6&&o===!0){const x=p[0].pointList,s=p[1].pointList;y=C([...x,...s])}return{transferViewData:p,viewRangePointList:y}}export{f as createThreeMatrix4,b as getCuboidFromPointCloudBox,v as lidar2image,F as pointCloudLidar2image,m as rotatePoint,g as transferKitti2Matrix};
1
+ import*as u from"three";import{MatrixUtils as g,PointCloudUtils as T}from"@labelbee/lb-utils";import z from"../../utils/uuid.js";var O=Object.defineProperty,R=Object.defineProperties,V=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,v=(r,t,e)=>t in r?O(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H=(r,t)=>{for(var e in t||(t={}))I.call(t,e)&&v(r,e,t[e]);if(d)for(var e of d(t))L.call(t,e)&&v(r,e,t[e]);return r},D=(r,t)=>R(r,V(t));function y(r){return new u.Matrix4().set(...r)}function h(r,t,e){const n=g.transferMatrix34FromKitti2Three(r),i=g.transferMatrix33FromKitti2Three(t),o=g.transferMatrix34FromKitti2Three(e),s=y(n),l=y(i),a=y(o);return{composeMatrix4:a.clone().premultiply(l).premultiply(s),PM:s,RM:l,TM:a}}function m(r,t,e){var n;const i=new u.Vector3(r.x,r.y,(n=r==null?void 0:r.z)!=null?n:1),o=new u.Matrix4().makeRotationZ(e),s=new u.Matrix4().makeTranslation(t.x,t.y,t.z),l=new u.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(l).applyMatrix4(o).applyMatrix4(s)}function M(r,t){const n=new u.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(n.z<0)return;const i=1/n.z,o=new u.Matrix4().set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,1);return n.applyMatrix4(o)}function j(r){const{center:t,width:e,height:n,depth:i,rotation:o}=r,s=[{x:t.x+e/2,y:t.y-n/2},{x:t.x+e/2,y:t.y+n/2},{x:t.x-e/2,y:t.y+n/2},{x:t.x-e/2,y:t.y-n/2}].map(p=>{const f=m(p,t,o);return{x:f.x,y:f.y}}),l=t.z+i/2,a=t.z-i/2;return D(H({},r),{polygonPointList:s,zMax:l,zMin:a})}function b(r){const t=r.slice();return t.sort((e,n)=>e.x===n.x?n.y-e.y:e.x-n.x),t}function w(r,t,e){const n=t.x-r.x,i=t.y-r.y,o=e.x-r.x,s=e.y-r.y;return n*s-o*i}function C(r){const t=b(r),e=[];for(let o=0;o<t.length;o++){for(;e.length>=2&&w(e[e.length-2],e[e.length-1],t[o])<=0;)e.pop();e.push(t[o])}const n=[];for(let o=t.length-1;o>=0;o--){for(;n.length>=2&&w(n[n.length-2],n[n.length-1],t[o])<=0;)n.pop();n.push(t[o])}return e.pop(),n.pop(),e.concat(n)}const P=(r,t)=>{const{P:e,R:n,T:i}=t,{composeMatrix4:o}=h(e,n,i);return M(r,o)},F=(r,t)=>{const{P:e,R:n,T:i}=t,{composeMatrix4:o}=h(e,n,i);return new u.Vector4(r.x,r.y,r.z).applyMatrix4(o.invert())},_=({point:r,calib:t,width:e,height:n})=>{if(!t)return!1;const i=P(r,t);return i?i.x>=0&&i.x<=e&&i.y>=0&&i.y<=n:!1},k=({points:r,calib:t,width:e,height:n})=>{const i=[];for(let o=0;o<r.length;o+=3){const s=r[o],l=r[o+1],a=r[o+2];_({point:{x:s,y:l,z:a},calib:t,width:e,height:n})?i.push(1):i.push(0)}return i},A=r=>{if(r.length===0)return[];const t=[];for(let e=0;e<r[0].length;e++){for(let n=0;n<r.length;n++)if(r[n][e]===1){t.push(1);break}t.length===e&&t.push(0)}return t};function E(r,t,e={createRange:!1}){const{createRange:n}=e,i=T.getAllViewData(r),{P:o,R:s,T:l}=t,{composeMatrix4:a}=h(o,s,l),p=i.map(x=>({type:x.type,pointList:x.pointList.map(c=>m(c,r.center,r.rotation)).map(c=>M(c,a)).map(c=>{if(!!c)return{id:z(),x:c==null?void 0:c.x,y:c==null?void 0:c.y}}).filter(c=>c!==void 0)})).filter(x=>x.pointList.length!==0);let f=[];if(p.length===6&&n===!0){const x=p[0].pointList,c=p[1].pointList;f=C([...x,...c])}return{transferViewData:p,viewRangePointList:f}}export{y as createThreeMatrix4,j as getCuboidFromPointCloudBox,k as getHighlightIndexByPoints,_ as isInImage,M as lidar2image,A as mergeHighlightList,F as point2dTo3D,P as point3DLidar2Image,E as pointCloudLidar2image,m as rotatePoint,h as transferKitti2Matrix};
@@ -1 +1 @@
1
- import I from"lodash";import{INVALID_COLOR as b,toolStyleConverter as _}from"@labelbee/lb-utils";import{ESortDirection as C,EDragTarget as w,DEFAULT_TEXT_OFFSET as S}from"../../constant/annotation.js";import{EPolygonPattern as D}from"../../constant/tool.js";import f from"../../utils/tool/AxisUtils.js";import y from"../../utils/tool/CommonToolUtils.js";import P from"../../utils/tool/DrawUtils.js";import v from"../../utils/tool/PolygonUtils.js";import{polygonConfig as A}from"../../constant/defaultConfig.js";import x from"./polygonOperation.js";import{BasicToolOperation as T}from"./basicToolOperation.js";var O=Object.defineProperty,k=Object.defineProperties,B=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,L=(d,t,e)=>t in d?O(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,u=(d,t)=>{for(var e in t||(t={}))R.call(t,e)&&L(d,e,t[e]);if(m)for(var e of m(t))U.call(t,e)&&L(d,e,t[e]);return d},g=(d,t)=>k(d,B(t));class j extends x{constructor(t){super(t);this.rightMouseUp=s=>{var a;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.selection.setSelectedIDs(this.hoverID,s.ctrlKey),this.emit("setSelectedIDs",this.selection.selectedIDs);const l=(a=this.polygonList.find(c=>c.id===this.hoverID))==null?void 0:a.attribute;l&&l!==this.defaultAttribute&&this.emit("syncAttribute",l)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=s=>{var a;if(s){const l=this.getPointCloudLineColor(s),c=f.changePointListByZoom(s.pointList,this.zoom,this.currentPos);P.drawSelectedPolygonWithFillAndLine(this.canvas,c,{fillColor:"transparent",strokeColor:l,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(a=this.config)==null?void 0:a.lineType}),s.isRect===!0&&this.showDirectionLine===!0&&(this.renderRectPolygonDirection(c),(s==null?void 0:s.trackID)&&this.renderdrawTrackID(s))}},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygonList:s}=this.dragInfo;if(this.selectedIDs.length>0){const a=[];this.polygonList.forEach(l=>{if(this.selectedIDs.includes(l.id)){const c=s.find(p=>p.id===l.id);c&&a.push({newPolygon:l,originPolygon:c})}}),this.emit("updatePolygonByDrag",a)}}};var e,i,o,r,n,h;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=y.jsonParser(t.config))!=null?o:{},this.hideAttributes=[],this.checkMode=(r=t.checkMode)!=null?r:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=g(u({},A),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(h=(n=this.pointCloudConfig)==null?void 0:n.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=y.jsonParser(t);this.pointCloudConfig=i,this.config=g(u({},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 v.getPolygonByIDs(this.polygonList,this.selectedIDs)}updateSelectedPolygonsPoints(t){var e,i;if(this.selectedPolygons&&((e=this.selectedPolygons)==null?void 0:e.length)>0){const o=I.cloneDeep(this.selectedPolygons),r=[];(i=this.selectedPolygons)==null||i.forEach((n,h)=>{n.pointList=n.pointList.map(s=>{var a,l;const{x:c,y:p}=s;return g(u({},s),{x:c+((a=t.x)!=null?a:0),y:p+((l=t.y)!=null?l:0)})}),r.push({originPolygon:o[h],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?b:_.getColorFromConfig({attribute:t.attribute},g(u({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.visiblePolygonList)==null||t.forEach(e=>{var i,o,r;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const n=this.getPointCloudLineColor(e),h=f.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);P.drawPolygonWithFillAndLine(this.canvas,h,{fillColor:"transparent",strokeColor:n,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(r=this.config)==null?void 0:r.lineType}),(e==null?void 0:e.trackID)&&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=f.changePointListByZoom(t.pointList,this.zoom,this.currentPos),i=e[e.length-1],o=t==null?void 0:t.trackID;P.drawText(this.canvas,i,`${o}`,u({textAlign:"center",color:"white"},S))}renderRectPolygonDirection(t){t.length<2||P.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===D.Rect?t.isRect===!0:this.pattern===D.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),r=this.currentPolygonListByPattern.map(n=>g(u({},n),{pointList:f.changePointListByZoom(n.pointList,this.zoom)}));return v.getHoverPolygonID(i,r,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=C.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var r,n,h,s;return g(u({},o),{x:(n=(r=o.pointList[0])==null?void 0:r.x)!=null?n:0,y:(s=(h=o.pointList[0])==null?void 0:h.y)!=null?s:0})}),i=y.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 o=this.selectedID;t!==o&&o&&((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 o=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(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);return}this.emit("validUpdate",t)}onMouseDown(t){if(T.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:w.Plane,initPointList:[],changePointIndex:[0],originPolygon:this.selectedPolygon,dragPrevCoord:e,originPolygonList:this.polygonList,selectedPolygons:this.selectedPolygons}}setResultAndSelectedID(t,e){this.setPolygonList(t),this.setSelectedIDs([e])}}export{j as default};
1
+ import I from"lodash";import{INVALID_COLOR as b,toolStyleConverter as _}from"@labelbee/lb-utils";import{ESortDirection as C,EDragTarget as w,DEFAULT_TEXT_OFFSET as S}from"../../constant/annotation.js";import{EPolygonPattern as D}from"../../constant/tool.js";import f from"../../utils/tool/AxisUtils.js";import y from"../../utils/tool/CommonToolUtils.js";import P from"../../utils/tool/DrawUtils.js";import L from"../../utils/tool/PolygonUtils.js";import{polygonConfig as A}from"../../constant/defaultConfig.js";import x from"./polygonOperation.js";import{BasicToolOperation as T}from"./basicToolOperation.js";var O=Object.defineProperty,k=Object.defineProperties,B=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,m=(d,t,e)=>t in d?O(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,u=(d,t)=>{for(var e in t||(t={}))R.call(t,e)&&m(d,e,t[e]);if(v)for(var e of v(t))U.call(t,e)&&m(d,e,t[e]);return d},g=(d,t)=>k(d,B(t));class j extends x{constructor(t){super(t);this.highlightAttributeList=[],this.rightMouseUp=s=>{var a;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.selection.setSelectedIDs(this.hoverID,s.ctrlKey),this.emit("setSelectedIDs",this.selection.selectedIDs);const l=(a=this.polygonList.find(c=>c.id===this.hoverID))==null?void 0:a.attribute;l&&l!==this.defaultAttribute&&this.emit("syncAttribute",l)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=s=>{var a;if(s){const l=this.getPointCloudLineColor(s),c=f.changePointListByZoom(s.pointList,this.zoom,this.currentPos);P.drawSelectedPolygonWithFillAndLine(this.canvas,c,{fillColor:"transparent",strokeColor:l,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(a=this.config)==null?void 0:a.lineType}),s.isRect===!0&&this.showDirectionLine===!0&&(this.renderRectPolygonDirection(c),(s==null?void 0:s.trackID)&&this.renderdrawTrackID(s))}},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygonList:s}=this.dragInfo;if(this.selectedIDs.length>0){const a=[];this.polygonList.forEach(l=>{if(this.selectedIDs.includes(l.id)){const c=s.find(p=>p.id===l.id);c&&a.push({newPolygon:l,originPolygon:c})}}),this.emit("updatePolygonByDrag",a)}}};var e,i,o,r,n,h;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=y.jsonParser(t.config))!=null?o:{},this.hideAttributes=[],this.checkMode=(r=t.checkMode)!=null?r:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=g(u({},A),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(h=(n=this.pointCloudConfig)==null?void 0:n.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=y.jsonParser(t);this.pointCloudConfig=i,this.config=g(u({},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 L.getPolygonByIDs(this.polygonList,this.selectedIDs)}updateSelectedPolygonsPoints(t){var e,i;if(this.selectedPolygons&&((e=this.selectedPolygons)==null?void 0:e.length)>0){const o=I.cloneDeep(this.selectedPolygons),r=[];(i=this.selectedPolygons)==null||i.forEach((n,h)=>{n.pointList=n.pointList.map(s=>{var a,l;const{x:c,y:p}=s;return g(u({},s),{x:c+((a=t.x)!=null?a:0),y:p+((l=t.y)!=null?l:0)})}),r.push({originPolygon:o[h],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?b:_.getColorFromConfig({attribute:t.attribute},g(u({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.visiblePolygonList)==null||t.forEach(e=>{var i,o,r;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const n=this.getPointCloudLineColor(e),h=f.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos),s=this.highlightAttributeList.includes(e.attribute);P.drawPolygonWithFillAndLine(this.canvas,h,{fillColor:s?n:"transparent",strokeColor:n,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(r=this.config)==null?void 0:r.lineType}),(e==null?void 0:e.trackID)&&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=f.changePointListByZoom(t.pointList,this.zoom,this.currentPos),i=e[e.length-1],o=t==null?void 0:t.trackID;P.drawText(this.canvas,i,`${o}`,u({textAlign:"center",color:"white"},S))}renderRectPolygonDirection(t){t.length<2||P.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===D.Rect?t.isRect===!0:this.pattern===D.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),r=this.currentPolygonListByPattern.map(n=>g(u({},n),{pointList:f.changePointListByZoom(n.pointList,this.zoom)}));return L.getHoverPolygonID(i,r,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=C.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var r,n,h,s;return g(u({},o),{x:(n=(r=o.pointList[0])==null?void 0:r.x)!=null?n:0,y:(s=(h=o.pointList[0])==null?void 0:h.y)!=null?s:0})}),i=y.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 o=this.selectedID;t!==o&&o&&((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 o=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(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);return}this.emit("validUpdate",t)}onMouseDown(t){if(T.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:w.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()}}export{j as default};
package/es/index.js CHANGED
@@ -1 +1 @@
1
- export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
1
+ export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isInImage,lidar2image,mergeHighlightList,point2dTo3D,point3DLidar2Image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-annotation",
3
- "version": "1.17.1",
3
+ "version": "1.18.0-alpha.1",
4
4
  "description": "Annotation tool collection",
5
5
  "keywords": [
6
6
  "annotation",
@@ -94,7 +94,7 @@
94
94
  "typescript": "^4.2.3"
95
95
  },
96
96
  "dependencies": {
97
- "@labelbee/lb-utils": "1.9.0",
97
+ "@labelbee/lb-utils": "1.10.0-alpha.1",
98
98
  "@turf/turf": "5.1.6",
99
99
  "color-rgba": "^2.3.0",
100
100
  "lodash": "^4.17.20",