@labelbee/lb-components 1.11.0-alpha.1 → 1.11.0-alpha.2
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";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,i)=>new Promise((l,e)=>{var a=d=>{try{r(i.next(d))}catch(h){e(h)}},p=d=>{try{r(i.throw(d))}catch(h){e(h)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(t,o,i,l,e)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:t.id},h=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return e&&Object.assign(h,e),h},topViewPolygon2PointCloud=(t,o,i,l,e,a)=>{let p=t.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,o)),r=0,d=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,h={count:y.zCount}}const[f,x,_]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,_]),D=lbAnnotation.MathUtils.getLineLength(f,x),O=lbAnnotation.MathUtils.getLineLength(x,_),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:U.x,y:U.y,z:r},width:O,height:D,depth:d,rotation:k,id:t.id},w=__spreadValues(l?__spreadValues(__spreadValues({},l),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);e&&Object.assign(w,e);const A=p.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,o));return{boxParams:w,newPointList:A}},sideViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),w=lbAnnotation.MathUtils.getLineLength(d,h),A=V-w,{newBoxParams:y}=l.getNewBoxBySideUpdate(U,A,k,i);return y},backViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),w=lbAnnotation.MathUtils.getLineLength(d,h),A=V-w;let{newBoxParams:y}=l.getNewBoxByBackUpdate(U,A,k,i);return y},syncSideViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncBackViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncTopViewByPoint=(t,o,i,l)=>{if(!i||!l)return;l.generateSphere(t),l.updateCameraBySphere(t,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:e,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...e.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):d);e.setResult(r),e.setSelectedID(o.id)},synchronizeTopView=(t,o,i,l)=>{var e;if(!i||!l)return;l.generateBox(t,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),d=[...a.polygonList],h=d.find(f=>f.id===o.id);h?h.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:e,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:h,pointCloudSphereList:f,hideAttributes:x}=t,{addHistory:_,initHistory:U,pushHistoryUnderUpdatePolygon:D,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{updateSelectedBox:V,updateSelectedBoxes:w,getPointCloudByID:A}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:y,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:T,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:j}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=j==null?void 0:j.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{e==null||e.generateBox(n),e==null||e.controls.update(),e==null||e.render()},X=n=>{e==null||e.generateSphere(n),e==null||e.controls.update(),e==null||e.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const g=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const v=p(g);M(PointCloudView.Top,n,g,P,v,L),_({newSphereParams:g})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=o.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:f})});const m=o==null?void 0:o.toolInstance,b=__spreadValues({},n),{boxParams:B,newPointList:I}=topViewPolygon2PointCloud(b,s,E,void 0,v,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),m.deletePolygon(B.id);return}C&&(I==null?void 0:I.length)&&(b.pointList=I);const q=x.includes(b.attribute),S=a(B);q?r([]):(r(B.id),m.selection.setSelectedIDs(b.id),R(PointCloudView.Top,b,B,u,S),C&&synchronizeTopView(B,b,o,e)),o==null||o.updatePolygonList(S!=null?S:[]),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(j==null?void 0:j.info)){const g=n!=null?n:j==null?void 0:j.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&g){R(PointCloudView.Top,v,g,void 0,s);return}}if((P||z)&&d.length===1){const g=P!=null?P:z;C.setSelectedID(d[0]);const v=C.selectedPoint;g&&M(PointCloudView.Top,v,g,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),e){const{count:g}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:g})}const C=V(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(z){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,z);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{O(n)},nt=(n,s)=>{const P=y(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(k){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),D(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=A(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=w(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=w(P);c&&t.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const g=T==null?void 0:T.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,g,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),c&&(e==null||e.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=T==null?void 0:T.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,e)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),c&&(e==null||e.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),e==null||e.generateBoxes(n)},initPointCloud3d:n=>{if(!e)return;const s={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};e.initOrthographicCamera(s),e.initRenderer(),e.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=T){var P,c,u,C,g,v;if(!(s==null?void 0:s.url)||!e)return;actionCreators.SetPointCloudLoading(F,!0),yield e.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),h.forEach(S=>{e==null||e.removeObjectByName(S.id)}),f.forEach(S=>{e==null||e.removeObjectByName(S.id)});let m=[],b=[],B=[],I=[];s.result?(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),B=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),I=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),m.forEach(S=>{e==null||e.generateBox(S)}),I.forEach(S=>{e==null||e.generateSphere(S)}),t.syncAllViewPointCloudColor(m),t.setPointCloudResult(m),t.setPolygonList(B),t.setLineList(b),t.setPointCloudSphereList(I)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),U({pointCloudBoxList:m,polygonList:B,pointCloudSphereList:I}),e.updateTopCamera();const q=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),o.updateData(s.url,s.result,{radius:(v=L==null?void 0:L.radius)!=null?v:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,i)=>new Promise((l,e)=>{var a=d=>{try{r(i.next(d))}catch(h){e(h)}},p=d=>{try{r(i.throw(d))}catch(h){e(h)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(t,o,i,l,e)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:t.id},h=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return e&&Object.assign(h,e),h},topViewPolygon2PointCloud=(t,o,i,l,e,a)=>{let p=t.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,o)),r=0,d=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,h={count:y.zCount}}const[f,x,_]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,_]),D=lbAnnotation.MathUtils.getLineLength(f,x),O=lbAnnotation.MathUtils.getLineLength(x,_),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:U.x,y:U.y,z:r},width:O,height:D,depth:d,rotation:k,id:t.id},w=__spreadValues(l?__spreadValues(__spreadValues({},l),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);e&&Object.assign(w,e);const A=p.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,o));return{boxParams:w,newPointList:A}},sideViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),w=lbAnnotation.MathUtils.getLineLength(d,h),A=V-w,{newBoxParams:y}=l.getNewBoxBySideUpdate(U,A,k,i);return y},backViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),w=lbAnnotation.MathUtils.getLineLength(d,h),A=V-w;let{newBoxParams:y}=l.getNewBoxByBackUpdate(U,A,k,i);return y},syncSideViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncBackViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncTopViewByPoint=(t,o,i,l)=>{if(!i||!l)return;l.generateSphere(t),l.updateCameraBySphere(t,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:e,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...e.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):d);e.setResult(r),e.setSelectedID(o.id)},synchronizeTopView=(t,o,i,l)=>{var e;if(!i||!l)return;l.generateBox(t,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),d=[...a.polygonList],h=d.find(f=>f.id===o.id);h?h.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:e,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:h,pointCloudSphereList:f,hideAttributes:x}=t,{addHistory:_,initHistory:U,pushHistoryUnderUpdatePolygon:D,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{updateSelectedBox:V,updateSelectedBoxes:w,getPointCloudByID:A}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:y,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:T,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:j}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=j==null?void 0:j.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{e==null||e.generateBox(n),e==null||e.controls.update(),e==null||e.render()},X=n=>{e==null||e.generateSphere(n),e==null||e.controls.update(),e==null||e.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const g=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const v=p(g);M(PointCloudView.Top,n,g,P,v,L),_({newSphereParams:g})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=o.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:f})});const m=o==null?void 0:o.toolInstance,b=__spreadValues({},n),{boxParams:B,newPointList:I}=topViewPolygon2PointCloud(b,s,E,void 0,v,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),m.deletePolygon(B.id);return}C&&(I==null?void 0:I.length)&&(b.pointList=I);const q=x.includes(b.attribute),S=a(B);o==null||o.updatePolygonList(S!=null?S:[]),q?r([]):(r(B.id),m.selection.setSelectedIDs(b.id),R(PointCloudView.Top,b,B,u,S),C&&synchronizeTopView(B,b,o,e)),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(j==null?void 0:j.info)){const g=n!=null?n:j==null?void 0:j.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&g){R(PointCloudView.Top,v,g,void 0,s);return}}if((P||z)&&d.length===1){const g=P!=null?P:z;C.setSelectedID(d[0]);const v=C.selectedPoint;g&&M(PointCloudView.Top,v,g,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),e){const{count:g}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:g})}const C=V(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(z){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,z);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{O(n)},nt=(n,s)=>{const P=y(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(k){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),D(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=A(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=w(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=w(P);c&&t.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const g=T==null?void 0:T.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,g,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),c&&(e==null||e.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=T==null?void 0:T.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,e)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),c&&(e==null||e.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),e==null||e.generateBoxes(n)},initPointCloud3d:n=>{if(!e)return;const s={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};e.initOrthographicCamera(s),e.initRenderer(),e.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=T){var P,c,u,C,g,v;if(!(s==null?void 0:s.url)||!e)return;actionCreators.SetPointCloudLoading(F,!0),yield e.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),h.forEach(S=>{e==null||e.removeObjectByName(S.id)}),f.forEach(S=>{e==null||e.removeObjectByName(S.id)});let m=[],b=[],B=[],I=[];s.result?(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),B=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),I=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),m.forEach(S=>{e==null||e.generateBox(S)}),I.forEach(S=>{e==null||e.generateSphere(S)}),t.syncAllViewPointCloudColor(m),t.setPointCloudResult(m),t.setPolygonList(B),t.setLineList(b),t.setPointCloudSphereList(I)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),U({pointCloudBoxList:m,polygonList:B,pointCloudSphereList:I}),e.updateTopCamera();const q=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),o.updateData(s.url,s.result,{radius:(v=L==null?void 0:L.radius)!=null?v:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MathUtils as x,getCuboidFromPointCloudBox as Ot}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as D,DEFAULT_SPHERE_PARAMS as Vt}from"@labelbee/lb-utils";import{useContext as Ut}from"react";import{PointCloudContext as kt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as At}from"./useSphere.js";import{useSelector as jt,useDispatch as Tt}from"../../../store/ctx.js";import zt from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as dt}from"../../../store/annotation/actionCreators.js";import{message as Rt}from"antd";import{useTranslation as Et}from"react-i18next";import{useHistory as Ht}from"./useHistory.js";import{usePolygon as Ft}from"./usePolygon.js";var Nt=Object.defineProperty,Zt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,at=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&at(t,n,e[n]);if(lt)for(var n of lt(e))Gt.call(e,n)&&at(t,n,e[n]);return t},A=(t,e)=>Zt(t,Wt(e)),q=(t,e,n)=>new Promise((d,o)=>{var a=l=>{try{r(n.next(l))}catch(P){o(P)}},p=l=>{try{r(n.throw(l))}catch(P){o(P)}},r=l=>l.done?d(l.value):Promise.resolve(l.value).then(a,p);r((n=n.apply(t,e)).next())});const G=5,Q=90,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(t,e,n,d,o)=>{const{x:a,y:p}=D.transferCanvas2World(t,e),{defaultZ:r}=Vt,l={center:{x:a,y:p,z:r},id:t.id},P=d?y(y({},d),l):A(y({},l),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},K=(t,e,n,d,o,a)=>{let p=t.pointList.map(m=>D.transferCanvas2World(m,e)),r=0,l=1,P={};if(n){const m=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&m.fittedCoordinates.length>0&&(p=m.fittedCoordinates),r=(m.maxZ+m.minZ)/2,l=m.maxZ-m.minZ,P={count:m.zCount}}const[h,B,j]=p,V=x.getLineCenterPoint([h,j]),T=x.getLineLength(h,B),z=x.getLineLength(B,j),R=x.getRadiusFromQuadrangle(t.pointList);d&&(r=d.center.z,l=d.depth);const U={center:{x:V.x,y:V.y,z:r},width:z,height:T,depth:l,rotation:R,id:t.id},_=y(d?y(y({},d),U):A(y({},U),{attribute:"",valid:!0}),P);o&&Object.assign(_,o);const E=p.map(m=>D.transferWorld2Canvas(m,e));return{boxParams:_,newPointList:E}},ct=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(y({},n),{center:{x:n.center.x-d.x,y:n.center.y,z:n.center.z-d.y}})},ut=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),_=x.getLineLength(l,P),E=U-_,{newBoxParams:m}=d.getNewBoxBySideUpdate(V,E,R,n);return m},Qt=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(y({},n),{center:{x:n.center.x,y:n.center.y-d.x,z:n.center.z-d.y}})},Xt=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),_=x.getLineLength(l,P),E=U-_;let{newBoxParams:m}=d.getNewBoxByBackUpdate(V,E,R,n);return m},pt=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Left);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(y(y({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},ft=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},Ct=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Back);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(y(y({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},Pt=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},gt=(t,e,n,d)=>{if(!n||!d)return;d.generateSphere(t),d.updateCameraBySphere(t,N.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...o.pointList].map(l=>l.id===e.id?A(y(y({},e),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):l);o.setResult(r),o.setSelectedID(e.id)},$=(t,e,n,d)=>{var o;if(!n||!d)return;d.generateBox(t,e.id),d.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),l=[...a.polygonList],P=l.find(h=>h.id===e.id);P?P.pointList=r:l.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),a.setResultAndSelectedID(l,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:l,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:B}=t,{addHistory:j,initHistory:V,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:z}=Ht(),{selectedPolygon:R}=Ft(),{updateSelectedBox:U,updateSelectedBoxes:_,getPointCloudByID:E}=st(),{getPointCloudSphereByID:m,updatePointCloudSphere:tt,selectedSphere:Z}=At(),{currentData:F,config:S}=jt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(zt.getCurrentStepInfo(f,s).config)}}),ot=Tt(),{selectedBox:H}=st(),{t:ht}=Et(),et=H==null?void 0:H.info;if(!e||!n||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,Lt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},yt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},mt=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:D.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const g=J(i,s,X,void 0,C);r(i.id);const v=p(g);W(L.Top,i,g,f,v,S),j({newSphereParams:g})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=e.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:D.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const w=e==null?void 0:e.toolInstance,O=y({},i),{boxParams:b,newPointList:k}=K(O,s,X,void 0,v,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Rt.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),w.deletePolygon(b.id);return}C&&(k==null?void 0:k.length)&&(O.pointList=k);const Y=B.includes(O.attribute),I=a(b);Y?r([]):(r(b.id),w.selection.setSelectedIDs(O.id),M(L.Top,O,b,u,I),C&&$(b,O,e,o)),e==null||e.updatePolygonList(I!=null?I:[]),j({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(l.length===0||!C)){if(i||(H==null?void 0:H.info)){const g=i!=null?i:H==null?void 0:H.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(l[0]);const v=C.selectedPolygon;if(l.length===1&&g){M(L.Top,v,g,void 0,s);return}}if((f||Z)&&l.length===1){const g=f!=null?f:Z;C.setSelectedID(l[0]);const v=C.selectedPoint;g&&W(L.Top,v,g,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case L.Back:c=Xt;break;case L.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),o){const{count:g}=o.getSensesPointZAxisInPolygon(Ot(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(y({},u),{count:g})}const C=U(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case L.Back:c=Qt;break;case L.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,L.Side)},St=(i,s)=>{it(i,s,L.Back)},bt=(i,s)=>{nt(i,s,L.Side)},wt=(i,s)=>{nt(i,s,L.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=m(i.id),c=J(i,s,X,f),u=tt(c);W(L.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(R){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>D.transferCanvas2World(u,s)),T(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=E(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=_(f);M(L.Top,c,f[0],void 0,u)}else{const c=_(f);c&&t.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const g=F==null?void 0:F.url,v={[L.Side]:()=>{pt(f,s,n,g,C)},[L.Back]:()=>{d&&Ct(f,s,d,g,C)},[L.Top]:()=>{gt(f,s,e,o)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(o==null||o.updateCameraZoom(c)),yt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=F==null?void 0:F.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[L.Side]:()=>{ft(f,s,n,C)},[L.Back]:()=>{d&&Pt(f,s,d,C)},[L.Top]:()=>{$(f,s,e,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),c&&(o==null||o.updateCameraZoom(c)),Lt(f)});return{topViewAddSphere:mt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=F){var f,c,u,C,g,v;if(!(s==null?void 0:s.url)||!o)return;dt(ot,!0),yield o.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),P.forEach(I=>{o==null||o.removeObjectByName(I.id)}),h.forEach(I=>{o==null||o.removeObjectByName(I.id)});let w=[],O=[],b=[],k=[];s.result?(w=D.getBoxParamsFromResultList(s.result),b=D.getPolygonListFromResultList(s.result),O=D.getLineListFromResultList(s.result),k=D.getSphereParamsFromResultList(s.result),w.forEach(I=>{o==null||o.generateBox(I)}),k.forEach(I=>{o==null||o.generateSphere(I)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(O),t.setPointCloudSphereList(k)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:k}),o.updateTopCamera();const Y=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),dt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,gt as syncTopViewByPoint,Pt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Yt as usePointCloudViews};
|
|
1
|
+
import{MathUtils as x,getCuboidFromPointCloudBox as Ot}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as D,DEFAULT_SPHERE_PARAMS as Vt}from"@labelbee/lb-utils";import{useContext as Ut}from"react";import{PointCloudContext as kt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as At}from"./useSphere.js";import{useSelector as jt,useDispatch as Tt}from"../../../store/ctx.js";import zt from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as dt}from"../../../store/annotation/actionCreators.js";import{message as Rt}from"antd";import{useTranslation as Et}from"react-i18next";import{useHistory as Ht}from"./useHistory.js";import{usePolygon as Ft}from"./usePolygon.js";var Nt=Object.defineProperty,Zt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,at=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&at(t,n,e[n]);if(lt)for(var n of lt(e))Gt.call(e,n)&&at(t,n,e[n]);return t},A=(t,e)=>Zt(t,Wt(e)),q=(t,e,n)=>new Promise((d,o)=>{var a=l=>{try{r(n.next(l))}catch(P){o(P)}},p=l=>{try{r(n.throw(l))}catch(P){o(P)}},r=l=>l.done?d(l.value):Promise.resolve(l.value).then(a,p);r((n=n.apply(t,e)).next())});const G=5,Q=90,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(t,e,n,d,o)=>{const{x:a,y:p}=D.transferCanvas2World(t,e),{defaultZ:r}=Vt,l={center:{x:a,y:p,z:r},id:t.id},P=d?y(y({},d),l):A(y({},l),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},K=(t,e,n,d,o,a)=>{let p=t.pointList.map(m=>D.transferCanvas2World(m,e)),r=0,l=1,P={};if(n){const m=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&m.fittedCoordinates.length>0&&(p=m.fittedCoordinates),r=(m.maxZ+m.minZ)/2,l=m.maxZ-m.minZ,P={count:m.zCount}}const[h,B,j]=p,V=x.getLineCenterPoint([h,j]),T=x.getLineLength(h,B),z=x.getLineLength(B,j),R=x.getRadiusFromQuadrangle(t.pointList);d&&(r=d.center.z,l=d.depth);const U={center:{x:V.x,y:V.y,z:r},width:z,height:T,depth:l,rotation:R,id:t.id},_=y(d?y(y({},d),U):A(y({},U),{attribute:"",valid:!0}),P);o&&Object.assign(_,o);const E=p.map(m=>D.transferWorld2Canvas(m,e));return{boxParams:_,newPointList:E}},ct=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(y({},n),{center:{x:n.center.x-d.x,y:n.center.y,z:n.center.z-d.y}})},ut=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),_=x.getLineLength(l,P),E=U-_,{newBoxParams:m}=d.getNewBoxBySideUpdate(V,E,R,n);return m},Qt=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(y({},n),{center:{x:n.center.x,y:n.center.y-d.x,z:n.center.z-d.y}})},Xt=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),_=x.getLineLength(l,P),E=U-_;let{newBoxParams:m}=d.getNewBoxByBackUpdate(V,E,R,n);return m},pt=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Left);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(y(y({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},ft=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},Ct=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Back);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(y(y({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},Pt=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},gt=(t,e,n,d)=>{if(!n||!d)return;d.generateSphere(t),d.updateCameraBySphere(t,N.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...o.pointList].map(l=>l.id===e.id?A(y(y({},e),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):l);o.setResult(r),o.setSelectedID(e.id)},$=(t,e,n,d)=>{var o;if(!n||!d)return;d.generateBox(t,e.id),d.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),l=[...a.polygonList],P=l.find(h=>h.id===e.id);P?P.pointList=r:l.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),a.setResultAndSelectedID(l,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:l,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:B}=t,{addHistory:j,initHistory:V,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:z}=Ht(),{selectedPolygon:R}=Ft(),{updateSelectedBox:U,updateSelectedBoxes:_,getPointCloudByID:E}=st(),{getPointCloudSphereByID:m,updatePointCloudSphere:tt,selectedSphere:Z}=At(),{currentData:F,config:S}=jt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(zt.getCurrentStepInfo(f,s).config)}}),ot=Tt(),{selectedBox:H}=st(),{t:ht}=Et(),et=H==null?void 0:H.info;if(!e||!n||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,Lt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},yt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},mt=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:D.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const g=J(i,s,X,void 0,C);r(i.id);const v=p(g);W(L.Top,i,g,f,v,S),j({newSphereParams:g})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=e.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:D.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const w=e==null?void 0:e.toolInstance,O=y({},i),{boxParams:b,newPointList:k}=K(O,s,X,void 0,v,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Rt.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),w.deletePolygon(b.id);return}C&&(k==null?void 0:k.length)&&(O.pointList=k);const Y=B.includes(O.attribute),I=a(b);e==null||e.updatePolygonList(I!=null?I:[]),Y?r([]):(r(b.id),w.selection.setSelectedIDs(O.id),M(L.Top,O,b,u,I),C&&$(b,O,e,o)),j({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(l.length===0||!C)){if(i||(H==null?void 0:H.info)){const g=i!=null?i:H==null?void 0:H.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(l[0]);const v=C.selectedPolygon;if(l.length===1&&g){M(L.Top,v,g,void 0,s);return}}if((f||Z)&&l.length===1){const g=f!=null?f:Z;C.setSelectedID(l[0]);const v=C.selectedPoint;g&&W(L.Top,v,g,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case L.Back:c=Xt;break;case L.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),o){const{count:g}=o.getSensesPointZAxisInPolygon(Ot(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(y({},u),{count:g})}const C=U(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case L.Back:c=Qt;break;case L.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,L.Side)},St=(i,s)=>{it(i,s,L.Back)},bt=(i,s)=>{nt(i,s,L.Side)},wt=(i,s)=>{nt(i,s,L.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=m(i.id),c=J(i,s,X,f),u=tt(c);W(L.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(R){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>D.transferCanvas2World(u,s)),T(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=E(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=_(f);M(L.Top,c,f[0],void 0,u)}else{const c=_(f);c&&t.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const g=F==null?void 0:F.url,v={[L.Side]:()=>{pt(f,s,n,g,C)},[L.Back]:()=>{d&&Ct(f,s,d,g,C)},[L.Top]:()=>{gt(f,s,e,o)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(o==null||o.updateCameraZoom(c)),yt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=F==null?void 0:F.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[L.Side]:()=>{ft(f,s,n,C)},[L.Back]:()=>{d&&Pt(f,s,d,C)},[L.Top]:()=>{$(f,s,e,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),c&&(o==null||o.updateCameraZoom(c)),Lt(f)});return{topViewAddSphere:mt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=F){var f,c,u,C,g,v;if(!(s==null?void 0:s.url)||!o)return;dt(ot,!0),yield o.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),P.forEach(I=>{o==null||o.removeObjectByName(I.id)}),h.forEach(I=>{o==null||o.removeObjectByName(I.id)});let w=[],O=[],b=[],k=[];s.result?(w=D.getBoxParamsFromResultList(s.result),b=D.getPolygonListFromResultList(s.result),O=D.getLineListFromResultList(s.result),k=D.getSphereParamsFromResultList(s.result),w.forEach(I=>{o==null||o.generateBox(I)}),k.forEach(I=>{o==null||o.generateSphere(I)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(O),t.setPointCloudSphereList(k)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:k}),o.updateTopCamera();const Y=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),dt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,gt as syncTopViewByPoint,Pt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Yt as usePointCloudViews};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.11.0-alpha.
|
|
3
|
+
"version": "1.11.0-alpha.2",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.15.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.15.0-alpha.2",
|
|
47
47
|
"@labelbee/lb-utils": "1.7.1-alpha.1",
|
|
48
48
|
"ahooks": "^3.4.0",
|
|
49
49
|
"classnames": "^2.3.0",
|