@labelbee/lb-components 1.9.0-alpha.6 → 1.9.0-alpha.7

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 dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:e})=>{const{isActive:t,setTarget3DView:n}=React.useContext(PointCloud3DContext),a=m=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",m)]:!0,active:t});return React__default.default.createElement("span",{onClick:()=>{n(lbUtils.EPerspectiveView[e])},className:a(e.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:e,followTopView:t}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"}),React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{t()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{e()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:e,config:t})=>{var n;const a=React.useContext(PointCloudContext.PointCloudContext),[m,w]=React.useState(!0),u=React.useRef(null),{initPointCloud3d:p}=usePointCloudViews.usePointCloudViews(),l=useSize(u),{t:v}=reactI18next.useTranslation();React.useEffect(()=>{!a.mainViewInstance||p==null||p(l)},[l]);const{selectedBox:s}=useSingleBox.useSingleBox(),f=o=>{var i;const r=s==null?void 0:s.info;r&&((i=a.mainViewInstance)==null||i.updateCameraByBox(r,o))},C=()=>{var o;(o=a.mainViewInstance)==null||o.resetCamera()},V=()=>{var o,i;const r=(o=a.topViewInstance)==null?void 0:o.pointCloudInstance.camera;r&&((i=a.mainViewInstance)==null||i.applyCameraTarget(r))};React.useEffect(()=>{if(u.current&&(e==null?void 0:e.url)){let o=a.mainViewInstance;if(!o&&l.width){const i={left:-l.width/2,right:l.width/2,top:l.height/2,bottom:-l.height/2,near:100,far:-100};o=new lbAnnotation.PointCloud({container:u.current,isOrthographicCamera:!0,orthographicParams:i,config:t}),a.setMainViewInstance(o)}}},[l]),React.useEffect(()=>{var o;if(u.current&&(e==null?void 0:e.url)&&e.result&&a.mainViewInstance){let i=a.mainViewInstance;const r=lbUtils.PointCloudUtils.getBoxParamsFromResultList(e.result);r.forEach(c=>{var d;const _=(d=lbUtils.toolStyleConverter.getColorFromConfig({attribute:c.attribute},__spreadProps(__spreadValues({},t),{attributeConfigurable:!0}),{}))==null?void 0:d.hex;i==null||i.generateBox(c,_)}),a.setPointCloudResult(r),a.setPointCloudValid((o=index.jsonParser(e.result))==null?void 0:o.valid)}},[e,a.mainViewInstance]),React.useEffect(()=>{var o,i,r,c;if(s){f(lbUtils.EPerspectiveView.Top);const d=(r=(i=(o=a.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(c=a.mainViewInstance)==null||c.updateCameraZoom(d)}},[s]);const g=React.useMemo(()=>({reset3DView:C,setTarget3DView:f,isActive:!!s,followTopView:V}),[s,a.mainViewInstance]),P=React__default.default.createElement("div",null,React__default.default.createElement("span",{style:{marginRight:8}},v("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:m,onChange:o=>{var i;w(o),(i=a.mainViewInstance)==null||i.setShowDirection(o)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:v("3DView"),toolbar:P,style:{height:e.mappingImgList&&((n=e.mappingImgList)==null?void 0:n.length)>0?"55%":"100%"}},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:g},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:u})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
1
+ "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,o,n)=>o in e?__defProp(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,__spreadValues=(e,o)=>{for(var n in o||(o={}))__hasOwnProp.call(o,n)&&__defNormalProp(e,n,o[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(o))__propIsEnum.call(o,n)&&__defNormalProp(e,n,o[n]);return e},__spreadProps=(e,o)=>__defProps(e,__getOwnPropDescs(o));const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:e})=>{const{isActive:o,setTarget3DView:n}=React.useContext(PointCloud3DContext),a=m=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",m)]:!0,active:o});return React__default.default.createElement("span",{onClick:()=>{n(lbUtils.EPerspectiveView[e])},className:a(e.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:e,followTopView:o}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"}),React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{o()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{e()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:e,config:o})=>{var n;const a=React.useContext(PointCloudContext.PointCloudContext),[m,w]=React.useState(!0),d=React.useRef(null),{initPointCloud3d:p}=usePointCloudViews.usePointCloudViews(),s=useSize(d),{t:v}=reactI18next.useTranslation();React.useEffect(()=>{!a.mainViewInstance||p==null||p(s)},[s]);const{selectedBox:u}=useSingleBox.useSingleBox(),f=t=>{var i;const r=u==null?void 0:u.info;if(r){const l=__spreadValues({},r.center);l.x=l.x-.01,l.z=10;const c=t===lbUtils.EPerspectiveView.Top;(i=a.mainViewInstance)==null||i.updateCameraByBox(r,t,c?l:void 0)}},C=()=>{var t;(t=a.mainViewInstance)==null||t.resetCamera()},V=()=>{var t,i;const r=(t=a.topViewInstance)==null?void 0:t.pointCloudInstance.camera;r&&((i=a.mainViewInstance)==null||i.applyCameraTarget(r))};React.useEffect(()=>{if(d.current&&(e==null?void 0:e.url)){let t=a.mainViewInstance;if(!t&&s.width){const i={left:-s.width/2,right:s.width/2,top:s.height/2,bottom:-s.height/2,near:100,far:-100};t=new lbAnnotation.PointCloud({container:d.current,isOrthographicCamera:!0,orthographicParams:i,config:o}),a.setMainViewInstance(t)}}},[s]),React.useEffect(()=>{var t;if(d.current&&(e==null?void 0:e.url)&&e.result&&a.mainViewInstance){let i=a.mainViewInstance;const r=lbUtils.PointCloudUtils.getBoxParamsFromResultList(e.result);r.forEach(l=>{var c;const _=(c=lbUtils.toolStyleConverter.getColorFromConfig({attribute:l.attribute},__spreadProps(__spreadValues({},o),{attributeConfigurable:!0}),{}))==null?void 0:c.hex;i==null||i.generateBox(l,_)}),a.setPointCloudResult(r),a.setPointCloudValid((t=index.jsonParser(e.result))==null?void 0:t.valid)}},[e,a.mainViewInstance]),React.useEffect(()=>{var t,i,r,l;if(u){f(lbUtils.EPerspectiveView.Top);const c=(r=(i=(t=a.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(l=a.mainViewInstance)==null||l.updateCameraZoom(c)}},[u]);const P=React.useMemo(()=>({reset3DView:C,setTarget3DView:f,isActive:!!u,followTopView:V}),[u,a.mainViewInstance]),g=React__default.default.createElement("div",null,React__default.default.createElement("span",{style:{marginRight:8}},v("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:m,onChange:t=>{var i;w(t),(i=a.mainViewInstance)==null||i.setShowDirection(t)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:v("3DView"),toolbar:g,style:{height:e.mappingImgList&&((n=e.mappingImgList)==null?void 0:n.length)>0?"55%":"100%"}},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:P},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:d})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),dom=require("../../utils/dom.js"),PointCloudLayout=require("./PointCloudLayout.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudInfos=require("./PointCloudInfos.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),index=require("./components/EmptyPage/index.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,n,o)=>n in t?__defProp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,__spreadValues=(t,n)=>{for(var o in n||(n={}))__hasOwnProp.call(n,o)&&__defNormalProp(t,o,n[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(n))__propIsEnum.call(n,o)&&__defNormalProp(t,o,n[o]);return t},__spreadProps=(t,n)=>__defProps(t,__getOwnPropDescs(n));const TransferCanvas2WorldOffset=(t,n,o=1)=>{const{width:e,height:i}=n,s={x:t.x+e*o/2,y:t.y+i*o/2},d={x:n.width/2,y:n.height/2};return{offsetX:(d.x-s.x)/o,offsetY:-(d.y-s.y)/o}},updateBackViewByCanvas2D=(t,n,o,e,i)=>{const{offsetX:s,offsetY:d}=TransferCanvas2WorldOffset(t,o,n);if(i.camera.zoom=n,t){const p=Math.cos(e.rotation),P=Math.sin(e.rotation),g=s*p,h=s*P,{x:r,y:u,z:c}=i.initCameraPosition;i.camera.position.set(r+h,u-g,c+d)}i.camera.updateProjectionMatrix(),i.render()},PointCloudSideView=({currentData:t,config:n,checkMode:o})=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),i=React.useRef(null),s=useSize(i),{selectedBox:d,updateSelectedBox:p}=useSingleBox.useSingleBox(),{t:P}=reactI18next.useTranslation(),{backViewUpdateBox:g}=usePointCloudViews.usePointCloudViews(),h=(r,u)=>{if(!e.selectedPointCloudBox||!e.mainViewInstance||!t.url||!e.backViewInstance)return;const{pointCloudInstance:c}=e.backViewInstance,[l,f,x]=r.pointList,[v,m,y]=u.pointList,w=lbAnnotation.MathUtils.getLineCenterPoint([l,x]),C=lbAnnotation.MathUtils.getLineCenterPoint([v,y]),V={x:{x:w.x-C.x,y:w.y-C.y}.x,y:0,z:w.y-C.y},B=lbAnnotation.MathUtils.getLineLength(l,f),b=lbAnnotation.MathUtils.getLineLength(v,m),I=B-b,_=lbAnnotation.MathUtils.getLineLength(f,x),O=lbAnnotation.MathUtils.getLineLength(m,y),L=_-O;let{newBoxParams:a}=c.getNewBoxByBackUpdate(V,L,I,e.selectedPointCloudBox);if(e.mainViewInstance){const{count:j}=e.mainViewInstance.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=__spreadProps(__spreadValues({},a),{count:j})}usePointCloudViews.synchronizeTopView(a,r,e.topViewInstance,e.mainViewInstance),usePointCloudViews.synchronizeSideView(a,r,e.sideViewInstance,t.url),e.mainViewInstance.highlightOriginPointCloud([a]),p(a)};return React.useEffect(()=>{if(i.current){const r={width:i.current.clientWidth,height:i.current.clientHeight},u=new lbAnnotation.PointCloudAnnotation({container:i.current,size:r,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0},config:n,checkMode:o});e.setBackViewInstance(u)}},[]),React.useEffect(()=>{if(!s||!e.backViewInstance)return;const{pointCloud2dOperation:r,pointCloudInstance:u}=e.backViewInstance;r.singleOn("renderZoom",(c,l)=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(l,c,s,e.selectedPointCloudBox,u)}),r.singleOn("dragMove",({currentPos:c,zoom:l})=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(c,l,s,e.selectedPointCloudBox,u)}),r.singleOn("updatePolygonByDrag",c=>{if(e.selectedIDs.length===1&&c.length===1){const{newPolygon:l,originPolygon:f}=c[0];l&&f&&(h(l,f),g(l,f))}})},[e,s]),React.useEffect(()=>{var r;(r=e==null?void 0:e.backViewInstance)==null||r.initSize(s)},[s]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","back-view"),title:P("BackView"),toolbar:React__default.default.createElement(PointCloudInfos.SizeInfoForView,{perspectiveView:lbUtils.EPerspectiveView.Back})},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","bottom-view-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","core-instance"),ref:i}),!d&&React__default.default.createElement(index,null)))};var PointCloudBackView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudSideView);module.exports=PointCloudBackView;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),dom=require("../../utils/dom.js"),PointCloudLayout=require("./PointCloudLayout.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudInfos=require("./PointCloudInfos.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),index=require("./components/EmptyPage/index.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var React__default=_interopDefaultLegacy(React);const TransferCanvas2WorldOffset=(n,a,r=1)=>{const{width:e,height:t}=a,o={x:n.x+e*r/2,y:n.y+t*r/2},l={x:a.width/2,y:a.height/2};return{offsetX:(l.x-o.x)/r,offsetY:-(l.y-o.y)/r}},updateBackViewByCanvas2D=(n,a,r,e,t)=>{const{offsetX:o,offsetY:l}=TransferCanvas2WorldOffset(n,r,a);if(t.camera.zoom=a,n){const f=Math.cos(e.rotation),C=Math.sin(e.rotation),i=o*f,u=o*C,{x:s,y:c,z:d}=t.initCameraPosition;t.camera.position.set(s+u,c-i,d+l)}t.camera.updateProjectionMatrix(),t.render()},PointCloudSideView=({currentData:n,config:a,checkMode:r})=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),t=React.useRef(null),o=useSize(t),{selectedBox:l}=useSingleBox.useSingleBox(),{t:f}=reactI18next.useTranslation(),{backViewUpdateBox:C}=usePointCloudViews.usePointCloudViews();return React.useEffect(()=>{if(t.current){const i={width:t.current.clientWidth,height:t.current.clientHeight},u=new lbAnnotation.PointCloudAnnotation({container:t.current,size:i,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0},config:a,checkMode:r});e.setBackViewInstance(u)}},[]),React.useEffect(()=>{if(!o||!e.backViewInstance)return;const{pointCloud2dOperation:i,pointCloudInstance:u}=e.backViewInstance;i.singleOn("renderZoom",(s,c)=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(c,s,o,e.selectedPointCloudBox,u)}),i.singleOn("dragMove",({currentPos:s,zoom:c})=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(s,c,o,e.selectedPointCloudBox,u)}),i.singleOn("updatePolygonByDrag",s=>{if(e.selectedIDs.length===1&&s.length===1){const{newPolygon:c,originPolygon:d}=s[0];c&&d&&C(c,d)}})},[e,o]),React.useEffect(()=>{var i;(i=e==null?void 0:e.backViewInstance)==null||i.initSize(o)},[o]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","back-view"),title:f("BackView"),toolbar:React__default.default.createElement(PointCloudInfos.SizeInfoForView,{perspectiveView:lbUtils.EPerspectiveView.Back})},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","bottom-view-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","core-instance"),ref:t}),!l&&React__default.default.createElement(index,null)))};var PointCloudBackView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudSideView);module.exports=PointCloudBackView;
@@ -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"),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,n)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,__spreadValues=(t,o)=>{for(var n in o||(o={}))__hasOwnProp.call(o,n)&&__defNormalProp(t,n,o[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(o))__propIsEnum.call(o,n)&&__defNormalProp(t,n,o[n]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,n)=>new Promise((c,e)=>{var s=d=>{try{u(n.next(d))}catch(C){e(C)}},g=d=>{try{u(n.throw(d))}catch(C){e(C)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(s,g);u((n=n.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPolygon2PointCloud=(t,o,n,c,e)=>{const[s,g,u,d]=t.pointList.map(P=>lbUtils.PointCloudUtils.transferCanvas2World(P,o)),C=lbAnnotation.MathUtils.getLineCenterPoint([s,u]),h=lbAnnotation.MathUtils.getLineLength(s,g),x=lbAnnotation.MathUtils.getLineLength(g,u),_=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);let m=0,w=1,y={};if(n){const P=n.getSensesPointZAxisInPolygon([s,g,u,d]);m=(P.maxZ+P.minZ)/2,w=P.maxZ-P.minZ,y={count:P.zCount}}c&&(m=c.center.z,w=c.depth);const U={center:{x:C.x,y:C.y,z:m},width:x,height:h,depth:w,rotation:_,id:t.id},v=__spreadValues(c?__spreadValues(__spreadValues({},c),U):__spreadProps(__spreadValues({},U),{attribute:"",valid:!0}),y);return e&&Object.assign(v,e),v},sideViewPolygon2PointCloud=(t,o,n,c)=>{const[e,s,g]=t.pointList,[u,d,C]=o.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,g]),x=lbAnnotation.MathUtils.getLineCenterPoint([u,C]),m={x:{x:h.x-x.x,y:h.y-x.y}.x,y:0,z:h.y-x.y},w=lbAnnotation.MathUtils.getLineLength(e,s),y=lbAnnotation.MathUtils.getLineLength(u,d),U=w-y,v=lbAnnotation.MathUtils.getLineLength(s,g),P=lbAnnotation.MathUtils.getLineLength(d,C),O=v-P,{newBoxParams:b}=c.getNewBoxBySideUpdate(m,O,U,n);return b},backViewPolygon2PointCloud=(t,o,n,c)=>{const[e,s,g]=t.pointList,[u,d,C]=o.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,g]),x=lbAnnotation.MathUtils.getLineCenterPoint([u,C]),m={x:{x:h.x-x.x,y:h.y-x.y}.x,y:0,z:h.y-x.y},w=lbAnnotation.MathUtils.getLineLength(e,s),y=lbAnnotation.MathUtils.getLineLength(u,d),U=w-y,v=lbAnnotation.MathUtils.getLineLength(s,g),P=lbAnnotation.MathUtils.getLineLength(d,C),O=v-P;let{newBoxParams:b}=c.getNewBoxByBackUpdate(m,O,U,n);return b},synchronizeSideView=(t,o,n,c)=>{if(!n)return;const{pointCloud2dOperation:e,pointCloudInstance:s}=n;s.loadPCDFileByBox(c,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=s.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);s.setInitCameraPosition(g);const{polygon2d:u,zoom:d}=s.getBoxSidePolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:u,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},synchronizeBackView=(t,o,n,c)=>{if(!n)return;const{pointCloud2dOperation:e,pointCloudInstance:s}=n;s.loadPCDFileByBox(c,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=s.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);s.setInitCameraPosition(g);const{polygon2d:u,zoom:d}=s.getBoxBackPolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:u,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},synchronizeTopView=(t,o,n,c)=>{var e;if(!n||!c)return;c.generateBox(t,o.id),c.updateCameraByBox(t,lbUtils.EPerspectiveView.Top),c.render();const{pointCloud2dOperation:s,pointCloudInstance:g}=n,{polygon2d:u}=g.getBoxTopPolygon2DCoordinate(t),d=[...s.polygonList],C=d.find(h=>h.id===o.id);C?C.pointList=u:d.push({id:o.id,pointList:u,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),s.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:n,backViewInstance:c,mainViewInstance:e,addPointCloudBox:s,setSelectedIDs:g,selectedIDs:u,pointCloudBoxList:d,hideAttributes:C}=t,{addHistory:h,initHistory:x,pushHistoryUnderUpdatePolygon:_}=useHistory.useHistory(),{selectedPolygon:m}=usePolygon.usePolygon(),{updateSelectedBox:w,updateSelectedBoxes:y,getPointCloudByID:U}=useSingleBox.useSingleBox(),{currentData:v,config:P}=ctx.useSelector(i=>{const{stepList:r,step:p,imgList:l,imgIndex:a}=i.annotation;return{currentData:l[a],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,r).config)}}),O=ctx.useDispatch(),{selectedBox:b}=useSingleBox.useSingleBox(),{t:M}=reactI18next.useTranslation(),A=b==null?void 0:b.info;if(!o||!n||!c)return{topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:T}=o,z=i=>{e==null||e.generateBox(i),e==null||e.controls.update(),e==null||e.render()},R=({newPolygon:i,size:r,imgList:p,trackConfigurable:l,zoom:a})=>{var f;const L={attribute:(f=o.pointCloud2dOperation.defaultAttribute)!=null?f:""};l===!0&&Object.assign(L,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:d})});const B=topViewPolygon2PointCloud(i,r,T,void 0,L),S=o==null?void 0:o.pointCloud2dOperation,V=B;if((P==null?void 0:P.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<P.lowerLimitPointsNumInBox){antd.message.info(M("LowerLimitPointsNumInBox",{num:P.lowerLimitPointsNumInBox})),S.deletePolygon(B.id);return}const j=C.includes(i.attribute),I=s(V);j?g([]):(g(V.id),S.setSelectedIDs([i.id]),D(PointCloudView.Top,i,V,a,I)),h({newBoxParams:V})},q=(i,r)=>{const p=i!=null?i:b==null?void 0:b.info,l=o==null?void 0:o.pointCloud2dOperation;if(l.setSelectedIDs(u),u.length===0||!l)return;const a=l.selectedPolygon;if(u.length===1&&p){D(PointCloudView.Top,a,p,void 0,r);return}},k=(i,r,p)=>{if(A){let l,a;switch(p){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(a=l(i,r,A,n.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=__spreadProps(__spreadValues({},a),{count:L})}const f=w(a);return D(p,i,a,void 0,f),f}},E=(i,r)=>{k(i,r,PointCloudView.Side)},H=(i,r)=>{k(i,r,PointCloudView.Back)},F=(i,r)=>{if(m){const l=i[0].newPolygon;l.pointList=l.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,r)),_(i[0].newPolygon);return}const p=i.map(({newPolygon:l})=>{const a=U(l.id);return topViewPolygon2PointCloud(l,r,o.pointCloudInstance,a)});if(p.length===1){const{newPolygon:l}=i[0],a=y(p);D(PointCloudView.Top,l,p[0],void 0,a)}else{const l=y(p);l&&t.syncAllViewPointCloudColor(l)}},D=(i,r,p,l,a)=>__async(void 0,null,function*(){const f=v==null?void 0:v.url;a&&(yield t.syncAllViewPointCloudColor(a));const L={[PointCloudView.Side]:()=>{synchronizeSideView(p,r,n,f)},[PointCloudView.Back]:()=>{c&&synchronizeBackView(p,r,c,f)},[PointCloudView.Top]:()=>{synchronizeTopView(p,r,o,e)}};Object.keys(L).forEach(B=>{B!==i&&L[B]()}),l&&(e==null||e.updateCameraZoom(l)),z(p)});return{topViewAddBox:R,topViewSelectedChanged:q,topViewUpdateBox:F,sideViewUpdateBox:E,backViewUpdateBox:H,pointCloudBoxListUpdated:i=>{o.updatePolygonList(i),e==null||e.generateBoxes(i)},initPointCloud3d:i=>{if(!e)return;const r={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};e.initOrthographicCamera(r),e.initRenderer(),e.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(r=v){var p,l,a,f,L,B;if(!(r==null?void 0:r.url)||!e)return;actionCreators.SetPointCloudLoading(O,!0),yield e.loadPCDFile(r.url,(p=P==null?void 0:P.radius)!=null?p:DEFAULT_RADIUS),d.forEach(I=>{e==null||e.removeObjectByName(I.id)});let S=[],V=[];r.result?(S=lbUtils.PointCloudUtils.getBoxParamsFromResultList(r.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(r.result),S.forEach(I=>{e==null||e.generateBox(I)}),t.syncAllViewPointCloudColor(S),t.setPointCloudResult(S),t.setPolygonList(V)):(t.setPointCloudResult([]),t.setPolygonList([])),x({pointCloudBoxList:S,polygonList:V}),e.updateTopCamera();const j=(a=(l=index.jsonParser(r.result))==null?void 0:l.valid)!=null?a:!0;t.setPointCloudValid(j),(f=t.sideViewInstance)==null||f.clearAllData(),(L=t.backViewInstance)==null||L.clearAllData(),o.updateData(r.url,r.result,{radius:(B=P==null?void 0:P.radius)!=null?B:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(O,!1)})}};exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,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"),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,n)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,__spreadValues=(t,o)=>{for(var n in o||(o={}))__hasOwnProp.call(o,n)&&__defNormalProp(t,n,o[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(o))__propIsEnum.call(o,n)&&__defNormalProp(t,n,o[n]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,n)=>new Promise((u,e)=>{var s=d=>{try{c(n.next(d))}catch(C){e(C)}},g=d=>{try{c(n.throw(d))}catch(C){e(C)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(s,g);c((n=n.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPolygon2PointCloud=(t,o,n,u,e)=>{const[s,g,c,d]=t.pointList.map(P=>lbUtils.PointCloudUtils.transferCanvas2World(P,o)),C=lbAnnotation.MathUtils.getLineCenterPoint([s,c]),h=lbAnnotation.MathUtils.getLineLength(s,g),x=lbAnnotation.MathUtils.getLineLength(g,c),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);let m=0,w=1,y={};if(n){const P=n.getSensesPointZAxisInPolygon([s,g,c,d]);m=(P.maxZ+P.minZ)/2,w=P.maxZ-P.minZ,y={count:P.zCount}}u&&(m=u.center.z,w=u.depth);const U={center:{x:C.x,y:C.y,z:m},width:x,height:h,depth:w,rotation:O,id:t.id},v=__spreadValues(u?__spreadValues(__spreadValues({},u),U):__spreadProps(__spreadValues({},U),{attribute:"",valid:!0}),y);return e&&Object.assign(v,e),v},sideViewPolygon2PointCloud=(t,o,n,u)=>{const[e,s,g]=t.pointList,[c,d,C]=o.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,g]),x=lbAnnotation.MathUtils.getLineCenterPoint([c,C]),m={x:{x:h.x-x.x,y:h.y-x.y}.x,y:0,z:h.y-x.y},w=lbAnnotation.MathUtils.getLineLength(e,s),y=lbAnnotation.MathUtils.getLineLength(c,d),U=w-y,v=lbAnnotation.MathUtils.getLineLength(s,g),P=lbAnnotation.MathUtils.getLineLength(d,C),I=v-P,{newBoxParams:b}=u.getNewBoxBySideUpdate(m,I,U,n);return b},backViewPolygon2PointCloud=(t,o,n,u)=>{const[e,s,g]=t.pointList,[c,d,C]=o.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,g]),x=lbAnnotation.MathUtils.getLineCenterPoint([c,C]),m={x:{x:h.x-x.x,y:h.y-x.y}.x,y:0,z:h.y-x.y},w=lbAnnotation.MathUtils.getLineLength(e,s),y=lbAnnotation.MathUtils.getLineLength(c,d),U=w-y,v=lbAnnotation.MathUtils.getLineLength(s,g),P=lbAnnotation.MathUtils.getLineLength(d,C),I=v-P;let{newBoxParams:b}=u.getNewBoxByBackUpdate(m,I,U,n);return b},synchronizeSideView=(t,o,n,u)=>{if(!n)return;const{pointCloud2dOperation:e,pointCloudInstance:s}=n;s.loadPCDFileByBox(u,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=s.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);s.setInitCameraPosition(g);const{polygon2d:c,zoom:d}=s.getBoxSidePolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:c,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},synchronizeBackView=(t,o,n,u)=>{if(!n)return;const{pointCloud2dOperation:e,pointCloudInstance:s}=n;s.loadPCDFileByBox(u,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=s.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);s.setInitCameraPosition(g);const{polygon2d:c,zoom:d}=s.getBoxBackPolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:c,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},synchronizeTopView=(t,o,n,u)=>{var e;if(!n||!u)return;u.generateBox(t,o.id),u.render();const{pointCloud2dOperation:s,pointCloudInstance:g}=n,{polygon2d:c}=g.getBoxTopPolygon2DCoordinate(t),d=[...s.polygonList],C=d.find(h=>h.id===o.id);C?C.pointList=c:d.push({id:o.id,pointList:c,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),s.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:n,backViewInstance:u,mainViewInstance:e,addPointCloudBox:s,setSelectedIDs:g,selectedIDs:c,pointCloudBoxList:d,hideAttributes:C}=t,{addHistory:h,initHistory:x,pushHistoryUnderUpdatePolygon:O}=useHistory.useHistory(),{selectedPolygon:m}=usePolygon.usePolygon(),{updateSelectedBox:w,updateSelectedBoxes:y,getPointCloudByID:U}=useSingleBox.useSingleBox(),{currentData:v,config:P}=ctx.useSelector(i=>{const{stepList:r,step:p,imgList:l,imgIndex:a}=i.annotation;return{currentData:l[a],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,r).config)}}),I=ctx.useDispatch(),{selectedBox:b}=useSingleBox.useSingleBox(),{t:M}=reactI18next.useTranslation(),A=b==null?void 0:b.info;if(!o||!n||!u)return{topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:z}=o,T=i=>{e==null||e.generateBox(i),e==null||e.controls.update(),e==null||e.render()},R=({newPolygon:i,size:r,imgList:p,trackConfigurable:l,zoom:a})=>{var f;const L={attribute:(f=o.pointCloud2dOperation.defaultAttribute)!=null?f:""};l===!0&&Object.assign(L,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:d})});const B=topViewPolygon2PointCloud(i,r,z,void 0,L),S=o==null?void 0:o.pointCloud2dOperation,V=B;if((P==null?void 0:P.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<P.lowerLimitPointsNumInBox){antd.message.info(M("LowerLimitPointsNumInBox",{num:P.lowerLimitPointsNumInBox})),S.deletePolygon(B.id);return}const j=C.includes(i.attribute),_=s(V);j?g([]):(g(V.id),S.setSelectedIDs([i.id]),D(PointCloudView.Top,i,V,a,_)),h({newBoxParams:V})},q=(i,r)=>{const p=i!=null?i:b==null?void 0:b.info,l=o==null?void 0:o.pointCloud2dOperation;if(l.setSelectedIDs(c),c.length===0||!l)return;const a=l.selectedPolygon;if(c.length===1&&p){D(PointCloudView.Top,a,p,void 0,r);return}},k=(i,r,p)=>{if(A){let l,a;switch(p){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(a=l(i,r,A,n.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=__spreadProps(__spreadValues({},a),{count:L})}const f=w(a);return D(p,i,a,void 0,f),f}},H=(i,r)=>{k(i,r,PointCloudView.Side)},E=(i,r)=>{k(i,r,PointCloudView.Back)},F=(i,r)=>{if(m){const l=i[0].newPolygon;l.pointList=l.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,r)),O(i[0].newPolygon);return}const p=i.map(({newPolygon:l})=>{const a=U(l.id);return topViewPolygon2PointCloud(l,r,o.pointCloudInstance,a)});if(p.length===1){const{newPolygon:l}=i[0],a=y(p);D(PointCloudView.Top,l,p[0],void 0,a)}else{const l=y(p);l&&t.syncAllViewPointCloudColor(l)}},D=(i,r,p,l,a)=>__async(void 0,null,function*(){const f=v==null?void 0:v.url;a&&(yield t.syncAllViewPointCloudColor(a));const L={[PointCloudView.Side]:()=>{synchronizeSideView(p,r,n,f)},[PointCloudView.Back]:()=>{u&&synchronizeBackView(p,r,u,f)},[PointCloudView.Top]:()=>{synchronizeTopView(p,r,o,e)}};Object.keys(L).forEach(B=>{B!==i&&L[B]()}),l&&(e==null||e.updateCameraZoom(l)),T(p)});return{topViewAddBox:R,topViewSelectedChanged:q,topViewUpdateBox:F,sideViewUpdateBox:H,backViewUpdateBox:E,pointCloudBoxListUpdated:i=>{o.updatePolygonList(i),e==null||e.generateBoxes(i)},initPointCloud3d:i=>{if(!e)return;const r={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};e.initOrthographicCamera(r),e.initRenderer(),e.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(r=v){var p,l,a,f,L,B;if(!(r==null?void 0:r.url)||!e)return;actionCreators.SetPointCloudLoading(I,!0),yield e.loadPCDFile(r.url,(p=P==null?void 0:P.radius)!=null?p:DEFAULT_RADIUS),d.forEach(_=>{e==null||e.removeObjectByName(_.id)});let S=[],V=[];r.result?(S=lbUtils.PointCloudUtils.getBoxParamsFromResultList(r.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(r.result),S.forEach(_=>{e==null||e.generateBox(_)}),t.syncAllViewPointCloudColor(S),t.setPointCloudResult(S),t.setPolygonList(V)):(t.setPointCloudResult([]),t.setPolygonList([])),x({pointCloudBoxList:S,polygonList:V}),e.updateTopCamera();const j=(a=(l=index.jsonParser(r.result))==null?void 0:l.valid)!=null?a:!0;t.setPointCloudValid(j),(f=t.sideViewInstance)==null||f.clearAllData(),(L=t.backViewInstance)==null||L.clearAllData(),o.updateData(r.url,r.result,{radius:(B=P==null?void 0:P.radius)!=null?B:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(I,!1)})}};exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
@@ -1 +1 @@
1
- import{getClassName as c}from"../../utils/dom.js";import{PointCloud as B}from"@labelbee/lb-annotation";import{PointCloudUtils as L,toolStyleConverter as N,EPerspectiveView as _}from"@labelbee/lb-utils";import D from"classnames";import t,{useContext as C,useState as R,useRef as k,useEffect as v,useMemo as z}from"react";import{PointCloudContainer as A}from"./PointCloudLayout.js";import{PointCloudContext as F}from"./PointCloudContext.js";import{a2MapStateToProps as M}from"../../store/annotation/map.js";import{connect as U}from"react-redux";import{jsonParser as Z}from"../../utils/index.js";import{useSingleBox as q}from"./hooks/useSingleBox.js";import{Switch as G,Tooltip as H}from"antd";import J from"../../hooks/useSize.js";import{usePointCloudViews as K}from"./hooks/usePointCloudViews.js";import{useTranslation as E}from"react-i18next";import{LabelBeeContext as Q}from"../../store/ctx.js";var W=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,I=(e,o,r)=>o in e?W(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,te=(e,o)=>{for(var r in o||(o={}))$.call(o,r)&&I(e,r,o[r]);if(x)for(var r of x(o))ee.call(o,r)&&I(e,r,o[r]);return e},oe=(e,o)=>X(e,Y(o));const ie="LABELBEE-POINTCLOUD",V=t.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),m=({perspectiveView:e})=>{const{isActive:o,setTarget3DView:r}=C(V),n=f=>D({[c("point-cloud-3d-view",f)]:!0,active:o});return t.createElement("span",{onClick:()=>{r(_[e])},className:n(e.toLocaleLowerCase())})},ne=()=>{const{reset3DView:e,followTopView:o}=C(V),{t:r}=E();return t.createElement("div",{className:c("point-cloud-3d-sidebar")},t.createElement(m,{perspectiveView:"Top"}),t.createElement(m,{perspectiveView:"Front"}),t.createElement(m,{perspectiveView:"Left"}),t.createElement(m,{perspectiveView:"Back"}),t.createElement(m,{perspectiveView:"Right"}),t.createElement(m,{perspectiveView:"LFT"}),t.createElement(m,{perspectiveView:"RBT"}),t.createElement(H,{title:r("CameraFollowTopView")},t.createElement("span",{onClick:()=>{o()},className:c("point-cloud-3d-view","followTop")})),t.createElement("span",{onClick:()=>{e()},className:c("point-cloud-3d-view","reset")}))},re=({currentData:e,config:o})=>{var r;const n=C(F),[f,b]=R(!0),p=k(null),{initPointCloud3d:P}=K(),s=J(p),{t:g}=E();v(()=>{!n.mainViewInstance||P==null||P(s)},[s]);const{selectedBox:u}=q(),h=i=>{var a;const l=u==null?void 0:u.info;l&&((a=n.mainViewInstance)==null||a.updateCameraByBox(l,i))},T=()=>{var i;(i=n.mainViewInstance)==null||i.resetCamera()},O=()=>{var i,a;const l=(i=n.topViewInstance)==null?void 0:i.pointCloudInstance.camera;l&&((a=n.mainViewInstance)==null||a.applyCameraTarget(l))};v(()=>{if(p.current&&(e==null?void 0:e.url)){let i=n.mainViewInstance;if(!i&&s.width){const a={left:-s.width/2,right:s.width/2,top:s.height/2,bottom:-s.height/2,near:100,far:-100};i=new B({container:p.current,isOrthographicCamera:!0,orthographicParams:a,config:o}),n.setMainViewInstance(i)}}},[s]),v(()=>{var i;if(p.current&&(e==null?void 0:e.url)&&e.result&&n.mainViewInstance){let a=n.mainViewInstance;const l=L.getBoxParamsFromResultList(e.result);l.forEach(d=>{var w;const y=(w=N.getColorFromConfig({attribute:d.attribute},oe(te({},o),{attributeConfigurable:!0}),{}))==null?void 0:w.hex;a==null||a.generateBox(d,y)}),n.setPointCloudResult(l),n.setPointCloudValid((i=Z(e.result))==null?void 0:i.valid)}},[e,n.mainViewInstance]),v(()=>{var i,a,l,d;if(u){h(_.Top);const w=(l=(a=(i=n.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(d=n.mainViewInstance)==null||d.updateCameraZoom(w)}},[u]);const j=z(()=>({reset3DView:T,setTarget3DView:h,isActive:!!u,followTopView:O}),[u,n.mainViewInstance]),S=t.createElement("div",null,t.createElement("span",{style:{marginRight:8}},g("ShowArrows")),t.createElement(G,{size:"small",checked:f,onChange:i=>{var a;b(i),(a=n.mainViewInstance)==null||a.setShowDirection(i)}}));return t.createElement(A,{className:c("point-cloud-3d-container"),title:g("3DView"),toolbar:S,style:{height:e.mappingImgList&&((r=e.mappingImgList)==null?void 0:r.length)>0?"55%":"100%"}},t.createElement("div",{className:c("point-cloud-3d-content")},t.createElement(V.Provider,{value:j},t.createElement(ne,null)),t.createElement("div",{className:c("point-cloud-3d-view"),id:ie,ref:p})))};var ae=U(M,null,null,{context:Q})(re);export{ae as default};
1
+ import{getClassName as m}from"../../utils/dom.js";import{PointCloud as L}from"@labelbee/lb-annotation";import{PointCloudUtils as N,toolStyleConverter as D,EPerspectiveView as C}from"@labelbee/lb-utils";import z from"classnames";import o,{useContext as V,useState as R,useRef as k,useEffect as v,useMemo as A}from"react";import{PointCloudContainer as F}from"./PointCloudLayout.js";import{PointCloudContext as M}from"./PointCloudContext.js";import{a2MapStateToProps as U}from"../../store/annotation/map.js";import{connect as Z}from"react-redux";import{jsonParser as q}from"../../utils/index.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{Switch as H,Tooltip as J}from"antd";import K from"../../hooks/useSize.js";import{usePointCloudViews as Q}from"./hooks/usePointCloudViews.js";import{useTranslation as E}from"react-i18next";import{LabelBeeContext as W}from"../../store/ctx.js";var X=Object.defineProperty,Y=Object.defineProperties,$=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,I=(e,i,r)=>i in e?X(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,b=(e,i)=>{for(var r in i||(i={}))ee.call(i,r)&&I(e,r,i[r]);if(x)for(var r of x(i))te.call(i,r)&&I(e,r,i[r]);return e},oe=(e,i)=>Y(e,$(i));const ie="LABELBEE-POINTCLOUD",P=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),u=({perspectiveView:e})=>{const{isActive:i,setTarget3DView:r}=V(P),n=f=>z({[m("point-cloud-3d-view",f)]:!0,active:i});return o.createElement("span",{onClick:()=>{r(C[e])},className:n(e.toLocaleLowerCase())})},ne=()=>{const{reset3DView:e,followTopView:i}=V(P),{t:r}=E();return o.createElement("div",{className:m("point-cloud-3d-sidebar")},o.createElement(u,{perspectiveView:"Top"}),o.createElement(u,{perspectiveView:"Front"}),o.createElement(u,{perspectiveView:"Left"}),o.createElement(u,{perspectiveView:"Back"}),o.createElement(u,{perspectiveView:"Right"}),o.createElement(u,{perspectiveView:"LFT"}),o.createElement(u,{perspectiveView:"RBT"}),o.createElement(J,{title:r("CameraFollowTopView")},o.createElement("span",{onClick:()=>{i()},className:m("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{e()},className:m("point-cloud-3d-view","reset")}))},re=({currentData:e,config:i})=>{var r;const n=V(M),[f,T]=R(!0),w=k(null),{initPointCloud3d:g}=Q(),c=K(w),{t:h}=E();v(()=>{!n.mainViewInstance||g==null||g(c)},[c]);const{selectedBox:p}=G(),_=t=>{var a;const l=p==null?void 0:p.info;if(l){const s=b({},l.center);s.x=s.x-.01,s.z=10;const d=t===C.Top;(a=n.mainViewInstance)==null||a.updateCameraByBox(l,t,d?s:void 0)}},O=()=>{var t;(t=n.mainViewInstance)==null||t.resetCamera()},j=()=>{var t,a;const l=(t=n.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((a=n.mainViewInstance)==null||a.applyCameraTarget(l))};v(()=>{if(w.current&&(e==null?void 0:e.url)){let t=n.mainViewInstance;if(!t&&c.width){const a={left:-c.width/2,right:c.width/2,top:c.height/2,bottom:-c.height/2,near:100,far:-100};t=new L({container:w.current,isOrthographicCamera:!0,orthographicParams:a,config:i}),n.setMainViewInstance(t)}}},[c]),v(()=>{var t;if(w.current&&(e==null?void 0:e.url)&&e.result&&n.mainViewInstance){let a=n.mainViewInstance;const l=N.getBoxParamsFromResultList(e.result);l.forEach(s=>{var d;const B=(d=D.getColorFromConfig({attribute:s.attribute},oe(b({},i),{attributeConfigurable:!0}),{}))==null?void 0:d.hex;a==null||a.generateBox(s,B)}),n.setPointCloudResult(l),n.setPointCloudValid((t=q(e.result))==null?void 0:t.valid)}},[e,n.mainViewInstance]),v(()=>{var t,a,l,s;if(p){_(C.Top);const d=(l=(a=(t=n.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(s=n.mainViewInstance)==null||s.updateCameraZoom(d)}},[p]);const S=A(()=>({reset3DView:O,setTarget3DView:_,isActive:!!p,followTopView:j}),[p,n.mainViewInstance]),y=o.createElement("div",null,o.createElement("span",{style:{marginRight:8}},h("ShowArrows")),o.createElement(H,{size:"small",checked:f,onChange:t=>{var a;T(t),(a=n.mainViewInstance)==null||a.setShowDirection(t)}}));return o.createElement(F,{className:m("point-cloud-3d-container"),title:h("3DView"),toolbar:y,style:{height:e.mappingImgList&&((r=e.mappingImgList)==null?void 0:r.length)>0?"55%":"100%"}},o.createElement("div",{className:m("point-cloud-3d-content")},o.createElement(P.Provider,{value:S},o.createElement(ne,null)),o.createElement("div",{className:m("point-cloud-3d-view"),id:ie,ref:w})))};var ae=Z(U,null,null,{context:W})(re);export{ae as default};
@@ -1 +1 @@
1
- import{PointCloudAnnotation as T,MathUtils as u,getCuboidFromPointCloudBox as X}from"@labelbee/lb-annotation";import{getClassName as y}from"../../utils/dom.js";import{PointCloudContainer as A}from"./PointCloudLayout.js";import m,{useRef as W,useEffect as V}from"react";import{PointCloudContext as H}from"./PointCloudContext.js";import{EPerspectiveView as U}from"@labelbee/lb-utils";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{SizeInfoForView as F}from"./PointCloudInfos.js";import{connect as R}from"react-redux";import{a2MapStateToProps as Z}from"../../store/annotation/map.js";import{usePointCloudViews as q,synchronizeTopView as G,synchronizeSideView as J}from"./hooks/usePointCloudViews.js";import K from"../../hooks/useSize.js";import Q from"./components/EmptyPage/index.js";import{useTranslation as $}from"react-i18next";import{LabelBeeContext as ee}from"../../store/ctx.js";var te=Object.defineProperty,oe=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,_=(n,t,o)=>t in n?te(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,se=(n,t)=>{for(var o in t||(t={}))ie.call(t,o)&&_(n,o,t[o]);if(O)for(var o of O(t))re.call(t,o)&&_(n,o,t[o]);return n},ae=(n,t)=>oe(n,ne(t));const ce=(n,t,o=1)=>{const{width:e,height:i}=t,s={x:n.x+e*o/2,y:n.y+i*o/2},d={x:t.width/2,y:t.height/2};return{offsetX:(d.x-s.x)/o,offsetY:-(d.y-s.y)/o}},j=(n,t,o,e,i)=>{const{offsetX:s,offsetY:d}=ce(n,o,t);if(i.camera.zoom=t,n){const P=Math.cos(e.rotation),g=Math.sin(e.rotation),w=s*P,h=s*g,{x:r,y:p,z:c}=i.initCameraPosition;i.camera.position.set(r+h,p-w,c+d)}i.camera.updateProjectionMatrix(),i.render()},le=({currentData:n,config:t,checkMode:o})=>{const e=m.useContext(H),i=W(null),s=K(i),{selectedBox:d,updateSelectedBox:P}=Y(),{t:g}=$(),{backViewUpdateBox:w}=q(),h=(r,p)=>{if(!e.selectedPointCloudBox||!e.mainViewInstance||!n.url||!e.backViewInstance)return;const{pointCloudInstance:c}=e.backViewInstance,[l,f,v]=r.pointList,[B,b,I]=p.pointList,x=u.getLineCenterPoint([l,v]),C=u.getLineCenterPoint([B,I]),L={x:{x:x.x-C.x,y:x.y-C.y}.x,y:0,z:x.y-C.y},k=u.getLineLength(l,f),S=u.getLineLength(B,b),E=k-S,z=u.getLineLength(f,v),N=u.getLineLength(b,I),D=z-N;let{newBoxParams:a}=c.getNewBoxByBackUpdate(L,D,E,e.selectedPointCloudBox);if(e.mainViewInstance){const{count:M}=e.mainViewInstance.getSensesPointZAxisInPolygon(X(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=ae(se({},a),{count:M})}G(a,r,e.topViewInstance,e.mainViewInstance),J(a,r,e.sideViewInstance,n.url),e.mainViewInstance.highlightOriginPointCloud([a]),P(a)};return V(()=>{if(i.current){const r={width:i.current.clientWidth,height:i.current.clientHeight},p=new T({container:i.current,size:r,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0},config:t,checkMode:o});e.setBackViewInstance(p)}},[]),V(()=>{if(!s||!e.backViewInstance)return;const{pointCloud2dOperation:r,pointCloudInstance:p}=e.backViewInstance;r.singleOn("renderZoom",(c,l)=>{!e.selectedPointCloudBox||j(l,c,s,e.selectedPointCloudBox,p)}),r.singleOn("dragMove",({currentPos:c,zoom:l})=>{!e.selectedPointCloudBox||j(c,l,s,e.selectedPointCloudBox,p)}),r.singleOn("updatePolygonByDrag",c=>{if(e.selectedIDs.length===1&&c.length===1){const{newPolygon:l,originPolygon:f}=c[0];l&&f&&(h(l,f),w(l,f))}})},[e,s]),V(()=>{var r;(r=e==null?void 0:e.backViewInstance)==null||r.initSize(s)},[s]),m.createElement(A,{className:y("point-cloud-container","back-view"),title:g("BackView"),toolbar:m.createElement(F,{perspectiveView:U.Back})},m.createElement("div",{className:y("point-cloud-container","bottom-view-content")},m.createElement("div",{className:y("point-cloud-container","core-instance"),ref:i}),!d&&m.createElement(Q,null)))};var pe=R(Z,null,null,{context:ee})(le);export{pe as default};
1
+ import{PointCloudAnnotation as g}from"@labelbee/lb-annotation";import{getClassName as C}from"../../utils/dom.js";import{PointCloudContainer as P}from"./PointCloudLayout.js";import d,{useRef as h,useEffect as w}from"react";import{PointCloudContext as y}from"./PointCloudContext.js";import{EPerspectiveView as B}from"@labelbee/lb-utils";import{useSingleBox as v}from"./hooks/useSingleBox.js";import{SizeInfoForView as V}from"./PointCloudInfos.js";import{connect as b}from"react-redux";import{a2MapStateToProps as j}from"../../store/annotation/map.js";import{usePointCloudViews as k}from"./hooks/usePointCloudViews.js";import E from"../../hooks/useSize.js";import I from"./components/EmptyPage/index.js";import{useTranslation as S}from"react-i18next";import{LabelBeeContext as O}from"../../store/ctx.js";const D=(c,i,r=1)=>{const{width:t,height:e}=i,o={x:c.x+t*r/2,y:c.y+e*r/2},l={x:i.width/2,y:i.height/2};return{offsetX:(l.x-o.x)/r,offsetY:-(l.y-o.y)/r}},x=(c,i,r,t,e)=>{const{offsetX:o,offsetY:l}=D(c,r,i);if(e.camera.zoom=i,c){const f=Math.cos(t.rotation),p=Math.sin(t.rotation),n=o*f,u=o*p,{x:s,y:a,z:m}=e.initCameraPosition;e.camera.position.set(s+u,a-n,m+l)}e.camera.updateProjectionMatrix(),e.render()},M=({currentData:c,config:i,checkMode:r})=>{const t=d.useContext(y),e=h(null),o=E(e),{selectedBox:l}=v(),{t:f}=S(),{backViewUpdateBox:p}=k();return w(()=>{if(e.current){const n={width:e.current.clientWidth,height:e.current.clientHeight},u=new g({container:e.current,size:n,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0},config:i,checkMode:r});t.setBackViewInstance(u)}},[]),w(()=>{if(!o||!t.backViewInstance)return;const{pointCloud2dOperation:n,pointCloudInstance:u}=t.backViewInstance;n.singleOn("renderZoom",(s,a)=>{!t.selectedPointCloudBox||x(a,s,o,t.selectedPointCloudBox,u)}),n.singleOn("dragMove",({currentPos:s,zoom:a})=>{!t.selectedPointCloudBox||x(s,a,o,t.selectedPointCloudBox,u)}),n.singleOn("updatePolygonByDrag",s=>{if(t.selectedIDs.length===1&&s.length===1){const{newPolygon:a,originPolygon:m}=s[0];a&&m&&p(a,m)}})},[t,o]),w(()=>{var n;(n=t==null?void 0:t.backViewInstance)==null||n.initSize(o)},[o]),d.createElement(P,{className:C("point-cloud-container","back-view"),title:f("BackView"),toolbar:d.createElement(V,{perspectiveView:B.Back})},d.createElement("div",{className:C("point-cloud-container","bottom-view-content")},d.createElement("div",{className:C("point-cloud-container","core-instance"),ref:e}),!l&&d.createElement(I,null)))};var N=b(j,null,null,{context:O})(M);export{N as default};
@@ -1 +1 @@
1
- import{MathUtils as P,getCuboidFromPointCloudBox as at}from"@labelbee/lb-annotation";import{EPerspectiveView as H,PointCloudUtils as k}from"@labelbee/lb-utils";import{useContext as ct}from"react";import{PointCloudContext as ut}from"../PointCloudContext.js";import{useSingleBox as Z}from"./useSingleBox.js";import{useSelector as pt,useDispatch as gt}from"../../../store/ctx.js";import ft from"../../../utils/StepUtils.js";import{jsonParser as W}from"../../../utils/index.js";import{SetPointCloudLoading as M}from"../../../store/annotation/actionCreators.js";import{message as Ct}from"antd";import{useTranslation as Pt}from"react-i18next";import{useHistory as mt}from"./useHistory.js";import{usePolygon as ht}from"./usePolygon.js";var yt=Object.defineProperty,Lt=Object.defineProperties,xt=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable,Q=(t,e,n)=>e in t?yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,U=(t,e)=>{for(var n in e||(e={}))vt.call(e,n)&&Q(t,n,e[n]);if(G)for(var n of G(e))Bt.call(e,n)&&Q(t,n,e[n]);return t},q=(t,e)=>Lt(t,xt(e)),J=(t,e,n)=>new Promise((c,o)=>{var s=d=>{try{u(n.next(d))}catch(C){o(C)}},g=d=>{try{u(n.throw(d))}catch(C){o(C)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(s,g);u((n=n.apply(t,e)).next())});const R=5,K=90,w={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},E=(t,e,n,c,o)=>{const[s,g,u,d]=t.pointList.map(f=>k.transferCanvas2World(f,e)),C=P.getLineCenterPoint([s,u]),m=P.getLineLength(s,g),y=P.getLineLength(g,u),A=P.getRadiusFromQuadrangle(t.pointList);let b=0,O=1,L={};if(n){const f=n.getSensesPointZAxisInPolygon([s,g,u,d]);b=(f.maxZ+f.minZ)/2,O=f.maxZ-f.minZ,L={count:f.zCount}}c&&(b=c.center.z,O=c.depth);const I={center:{x:C.x,y:C.y,z:b},width:y,height:m,depth:O,rotation:A,id:t.id},x=U(c?U(U({},c),I):q(U({},I),{attribute:"",valid:!0}),L);return o&&Object.assign(x,o),x},X=(t,e,n,c)=>{const[o,s,g]=t.pointList,[u,d,C]=e.pointList,m=P.getLineCenterPoint([o,g]),y=P.getLineCenterPoint([u,C]),b={x:{x:m.x-y.x,y:m.y-y.y}.x,y:0,z:m.y-y.y},O=P.getLineLength(o,s),L=P.getLineLength(u,d),I=O-L,x=P.getLineLength(s,g),f=P.getLineLength(d,C),D=x-f,{newBoxParams:S}=c.getNewBoxBySideUpdate(b,D,I,n);return S},wt=(t,e,n,c)=>{const[o,s,g]=t.pointList,[u,d,C]=e.pointList,m=P.getLineCenterPoint([o,g]),y=P.getLineCenterPoint([u,C]),b={x:{x:m.x-y.x,y:m.y-y.y}.x,y:0,z:m.y-y.y},O=P.getLineLength(o,s),L=P.getLineLength(u,d),I=O-L,x=P.getLineLength(s,g),f=P.getLineLength(d,C),D=x-f;let{newBoxParams:S}=c.getNewBoxByBackUpdate(b,D,I,n);return S},Y=(t,e,n,c)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:s}=n;s.loadPCDFileByBox(c,t,{width:R,depth:R});const{cameraPositionVector:g}=s.updateOrthoCamera(t,H.Left);s.setInitCameraPosition(g);const{polygon2d:u,zoom:d}=s.getBoxSidePolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:u,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},$=(t,e,n,c)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:s}=n;s.loadPCDFileByBox(c,t,{height:R,depth:R});const{cameraPositionVector:g}=s.updateOrthoCamera(t,H.Back);s.setInitCameraPosition(g);const{polygon2d:u,zoom:d}=s.getBoxBackPolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:u,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},tt=(t,e,n,c)=>{var o;if(!n||!c)return;c.generateBox(t,e.id),c.updateCameraByBox(t,H.Top),c.render();const{pointCloud2dOperation:s,pointCloudInstance:g}=n,{polygon2d:u}=g.getBoxTopPolygon2DCoordinate(t),d=[...s.polygonList],C=d.find(m=>m.id===e.id);C?C.pointList=u:d.push({id:e.id,pointList:u,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),s.setResultAndSelectedID(d,e.id)},bt=()=>{const t=ct(ut),{topViewInstance:e,sideViewInstance:n,backViewInstance:c,mainViewInstance:o,addPointCloudBox:s,setSelectedIDs:g,selectedIDs:u,pointCloudBoxList:d,hideAttributes:C}=t,{addHistory:m,initHistory:y,pushHistoryUnderUpdatePolygon:A}=mt(),{selectedPolygon:b}=ht(),{updateSelectedBox:O,updateSelectedBoxes:L,getPointCloudByID:I}=Z(),{currentData:x,config:f}=pt(i=>{const{stepList:r,step:p,imgList:l,imgIndex:a}=i.annotation;return{currentData:l[a],config:W(ft.getCurrentStepInfo(p,r).config)}}),D=gt(),{selectedBox:S}=Z(),{t:ot}=Pt(),F=S==null?void 0:S.info;if(!e||!n||!c)return{topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:et}=e,nt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},it=({newPolygon:i,size:r,imgList:p,trackConfigurable:l,zoom:a})=>{var h;const v={attribute:(h=e.pointCloud2dOperation.defaultAttribute)!=null?h:""};l===!0&&Object.assign(v,{trackID:k.getNextTrackID({imgList:[],extraBoxList:d})});const B=E(i,r,et,void 0,v),_=e==null?void 0:e.pointCloud2dOperation,V=B;if((f==null?void 0:f.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<f.lowerLimitPointsNumInBox){Ct.info(ot("LowerLimitPointsNumInBox",{num:f.lowerLimitPointsNumInBox})),_.deletePolygon(B.id);return}const z=C.includes(i.attribute),j=s(V);z?g([]):(g(V.id),_.setSelectedIDs([i.id]),T(w.Top,i,V,a,j)),m({newBoxParams:V})},st=(i,r)=>{const p=i!=null?i:S==null?void 0:S.info,l=e==null?void 0:e.pointCloud2dOperation;if(l.setSelectedIDs(u),u.length===0||!l)return;const a=l.selectedPolygon;if(u.length===1&&p){T(w.Top,a,p,void 0,r);return}},N=(i,r,p)=>{if(F){let l,a;switch(p){case w.Back:l=wt;break;case w.Side:l=X;break;default:l=X;break}if(a=l(i,r,F,n.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(at(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=q(U({},a),{count:v})}const h=O(a);return T(p,i,a,void 0,h),h}},rt=(i,r)=>{N(i,r,w.Side)},lt=(i,r)=>{N(i,r,w.Back)},dt=(i,r)=>{if(b){const l=i[0].newPolygon;l.pointList=l.pointList.map(a=>k.transferCanvas2World(a,r)),A(i[0].newPolygon);return}const p=i.map(({newPolygon:l})=>{const a=I(l.id);return E(l,r,e.pointCloudInstance,a)});if(p.length===1){const{newPolygon:l}=i[0],a=L(p);T(w.Top,l,p[0],void 0,a)}else{const l=L(p);l&&t.syncAllViewPointCloudColor(l)}},T=(i,r,p,l,a)=>J(void 0,null,function*(){const h=x==null?void 0:x.url;a&&(yield t.syncAllViewPointCloudColor(a));const v={[w.Side]:()=>{Y(p,r,n,h)},[w.Back]:()=>{c&&$(p,r,c,h)},[w.Top]:()=>{tt(p,r,e,o)}};Object.keys(v).forEach(B=>{B!==i&&v[B]()}),l&&(o==null||o.updateCameraZoom(l)),nt(p)});return{topViewAddBox:it,topViewSelectedChanged:st,topViewUpdateBox:dt,sideViewUpdateBox:rt,backViewUpdateBox:lt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const r={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(r),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>J(void 0,[...i],function*(r=x){var p,l,a,h,v,B;if(!(r==null?void 0:r.url)||!o)return;M(D,!0),yield o.loadPCDFile(r.url,(p=f==null?void 0:f.radius)!=null?p:K),d.forEach(j=>{o==null||o.removeObjectByName(j.id)});let _=[],V=[];r.result?(_=k.getBoxParamsFromResultList(r.result),V=k.getPolygonListFromResultList(r.result),_.forEach(j=>{o==null||o.generateBox(j)}),t.syncAllViewPointCloudColor(_),t.setPointCloudResult(_),t.setPolygonList(V)):(t.setPointCloudResult([]),t.setPolygonList([])),y({pointCloudBoxList:_,polygonList:V}),o.updateTopCamera();const z=(a=(l=W(r.result))==null?void 0:l.valid)!=null?a:!0;t.setPointCloudValid(z),(h=t.sideViewInstance)==null||h.clearAllData(),(v=t.backViewInstance)==null||v.clearAllData(),e.updateData(r.url,r.result,{radius:(B=f==null?void 0:f.radius)!=null?B:K}),M(D,!1)})}};export{$ as synchronizeBackView,Y as synchronizeSideView,tt as synchronizeTopView,E as topViewPolygon2PointCloud,bt as usePointCloudViews};
1
+ import{MathUtils as C,getCuboidFromPointCloudBox as at}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as k}from"@labelbee/lb-utils";import{useContext as ct}from"react";import{PointCloudContext as ut}from"../PointCloudContext.js";import{useSingleBox as Z}from"./useSingleBox.js";import{useSelector as pt,useDispatch as gt}from"../../../store/ctx.js";import ft from"../../../utils/StepUtils.js";import{jsonParser as W}from"../../../utils/index.js";import{SetPointCloudLoading as M}from"../../../store/annotation/actionCreators.js";import{message as Pt}from"antd";import{useTranslation as Ct}from"react-i18next";import{useHistory as mt}from"./useHistory.js";import{usePolygon as ht}from"./usePolygon.js";var yt=Object.defineProperty,Lt=Object.defineProperties,xt=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable,Q=(t,e,n)=>e in t?yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,U=(t,e)=>{for(var n in e||(e={}))vt.call(e,n)&&Q(t,n,e[n]);if(G)for(var n of G(e))Bt.call(e,n)&&Q(t,n,e[n]);return t},q=(t,e)=>Lt(t,xt(e)),J=(t,e,n)=>new Promise((u,o)=>{var s=d=>{try{c(n.next(d))}catch(P){o(P)}},g=d=>{try{c(n.throw(d))}catch(P){o(P)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(s,g);c((n=n.apply(t,e)).next())});const R=5,K=90,w={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},H=(t,e,n,u,o)=>{const[s,g,c,d]=t.pointList.map(f=>k.transferCanvas2World(f,e)),P=C.getLineCenterPoint([s,c]),m=C.getLineLength(s,g),y=C.getLineLength(g,c),A=C.getRadiusFromQuadrangle(t.pointList);let b=0,I=1,L={};if(n){const f=n.getSensesPointZAxisInPolygon([s,g,c,d]);b=(f.maxZ+f.minZ)/2,I=f.maxZ-f.minZ,L={count:f.zCount}}u&&(b=u.center.z,I=u.depth);const O={center:{x:P.x,y:P.y,z:b},width:y,height:m,depth:I,rotation:A,id:t.id},x=U(u?U(U({},u),O):q(U({},O),{attribute:"",valid:!0}),L);return o&&Object.assign(x,o),x},X=(t,e,n,u)=>{const[o,s,g]=t.pointList,[c,d,P]=e.pointList,m=C.getLineCenterPoint([o,g]),y=C.getLineCenterPoint([c,P]),b={x:{x:m.x-y.x,y:m.y-y.y}.x,y:0,z:m.y-y.y},I=C.getLineLength(o,s),L=C.getLineLength(c,d),O=I-L,x=C.getLineLength(s,g),f=C.getLineLength(d,P),D=x-f,{newBoxParams:S}=u.getNewBoxBySideUpdate(b,D,O,n);return S},wt=(t,e,n,u)=>{const[o,s,g]=t.pointList,[c,d,P]=e.pointList,m=C.getLineCenterPoint([o,g]),y=C.getLineCenterPoint([c,P]),b={x:{x:m.x-y.x,y:m.y-y.y}.x,y:0,z:m.y-y.y},I=C.getLineLength(o,s),L=C.getLineLength(c,d),O=I-L,x=C.getLineLength(s,g),f=C.getLineLength(d,P),D=x-f;let{newBoxParams:S}=u.getNewBoxByBackUpdate(b,D,O,n);return S},Y=(t,e,n,u)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:s}=n;s.loadPCDFileByBox(u,t,{width:R,depth:R});const{cameraPositionVector:g}=s.updateOrthoCamera(t,N.Left);s.setInitCameraPosition(g);const{polygon2d:c,zoom:d}=s.getBoxSidePolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:c,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},$=(t,e,n,u)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:s}=n;s.loadPCDFileByBox(u,t,{height:R,depth:R});const{cameraPositionVector:g}=s.updateOrthoCamera(t,N.Back);s.setInitCameraPosition(g);const{polygon2d:c,zoom:d}=s.getBoxBackPolygon2DCoordinate(t);s.camera.zoom=d,s.camera.updateProjectionMatrix(),s.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:c,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},tt=(t,e,n,u)=>{var o;if(!n||!u)return;u.generateBox(t,e.id),u.render();const{pointCloud2dOperation:s,pointCloudInstance:g}=n,{polygon2d:c}=g.getBoxTopPolygon2DCoordinate(t),d=[...s.polygonList],P=d.find(m=>m.id===e.id);P?P.pointList=c:d.push({id:e.id,pointList:c,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),s.setResultAndSelectedID(d,e.id)},bt=()=>{const t=ct(ut),{topViewInstance:e,sideViewInstance:n,backViewInstance:u,mainViewInstance:o,addPointCloudBox:s,setSelectedIDs:g,selectedIDs:c,pointCloudBoxList:d,hideAttributes:P}=t,{addHistory:m,initHistory:y,pushHistoryUnderUpdatePolygon:A}=mt(),{selectedPolygon:b}=ht(),{updateSelectedBox:I,updateSelectedBoxes:L,getPointCloudByID:O}=Z(),{currentData:x,config:f}=pt(i=>{const{stepList:r,step:p,imgList:l,imgIndex:a}=i.annotation;return{currentData:l[a],config:W(ft.getCurrentStepInfo(p,r).config)}}),D=gt(),{selectedBox:S}=Z(),{t:ot}=Ct(),E=S==null?void 0:S.info;if(!e||!n||!u)return{topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:et}=e,nt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},it=({newPolygon:i,size:r,imgList:p,trackConfigurable:l,zoom:a})=>{var h;const v={attribute:(h=e.pointCloud2dOperation.defaultAttribute)!=null?h:""};l===!0&&Object.assign(v,{trackID:k.getNextTrackID({imgList:[],extraBoxList:d})});const B=H(i,r,et,void 0,v),_=e==null?void 0:e.pointCloud2dOperation,V=B;if((f==null?void 0:f.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<f.lowerLimitPointsNumInBox){Pt.info(ot("LowerLimitPointsNumInBox",{num:f.lowerLimitPointsNumInBox})),_.deletePolygon(B.id);return}const z=P.includes(i.attribute),j=s(V);z?g([]):(g(V.id),_.setSelectedIDs([i.id]),T(w.Top,i,V,a,j)),m({newBoxParams:V})},st=(i,r)=>{const p=i!=null?i:S==null?void 0:S.info,l=e==null?void 0:e.pointCloud2dOperation;if(l.setSelectedIDs(c),c.length===0||!l)return;const a=l.selectedPolygon;if(c.length===1&&p){T(w.Top,a,p,void 0,r);return}},F=(i,r,p)=>{if(E){let l,a;switch(p){case w.Back:l=wt;break;case w.Side:l=X;break;default:l=X;break}if(a=l(i,r,E,n.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(at(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=q(U({},a),{count:v})}const h=I(a);return T(p,i,a,void 0,h),h}},rt=(i,r)=>{F(i,r,w.Side)},lt=(i,r)=>{F(i,r,w.Back)},dt=(i,r)=>{if(b){const l=i[0].newPolygon;l.pointList=l.pointList.map(a=>k.transferCanvas2World(a,r)),A(i[0].newPolygon);return}const p=i.map(({newPolygon:l})=>{const a=O(l.id);return H(l,r,e.pointCloudInstance,a)});if(p.length===1){const{newPolygon:l}=i[0],a=L(p);T(w.Top,l,p[0],void 0,a)}else{const l=L(p);l&&t.syncAllViewPointCloudColor(l)}},T=(i,r,p,l,a)=>J(void 0,null,function*(){const h=x==null?void 0:x.url;a&&(yield t.syncAllViewPointCloudColor(a));const v={[w.Side]:()=>{Y(p,r,n,h)},[w.Back]:()=>{u&&$(p,r,u,h)},[w.Top]:()=>{tt(p,r,e,o)}};Object.keys(v).forEach(B=>{B!==i&&v[B]()}),l&&(o==null||o.updateCameraZoom(l)),nt(p)});return{topViewAddBox:it,topViewSelectedChanged:st,topViewUpdateBox:dt,sideViewUpdateBox:rt,backViewUpdateBox:lt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const r={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(r),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>J(void 0,[...i],function*(r=x){var p,l,a,h,v,B;if(!(r==null?void 0:r.url)||!o)return;M(D,!0),yield o.loadPCDFile(r.url,(p=f==null?void 0:f.radius)!=null?p:K),d.forEach(j=>{o==null||o.removeObjectByName(j.id)});let _=[],V=[];r.result?(_=k.getBoxParamsFromResultList(r.result),V=k.getPolygonListFromResultList(r.result),_.forEach(j=>{o==null||o.generateBox(j)}),t.syncAllViewPointCloudColor(_),t.setPointCloudResult(_),t.setPolygonList(V)):(t.setPointCloudResult([]),t.setPolygonList([])),y({pointCloudBoxList:_,polygonList:V}),o.updateTopCamera();const z=(a=(l=W(r.result))==null?void 0:l.valid)!=null?a:!0;t.setPointCloudValid(z),(h=t.sideViewInstance)==null||h.clearAllData(),(v=t.backViewInstance)==null||v.clearAllData(),e.updateData(r.url,r.result,{radius:(B=f==null?void 0:f.radius)!=null?B:K}),M(D,!1)})}};export{$ as synchronizeBackView,Y as synchronizeSideView,tt as synchronizeTopView,H as topViewPolygon2PointCloud,bt as usePointCloudViews};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.9.0-alpha.6",
3
+ "version": "1.9.0-alpha.7",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@ant-design/icons": "^4.6.2",
44
- "@labelbee/lb-annotation": "^1.13.0-alpha.5",
44
+ "@labelbee/lb-annotation": "^1.13.0-alpha.6",
45
45
  "@labelbee/lb-utils": "^1.6.0-alpha.5",
46
46
  "ahooks": "^3.4.0",
47
47
  "classnames": "^2.3.0",
@@ -97,5 +97,5 @@
97
97
  "path": "node_modules/cz-conventional-changelog"
98
98
  }
99
99
  },
100
- "gitHead": "953858a04304768a9ad9ac125ab665a287a61231"
100
+ "gitHead": "5fa52aaa658d7268a62fc0ba4ca7304c8a57958d"
101
101
  }