@labelbee/lb-components 1.23.0-alpha.57 → 1.23.0-alpha.59

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"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(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));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:o,setTarget3DView:i}=React.useContext(PointCloud3DContext),n=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:o});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[t])},className:n(t.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:t})=>{const{reset3DView:o,followTopView:i}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation(),u=React__default.default.createElement(React__default.default.Fragment,null,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"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{o()},className:dom.getClassName("point-cloud-3d-view","reset")}));return t?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,u):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},u,p)},PointCloud3D=({currentData:t,config:o,highlightAttribute:i})=>{const n=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState(!0),[d,C]=React.useState(!1),m=React.useRef(null),{initPointCloud3d:E}=usePointCloudViews.usePointCloudViews(),f=useSize(m),{t:g}=reactI18next.useTranslation();React.useEffect(()=>{!n.mainViewInstance||E==null||E(f)},[f]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:v}=useSphere.useSphere(),V=e=>{var a,l;const r=c==null?void 0:c.info;if(r){const s=__spreadValues({},r.center);s.x=s.x-.01,s.z=1e3;const w=e===lbUtils.EPerspectiveView.Top;(a=n.mainViewInstance)==null||a.updateCameraByBox(r,e,w?s:void 0)}v&&((l=n.mainViewInstance)==null||l.updateCameraBySphere(v,e))},_=()=>{var e;(e=n.mainViewInstance)==null||e.resetCamera()},h=()=>{var e,a;const l=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance.camera;l&&((a=n.mainViewInstance)==null||a.applyCameraTarget(l))};React.useEffect(()=>{if(m.current&&(t==null?void 0:t.url)){let e=n.mainViewInstance;!e&&f.width&&(e=new lbAnnotation.PointCloud({container:m.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(f),config:o}),n.setMainViewInstance(e))}},[f,t]),React.useEffect(()=>{var e;if(m.current&&(t==null?void 0:t.url)&&t.result&&n.mainViewInstance){let a=n.mainViewInstance;const l=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);l.forEach(s=>{var w;const b=(w=lbUtils.toolStyleConverter.getColorFromConfig({attribute:s.attribute},__spreadProps(__spreadValues({},o),{attributeConfigurable:!0}),{}))==null?void 0:w.hex;a==null||a.addBoxToSense(s,b)}),a.render(),n.setPointCloudResult(l);const r=lbUtils.PointCloudUtils.getRectParamsFromResultList(t.result);n.setRectList(r),n.setPointCloudValid((e=index.jsonParser(t.result))==null?void 0:e.valid)}},[t,n.mainViewInstance]),React.useEffect(()=>{var e,a,l,r;if(c){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[c]),React.useEffect(()=>{var e,a,l,r;if(v){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[v]),React.useEffect(()=>(window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P)}),[]);const P=e=>{if(e.keyCode===EKeyCode.Esc){C(!1);return}},x=React.useMemo(()=>({reset3DView:_,setTarget3DView:V,isActive:!!c,followTopView:h}),[c,n.mainViewInstance]);React.useEffect(()=>{var e,a,l;const r=n.pointCloudBoxList.filter(s=>s.attribute===i);(r==null?void 0:r.length)>0&&((e=n.mainViewInstance)==null||e.clearHighlightBoxes(),(a=n.mainViewInstance)==null||a.highlightBoxes(r)),r.length===0&&((l=n.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[i,n.mainViewInstance]);const I=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:e=>{var a;(a=n.mainViewInstance)==null||a.updatePointSize({customSize:e})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:u,onChange:e=>{var a;p(e),(a=n.mainViewInstance)==null||a.setShowDirection(e)}}),d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:d})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:d}),title:d?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{C(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{C(!0)}}),toolbar:I},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:m})))};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"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,a,i)=>a in t?__defProp(t,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[a]=i,__spreadValues=(t,a)=>{for(var i in a||(a={}))__hasOwnProp.call(a,i)&&__defNormalProp(t,i,a[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(a))__propIsEnum.call(a,i)&&__defNormalProp(t,i,a[i]);return t},__spreadProps=(t,a)=>__defProps(t,__getOwnPropDescs(a));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:a,setTarget3DView:i}=React.useContext(PointCloud3DContext),c=n=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",n)]:!0,active:a});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[t])},className:c(t.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:t})=>{const{reset3DView:a,followTopView:i}=React.useContext(PointCloud3DContext),{t:c}=reactI18next.useTranslation(),n=React__default.default.createElement(React__default.default.Fragment,null,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"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:c("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","reset")}));return t?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,n):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},n,p)},PointCloud3D=({currentData:t,config:a,highlightAttribute:i})=>{var c;const n=React.useContext(PointCloudContext.PointCloudContext),[p,h]=React.useState(!0),[d,C]=React.useState(!1),m=React.useRef(null),{initPointCloud3d:P}=usePointCloudViews.usePointCloudViews(),v=useSize(m),{t:g}=reactI18next.useTranslation();React.useEffect(()=>{!n.mainViewInstance||P==null||P(v)},[v]);const{selectedBox:u}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),V=e=>{var o,l;const r=u==null?void 0:u.info;if(r){const s=__spreadValues({},r.center);s.x=s.x-.01,s.z=1e3;const f=e===lbUtils.EPerspectiveView.Top;(o=n.mainViewInstance)==null||o.updateCameraByBox(r,e,f?s:void 0)}w&&((l=n.mainViewInstance)==null||l.updateCameraBySphere(w,e))},I=()=>{var e;(e=n.mainViewInstance)==null||e.resetCamera()},b=()=>{var e,o;const l=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance.camera;l&&((o=n.mainViewInstance)==null||o.applyCameraTarget(l))};React.useEffect(()=>{if(m.current&&(t==null?void 0:t.url)){let e=n.mainViewInstance;!e&&v.width&&(e=new lbAnnotation.PointCloud({container:m.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(v),config:a}),n.setMainViewInstance(e))}},[v,t]),React.useEffect(()=>{var e;if(m.current&&(t==null?void 0:t.url)&&t.result&&n.mainViewInstance){let o=n.mainViewInstance;const l=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);l.forEach(s=>{var f;const E=(f=lbUtils.toolStyleConverter.getColorFromConfig({attribute:s.attribute},__spreadProps(__spreadValues({},a),{attributeConfigurable:!0}),{}))==null?void 0:f.hex;o==null||o.addBoxToSense(s,E)}),o.render(),n.setPointCloudResult(l);const r=lbUtils.PointCloudUtils.getRectParamsFromResultList(t.result);n.setRectList(r),n.setPointCloudValid((e=index.jsonParser(t.result))==null?void 0:e.valid)}},[t,n.mainViewInstance]),React.useEffect(()=>{var e,o,l,r,s;if(((e=u==null?void 0:u.info)==null?void 0:e.id)!==void 0){V(lbUtils.EPerspectiveView.Top);const E=(r=(l=(o=n.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:l.camera.zoom)!=null?r:1;(s=n.mainViewInstance)==null||s.updateCameraZoom(E)}},[(c=u==null?void 0:u.info)==null?void 0:c.id]),React.useEffect(()=>{var e,o,l,r;if(w){V(lbUtils.EPerspectiveView.Top);const s=(l=(o=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}),[]);const x=e=>{if(e.keyCode===EKeyCode.Esc){C(!1);return}},_=React.useMemo(()=>({reset3DView:I,setTarget3DView:V,isActive:!!u,followTopView:b}),[u,n.mainViewInstance]);React.useEffect(()=>{var e,o,l;const r=n.pointCloudBoxList.filter(s=>s.attribute===i);(r==null?void 0:r.length)>0&&((e=n.mainViewInstance)==null||e.clearHighlightBoxes(),(o=n.mainViewInstance)==null||o.highlightBoxes(r)),r.length===0&&((l=n.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[i,n.mainViewInstance]);const S=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:e=>{var o;(o=n.mainViewInstance)==null||o.updatePointSize({customSize:e})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:p,onChange:e=>{var o;h(e),(o=n.mainViewInstance)==null||o.setShowDirection(e)}}),d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:_},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:d})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:d}),title:d?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{C(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{C(!0)}}),toolbar:S},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:_},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:m})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
@@ -1 +1 @@
1
- import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as M,PointCloud as Z}from"@labelbee/lb-annotation";import{PointCloudUtils as b,toolStyleConverter as H,EPerspectiveView as E}from"@labelbee/lb-utils";import L from"classnames";import e,{useContext as S,useState as j,useRef as U,useEffect as u,useMemo as q}from"react";import{PointCloudContainer as G}from"./PointCloudLayout.js";import{PointCloudContext as J}from"./PointCloudContext.js";import{a2MapStateToProps as Q}from"../../store/annotation/map.js";import{connect as W}from"react-redux";import{jsonParser as X}from"../../utils/index.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{useSphere as $}from"./hooks/useSphere.js";import{Switch as ee,Tooltip as te}from"antd";import oe from"../../hooks/useSize.js";import{usePointCloudViews as ne}from"./hooks/usePointCloudViews.js";import{useTranslation as O}from"react-i18next";import{LabelBeeContext as ie}from"../../store/ctx.js";import re from"./components/PointCloudSizeSlider/index.js";import ae from"./components/TitleButton/index.js";import{LeftOutlined as le}from"@ant-design/icons";var se=Object.defineProperty,ce=Object.defineProperties,me=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?se(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))ue.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))de.call(r,a)&&D(n,a,r[a]);return n},pe=(n,r)=>ce(n,me(r));const we=M.default,ve="LABELBEE-POINTCLOUD",_=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=S(_),o=p=>L({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=S(_),{t:o}=O(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(te,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},fe=({currentData:n,config:r,highlightAttribute:a})=>{const o=S(J),[p,V]=j(!0),[v,h]=j(!1),f=U(null),{initPointCloud3d:T}=ne(),C=oe(f),{t:x}=O();u(()=>{!o.mainViewInstance||T==null||T(C)},[C]);const{selectedBox:w}=Y(),{selectedSphere:g}=$(),I=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const P=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,P?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new Z({container:f.current,isOrthographicCamera:!0,orthographicParams:b.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=b.getBoxParamsFromResultList(n.result);l.forEach(c=>{var P;const K=(P=H.getColorFromConfig({attribute:c.attribute},pe(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:P.hex;i==null||i.addBoxToSense(c,K)}),i.render(),o.setPointCloudResult(l);const s=b.getRectParamsFromResultList(n.result);o.setRectList(s),o.setPointCloudValid((t=X(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}),[]);const y=t=>{if(t.keyCode===we.Esc){h(!1);return}},B=q(()=>({reset3DView:R,setTarget3DView:I,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(re,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},x("ShowArrows")),e.createElement(ee,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(_.Provider,{value:B},e.createElement(k,{isEnlarge:v})));return e.createElement(G,{className:L({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(le,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{h(!1)}}),x("3DView")):e.createElement(ae,{title:x("3DView"),onClick:()=>{h(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(_.Provider,{value:B},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:ve,ref:f})))};var Ce=W(Q,null,null,{context:ie})(fe);export{Ce as default};
1
+ import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as Z,PointCloud as H}from"@labelbee/lb-annotation";import{PointCloudUtils as S,toolStyleConverter as U,EPerspectiveView as E}from"@labelbee/lb-utils";import j from"classnames";import e,{useContext as T,useState as O,useRef as q,useEffect as u,useMemo as G}from"react";import{PointCloudContainer as J}from"./PointCloudLayout.js";import{PointCloudContext as Q}from"./PointCloudContext.js";import{a2MapStateToProps as W}from"../../store/annotation/map.js";import{connect as X}from"react-redux";import{jsonParser as Y}from"../../utils/index.js";import{useSingleBox as $}from"./hooks/useSingleBox.js";import{useSphere as ee}from"./hooks/useSphere.js";import{Switch as te,Tooltip as oe}from"antd";import ne from"../../hooks/useSize.js";import{usePointCloudViews as ie}from"./hooks/usePointCloudViews.js";import{useTranslation as z}from"react-i18next";import{LabelBeeContext as re}from"../../store/ctx.js";import le from"./components/PointCloudSizeSlider/index.js";import ae from"./components/TitleButton/index.js";import{LeftOutlined as se}from"@ant-design/icons";var ce=Object.defineProperty,me=Object.defineProperties,de=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,N=(n,r,l)=>r in n?ce(n,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[r]=l,k=(n,r)=>{for(var l in r||(r={}))ue.call(r,l)&&N(n,l,r[l]);if(D)for(var l of D(r))pe.call(r,l)&&N(n,l,r[l]);return n},ve=(n,r)=>me(n,de(r));const we=Z.default,fe="LABELBEE-POINTCLOUD",_=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),p=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:l}=T(_),v=o=>j({[m("point-cloud-3d-view",o)]:!0,active:r});return e.createElement("span",{onClick:()=>{l(E[n])},className:v(n.toLocaleLowerCase())})},R=({isEnlarge:n})=>{const{reset3DView:r,followTopView:l}=T(_),{t:v}=z(),o=e.createElement(e.Fragment,null,e.createElement(p,{perspectiveView:"Top"}),e.createElement(p,{perspectiveView:"Front"}),e.createElement(p,{perspectiveView:"Left"}),e.createElement(p,{perspectiveView:"Back"}),e.createElement(p,{perspectiveView:"Right"}),e.createElement(p,{perspectiveView:"LFT"}),e.createElement(p,{perspectiveView:"RBT"})),g=e.createElement(e.Fragment,null,e.createElement(oe,{title:v("CameraFollowTopView")},e.createElement("span",{onClick:()=>{l()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},g,o):e.createElement("div",{className:m("point-cloud-3d-sidebar")},o,g)},Ce=({currentData:n,config:r,highlightAttribute:l})=>{var v;const o=T(Q),[g,F]=O(!0),[w,h]=O(!1),f=q(null),{initPointCloud3d:y}=ie(),C=ne(f),{t:I}=z();u(()=>{!o.mainViewInstance||y==null||y(C)},[C]);const{selectedBox:d}=$(),{selectedSphere:P}=ee(),x=t=>{var i,a;const s=d==null?void 0:d.info;if(s){const c=k({},s.center);c.x=c.x-.01,c.z=1e3;const V=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,V?c:void 0)}P&&((a=o.mainViewInstance)==null||a.updateCameraBySphere(P,t))},A=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},K=()=>{var t,i;const a=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((i=o.mainViewInstance)==null||i.applyCameraTarget(a))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new H({container:f.current,isOrthographicCamera:!0,orthographicParams:S.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const a=S.getBoxParamsFromResultList(n.result);a.forEach(c=>{var V;const b=(V=U.getColorFromConfig({attribute:c.attribute},ve(k({},r),{attributeConfigurable:!0}),{}))==null?void 0:V.hex;i==null||i.addBoxToSense(c,b)}),i.render(),o.setPointCloudResult(a);const s=S.getRectParamsFromResultList(n.result);o.setRectList(s),o.setPointCloudValid((t=Y(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,a,s,c;if(((t=d==null?void 0:d.info)==null?void 0:t.id)!==void 0){x(E.Top);const b=(s=(a=(i=o.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?s:1;(c=o.mainViewInstance)==null||c.updateCameraZoom(b)}},[(v=d==null?void 0:d.info)==null?void 0:v.id]),u(()=>{var t,i,a,s;if(P){x(E.Top);const c=(a=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[P]),u(()=>(window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B)}),[]);const B=t=>{if(t.keyCode===we.Esc){h(!1);return}},L=G(()=>({reset3DView:A,setTarget3DView:x,isActive:!!d,followTopView:K}),[d,o.mainViewInstance]);u(()=>{var t,i,a;const s=o.pointCloudBoxList.filter(c=>c.attribute===l);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((a=o.mainViewInstance)==null||a.clearHighlightBoxesAndRender())},[l,o.mainViewInstance]);const M=e.createElement(e.Fragment,null,e.createElement(le,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},I("ShowArrows")),e.createElement(te,{size:"small",checked:g,onChange:t=>{var i;F(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),w&&e.createElement(_.Provider,{value:L},e.createElement(R,{isEnlarge:w})));return e.createElement(J,{className:j({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:w}),title:w?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(se,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{h(!1)}}),I("3DView")):e.createElement(ae,{title:I("3DView"),onClick:()=>{h(!0)}}),toolbar:M},e.createElement("div",{className:m("point-cloud-3d-content")},!w&&e.createElement(_.Provider,{value:L},e.createElement(R,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:fe,ref:f})))};var Ve=X(W,null,null,{context:re})(Ce);export{Ve as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.57",
3
+ "version": "1.23.0-alpha.59",
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.27.0-alpha.29",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.30",
47
47
  "@labelbee/lb-utils": "1.19.0-alpha.18",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",