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