@wandelbots/wandelbots-js-react-components 4.3.0 → 4.4.0
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.
- package/dist/3d.cjs.js +1 -1
- package/dist/3d.es.js +1 -1
- package/dist/{MotionGroupVisualizer-BgvrTXeT.js → MotionGroupVisualizer-Catdk92m.js} +339 -376
- package/dist/{MotionGroupVisualizer-BgvrTXeT.js.map → MotionGroupVisualizer-Catdk92m.js.map} +1 -1
- package/dist/MotionGroupVisualizer-DePl371W.cjs +2 -0
- package/dist/{MotionGroupVisualizer-C_fyiA-X.cjs.map → MotionGroupVisualizer-DePl371W.cjs.map} +1 -1
- package/dist/{auth0-spa-js.production.esm-mvPojIrB.js → auth0-spa-js.production.esm-DNao6_S5.js} +1478 -1457
- package/dist/auth0-spa-js.production.esm-DNao6_S5.js.map +1 -0
- package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs +5 -0
- package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs.map +1 -0
- package/dist/components/robots/MotionGroupVisualizer.d.ts.map +1 -1
- package/dist/core.cjs.js +1 -1
- package/dist/core.es.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +3 -3
- package/dist/{interpolation-6ZZN4S_x.js → interpolation-Chyc6Hfo.js} +3054 -2868
- package/dist/interpolation-Chyc6Hfo.js.map +1 -0
- package/dist/interpolation-CiEw5jkz.cjs +20 -0
- package/dist/interpolation-CiEw5jkz.cjs.map +1 -0
- package/dist/lib/ConnectedMotionGroup.d.ts +1 -0
- package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -1
- package/dist/{theming-gUgI75AD.js → theming-CZbXnFej.js} +2 -2
- package/dist/{theming-gUgI75AD.js.map → theming-CZbXnFej.js.map} +1 -1
- package/dist/{theming-Cqo-msxF.cjs → theming-b98f6nXs.cjs} +2 -2
- package/dist/{theming-Cqo-msxF.cjs.map → theming-b98f6nXs.cjs.map} +1 -1
- package/package.json +2 -3
- package/src/components/robots/MotionGroupVisualizer.tsx +33 -75
- package/dist/MotionGroupVisualizer-C_fyiA-X.cjs +0 -2
- package/dist/auth0-spa-js.production.esm-D_IhPirK.cjs +0 -5
- package/dist/auth0-spa-js.production.esm-D_IhPirK.cjs.map +0 -1
- package/dist/auth0-spa-js.production.esm-mvPojIrB.js.map +0 -1
- package/dist/interpolation-6ZZN4S_x.js.map +0 -1
- package/dist/interpolation-CyO6DaVa.cjs +0 -20
- package/dist/interpolation-CyO6DaVa.cjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const t=require("./externalizeComponent-CkVWk2F_.cjs"),g=require("three"),W=require("three-stdlib"),_=require("@react-three/fiber"),M=require("@react-three/drei"),y=require("@mui/material"),ae=require("mobx-react-lite"),m=require("react"),ue=require("react-i18next"),E=require("./interpolation-CiEw5jkz.cjs"),H=require("react-error-boundary");function ce(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const j=ce(g);function le(e){switch(e.shape_type){case"convex_hull":return new W.ConvexGeometry(e.vertices.map(r=>new j.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new j.SphereGeometry(e.radius/1e3);case"capsule":return new j.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new j.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new j.BufferGeometry}}function xe({name:e,collider:n,children:r}){var l,a;const i=((l=n.pose)==null?void 0:l.position)??[0,0,0],s=((a=n.pose)==null?void 0:a.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsxRuntimeExports.jsx("mesh",{name:e,position:new j.Vector3(i[0],i[1],i[2]).divideScalar(1e3),rotation:new j.Euler(s[0],s[1],s[2],"XYZ"),geometry:le(n.shape),children:r})}function me({name:e,colliders:n,meshChildrenProvider:r,...i}){return t.jsxRuntimeExports.jsx("group",{name:e,...i,children:Object.entries(n).map(([s,l])=>t.jsxRuntimeExports.jsx(xe,{name:s,collider:l,children:r(s,l)},s))})}function pe({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsxRuntimeExports.jsx("group",{children:r&&t.jsxRuntimeExports.jsx(me,{meshChildrenProvider:n,colliders:r})})}function F(){return t.jsxRuntimeExports.jsx(M.Environment,{children:t.jsxRuntimeExports.jsx(fe,{})})}function fe({positions:e=[2,0,2,0,2,0,2,0]}){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(M.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsxRuntimeExports.jsx("group",{rotation:[0,.5,0],children:t.jsxRuntimeExports.jsx("group",{children:e.map((n,r)=>t.jsxRuntimeExports.jsx(M.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsxRuntimeExports.jsx(M.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsxRuntimeExports.jsx(M.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsxRuntimeExports.jsx(M.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsxRuntimeExports.jsx(M.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsxRuntimeExports.jsx(M.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}function de(e){if(e.length<3)return console.log("Not enough vertices to define a plane"),{isCoplanar:!1};const n=new j.Vector3(e[0].x,e[0].y,e[0].z),r=new j.Vector3(e[1].x,e[1].y,e[1].z),i=new j.Vector3(e[2].x,e[2].y,e[2].z),s=new j.Vector3().subVectors(r,n),l=new j.Vector3().subVectors(i,n),a=new j.Vector3().crossVectors(s,l).normalize();for(let x=3;x<e.length;x++){const c=new j.Vector3(e[x].x,e[x].y,e[x].z),p=new j.Vector3().subVectors(c,n),d=a.dot(p);if(Math.abs(d)>1e-6)return console.log("Vertices are not on the same plane"),{isCoplanar:!1}}return{isCoplanar:!0,normal:a}}function he({safetyZones:e,...n}){return t.jsxRuntimeExports.jsx("group",{...n,children:e.map((r,i)=>{let s=[];return r.geometry&&(r.geometry.compound?s=r.geometry.compound.child_geometries:r.geometry.convex_hull&&(s=[r.geometry])),s.map((l,a)=>{if(!l.convex_hull)return null;const x=l.convex_hull.vertices.map(d=>new j.Vector3(d.x/1e3,d.y/1e3,d.z/1e3)),c=de(x);if(c.isCoplanar&&c.normal){const o=new j.Vector3().addVectors(x[0],c.normal.multiplyScalar(1e-4));x.push(o)}let p;try{p=new W.ConvexGeometry(x)}catch(d){return console.log("Error creating ConvexGeometry:",d),null}return t.jsxRuntimeExports.jsx("mesh",{geometry:p,children:t.jsxRuntimeExports.jsx("meshStandardMaterial",{attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-a},i)},`${i}-${a}`)})})})}function je({trajectory:e,...n}){var i;const r=((i=e.trajectory)==null?void 0:i.map(s=>s.tcp_pose?new j.Vector3(s.tcp_pose.position.x/1e3,s.tcp_pose.position.z/1e3,-s.tcp_pose.position.y/1e3):null).filter(s=>s!==null))||[];return t.jsxRuntimeExports.jsx("group",{...n,children:r.length>0&&t.jsxRuntimeExports.jsx(M.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const A=new Map;async function T(e,n){if(A.has(e))return A.get(e);const r=(async()=>{var a;const i=n||"",s=new E.NovaClient({instanceUrl:i}),l=s.api.motionGroupModels;(a=l.axios)!=null&&a.interceptors&&l.axios.interceptors.request.use(x=>{var c;return(c=x.url)!=null&&c.includes("/glb")&&(x.responseType="blob"),x});try{const x=await s.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(x)}catch(x){throw console.error("Failed to fetch model:",x),x}})();return A.set(e,r),r}function $(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(i=>n(i))]}return n(e).filter(r=>Y(r))}function N(e){return e.name.endsWith("_FLG")}function Y(e){return/_J[0-9]+$/.test(e.name)}function Re(e,n){let r;function i(s){if(N(s)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${s.name}. Only one _FLG group is allowed.`);r=s}Y(s),s.children.map(i)}if(i(e.scene),!r)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}function X({rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:r,children:i}){const s=m.useRef([]),l=m.useRef([]),a=m.useRef(null),{invalidate:x}=_.useThree();m.useEffect(()=>{const o=e.joint_position.filter(u=>u!==void 0);return a.current=new E.ValueInterpolator(o,{tension:120,friction:20,threshold:.001}),()=>{var u;(u=a.current)==null||u.destroy()}},[]),_.useFrame((o,u)=>{if(a.current){const f=a.current.update(u);p(),f||x()}});function c(o){o&&(l.current=$(o),p(),x())}function p(){var u;const o=((u=a.current)==null?void 0:u.getCurrentValues())||[];if(r)r(l.current,o);else for(const[f,R]of l.current.entries()){const h=n[f],w=h.theta||0,b=h.reverse_rotation_direction?-1:1;R.rotation.y=b*(o[f]||0)+w}}const d=m.useCallback(()=>{const o=e.joint_position.filter(u=>u!==void 0);requestAnimationFrame(()=>{var u;s.current=o,(u=a.current)==null||u.setTarget(o)})},[e]);return m.useEffect(()=>{d()},[e,d]),E.useAutorun(()=>{d()}),t.jsxRuntimeExports.jsx("group",{ref:c,children:i})}const ge="line",Ee="mesh";function ye({rapidlyChangingMotionState:e,dhParameters:n,...r}){const i=new g.Matrix4,s=m.useRef([]),l=m.useRef([]);m.useEffect(()=>{s.current=new Array(n.length).fill(null),l.current=new Array(n.length).fill(null)},[n.length]);function a(p,d){const o=new g.Vector3,u=new g.Quaternion,f=new g.Vector3;i.decompose(o,u,f);const R=o.clone(),h=new g.Matrix4().makeRotationY(p.theta+d*(p.reverse_rotation_direction?-1:1)).multiply(new g.Matrix4().makeTranslation(0,p.d/1e3,0)).multiply(new g.Matrix4().makeTranslation(p.a/1e3,0,0)).multiply(new g.Matrix4().makeRotationX(p.alpha));return i.multiply(h),i.decompose(o,u,f),{a:R,b:o}}function x(p,d,o,u){if(!n)return;const f=n[p];if(!f)return;const{a:R,b:h}=a(f,u);d.geometry.setPositions([R.toArray(),h.toArray()].flat()),o.position.set(h.x,h.y,h.z)}function c(p,d){i.identity();for(let o=0;o<Math.min(p.length,d.length);o++){const u=s.current[o],f=l.current[o];u&&f&&x(o,u,f,d[o])}}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(X,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:c,children:t.jsxRuntimeExports.jsxs("group",{...r,name:"Scene",children:[t.jsxRuntimeExports.jsxs("mesh",{children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n.map((p,d)=>{const{a:o,b:u}=a(p,e.joint_position[d]??0),f=`dhrobot_J0${d}`;return t.jsxRuntimeExports.jsxs("group",{name:f,children:[t.jsxRuntimeExports.jsx(M.Line,{ref:R=>{s.current[d]=R},name:ge,points:[o,u],color:"white",lineWidth:5}),t.jsxRuntimeExports.jsxs("mesh",{ref:R=>{l.current[d]=R},name:Ee,position:u,children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},"mesh_"+d)]},f)})]})})})}const be=console.warn;function K(){return m.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&be(e)}},[]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{})}function we(e){return e.type==="Mesh"}function Me({url:e,flangeRef:n,postModelRender:r,...i}){const s=M.useGLTF(e);let l;try{l=Re(s,"robot.glb").gltf}catch(c){throw c}const a=m.useCallback(c=>{c&&r&&r()},[r]);function x(c){try{return we(c)?c.geometry?t.jsxRuntimeExports.jsx("mesh",{name:c.name,geometry:c.geometry,material:c.material,position:c.position,rotation:c.rotation},c.uuid):t.jsxRuntimeExports.jsx("group",{name:c.name,position:c.position,rotation:c.rotation},c.uuid):t.jsxRuntimeExports.jsx("group",{name:c.name,position:c.position,rotation:c.rotation,ref:N(c)?n:void 0,children:c.children.map(x)},c.uuid)}catch(p){return console.warn("Error rendering node",c.name,p),null}}return t.jsxRuntimeExports.jsx("group",{...i,dispose:null,ref:a,children:x(l.scene)})}function Q({modelURL:e,flangeRef:n,postModelRender:r,...i}){const[s,l]=m.useState(null);return m.useEffect(()=>{(async()=>{try{if(typeof e=="string")l(e);else{const x=await e;l(x)}}catch(x){console.error("Failed to resolve model URL:",x)}})()},[e]),s?t.jsxRuntimeExports.jsx(Me,{url:s,flangeRef:n,postModelRender:r,...i}):null}const Z=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof j.Mesh){r.material instanceof j.Material&&(r.material.colorWrite=!1);const i=r.clone(),s=r.clone();i.material=new j.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:j.DoubleSide}),i.userData.isGhost=!0,s.material=new j.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:j.DoubleSide}),s.userData.isGhost=!0,r.parent&&(r.parent.add(i),r.parent.add(s))}}),e.userData.isGhost=!0)},ee=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var i;r instanceof j.Mesh&&((i=r.userData)!=null&&i.isGhost?n.push(r):r.material instanceof j.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},I=t.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:i=T,flangeRef:s,postModelRender:l,transparentColor:a,instanceUrl:x,...c})=>{const[p,d]=m.useState(null),o=m.useCallback(f=>{d(f)},[]);m.useEffect(()=>{p&&(a?Z(p,a):ee(p))},[p,a]);const u=t.jsxRuntimeExports.jsx(ye,{rapidlyChangingMotionState:e,dhParameters:r,...c});return t.jsxRuntimeExports.jsxs(H.ErrorBoundary,{fallback:u,onError:f=>{console.warn(f)},children:[t.jsxRuntimeExports.jsx(m.Suspense,{fallback:u,children:t.jsxRuntimeExports.jsx("group",{ref:o,children:t.jsxRuntimeExports.jsx(X,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsxRuntimeExports.jsx(Q,{modelURL:(()=>{const f=i(n,x);if(!f){const R=new Blob([],{type:"model/gltf-binary"}),h=new File([R],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(h))}return f})(),postModelRender:l,flangeRef:s,...c})})})}),t.jsxRuntimeExports.jsx(K,{})]})});function te({connectedMotionGroup:e,getModel:n=T,flangeRef:r,transparentColor:i,postModelRender:s,...l}){return e.dhParameters?t.jsxRuntimeExports.jsx(I,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:i,postModelRender:s,...l}):null}const ve=t.externalizeComponent(ae.observer(({robotName:e,programState:n,safetyState:r,operationMode:i,driveToHomeEnabled:s=!1,onDriveToHomePress:l,onDriveToHomeRelease:a,connectedMotionGroup:x,robotComponent:c=te,customContentComponent:p,className:d})=>{var O;const o=y.useTheme(),{t:u}=ue.useTranslation(),[f,R]=m.useState(!1),h=m.useRef(null),w=m.useRef(null),[b,G]=m.useState(!1),[L,oe]=m.useState({width:400,height:600}),[Ce,ie]=m.useState(0);m.useEffect(()=>{const k=()=>{if(w.current){const{offsetWidth:J,offsetHeight:q}=w.current;G(J>q),oe({width:J,height:q})}};k();const U=new ResizeObserver(k);return w.current&&U.observe(w.current),()=>{U.disconnect()}},[]);const z=m.useCallback(()=>{ie(k=>k+1)},[]),S=m.useCallback(()=>{!s||!l||(R(!0),l())},[s,l]),C=m.useCallback(()=>{!s||!a||(R(!1),a())},[s,a]),D=m.useCallback(()=>{f&&a&&(R(!1),a())},[f,a]),v=b?L.width<350:L.height<200,V=b?L.height<310:L.height<450;return t.jsxRuntimeExports.jsx(y.Card,{ref:w,className:d,sx:{width:"100%",height:"100%",display:"flex",flexDirection:b?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:b?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${o.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((O=o.palette.backgroundPaperElevation)==null?void 0:O[8])||"#2A2A3F",backgroundImage:"none"},children:b?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(y.Box,{sx:{flex:"0 0 50%",position:"relative",height:"100%",minHeight:"100%",maxHeight:"100%",borderRadius:1,m:{xs:1.5,sm:2,md:3},mr:{xs:.75,sm:1,md:1.5},overflow:"hidden",display:v?"none":"block"},children:!v&&t.jsxRuntimeExports.jsxs(_.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:o.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsxRuntimeExports.jsx(F,{}),t.jsxRuntimeExports.jsx(M.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsxRuntimeExports.jsx(c,{connectedMotionGroup:x,postModelRender:z})})]})}),t.jsxRuntimeExports.jsxs(y.Box,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:v?"100%":"50%"},children:[t.jsxRuntimeExports.jsxs(y.Box,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsxRuntimeExports.jsx(y.Typography,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsxRuntimeExports.jsx(E.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:i})]}),t.jsxRuntimeExports.jsxs(y.Box,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!V&&p&&t.jsxRuntimeExports.jsxs(y.Box,{children:[t.jsxRuntimeExports.jsx(p,{}),t.jsxRuntimeExports.jsx(y.Divider,{sx:{mt:1,mb:0,borderColor:o.palette.divider,opacity:.5}})]}),t.jsxRuntimeExports.jsx(y.Box,{sx:{mt:!V&&p?"auto":0},children:t.jsxRuntimeExports.jsx(y.Box,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsxRuntimeExports.jsx(y.Button,{ref:h,variant:"contained",color:"secondary",size:"small",disabled:!s,onMouseDown:S,onMouseUp:C,onMouseLeave:D,onTouchStart:S,onTouchEnd:C,sx:{textTransform:"none",px:1.5,py:.5},children:u("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(y.Box,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxRuntimeExports.jsxs(y.Box,{children:[t.jsxRuntimeExports.jsx(y.Typography,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsxRuntimeExports.jsx(E.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:i})]}),t.jsxRuntimeExports.jsx(y.Box,{sx:{flex:v?0:1,position:"relative",minHeight:v?0:{xs:120,sm:150,md:200},height:v?0:"auto",borderRadius:1,overflow:"hidden",display:v?"none":"block"},children:!v&&t.jsxRuntimeExports.jsxs(_.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:o.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsxRuntimeExports.jsx(F,{}),t.jsxRuntimeExports.jsx(M.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsxRuntimeExports.jsx(c,{connectedMotionGroup:x,postModelRender:z})})]})}),t.jsxRuntimeExports.jsxs(y.Box,{children:[!V&&p&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(p,{}),t.jsxRuntimeExports.jsx(y.Divider,{sx:{mt:1,mb:0,borderColor:o.palette.divider,opacity:.5}})]}),t.jsxRuntimeExports.jsx(y.Box,{sx:{display:"flex",justifyContent:"flex-start",mt:!V&&p?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsxRuntimeExports.jsx(y.Button,{ref:h,variant:"contained",color:"secondary",size:"small",disabled:!s,onMouseDown:S,onMouseUp:C,onMouseLeave:D,onTouchStart:S,onTouchEnd:C,sx:{textTransform:"none",px:1.5,py:.5},children:u("RobotCard.DriveToHome.bt")})})]})]})})})})),_e=Array(6).fill(2*Math.PI);function re({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:i}){const s=m.useRef([]),l=m.useRef([]),a=m.useRef(null),{invalidate:x}=_.useThree();m.useEffect(()=>{const o=e.joint_position.filter(u=>u!==void 0);return a.current=new E.ValueInterpolator(o,{tension:120,friction:20,threshold:.001}),()=>{var u;(u=a.current)==null||u.destroy()}},[]),_.useFrame((o,u)=>{if(a.current){const f=a.current.update(u);p(),f||x()}});function c(o){o&&(l.current=$(o),p(),x())}function p(){var u;const o=((u=a.current)==null?void 0:u.getCurrentValues())||[];if(r)r(l.current,o);else for(const[f,R]of l.current.entries()){const w=n[f].reverse_rotation_direction?-1:1;R.position.y=w*(o[f]||0)/1e3}}const d=m.useCallback(()=>{const o=e.joint_position.filter(u=>u!==void 0);requestAnimationFrame(()=>{var u;s.current=o,(u=a.current)==null||u.setTarget(o)})},[e]);return m.useEffect(()=>{d()},[e,d]),E.useAutorun(()=>{d()}),t.jsxRuntimeExports.jsx("group",{ref:c,children:i})}function ne({rapidlyChangingMotionState:e,dhParameters:n,...r}){const i=new g.Matrix4,s=m.useRef(null),l=m.useRef(null);function a(p){const d=new g.Matrix4;for(let R=0;R<n.length;R++){const h=n[R],w=p[R]??0,b=new g.Matrix4().makeRotationY(h.theta).multiply(new g.Matrix4().makeTranslation(h.a/1e3,(h.d+w*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(h.alpha));d.multiply(b)}const o=new g.Vector3,u=new g.Quaternion,f=new g.Vector3;return d.decompose(o,u,f),o}const x=a(e.joint_position);function c(p,d){i.identity();let o=new g.Vector3;for(let h=0;h<n.length;h++){const w=d[h]??0,b=n[h],G=new g.Matrix4().makeRotationY(b.theta).multiply(new g.Matrix4().makeTranslation(b.a/1e3,(b.d+w*(b.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(b.alpha));i.multiply(G)}const u=new g.Vector3,f=new g.Quaternion,R=new g.Vector3;if(i.decompose(u,f,R),o=u,s.current&&s.current.position.set(o.x,o.y,o.z),l.current){const h=l.current.geometry;h&&h.setPositions&&h.setPositions([0,0,0,o.x,o.y,o.z])}}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(re,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:c,children:t.jsxRuntimeExports.jsxs("group",{...r,name:"Scene",children:[t.jsxRuntimeExports.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsxRuntimeExports.jsx(M.Line,{ref:l,points:[new g.Vector3(0,0,0),x],color:"White",lineWidth:5}),t.jsxRuntimeExports.jsxs("mesh",{ref:s,name:"TCP",position:x,children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})})}const B=t.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:i=T,flangeRef:s,postModelRender:l,transparentColor:a,instanceUrl:x,...c})=>{const[p,d]=m.useState(null),o=m.useCallback(f=>{d(f)},[]);m.useEffect(()=>{p&&(a?Z(p,a):ee(p))},[p,a]);const u=t.jsxRuntimeExports.jsx(ne,{rapidlyChangingMotionState:e,dhParameters:r,...c});return t.jsxRuntimeExports.jsxs(H.ErrorBoundary,{fallback:u,onError:f=>{console.warn(f)},children:[t.jsxRuntimeExports.jsx(m.Suspense,{fallback:u,children:t.jsxRuntimeExports.jsx("group",{ref:o,children:t.jsxRuntimeExports.jsx(re,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsxRuntimeExports.jsx(Q,{modelURL:(()=>{const f=i(n,x);if(!f){const R=new Blob([],{type:"model/gltf-binary"}),h=new File([R],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(h))}return f})(),postModelRender:l,flangeRef:s,...c})})})}),t.jsxRuntimeExports.jsx(K,{})]})});function Te({connectedMotionGroup:e,getModel:n=T,flangeRef:r,transparentColor:i,postModelRender:s,...l}){if(!e.dhParameters)return null;const a=e.modelFromController||"";return a&&n(a)?t.jsxRuntimeExports.jsx(B,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:a,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:i,postModelRender:s,...l}):t.jsxRuntimeExports.jsx(ne,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...l})}const P={[E.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[E.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[E.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[E.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[E.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0]};function se(e){const[n]=e.split("_");switch(n){case"ABB":return E.Manufacturer.Abb;case"FANUC":return E.Manufacturer.Fanuc;case"YASKAWA":return E.Manufacturer.Yaskawa;case"KUKA":return E.Manufacturer.Kuka;case"UniversalRobots":return E.Manufacturer.Universalrobots;default:return null}}function Le(e,n){const r=se(e);return r&&r in P?P[r]:n||null}const Se=t.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:r,...i}=e,[s,l]=m.useState(E.JointTypeEnum.RevoluteJoint);m.useEffect(()=>{r.length&&l(r[0].type??E.JointTypeEnum.RevoluteJoint)},[r]);const a=m.useMemo(()=>n===null&&s===E.JointTypeEnum.RevoluteJoint,[n,s]),x=m.useMemo(()=>n===null&&s===E.JointTypeEnum.PrismaticJoint,[n,s]);return m.useMemo(()=>!!n,[n])||a?t.jsxRuntimeExports.jsx(I,{dhParameters:r,...i}):x?t.jsxRuntimeExports.jsx(B,{dhParameters:r,...i}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{})});exports.CollisionSceneRenderer=pe;exports.LinearAxis=Te;exports.MANUFACTURER_HOME_CONFIGS=P;exports.MotionGroupVisualizer=Se;exports.PresetEnvironment=F;exports.Robot=te;exports.RobotCard=ve;exports.SafetyZonesRenderer=he;exports.SupportedLinearAxis=B;exports.SupportedRobot=I;exports.TrajectoryRenderer=je;exports.defaultAxisConfig=_e;exports.defaultGetModel=T;exports.extractManufacturer=se;exports.getDefaultHomeConfig=Le;
|
|
2
|
+
//# sourceMappingURL=MotionGroupVisualizer-DePl371W.cjs.map
|