@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.5d2eede → 6.4.0-pr.revamp.667.d7cab79

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 (56) hide show
  1. package/README.md +56 -5
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +1 -0
  4. package/dist/3d.js +16 -15
  5. package/dist/CurrentPoseBar/index.cjs +1 -1
  6. package/dist/CurrentPoseBar/index.js +1 -1
  7. package/dist/RobotControlPanel/index.cjs +1 -1
  8. package/dist/RobotControlPanel/index.js +1 -1
  9. package/dist/RobotHeader/index.js +1 -1
  10. package/dist/SafetyBar/index.js +1 -1
  11. package/dist/chunks/{CurrentPoseBar-zTZi68tY.js → CurrentPoseBar-DENCilvf.js} +1 -1
  12. package/dist/chunks/{CurrentPoseBar-CyHUWmjM.cjs → CurrentPoseBar-DrXTcV-I.cjs} +1 -1
  13. package/dist/chunks/{RobotControlPanel-BXtBHEe9.cjs → RobotControlPanel-DTE8-v2j.cjs} +1 -1
  14. package/dist/chunks/{RobotControlPanel-BiLexAWI.js → RobotControlPanel-E-hUzMIL.js} +1 -1
  15. package/dist/chunks/{RobotHeader-DDmDkUoV.js → RobotHeader-BvIzk8Fw.js} +1 -1
  16. package/dist/chunks/{SafetyBar-RkN0I1Cb.js → SafetyBar-eYzCHOFD.js} +1 -1
  17. package/dist/chunks/{converters-DAr6IQbG.js → converters-D9KpJ2HD.js} +2 -2
  18. package/dist/chunks/loadRobotSession-DlRzFjYE.cjs +3 -0
  19. package/dist/chunks/loadRobotSession-kKQ96rWu.js +4721 -0
  20. package/dist/chunks/robotModelSource-Bv1Z_miZ.cjs +1 -0
  21. package/dist/chunks/robotModelSource-CKuBOeQ-.js +1295 -0
  22. package/dist/chunks/useEveryFrame-B8t_yz-G.js +155 -0
  23. package/dist/chunks/useEveryFrame-CHxg25f4.cjs +1 -0
  24. package/dist/components/robotControl/poseText.d.ts +21 -5
  25. package/dist/components/robots/LinearAxis.d.ts +12 -11
  26. package/dist/components/robots/Robot.d.ts +26 -9
  27. package/dist/components/robots/robotModelSource.d.ts +38 -0
  28. package/dist/core.cjs +1 -1
  29. package/dist/core.d.ts +10 -0
  30. package/dist/core.js +58 -39
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.js +86 -66
  33. package/dist/lib/ConnectedMotionGroup.d.ts +5 -1
  34. package/dist/lib/controllerStateSource.d.ts +6 -4
  35. package/dist/lib/motionGroupModelResources.d.ts +1 -0
  36. package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
  37. package/dist/lib/robotSession/RobotActivation.d.ts +48 -0
  38. package/dist/lib/robotSession/RobotDescription.d.ts +84 -0
  39. package/dist/lib/robotSession/RobotLiveState.d.ts +56 -0
  40. package/dist/lib/robotSession/RobotLoadProgress.d.ts +72 -0
  41. package/dist/lib/robotSession/RobotSafety.d.ts +59 -0
  42. package/dist/lib/robotSession/RobotSession.d.ts +78 -0
  43. package/dist/lib/robotSession/RobotTargetPose.d.ts +78 -0
  44. package/dist/lib/robotSession/loadRobotResources.d.ts +46 -0
  45. package/dist/lib/robotSession/loadRobotSession.d.ts +81 -0
  46. package/dist/lib/robotSession/robotPose.d.ts +28 -0
  47. package/dist/nats.cjs +1 -0
  48. package/dist/nats.d.ts +4 -0
  49. package/dist/nats.js +131 -0
  50. package/package.json +11 -1
  51. package/dist/chunks/Robot-B3vKEVXP.cjs +0 -1
  52. package/dist/chunks/Robot-DXhaz1tq.js +0 -1272
  53. package/dist/chunks/TrajectoryExecutionStore-CKfEoKo8.cjs +0 -3
  54. package/dist/chunks/TrajectoryExecutionStore-DYVukgCz.js +0 -3613
  55. package/dist/chunks/useEveryFrame-G_-ma1nC.js +0 -142
  56. package/dist/chunks/useEveryFrame-dmPPTKtT.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";const i=require("react/jsx-runtime"),M=require("three"),k=require("three-stdlib"),S=require("@react-three/drei"),m=require("react"),P=require("./converters-BsXgcxCW.cjs"),E=require("@wandelbots/nova-js/v2"),G=require("./externalizeComponent-BdxGBLIv.cjs"),T=require("./Pose3-DIyg-aZA.cjs"),D=require("react-error-boundary"),Q=require("@react-three/fiber");function re(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const w=re(M);function ie(t){switch(t.shape_type){case"convex_hull":return new k.ConvexGeometry(t.vertices.map(e=>new w.Vector3(e[0]/1e3,e[1]/1e3,e[2]/1e3)));case"box":return new w.BoxGeometry(t.size_x/1e3,t.size_y/1e3,t.size_z/1e3);case"sphere":return new w.SphereGeometry(t.radius/1e3);case"capsule":return new w.CapsuleGeometry(t.radius/1e3,t.cylinder_height/1e3);case"cylinder":return new w.CylinderGeometry(t.radius/1e3,t.radius/1e3,t.height/1e3);case"rectangle":return new w.BoxGeometry(t.size_x/1e3,t.size_y/1e3,0);default:return console.warn(`${t.shape_type} is not supported`),new w.BufferGeometry}}function se({name:t,collider:n,children:e}){var c,l;const r=((c=n.pose)==null?void 0:c.position)??[0,0,0],s=((l=n.pose)==null?void 0:l.orientation)??[0,0,0];return n.margin&&console.warn(`${t} margin is not supported`),i.jsx("mesh",{name:t,position:new w.Vector3(r[0],r[1],r[2]).divideScalar(1e3),rotation:new w.Euler(s[0],s[1],s[2],"XYZ"),geometry:ie(n.shape),children:e})}function ae({name:t,colliders:n,meshChildrenProvider:e,...r}){return i.jsx("group",{name:t,...r,children:Object.entries(n).map(([s,c])=>i.jsx(se,{name:s,collider:c,children:e(s,c)},s))})}function ce({scene:t,meshChildrenProvider:n}){const e=t.colliders;return i.jsx("group",{children:e&&i.jsx(ae,{meshChildrenProvider:n,colliders:e})})}function le(t){const n=(t==null?void 0:t.position)??[],e=(t==null?void 0:t.orientation)??[],r=new M.Vector3(e[0]??0,e[1]??0,e[2]??0),s=r.length(),c=s>0?new M.Quaternion().setFromAxisAngle(r.normalize(),s):new M.Quaternion;return new M.Matrix4().compose(new M.Vector3(n[0]??0,n[1]??0,n[2]??0).divideScalar(1e3),c,new M.Vector3(1,1,1))}function ue(t,n=null,e=[]){const r=le(n);return t.map((s,c)=>{const l=r.clone(),o=(s.reverse_rotation_direction?-1:1)*(e[c]??0),a=s.type==="PRISMATIC_JOINT",p=(s.theta??0)+(a?0:o),f=(s.d??0)+(a?o:0);return r.multiply(new M.Matrix4().makeRotationZ(p)).multiply(new M.Matrix4().makeTranslation((s.a??0)/1e3,0,f/1e3)).multiply(new M.Matrix4().makeRotationX(s.alpha??0)),l})}const A="#ff4b4b",q="#2fa8ff",pe="#8a8d9e",fe=96,me=.15,he=new w.Vector3(0,1,0),de=.2,xe=2;function ge(t){const{lower_limit:n,upper_limit:e}=t??{};return typeof n!="number"||typeof e!="number"||!Number.isFinite(n)||!Number.isFinite(e)||!(n<e)?null:{lower_limit:n,upper_limit:e}}function C({base:t,direction:n,size:e,color:r,opacity:s}){const c=new w.Quaternion().setFromUnitVectors(he,n.clone().normalize()),l=t.clone().addScaledVector(n.clone().normalize(),e/2);return i.jsxs("mesh",{position:l,quaternion:c,renderOrder:10,children:[i.jsx("coneGeometry",{args:[e*.35,e,16]}),i.jsx("meshBasicMaterial",{color:r,depthTest:!1,transparent:!0,opacity:s})]})}function V({points:t,color:n,width:e,opacity:r}){return i.jsx(S.Line,{points:t,color:n,lineWidth:e,depthTest:!1,transparent:!0,opacity:r,renderOrder:10})}function J(t,n){const e=[...t];let r=n;for(;e.length>1;){const s=e[e.length-1],c=e[e.length-2],l=s.distanceTo(c);if(l>r)return e[e.length-1]=s.clone().lerp(c,r/l),e;r-=l,e.pop()}return e}function ye(t,n,e,r){const s=e*t,c=e*n,l=Math.abs(c-s),o=Math.max(2,Math.ceil(l/(2*Math.PI)*fe));return Array.from({length:o+1},(a,p)=>{const f=s+(c-s)*p/o,u=l*p/o/(2*Math.PI),j=r*(1+me*u);return new w.Vector3(Math.cos(f)*j,Math.sin(f)*j,0)})}function je(t,n,e,r){const s=t.theta??0,c=t.d??0,l=t.type==="PRISMATIC_JOINT",o=t.reverse_rotation_direction?-1:1,{lower_limit:a,upper_limit:p}=n;return m.useMemo(()=>{const f=new w.Matrix4().makeRotationZ(s).multiply(new w.Matrix4().makeTranslation(0,0,l?c/1e3:0)),u=(b,_,v)=>new w.Vector3(b,_,v).applyMatrix4(f),j=new w.Vector3().applyMatrix4(f),g=u(0,0,e),d=(l?[u(e*.25,0,o*a/1e3),u(e*.25,0,o*p/1e3)]:ye(a,p,o,e*.6)).map(b=>l?b:b.applyMatrix4(f)),h=u(l?e*.25:e*.6,0,0),R=d.slice(1).reduce((b,_,v)=>b+_.distanceTo(d[v]),0),x=Math.min(r,R/3),y=J(J(d,x).reverse(),x).reverse();return{axisPoints:[j,g],axisTip:g,origin:j,restPoints:[j,h],range:d,limitPoints:y,rangeStart:y[0],rangeEnd:y[y.length-1]}},[s,c,l,o,e,a,p,r])}function Me({frame:t,dh:n,limit:e,size:r,emphasis:s}){const c=s==="highlighted"?xe:1,l=s==="dimmed"?de:1,o=r*.2*(s==="highlighted"?1.4:1),a=2*c,{axisPoints:p,axisTip:f,origin:u,restPoints:j,range:g,limitPoints:d,rangeStart:h,rangeEnd:R}=je(n,e,r,o),{position:x,quaternion:y}=m.useMemo(()=>{const b=new w.Vector3,_=new w.Quaternion;return t.decompose(b,_,new w.Vector3),{position:b,quaternion:_}},[t]);return i.jsxs("group",{position:x,quaternion:y,children:[i.jsx(V,{points:p,color:q,width:a,opacity:l}),i.jsx(C,{base:f,direction:f.clone().sub(u),size:o,color:q,opacity:l}),i.jsx(V,{points:j,color:pe,width:1.5*c,opacity:l}),i.jsx(V,{points:d,color:A,width:a,opacity:l}),i.jsx(C,{base:h,direction:g[0].clone().sub(h),size:h.distanceTo(g[0]),color:A,opacity:l}),i.jsx(C,{base:R,direction:g[g.length-1].clone().sub(R),size:R.distanceTo(g[g.length-1]),color:A,opacity:l})]})}function we({dhParameters:t,chainOffset:n=null,limits:e,jointPositions:r,size:s=.15,highlightedJoint:c=null}){const l=m.useMemo(()=>ue(t,n,r),[t,n,r]);return i.jsx("group",{children:l.map((o,a)=>{const p=ge(e[a]);return p?i.jsx(Me,{frame:o,dh:t[a],limit:p,size:s,emphasis:c===null?"normal":c===a?"highlighted":"dimmed"},a):null})})}function Re(){return i.jsx(S.Environment,{frames:1,children:i.jsx(Se,{})})}const be=[2,0,2,0,2,0,2,0];function Se({positions:t=be}){return i.jsxs(i.Fragment,{children:[i.jsx(S.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),i.jsx("group",{rotation:[0,.5,0],children:i.jsx("group",{children:t.map((n,e)=>i.jsx(S.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,e*4],scale:[3,1,1]},e))})}),i.jsx(S.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),i.jsx(S.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),i.jsx(S.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),i.jsx(S.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),i.jsx(S.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const N={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function _e({safetyZones:t,dhParameters:n,...e}){const r=m.useMemo(()=>P.dhParametersToPlaneSize(n??[]),[n]),s=(l,o)=>{var j,g;if(!((j=o==null?void 0:o.pose)!=null&&j.position)||!((g=o==null?void 0:o.pose)!=null&&g.orientation))return null;const a=new w.Vector3(o.pose.position[0]/1e3,o.pose.position[1]/1e3,o.pose.position[2]/1e3),p=new w.Vector3(o.pose.orientation[0],o.pose.orientation[1],o.pose.orientation[2]);let f;const u=o.shape.shape_type==="plane"?{...N,side:w.DoubleSide}:{...N,side:w.FrontSide};switch(o.shape.shape_type){case"plane":f=i.jsx("planeGeometry",{args:[r,r]});break;case"sphere":{const d=(o==null?void 0:o.shape).radius/1e3;f=i.jsx("sphereGeometry",{args:[d]});break}case"capsule":{const d=(o==null?void 0:o.shape).radius/1e3,h=(o==null?void 0:o.shape).cylinder_height/1e3;f=i.jsx("capsuleGeometry",{args:[d,h]});break}case"convex_hull":{const d=(o==null?void 0:o.shape).vertices.map(R=>new w.Vector3(R[0]/1e3,R[1]/1e3,R[2]/1e3)),h=P.verticesToCoplanarity(d);if(h.isCoplanar&&h.normal){const x=new w.Vector3().addVectors(d[0],h.normal.multiplyScalar(1e-4));d.push(x)}try{f=i.jsx("primitive",{object:new k.ConvexGeometry(d),attach:"geometry"})}catch(R){return console.log("Error creating ConvexGeometry:",R),null}break}case"rectangular_capsule":{const d=o.shape,h=d.radius/1e3,R=d.sphere_center_distance_x/1e3,x=d.sphere_center_distance_y/1e3,y=h*2;f=i.jsx("primitive",{object:new k.RoundedBoxGeometry(R,x,y,2,h),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",o.shape.shape_type),f=null}return i.jsxs("mesh",{renderOrder:l,position:a,quaternion:P.orientationToQuaternion(p),children:[f,i.jsx("meshStandardMaterial",{...u,polygonOffsetFactor:-l})]},`safety-zone-${o.shape.shape_type}-${l}`)},c=m.useMemo(()=>Object.values(t??{}).map((l,o)=>s(o,l)),[t,r]);return i.jsx("group",{...e,children:c})}function ve({trajectory:t,...n}){const e=(t==null?void 0:t.map(r=>{if(r.position&&r.position.length>=3){const[s,c,l]=r.position;if(Number.isFinite(s)&&Number.isFinite(c)&&Number.isFinite(l))return new w.Vector3(s/1e3,l/1e3,-c/1e3)}return null}).filter(r=>r!==null))||[];return i.jsx("group",{...n,children:e.length>0&&i.jsx(S.Line,{points:e,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const O=new Map;async function L(t,n){const e=n||"";if(!e)throw new Error(`Cannot download the model "${t}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`);const r=`${Te(e)} ${t}`,s=O.get(r);if(s)return s;const c=(async()=>{const l=T.createNovaClient(e);try{const o=await l.api.motionGroupModels.getMotionGroupGlbModel(t,{responseType:"blob"});return URL.createObjectURL(o)}catch(o){throw console.error("Failed to fetch model:",o),o}})();return O.set(r,c),c.catch(()=>{O.get(r)===c&&O.delete(r)}),c}function Te(t){return typeof t=="string"?t:t.config.instanceUrl}function $(t){function n(e){return e.children.length===0?[e]:[e,...e.children.flatMap(r=>n(r))]}return n(t).filter(e=>W(e))}function U(t){return t.name.endsWith("_FLG")}function W(t){return/_J[0-9]+$/.test(t.name)}function Ge(t,n){let e;function r(s){if(U(s)){if(e)throw Error(`Found multiple flange groups in robot model ${n}; first ${e.name} then ${s.name}. Only one _FLG group is allowed.`);e=s}W(s),s.children.map(r)}if(r(t.scene),!e)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:t}}const H=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:e,chainOffsetPosition:r,chainOffsetQuaternion:s,onTranslationChanged:c,children:l},o){const a=m.useRef(null),p=m.useRef([]),f=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=Q.useThree(),j=m.useRef(n);j.current=n;function g(x){a.current=x,x&&d()}function d(){a.current&&(p.current=$(a.current),h(),u())}m.useImperativeHandle(o,()=>({recollectJoints:d}));function h(){const x=f.current;if(c)c(p.current,x);else for(const[y,b]of p.current.entries()){const v=e[y].reverse_rotation_direction?-1:1;b.position.y=v*(x[y]||0)/1e3}}function R(x){f.current=x.joint_position.filter(y=>y!==void 0),h(),u()}return T.useAutorun(()=>{R(j.current)}),i.jsx("group",{ref:g,position:r,quaternion:s,children:l})});function B({rapidlyChangingMotionState:t,dhParameters:n,...e}){const r=new M.Matrix4,s=m.useRef(null),c=m.useRef(null);function l(p){const f=new M.Matrix4;for(let d=0;d<n.length;d++){const h=n[d],R=p[d]??0,x=new M.Matrix4().makeRotationY(h.theta).multiply(new M.Matrix4().makeTranslation(h.a/1e3,(h.d+R*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new M.Matrix4().makeRotationX(h.alpha));f.multiply(x)}const u=new M.Vector3,j=new M.Quaternion,g=new M.Vector3;return f.decompose(u,j,g),u}const o=l(t.joint_position);function a(p,f){r.identity();let u=new M.Vector3;for(let h=0;h<n.length;h++){const R=f[h]??0,x=n[h],y=new M.Matrix4().makeRotationY(x.theta).multiply(new M.Matrix4().makeTranslation(x.a/1e3,(x.d+R*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new M.Matrix4().makeRotationX(x.alpha));r.multiply(y)}const j=new M.Vector3,g=new M.Quaternion,d=new M.Vector3;if(r.decompose(j,g,d),u=j,s.current&&s.current.position.set(u.x,u.y,u.z),c.current){const h=c.current.geometry;h!=null&&h.setPositions&&h.setPositions([0,0,0,u.x,u.y,u.z])}}return i.jsx(H,{rapidlyChangingMotionState:t,dhParameters:n,onTranslationChanged:a,children:i.jsxs("group",{...e,name:"Scene",children:[i.jsxs("mesh",{name:"Base",position:[0,0,0],children:[i.jsx("sphereGeometry",{args:[.02,32,32]}),i.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),i.jsx(S.Line,{ref:c,points:[new M.Vector3(0,0,0),o],color:"White",lineWidth:5}),i.jsxs("mesh",{ref:s,name:"TCP",position:o,children:[i.jsx("sphereGeometry",{args:[.025,32,32]}),i.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const Le=console.warn;function X(){return m.useEffect(()=>{console.warn=t=>{t!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Le(t)}},[]),null}function Ee(t){return t.type==="Mesh"}function Oe({url:t,flangeRef:n,postModelRender:e,...r}){const s=S.useGLTF(t),l=Ge(s,"robot.glb").gltf;m.useEffect(()=>{e==null||e()},[t,e]);function o(a){try{return Ee(a)?a.geometry?i.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):i.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):i.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:U(a)?n:void 0,children:a.children.map(o)},a.uuid)}catch(p){return console.warn("Error rendering node",a.name,p),null}}return i.jsx("group",{...r,dispose:null,children:o(l.scene)})}function Y({modelURL:t,flangeRef:n,postModelRender:e,...r}){const[s,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return(async()=>{try{const a=typeof t=="string"?t:await t;l||c(p=>p===a?p:a)}catch(a){console.error("Failed to resolve model URL:",a)}})(),()=>{l=!0}},[t]),s?i.jsx(Oe,{url:s,flangeRef:n,postModelRender:e,...r}):null}const Z=(t,n)=>{t.userData.isGhost||(t.traverse(e=>{if(e instanceof w.Mesh){e.material instanceof w.Material&&(e.material.colorWrite=!1);const r=e.clone(),s=e.clone();r.material=new w.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:w.DoubleSide}),r.userData.isGhost=!0,s.material=new w.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:w.DoubleSide}),s.userData.isGhost=!0,e.parent&&(e.parent.add(r),e.parent.add(s))}}),t.userData.isGhost=!0)},K=t=>{if(!t.userData.isGhost)return;const n=[];t.traverse(e=>{var r;e instanceof w.Mesh&&((r=e.userData)!=null&&r.isGhost?n.push(e):e.material instanceof w.Material&&(e.material.colorWrite=!0))}),n.forEach(e=>{e.parent&&e.parent.remove(e)}),t.userData.isGhost=!1},I=G.externalizeComponent(({rapidlyChangingMotionState:t,modelFromController:n,dhParameters:e,chainOffsetPosition:r,chainOffsetQuaternion:s,getModel:c=L,flangeRef:l,postModelRender:o,transparentColor:a,instanceUrl:p,...f})=>{const[u,j]=m.useState(null),g=m.useRef(null),d=m.useCallback(y=>{j(y)},[]),h=m.useCallback(()=>{var y;(y=g.current)==null||y.recollectJoints(),o==null||o()},[o]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const R=m.useMemo(()=>{const y=c(n,p);if(!y){const b=new Blob([],{type:"model/gltf-binary"}),_=new File([b],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(_))}return y},[n,p,c]),x=i.jsx(B,{rapidlyChangingMotionState:t,dhParameters:e,...f});return i.jsxs(D.ErrorBoundary,{fallback:x,onError:y=>{console.warn(y)},children:[i.jsx(m.Suspense,{fallback:x,children:i.jsx("group",{ref:d,children:i.jsx(H,{ref:g,rapidlyChangingMotionState:t,dhParameters:e,chainOffsetPosition:r,chainOffsetQuaternion:s,children:i.jsx(Y,{modelURL:R,postModelRender:h,flangeRef:l,...f})})})}),i.jsx(X,{})]})}),z=G.externalizeComponent(({rapidlyChangingMotionState:t,...n})=>{const e=T.useSmoothedMotionState(t);return i.jsx(I,{rapidlyChangingMotionState:e,...n})});function Pe({motionGroup:t,connectedMotionGroup:n,getModel:e,flangeRef:r,transparentColor:s,postModelRender:c,...l}){const o=t??n,a=o==null?void 0:o.nova,p=m.useCallback(g=>L(g,a),[a]),f=e??p;if(!(o!=null&&o.dhParameters))return null;const u=o.modelFromController||"";return u?i.jsx(z,{rapidlyChangingMotionState:o.rapidlyChangingMotionState,modelFromController:u,dhParameters:o.dhParameters,getModel:f,flangeRef:r,transparentColor:s,postModelRender:c,chainOffsetPosition:o.mountingPosition,chainOffsetQuaternion:o.mountingQuaternion,...l}):i.jsx(B,{rapidlyChangingMotionState:o.rapidlyChangingMotionState,dhParameters:o.dhParameters,chainOffsetPosition:o.mountingPosition,chainOffsetQuaternion:o.mountingQuaternion,...l})}const ee=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:e,chainOffsetPosition:r,chainOffsetQuaternion:s,onRotationChanged:c,children:l},o){const a=m.useRef(null),p=m.useRef([]),f=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=Q.useThree(),j=m.useRef(n);j.current=n;function g(x){a.current=x,x&&d()}function d(){a.current&&(p.current=$(a.current),h(),u())}m.useImperativeHandle(o,()=>({recollectJoints:d}));function h(){const x=f.current;if(c)c(p.current,x);else for(const[y,b]of p.current.entries()){const _=e[y],v=_.theta||0,oe=_.reverse_rotation_direction?-1:1;b.rotation.y=oe*(x[y]||0)+v}}function R(x){f.current=x.joint_position.filter(y=>y!==void 0),h(),u()}return T.useAutorun(()=>{R(j.current)}),m.useEffect(()=>{R(n)},[n]),i.jsx("group",{ref:g,position:r,quaternion:s,children:l})}),Ae="line",Ce="mesh";function Ve({rapidlyChangingMotionState:t,dhParameters:n,...e}){const r=new M.Matrix4,s=m.useRef([]),c=m.useRef([]);m.useEffect(()=>{s.current=new Array(n.length).fill(null),c.current=new Array(n.length).fill(null)},[n.length]);function l(p,f){const u=new M.Vector3,j=new M.Quaternion,g=new M.Vector3;r.decompose(u,j,g);const d=u.clone(),h=new M.Matrix4().makeRotationY(p.theta+f*(p.reverse_rotation_direction?-1:1)).multiply(new M.Matrix4().makeTranslation(0,p.d/1e3,0)).multiply(new M.Matrix4().makeTranslation(p.a/1e3,0,0)).multiply(new M.Matrix4().makeRotationX(p.alpha));return r.multiply(h),r.decompose(u,j,g),{a:d,b:u}}function o(p,f,u,j){if(!n)return;const g=n[p];if(!g)return;const{a:d,b:h}=l(g,j);f.geometry.setPositions([d.toArray(),h.toArray()].flat()),u.position.set(h.x,h.y,h.z)}function a(p,f){r.identity();for(let u=0;u<Math.min(p.length,f.length);u++){const j=s.current[u],g=c.current[u];j&&g&&o(u,j,g,f[u])}}return i.jsx(ee,{rapidlyChangingMotionState:t,dhParameters:n,onRotationChanged:a,children:i.jsxs("group",{...e,name:"Scene",children:[i.jsxs("mesh",{children:[i.jsx("sphereGeometry",{args:[.01,32,32]}),i.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((p,f)=>{const{a:u,b:j}=l(p,t.joint_position[f]??0),g=`dhrobot_J0${f}`;return i.jsxs("group",{name:g,children:[i.jsx(S.Line,{ref:d=>{s.current[f]=d},name:Ae,points:[u,j],color:"white",lineWidth:5}),i.jsxs("mesh",{ref:d=>{c.current[f]=d},name:Ce,position:j,children:[i.jsx("sphereGeometry",{args:[.01,32,32]}),i.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${f}`)]},g)})]})})}const F=G.externalizeComponent(({rapidlyChangingMotionState:t,modelFromController:n,dhParameters:e,chainOffsetPosition:r,chainOffsetQuaternion:s,getModel:c=L,flangeRef:l,postModelRender:o,transparentColor:a,instanceUrl:p,...f})=>{const[u,j]=m.useState(null),g=m.useRef(null),d=m.useCallback(y=>{j(y)},[]),h=m.useCallback(()=>{var y;(y=g.current)==null||y.recollectJoints(),o==null||o()},[o]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const R=m.useMemo(()=>{const y=c(n,p);if(!y)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return y},[n,p,c]),x=i.jsx(Ve,{rapidlyChangingMotionState:t,dhParameters:e,...f});return i.jsxs(D.ErrorBoundary,{fallback:x,onError:y=>{console.warn(y)},children:[i.jsx(m.Suspense,{fallback:x,children:i.jsx("group",{ref:d,children:i.jsx(ee,{ref:g,rapidlyChangingMotionState:t,dhParameters:e,chainOffsetPosition:r,chainOffsetQuaternion:s,children:i.jsx(Y,{modelURL:R,postModelRender:h,flangeRef:l,...f})})})}),i.jsx(X,{})]})}),te=G.externalizeComponent(({rapidlyChangingMotionState:t,...n})=>{const e=T.useSmoothedMotionState(t);return i.jsx(F,{rapidlyChangingMotionState:e,...n})}),ne=G.externalizeComponent(t=>{const{inverseSolver:n,dhParameters:e,...r}=t,[s,c]=m.useState(E.JointTypeEnum.RevoluteJoint);m.useEffect(()=>{e.length&&c(e[0].type??E.JointTypeEnum.RevoluteJoint)},[e]);const l=m.useMemo(()=>n===null&&s===E.JointTypeEnum.RevoluteJoint,[n,s]),o=m.useMemo(()=>n===null&&s===E.JointTypeEnum.PrismaticJoint,[n,s]);return m.useMemo(()=>!!n,[n])||l?i.jsx(F,{dhParameters:e,...r}):o?i.jsx(I,{dhParameters:e,...r}):null}),ke=G.externalizeComponent(t=>{const n=T.useSmoothedMotionState(t.rapidlyChangingMotionState);return i.jsx(ne,{...t,rapidlyChangingMotionState:n})});function Ie({motionGroup:t,connectedMotionGroup:n,getModel:e,flangeRef:r,transparentColor:s,postModelRender:c,...l}){const o=t??n,a=o==null?void 0:o.nova,p=m.useCallback(f=>L(f,a),[a]);return o!=null&&o.dhParameters?i.jsx(te,{rapidlyChangingMotionState:o.rapidlyChangingMotionState,modelFromController:o.modelFromController||"",dhParameters:o.dhParameters,getModel:e??p,flangeRef:r,transparentColor:s,postModelRender:c,chainOffsetPosition:o.mountingPosition,chainOffsetQuaternion:o.mountingQuaternion,...l}):null}function Fe(t){var s,c,l,o,a,p;const{description:n,state:e}=t,r=n.mounting;return{nova:t.nova,modelFromController:n.motionGroupModel,dhParameters:n.dhParameters,rapidlyChangingMotionState:e.rapidlyChangingMotionState,mountingPosition:[(((s=r==null?void 0:r.position)==null?void 0:s[0])??0)/1e3,(((c=r==null?void 0:r.position)==null?void 0:c[1])??0)/1e3,(((l=r==null?void 0:r.position)==null?void 0:l[2])??0)/1e3],mountingQuaternion:T.parseRotationToQuaternion([((o=r==null?void 0:r.orientation)==null?void 0:o[0])??0,((a=r==null?void 0:r.orientation)==null?void 0:a[1])??0,((p=r==null?void 0:r.orientation)==null?void 0:p[2])??0],"ROTATION_VECTOR")}}exports.CollisionSceneRenderer=ce;exports.JointLimitGizmo=we;exports.LinearAxis=Pe;exports.MotionGroupVisualizer=ke;exports.MotionGroupVisualizerExact=ne;exports.PresetEnvironment=Re;exports.Robot=Ie;exports.SafetyZonesRenderer=_e;exports.SupportedLinearAxis=z;exports.SupportedLinearAxisExact=I;exports.SupportedRobot=te;exports.SupportedRobotExact=F;exports.TrajectoryRenderer=ve;exports.defaultGetModel=L;exports.robotModelOf=Fe;