@wandelbots/wandelbots-js-react-components 6.1.0 → 6.2.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 +1 -1
- package/dist/3d.js +3 -3
- package/dist/chunks/{MotionGroupVisualizer-cHohruur.js → MotionGroupVisualizer-CEiRJk_l.js} +504 -464
- package/dist/chunks/MotionGroupVisualizer-rrhU4sYi.cjs +1 -0
- package/dist/chunks/{theming-DAGR3D4x.js → theming-mF9Rt8SS.js} +26 -26
- package/dist/chunks/{useSmoothedMotionState-CpGsrwj4.js → useSmoothedMotionState-DyDgSVYX.js} +9 -9
- package/dist/components/robots/LinearAxisAnimator.d.ts +4 -2
- package/dist/components/robots/RobotAnimator.d.ts +3 -1
- package/dist/components/robots/SupportedLinearAxis.d.ts +5 -1
- package/dist/components/robots/SupportedRobot.d.ts +3 -1
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunks/MotionGroupVisualizer-DSm6iyOs.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),b=require("three"),q=require("three-stdlib"),f=require("react"),_=require("./externalizeComponent-OO4jcrz5.cjs"),S=require("@react-three/drei"),ge=require("@mui/material/styles"),v=require("@mui/material/Box"),Z=require("@mui/material/Button"),ye=require("@mui/material/Card"),K=require("@mui/material/Divider"),z=require("@mui/material/Typography"),O=require("@react-three/fiber"),je=require("mobx-react-lite"),be=require("react-i18next"),L=require("./useSmoothedMotionState-VYxEIyfr.cjs"),w=require("@wandelbots/nova-js/v2"),te=require("react-error-boundary");function Me(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const M=Me(b);function Re(e){switch(e.shape_type){case"convex_hull":return new q.ConvexGeometry(e.vertices.map(n=>new M.Vector3(n[0]/1e3,n[1]/1e3,n[2]/1e3)));case"box":return new M.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new M.SphereGeometry(e.radius/1e3);case"capsule":return new M.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new M.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new M.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new M.BufferGeometry}}function we({name:e,collider:r,children:n}){var d,u;const s=((d=r.pose)==null?void 0:d.position)??[0,0,0],i=((u=r.pose)==null?void 0:u.orientation)??[0,0,0];return r.margin&&console.warn(`${e} margin is not supported`),t.jsx("mesh",{name:e,position:new M.Vector3(s[0],s[1],s[2]).divideScalar(1e3),rotation:new M.Euler(i[0],i[1],i[2],"XYZ"),geometry:Re(r.shape),children:n})}function Se({name:e,colliders:r,meshChildrenProvider:n,...s}){return t.jsx("group",{name:e,...s,children:Object.entries(r).map(([i,d])=>t.jsx(we,{name:i,collider:d,children:n(i,d)},i))})}function ve({scene:e,meshChildrenProvider:r}){const n=e.colliders;return t.jsx("group",{children:n&&t.jsx(Se,{meshChildrenProvider:r,colliders:n})})}function V(){return t.jsx(S.Environment,{frames:1,children:t.jsx(Te,{})})}const _e=[2,0,2,0,2,0,2,0];function Te({positions:e=_e}){return t.jsxs(t.Fragment,{children:[t.jsx(S.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsx("group",{rotation:[0,.5,0],children:t.jsx("group",{children:e.map((r,n)=>t.jsx(S.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[r,4,n*4],scale:[3,1,1]},n))})}),t.jsx(S.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsx(S.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsx(S.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsx(S.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsx(S.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const ee={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function Le({safetyZones:e,dhParameters:r,...n}){const s=f.useMemo(()=>_.dhParametersToPlaneSize(r??[]),[r]),i=(u,o)=>{var y,x;if(!((y=o==null?void 0:o.pose)!=null&&y.position)||!((x=o==null?void 0:o.pose)!=null&&x.orientation))return null;const p=new M.Vector3(o.pose.position[0]/1e3,o.pose.position[1]/1e3,o.pose.position[2]/1e3),a=new M.Vector3(o.pose.orientation[0],o.pose.orientation[1],o.pose.orientation[2]);let m;const c=o.shape.shape_type==="plane"?{...ee,side:M.DoubleSide}:{...ee,side:M.FrontSide};switch(o.shape.shape_type){case"plane":m=t.jsx("planeGeometry",{args:[s,s]});break;case"sphere":{const h=(o==null?void 0:o.shape).radius/1e3;m=t.jsx("sphereGeometry",{args:[h]});break}case"capsule":{const h=(o==null?void 0:o.shape).radius/1e3,l=(o==null?void 0:o.shape).cylinder_height/1e3;m=t.jsx("capsuleGeometry",{args:[h,l]});break}case"convex_hull":{const h=(o==null?void 0:o.shape).vertices.map(j=>new M.Vector3(j[0]/1e3,j[1]/1e3,j[2]/1e3)),l=_.verticesToCoplanarity(h);if(l.isCoplanar&&l.normal){const g=new M.Vector3().addVectors(h[0],l.normal.multiplyScalar(1e-4));h.push(g)}try{m=t.jsx("primitive",{object:new q.ConvexGeometry(h),attach:"geometry"})}catch(j){return console.log("Error creating ConvexGeometry:",j),null}break}case"rectangular_capsule":{const h=o.shape,l=h.radius/1e3,j=h.sphere_center_distance_x/1e3,g=h.sphere_center_distance_y/1e3,R=l*2;m=t.jsx("primitive",{object:new q.RoundedBoxGeometry(j,g,R,2,l),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",o.shape.shape_type),m=null}return t.jsxs("mesh",{renderOrder:u,position:p,quaternion:_.orientationToQuaternion(a),children:[m,t.jsx("meshStandardMaterial",{...c,polygonOffsetFactor:-u})]},`safety-zone-${o.shape.shape_type}-${u}`)},d=f.useMemo(()=>Object.values(e??{}).map((u,o)=>i(o,u)),[e,s]);return t.jsx("group",{...n,children:d})}function ke({trajectory:e,...r}){const n=(e==null?void 0:e.map(s=>{if(s.position&&s.position.length>=3){const[i,d,u]=s.position;if(Number.isFinite(i)&&Number.isFinite(d)&&Number.isFinite(u))return new M.Vector3(i/1e3,u/1e3,-d/1e3)}return null}).filter(s=>s!==null))||[];return t.jsx("group",{...r,children:n.length>0&&t.jsx(S.Line,{points:n,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const D=new Map;async function E(e,r){if(D.has(e))return D.get(e);const n=(async()=>{var u;const s=r||"",i=new w.Nova({instanceUrl:s}),d=i.api.motionGroupModels;(u=d.axios)!=null&&u.interceptors&&d.axios.interceptors.request.use(o=>{var p;return(p=o.url)!=null&&p.includes("/glb")&&(o.responseType="blob"),o});try{const o=await i.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(o)}catch(o){throw console.error("Failed to fetch model:",o),o}})();return D.set(e,n),n}function ne(e){function r(n){return n.children.length===0?[n]:[n,...n.children.flatMap(s=>r(s))]}return r(e).filter(n=>oe(n))}function re(e){return e.name.endsWith("_FLG")}function oe(e){return/_J[0-9]+$/.test(e.name)}function Ee(e,r){let n;function s(i){if(re(i)){if(n)throw Error(`Found multiple flange groups in robot model ${r}; first ${n.name} then ${i.name}. Only one _FLG group is allowed.`);n=i}oe(i),i.children.map(s)}if(s(e.scene),!n)throw Error(`No flange group found in robot model ${r}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}const se=f.forwardRef(function({rapidlyChangingMotionState:r,dhParameters:n,chainOffsetPosition:s,chainOffsetQuaternion:i,onRotationChanged:d,children:u},o){const p=f.useRef(null),a=f.useRef([]),m=f.useRef(r.joint_position.filter(g=>g!==void 0)),{invalidate:c}=O.useThree(),y=f.useRef(r);y.current=r;function x(g){p.current=g,g&&h()}function h(){p.current&&(a.current=ne(p.current),l(),c())}f.useImperativeHandle(o,()=>({recollectJoints:h}));function l(){const g=m.current;if(d)d(a.current,g);else for(const[R,k]of a.current.entries()){const P=n[R],N=P.theta||0,F=P.reverse_rotation_direction?-1:1;k.rotation.y=F*(g[R]||0)+N}}function j(g){m.current=g.joint_position.filter(R=>R!==void 0),l(),c()}return L.useAutorun(()=>{j(y.current)}),f.useEffect(()=>{j(r)},[r]),t.jsx("group",{ref:x,position:s,quaternion:i,children:u})}),Pe="line",Ce="mesh";function Ae({rapidlyChangingMotionState:e,dhParameters:r,...n}){const s=new b.Matrix4,i=f.useRef([]),d=f.useRef([]);f.useEffect(()=>{i.current=new Array(r.length).fill(null),d.current=new Array(r.length).fill(null)},[r.length]);function u(a,m){const c=new b.Vector3,y=new b.Quaternion,x=new b.Vector3;s.decompose(c,y,x);const h=c.clone(),l=new b.Matrix4().makeRotationY(a.theta+m*(a.reverse_rotation_direction?-1:1)).multiply(new b.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new b.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new b.Matrix4().makeRotationX(a.alpha));return s.multiply(l),s.decompose(c,y,x),{a:h,b:c}}function o(a,m,c,y){if(!r)return;const x=r[a];if(!x)return;const{a:h,b:l}=u(x,y);m.geometry.setPositions([h.toArray(),l.toArray()].flat()),c.position.set(l.x,l.y,l.z)}function p(a,m){s.identity();for(let c=0;c<Math.min(a.length,m.length);c++){const y=i.current[c],x=d.current[c];y&&x&&o(c,y,x,m[c])}}return t.jsx(se,{rapidlyChangingMotionState:e,dhParameters:r,onRotationChanged:p,children:t.jsxs("group",{...n,name:"Scene",children:[t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),r==null?void 0:r.map((a,m)=>{const{a:c,b:y}=u(a,e.joint_position[m]??0),x=`dhrobot_J0${m}`;return t.jsxs("group",{name:x,children:[t.jsx(S.Line,{ref:h=>{i.current[m]=h},name:Pe,points:[c,y],color:"white",lineWidth:5}),t.jsxs("mesh",{ref:h=>{d.current[m]=h},name:Ce,position:y,children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${m}`)]},x)})]})})}const Ge=console.warn;function ie(){return f.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ge(e)}},[]),null}function Ie(e){return e.type==="Mesh"}function Oe({url:e,flangeRef:r,postModelRender:n,...s}){const i=S.useGLTF(e),u=Ee(i,"robot.glb").gltf,o=f.useCallback(a=>{a&&n&&n()},[n]);function p(a){try{return Ie(a)?a.geometry?t.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:re(a)?r:void 0,children:a.children.map(p)},a.uuid)}catch(m){return console.warn("Error rendering node",a.name,m),null}}return t.jsx("group",{...s,dispose:null,ref:o,children:p(u.scene)})}function ae({modelURL:e,flangeRef:r,postModelRender:n,...s}){const[i,d]=f.useState(null);return f.useEffect(()=>{let u=!1;return(async()=>{try{const p=typeof e=="string"?e:await e;u||d(a=>a===p?a:p)}catch(p){console.error("Failed to resolve model URL:",p)}})(),()=>{u=!0}},[e]),i?t.jsx(Oe,{url:i,flangeRef:r,postModelRender:n,...s}):null}const ce=(e,r)=>{e.userData.isGhost||(e.traverse(n=>{if(n instanceof M.Mesh){n.material instanceof M.Material&&(n.material.colorWrite=!1);const s=n.clone(),i=n.clone();s.material=new M.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:M.DoubleSide}),s.userData.isGhost=!0,i.material=new M.MeshStandardMaterial({color:r,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:M.DoubleSide}),i.userData.isGhost=!0,n.parent&&(n.parent.add(s),n.parent.add(i))}}),e.userData.isGhost=!0)},ue=e=>{if(!e.userData.isGhost)return;const r=[];e.traverse(n=>{var s;n instanceof M.Mesh&&((s=n.userData)!=null&&s.isGhost?r.push(n):n.material instanceof M.Material&&(n.material.colorWrite=!0))}),r.forEach(n=>{n.parent&&n.parent.remove(n)}),e.userData.isGhost=!1},B=_.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:r,dhParameters:n,chainOffsetPosition:s,chainOffsetQuaternion:i,getModel:d=E,flangeRef:u,postModelRender:o,transparentColor:p,instanceUrl:a,...m})=>{const[c,y]=f.useState(null),x=f.useRef(null),h=f.useCallback(R=>{y(R)},[]),l=f.useCallback(()=>{var R;(R=x.current)==null||R.recollectJoints(),o==null||o()},[o]);f.useEffect(()=>{c&&(p?ce(c,p):ue(c))},[c,p]);const j=f.useMemo(()=>{const R=d(r,a);if(!R)throw new Error(`No model found for robot "${r}". Ensure the model is available or provide a custom getModel function.`);return R},[r,a,d]),g=t.jsx(Ae,{rapidlyChangingMotionState:e,dhParameters:n,...m});return t.jsxs(te.ErrorBoundary,{fallback:g,onError:R=>{console.warn(R)},children:[t.jsx(f.Suspense,{fallback:g,children:t.jsx("group",{ref:h,children:t.jsx(se,{ref:x,rapidlyChangingMotionState:e,dhParameters:n,chainOffsetPosition:s,chainOffsetQuaternion:i,children:t.jsx(ae,{modelURL:j,postModelRender:l,flangeRef:u,...m})})})}),t.jsx(ie,{})]})}),le=_.externalizeComponent(({rapidlyChangingMotionState:e,...r})=>{const n=L.useSmoothedMotionState(e);return t.jsx(B,{rapidlyChangingMotionState:n,...r})});function fe({connectedMotionGroup:e,getModel:r=E,flangeRef:n,transparentColor:s,postModelRender:i,...d}){if(!e.dhParameters)return null;const u=e.mountingPosition,o=e.mountingQuaternion;return t.jsx(le,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:r,flangeRef:n,transparentColor:s,postModelRender:i,chainOffsetPosition:u,chainOffsetQuaternion:o,...d})}const Fe=_.externalizeComponent(je.observer(({robotName:e,programState:r,safetyState:n,operationMode:s,driveToHomeEnabled:i=!1,onDriveToHomePress:d,onDriveToHomeRelease:u,connectedMotionGroup:o,robotComponent:p=fe,customContentComponent:a,className:m})=>{var $;const c=ge.useTheme(),{t:y}=be.useTranslation(),[x,h]=f.useState(!1),l=f.useRef(null),j=f.useRef(null),[g,R]=f.useState(!1),[k,P]=f.useState({width:400,height:600}),[N,F]=f.useState(0);f.useEffect(()=>{const I=()=>{if(j.current){const{offsetWidth:Y,offsetHeight:X}=j.current;R(Y>X),P({width:Y,height:X})}};I();const Q=new ResizeObserver(I);return j.current&&Q.observe(j.current),()=>{Q.disconnect()}},[]);const W=f.useCallback(()=>{F(I=>I+1)},[]),C=f.useCallback(()=>{!i||!d||(h(!0),d())},[i,d]),A=f.useCallback(()=>{!i||!u||(h(!1),u())},[i,u]),H=f.useCallback(()=>{x&&u&&(h(!1),u())},[x,u]),T=g?k.width<350:k.height<200,G=g?k.height<310:k.height<450;return t.jsx(ye,{ref:j,className:m,sx:{width:"100%",height:"100%",display:"flex",flexDirection:g?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:g?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${c.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:(($=c.palette.backgroundPaperElevation)==null?void 0:$[8])||"#292B3F",backgroundImage:"none"},children:g?t.jsxs(t.Fragment,{children:[t.jsx(v,{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:T?"none":"block"},children:!T&&t.jsxs(O.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(V,{}),t.jsx(S.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(p,{connectedMotionGroup:o,postModelRender:W})})]})}),t.jsxs(v,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:T?"100%":"50%"},children:[t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsx(z,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:r,safetyState:n,operationMode:s})]}),t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!G&&a&&t.jsxs(v,{children:[t.jsx(a,{}),t.jsx(K,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{mt:!G&&a?"auto":0},children:t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Z,{ref:l,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:H,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:y("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs(v,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs(v,{children:[t.jsx(z,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:r,safetyState:n,operationMode:s})]}),t.jsx(v,{sx:{flex:T?0:1,position:"relative",minHeight:T?0:{xs:120,sm:150,md:200},height:T?0:"auto",borderRadius:1,overflow:"hidden",display:T?"none":"block"},children:!T&&t.jsxs(O.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(V,{}),t.jsx(S.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(p,{connectedMotionGroup:o,postModelRender:W})})]})}),t.jsxs(v,{children:[!G&&a&&t.jsxs(t.Fragment,{children:[t.jsx(a,{}),t.jsx(K,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:!G&&a?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Z,{ref:l,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:H,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:y("RobotCard.DriveToHome.bt")})})]})]})})})})),De=Array(6).fill(2*Math.PI);function de({rapidlyChangingMotionState:e,dhParameters:r,chainOffsetPosition:n,chainOffsetQuaternion:s,onTranslationChanged:i,children:d}){const u=f.useRef([]),o=f.useRef(e.joint_position.filter(x=>x!==void 0)),{invalidate:p}=O.useThree(),a=f.useRef(e);a.current=e;function m(x){x&&(u.current=ne(x),c(),p())}function c(){const x=o.current;if(i)i(u.current,x);else for(const[h,l]of u.current.entries()){const g=r[h].reverse_rotation_direction?-1:1;l.position.y=g*(x[h]||0)/1e3}}function y(x){o.current=x.joint_position.filter(h=>h!==void 0),c(),p()}return L.useAutorun(()=>{y(a.current)}),t.jsx("group",{ref:m,position:n,quaternion:s,children:d})}function he({rapidlyChangingMotionState:e,dhParameters:r,...n}){const s=new b.Matrix4,i=f.useRef(null),d=f.useRef(null);function u(a){const m=new b.Matrix4;for(let h=0;h<r.length;h++){const l=r[h],j=a[h]??0,g=new b.Matrix4().makeRotationY(l.theta).multiply(new b.Matrix4().makeTranslation(l.a/1e3,(l.d+j*(l.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new b.Matrix4().makeRotationX(l.alpha));m.multiply(g)}const c=new b.Vector3,y=new b.Quaternion,x=new b.Vector3;return m.decompose(c,y,x),c}const o=u(e.joint_position);function p(a,m){s.identity();let c=new b.Vector3;for(let l=0;l<r.length;l++){const j=m[l]??0,g=r[l],R=new b.Matrix4().makeRotationY(g.theta).multiply(new b.Matrix4().makeTranslation(g.a/1e3,(g.d+j*(g.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new b.Matrix4().makeRotationX(g.alpha));s.multiply(R)}const y=new b.Vector3,x=new b.Quaternion,h=new b.Vector3;if(s.decompose(y,x,h),c=y,i.current&&i.current.position.set(c.x,c.y,c.z),d.current){const l=d.current.geometry;l!=null&&l.setPositions&&l.setPositions([0,0,0,c.x,c.y,c.z])}}return t.jsx(de,{rapidlyChangingMotionState:e,dhParameters:r,onTranslationChanged:p,children:t.jsxs("group",{...n,name:"Scene",children:[t.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsx(S.Line,{ref:d,points:[new b.Vector3(0,0,0),o],color:"White",lineWidth:5}),t.jsxs("mesh",{ref:i,name:"TCP",position:o,children:[t.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const J=_.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:r,dhParameters:n,chainOffsetPosition:s,chainOffsetQuaternion:i,getModel:d=E,flangeRef:u,postModelRender:o,transparentColor:p,instanceUrl:a,...m})=>{const[c,y]=f.useState(null),x=f.useCallback(l=>{y(l)},[]);f.useEffect(()=>{c&&(p?ce(c,p):ue(c))},[c,p]);const h=t.jsx(he,{rapidlyChangingMotionState:e,dhParameters:n,...m});return t.jsxs(te.ErrorBoundary,{fallback:h,onError:l=>{console.warn(l)},children:[t.jsx(f.Suspense,{fallback:h,children:t.jsx("group",{ref:x,children:t.jsx(de,{rapidlyChangingMotionState:e,dhParameters:n,chainOffsetPosition:s,chainOffsetQuaternion:i,children:t.jsx(ae,{modelURL:(()=>{const l=d(r,a);if(!l){const j=new Blob([],{type:"model/gltf-binary"}),g=new File([j],`${r}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(g))}return l})(),postModelRender:o,flangeRef:u,...m})})})}),t.jsx(ie,{})]})}),pe=_.externalizeComponent(({rapidlyChangingMotionState:e,...r})=>{const n=L.useSmoothedMotionState(e);return t.jsx(J,{rapidlyChangingMotionState:n,...r})});function qe({connectedMotionGroup:e,getModel:r=E,flangeRef:n,transparentColor:s,postModelRender:i,...d}){if(!e.dhParameters)return null;const u=e.mountingPosition,o=e.mountingQuaternion,p=e.modelFromController||"";return p&&r(p)?t.jsx(pe,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:p,dhParameters:e.dhParameters,getModel:r,flangeRef:n,transparentColor:s,postModelRender:i,chainOffsetPosition:u,chainOffsetQuaternion:o,...d}):t.jsx(he,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,chainOffsetPosition:u,chainOffsetQuaternion:o,...d})}const U={[w.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[w.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[w.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[w.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[w.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0],[w.Manufacturer.Staubli]:[0,-Math.PI/2,Math.PI/2,0,0,0,0]};function me(e){const[r]=e.split("_");switch(r){case"ABB":return w.Manufacturer.Abb;case"FANUC":return w.Manufacturer.Fanuc;case"YASKAWA":return w.Manufacturer.Yaskawa;case"KUKA":return w.Manufacturer.Kuka;case"UniversalRobots":return w.Manufacturer.Universalrobots;case"STAUBLI":return w.Manufacturer.Staubli;default:return null}}function Ve(e,r){const n=me(e);return n&&n in U?U[n]:r||null}const xe=_.externalizeComponent(e=>{const{inverseSolver:r,dhParameters:n,...s}=e,[i,d]=f.useState(w.JointTypeEnum.RevoluteJoint);f.useEffect(()=>{n.length&&d(n[0].type??w.JointTypeEnum.RevoluteJoint)},[n]);const u=f.useMemo(()=>r===null&&i===w.JointTypeEnum.RevoluteJoint,[r,i]),o=f.useMemo(()=>r===null&&i===w.JointTypeEnum.PrismaticJoint,[r,i]);return f.useMemo(()=>!!r,[r])||u?t.jsx(B,{dhParameters:n,...s}):o?t.jsx(J,{dhParameters:n,...s}):null}),Ue=_.externalizeComponent(e=>{const r=L.useSmoothedMotionState(e.rapidlyChangingMotionState);return t.jsx(xe,{...e,rapidlyChangingMotionState:r})});exports.CollisionSceneRenderer=ve;exports.LinearAxis=qe;exports.MANUFACTURER_HOME_CONFIGS=U;exports.MotionGroupVisualizer=Ue;exports.MotionGroupVisualizerExact=xe;exports.PresetEnvironment=V;exports.Robot=fe;exports.RobotCard=Fe;exports.SafetyZonesRenderer=Le;exports.SupportedLinearAxis=pe;exports.SupportedLinearAxisExact=J;exports.SupportedRobot=le;exports.SupportedRobotExact=B;exports.TrajectoryRenderer=ke;exports.defaultAxisConfig=De;exports.defaultGetModel=E;exports.extractManufacturer=me;exports.getDefaultHomeConfig=Ve;
|
|
@@ -17,7 +17,7 @@ import ce from "@mui/material/SvgIcon";
|
|
|
17
17
|
import q from "@mui/material/Fade";
|
|
18
18
|
import { Gauge as de } from "@mui/x-charts/Gauge";
|
|
19
19
|
import { useTranslation as N } from "react-i18next";
|
|
20
|
-
import {
|
|
20
|
+
import { d as Wt, u as xt } from "./useSmoothedMotionState-DyDgSVYX.js";
|
|
21
21
|
import ue from "@mui/icons-material/Clear";
|
|
22
22
|
import ge from "@mui/icons-material/FilterList";
|
|
23
23
|
import Pt from "@mui/icons-material/Search";
|
|
@@ -5502,9 +5502,9 @@ function Gi(e = {}) {
|
|
|
5502
5502
|
}
|
|
5503
5503
|
export {
|
|
5504
5504
|
Ei as A,
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5505
|
+
bt as C,
|
|
5506
|
+
vt as J,
|
|
5507
|
+
Io as L,
|
|
5508
5508
|
St as M,
|
|
5509
5509
|
$i as N,
|
|
5510
5510
|
Ai as P,
|
|
@@ -5513,28 +5513,28 @@ export {
|
|
|
5513
5513
|
Ni as T,
|
|
5514
5514
|
Vo as V,
|
|
5515
5515
|
bo as W,
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5516
|
+
ji as a,
|
|
5517
|
+
Pi as b,
|
|
5518
|
+
Lt as c,
|
|
5519
|
+
wo as d,
|
|
5520
|
+
_i as e,
|
|
5521
|
+
wt as f,
|
|
5522
|
+
ko as g,
|
|
5523
|
+
Bi as h,
|
|
5524
|
+
Ho as i,
|
|
5525
|
+
Uo as j,
|
|
5526
|
+
Oi as k,
|
|
5527
|
+
Qo as l,
|
|
5528
|
+
ne as m,
|
|
5529
|
+
Wi as n,
|
|
5530
|
+
Kt as o,
|
|
5531
|
+
Di as p,
|
|
5532
|
+
Fi as q,
|
|
5533
|
+
Ji as r,
|
|
5534
|
+
pt as s,
|
|
5535
|
+
Gi as t,
|
|
5536
|
+
cn as u,
|
|
5537
|
+
Li as v,
|
|
5538
5538
|
Zt as w,
|
|
5539
5539
|
Co as x,
|
|
5540
5540
|
Qt as y,
|
package/dist/chunks/{useSmoothedMotionState-CpGsrwj4.js → useSmoothedMotionState-DyDgSVYX.js}
RENAMED
|
@@ -10,7 +10,7 @@ import S from "@mui/icons-material/PlayArrow";
|
|
|
10
10
|
import P from "@mui/icons-material/Stop";
|
|
11
11
|
import A from "@mui/material/Box";
|
|
12
12
|
import D from "@mui/material/Button";
|
|
13
|
-
import {
|
|
13
|
+
import { reaction as U, autorun as N, observable as L, runInAction as C } from "mobx";
|
|
14
14
|
import b, { useEffect as _, useState as G, useRef as I } from "react";
|
|
15
15
|
var d = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.PREPARING = "preparing", t.STARTING = "starting", t.RUNNING = "running", t.PAUSING = "pausing", t.PAUSED = "paused", t.STOPPING = "stopping", t.COMPLETED = "completed", t.FAILED = "failed", t.STOPPED = "stopped", t.ERROR = "error", t))(d || {});
|
|
16
16
|
const et = x(
|
|
@@ -465,14 +465,14 @@ function st(t, e) {
|
|
|
465
465
|
}, [e]), _(() => N(() => m(t)), [t]), i;
|
|
466
466
|
}
|
|
467
467
|
export {
|
|
468
|
-
|
|
468
|
+
et as P,
|
|
469
469
|
v as V,
|
|
470
|
-
|
|
470
|
+
d as a,
|
|
471
471
|
rt as b,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
472
|
+
nt as c,
|
|
473
|
+
at as d,
|
|
474
|
+
E as e,
|
|
475
|
+
ot as f,
|
|
476
|
+
st as g,
|
|
477
|
+
it as u
|
|
478
478
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-js/v2";
|
|
2
2
|
import type React from "react";
|
|
3
|
-
import type { Object3D } from "three";
|
|
3
|
+
import type { Object3D, Quaternion } from "three";
|
|
4
4
|
type LinearAxisAnimatorProps = {
|
|
5
5
|
rapidlyChangingMotionState: MotionGroupState;
|
|
6
6
|
dhParameters: DHParameter[];
|
|
7
|
+
chainOffsetPosition?: [number, number, number];
|
|
8
|
+
chainOffsetQuaternion?: Quaternion;
|
|
7
9
|
onTranslationChanged?: (joints: Object3D[], jointValues: number[]) => void;
|
|
8
10
|
children: React.ReactNode;
|
|
9
11
|
};
|
|
@@ -14,5 +16,5 @@ type LinearAxisAnimatorProps = {
|
|
|
14
16
|
* given. If damped/spring transitions are desired, run the motion state
|
|
15
17
|
* through {@link useSmoothedMotionState} before passing it here.
|
|
16
18
|
*/
|
|
17
|
-
export default function LinearAxisAnimator({ rapidlyChangingMotionState, dhParameters, onTranslationChanged, children, }: LinearAxisAnimatorProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default function LinearAxisAnimator({ rapidlyChangingMotionState, dhParameters, chainOffsetPosition, chainOffsetQuaternion, onTranslationChanged, children, }: LinearAxisAnimatorProps): import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-js/v2";
|
|
2
2
|
import type React from "react";
|
|
3
|
-
import type { Object3D } from "three";
|
|
3
|
+
import type { Object3D, Quaternion } from "three";
|
|
4
4
|
export type RobotAnimatorHandle = {
|
|
5
5
|
/**
|
|
6
6
|
* Re-scan the robot group for joints and re-apply the current pose.
|
|
@@ -13,6 +13,8 @@ export type RobotAnimatorHandle = {
|
|
|
13
13
|
type RobotAnimatorProps = {
|
|
14
14
|
rapidlyChangingMotionState: MotionGroupState;
|
|
15
15
|
dhParameters: DHParameter[];
|
|
16
|
+
chainOffsetPosition?: [number, number, number];
|
|
17
|
+
chainOffsetQuaternion?: Quaternion;
|
|
16
18
|
onRotationChanged?: (joints: Object3D[], jointValues: number[]) => void;
|
|
17
19
|
children: React.ReactNode;
|
|
18
20
|
};
|
|
@@ -4,11 +4,15 @@ import type * as THREE from "three";
|
|
|
4
4
|
export type DHLinearAxisProps = {
|
|
5
5
|
rapidlyChangingMotionState: MotionGroupState;
|
|
6
6
|
dhParameters: Array<DHParameter>;
|
|
7
|
+
chainOffsetPosition?: [number, number, number];
|
|
8
|
+
chainOffsetQuaternion?: THREE.Quaternion;
|
|
7
9
|
} & ThreeElements["group"];
|
|
8
10
|
export type SupportedLinearAxisProps = {
|
|
9
11
|
rapidlyChangingMotionState: MotionGroupState;
|
|
10
12
|
modelFromController: string;
|
|
11
13
|
dhParameters: DHParameter[];
|
|
14
|
+
chainOffsetPosition?: [number, number, number];
|
|
15
|
+
chainOffsetQuaternion?: THREE.Quaternion;
|
|
12
16
|
flangeRef?: React.Ref<THREE.Group>;
|
|
13
17
|
instanceUrl?: string;
|
|
14
18
|
getModel?: (modelFromController: string, instanceUrl?: string) => Promise<string> | undefined;
|
|
@@ -23,7 +27,7 @@ export type SupportedLinearAxisProps = {
|
|
|
23
27
|
* spring-damped transitions, use {@link SupportedLinearAxis}, or compose
|
|
24
28
|
* {@link useSmoothedMotionState} with this component yourself.
|
|
25
29
|
*/
|
|
26
|
-
export declare const SupportedLinearAxisExact: ({ rapidlyChangingMotionState, modelFromController, dhParameters, getModel, flangeRef, postModelRender, transparentColor, instanceUrl, ...props }: SupportedLinearAxisProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare const SupportedLinearAxisExact: ({ rapidlyChangingMotionState, modelFromController, dhParameters, chainOffsetPosition, chainOffsetQuaternion, getModel, flangeRef, postModelRender, transparentColor, instanceUrl, ...props }: SupportedLinearAxisProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
31
|
/**
|
|
28
32
|
* Linear axis visualizer with built-in spring smoothing of the joint stream.
|
|
29
33
|
*
|
|
@@ -9,6 +9,8 @@ export type SupportedRobotProps = {
|
|
|
9
9
|
rapidlyChangingMotionState: MotionGroupState;
|
|
10
10
|
modelFromController: string;
|
|
11
11
|
dhParameters: DHParameter[];
|
|
12
|
+
chainOffsetPosition?: [number, number, number];
|
|
13
|
+
chainOffsetQuaternion?: THREE.Quaternion;
|
|
12
14
|
flangeRef?: React.Ref<THREE.Group>;
|
|
13
15
|
instanceUrl?: string;
|
|
14
16
|
getModel?: (modelFromController: string, instanceUrl?: string) => Promise<string> | undefined;
|
|
@@ -24,7 +26,7 @@ export type SupportedRobotProps = {
|
|
|
24
26
|
* {@link SupportedRobot}, or compose {@link useSmoothedMotionState} with this
|
|
25
27
|
* component yourself.
|
|
26
28
|
*/
|
|
27
|
-
export declare const SupportedRobotExact: ({ rapidlyChangingMotionState, modelFromController, dhParameters, getModel, flangeRef, postModelRender, transparentColor, instanceUrl, ...props }: SupportedRobotProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const SupportedRobotExact: ({ rapidlyChangingMotionState, modelFromController, dhParameters, chainOffsetPosition, chainOffsetQuaternion, getModel, flangeRef, postModelRender, transparentColor, instanceUrl, ...props }: SupportedRobotProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
30
|
/**
|
|
29
31
|
* Robot visualizer with built-in spring smoothing of the joint stream.
|
|
30
32
|
*
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as o,
|
|
2
|
-
import {
|
|
1
|
+
import { A as o, a as s, C as t, b as r, J as n, c as i, d as g, e as l, f as u, L as c, g as d, h as m, i as p, j as S, M, N as b, P as C, k as V, R as L, l as P, m as f, S as J, T as R, n as x, V as T, o as A, W as I, p as y, q as E, r as h, s as q, t as v, u as N, v as w, w as F, x as G, y as W, z as j } from "./chunks/theming-mF9Rt8SS.js";
|
|
2
|
+
import { P as D, a as k, b as z, V as H, u as K, c as O, d as Q, e as U, f as X, g as Y } from "./chunks/useSmoothedMotionState-DyDgSVYX.js";
|
|
3
3
|
import { i as _ } from "./chunks/externalizeComponent-EDymnaGR.js";
|
|
4
4
|
import { S as aa } from "./chunks/SafetyBar-Cy9DiXp9.js";
|
|
5
5
|
export {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-rrhU4sYi.cjs"),t=require("./chunks/useSmoothedMotionState-VYxEIyfr.cjs"),e=require("./chunks/theming-DfSy4-Ic.cjs"),r=require("./chunks/externalizeComponent-OO4jcrz5.cjs"),a=require("./chunks/SafetyBar-DPrv_OQA.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.LinearAxis=o.LinearAxis;exports.MANUFACTURER_HOME_CONFIGS=o.MANUFACTURER_HOME_CONFIGS;exports.MotionGroupVisualizer=o.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=o.MotionGroupVisualizerExact;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.RobotCard=o.RobotCard;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedLinearAxis=o.SupportedLinearAxis;exports.SupportedLinearAxisExact=o.SupportedLinearAxisExact;exports.SupportedRobot=o.SupportedRobot;exports.SupportedRobotExact=o.SupportedRobotExact;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultAxisConfig=o.defaultAxisConfig;exports.defaultGetModel=o.defaultGetModel;exports.extractManufacturer=o.extractManufacturer;exports.getDefaultHomeConfig=o.getDefaultHomeConfig;exports.ProgramControl=t.ProgramControl;exports.ProgramState=t.ProgramState;exports.ProgramStateIndicator=t.ProgramStateIndicator;exports.ValueInterpolator=t.ValueInterpolator;exports.useAnimationFrame=t.useAnimationFrame;exports.useAutorun=t.useAutorun;exports.useInterpolation=t.useInterpolation;exports.useMounted=t.useMounted;exports.useReaction=t.useReaction;exports.useSmoothedMotionState=t.useSmoothedMotionState;exports.AdornedTextField=e.AdornedTextField;exports.AppHeader=e.AppHeader;exports.ConnectedMotionGroup=e.ConnectedMotionGroup;exports.CycleTimer=e.CycleTimer;exports.JoggerConnection=e.JoggerConnection;exports.JoggingCartesianAxisControl=e.JoggingCartesianAxisControl;exports.JoggingJointValueControl=e.JoggingJointValueControl;exports.JoggingPanel=e.JoggingPanel;exports.JoggingStore=e.JoggingStore;exports.LoadingCover=e.LoadingCover;exports.LoadingErrorMessage=e.LoadingErrorMessage;exports.LogPanel=e.LogPanel;exports.LogStore=e.LogStore;exports.LogViewer=e.LogViewer;exports.MotionStreamConnection=e.MotionStreamConnection;exports.NoMotionGroupModal=e.NoMotionGroupModal;exports.PoseCartesianValues=e.PoseCartesianValues;exports.PoseJointValues=e.PoseJointValues;exports.RobotListItem=e.RobotListItem;exports.RobotSetupReadinessIndicator=e.RobotSetupReadinessIndicator;exports.RobotSetupReadinessState=e.RobotSetupReadinessState;exports.SelectableFab=e.SelectableFab;exports.TabBar=e.TabBar;exports.Timer=e.Timer;exports.VelocitySlider=e.VelocitySlider;exports.VelocitySliderLabel=e.VelocitySliderLabel;exports.WandelbotsDataGrid=e.WandelbotsDataGrid;exports.createDebugMessage=e.createDebugMessage;exports.createErrorMessage=e.createErrorMessage;exports.createInfoMessage=e.createInfoMessage;exports.createLogMessage=e.createLogMessage;exports.createNovaMuiTheme=e.createNovaMuiTheme;exports.createNovaTheme=e.createNovaTheme;exports.createWarningMessage=e.createWarningMessage;exports.jointValuesEqual=e.jointValuesEqual;exports.poseEqual=e.poseEqual;exports.tcpMotionEqual=e.tcpMotionEqual;exports.unwrapRotationVector=e.unwrapRotationVector;exports.i18n=r.i18n;exports.SafetyBar=a.SafetyBar;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as o, L as s, M as t,
|
|
2
|
-
import {
|
|
3
|
-
import { A as N,
|
|
1
|
+
import { C as o, L as s, M as t, a as r, b as n, P as i, R as u, c as g, S as l, d, e as c, f as p, g as S, T as M, h as m, i as C, j as R, k as f } from "./chunks/MotionGroupVisualizer-CEiRJk_l.js";
|
|
2
|
+
import { P as x, a as L, b as V, V as A, u as E, c as P, d as T, e as J, f as y, g as G } from "./chunks/useSmoothedMotionState-DyDgSVYX.js";
|
|
3
|
+
import { A as N, a as h, C as v, b as F, J as j, c as q, d as w, e as z, f as D, L as H, g as W, h as k, i as B, j as O, M as U, N as _, P as Z, k as K, R as Q, l as X, m as Y, S as $, T as aa, n as ea, V as oa, o as sa, W as ta, p as ra, q as na, r as ia, s as ua, t as ga, u as la, v as da, w as ca, x as pa, y as Sa, z as Ma } from "./chunks/theming-mF9Rt8SS.js";
|
|
4
4
|
import { i as Ca } from "./chunks/externalizeComponent-EDymnaGR.js";
|
|
5
5
|
import { S as fa } from "./chunks/SafetyBar-Cy9DiXp9.js";
|
|
6
6
|
export {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),j=require("three"),D=require("three-stdlib"),f=require("react"),v=require("./externalizeComponent-OO4jcrz5.cjs"),w=require("@react-three/drei"),xe=require("@mui/material/styles"),S=require("@mui/material/Box"),Q=require("@mui/material/Button"),ye=require("@mui/material/Card"),X=require("@mui/material/Divider"),Z=require("@mui/material/Typography"),P=require("@react-three/fiber"),ge=require("mobx-react-lite"),je=require("react-i18next"),L=require("./useSmoothedMotionState-VYxEIyfr.cjs"),R=require("@wandelbots/nova-js/v2"),z=require("react-error-boundary");function be(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const b=be(j);function Me(e){switch(e.shape_type){case"convex_hull":return new D.ConvexGeometry(e.vertices.map(r=>new b.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new b.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new b.SphereGeometry(e.radius/1e3);case"capsule":return new b.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new b.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new b.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new b.BufferGeometry}}function Re({name:e,collider:n,children:r}){var d,c;const s=((d=n.pose)==null?void 0:d.position)??[0,0,0],i=((c=n.pose)==null?void 0:c.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsx("mesh",{name:e,position:new b.Vector3(s[0],s[1],s[2]).divideScalar(1e3),rotation:new b.Euler(i[0],i[1],i[2],"XYZ"),geometry:Me(n.shape),children:r})}function we({name:e,colliders:n,meshChildrenProvider:r,...s}){return t.jsx("group",{name:e,...s,children:Object.entries(n).map(([i,d])=>t.jsx(Re,{name:i,collider:d,children:r(i,d)},i))})}function Se({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsx("group",{children:r&&t.jsx(we,{meshChildrenProvider:n,colliders:r})})}function V(){return t.jsx(w.Environment,{frames:1,children:t.jsx(_e,{})})}const ve=[2,0,2,0,2,0,2,0];function _e({positions:e=ve}){return t.jsxs(t.Fragment,{children:[t.jsx(w.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsx("group",{rotation:[0,.5,0],children:t.jsx("group",{children:e.map((n,r)=>t.jsx(w.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsx(w.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsx(w.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsx(w.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsx(w.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsx(w.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const K={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function Te({safetyZones:e,dhParameters:n,...r}){const s=f.useMemo(()=>v.dhParametersToPlaneSize(n??[]),[n]),i=(c,o)=>{var x,m;if(!((x=o==null?void 0:o.pose)!=null&&x.position)||!((m=o==null?void 0:o.pose)!=null&&m.orientation))return null;const g=new b.Vector3(o.pose.position[0]/1e3,o.pose.position[1]/1e3,o.pose.position[2]/1e3),a=new b.Vector3(o.pose.orientation[0],o.pose.orientation[1],o.pose.orientation[2]);let p;const u=o.shape.shape_type==="plane"?{...K,side:b.DoubleSide}:{...K,side:b.FrontSide};switch(o.shape.shape_type){case"plane":p=t.jsx("planeGeometry",{args:[s,s]});break;case"sphere":{const h=(o==null?void 0:o.shape).radius/1e3;p=t.jsx("sphereGeometry",{args:[h]});break}case"capsule":{const h=(o==null?void 0:o.shape).radius/1e3,l=(o==null?void 0:o.shape).cylinder_height/1e3;p=t.jsx("capsuleGeometry",{args:[h,l]});break}case"convex_hull":{const h=(o==null?void 0:o.shape).vertices.map(y=>new b.Vector3(y[0]/1e3,y[1]/1e3,y[2]/1e3)),l=v.verticesToCoplanarity(h);if(l.isCoplanar&&l.normal){const M=new b.Vector3().addVectors(h[0],l.normal.multiplyScalar(1e-4));h.push(M)}try{p=t.jsx("primitive",{object:new D.ConvexGeometry(h),attach:"geometry"})}catch(y){return console.log("Error creating ConvexGeometry:",y),null}break}case"rectangular_capsule":{const h=o.shape,l=h.radius/1e3,y=h.sphere_center_distance_x/1e3,M=h.sphere_center_distance_y/1e3,T=l*2;p=t.jsx("primitive",{object:new D.RoundedBoxGeometry(y,M,T,2,l),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",o.shape.shape_type),p=null}return t.jsxs("mesh",{renderOrder:c,position:g,quaternion:v.orientationToQuaternion(a),children:[p,t.jsx("meshStandardMaterial",{...u,polygonOffsetFactor:-c})]},`safety-zone-${o.shape.shape_type}-${c}`)},d=f.useMemo(()=>Object.values(e??{}).map((c,o)=>i(o,c)),[e,s]);return t.jsx("group",{...r,children:d})}function Le({trajectory:e,...n}){const r=(e==null?void 0:e.map(s=>{if(s.position&&s.position.length>=3){const[i,d,c]=s.position;if(Number.isFinite(i)&&Number.isFinite(d)&&Number.isFinite(c))return new b.Vector3(i/1e3,c/1e3,-d/1e3)}return null}).filter(s=>s!==null))||[];return t.jsx("group",{...n,children:r.length>0&&t.jsx(w.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const O=new Map;async function E(e,n){if(O.has(e))return O.get(e);const r=(async()=>{var c;const s=n||"",i=new R.Nova({instanceUrl:s}),d=i.api.motionGroupModels;(c=d.axios)!=null&&c.interceptors&&d.axios.interceptors.request.use(o=>{var g;return(g=o.url)!=null&&g.includes("/glb")&&(o.responseType="blob"),o});try{const o=await i.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(o)}catch(o){throw console.error("Failed to fetch model:",o),o}})();return O.set(e,r),r}function ee(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(s=>n(s))]}return n(e).filter(r=>re(r))}function te(e){return e.name.endsWith("_FLG")}function re(e){return/_J[0-9]+$/.test(e.name)}function ke(e,n){let r;function s(i){if(te(i)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${i.name}. Only one _FLG group is allowed.`);r=i}re(i),i.children.map(s)}if(s(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}}const ne=f.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:r,onRotationChanged:s,children:i},d){const c=f.useRef(null),o=f.useRef([]),g=f.useRef(n.joint_position.filter(l=>l!==void 0)),{invalidate:a}=P.useThree(),p=f.useRef(n);p.current=n;function u(l){c.current=l,l&&x()}function x(){c.current&&(o.current=ee(c.current),m(),a())}f.useImperativeHandle(d,()=>({recollectJoints:x}));function m(){const l=g.current;if(s)s(o.current,l);else for(const[y,M]of o.current.entries()){const T=r[y],k=T.theta||0,F=T.reverse_rotation_direction?-1:1;M.rotation.y=F*(l[y]||0)+k}}function h(l){g.current=l.joint_position.filter(y=>y!==void 0),m(),a()}return L.useAutorun(()=>{h(p.current)}),f.useEffect(()=>{h(n)},[n]),t.jsx("group",{ref:u,children:i})}),Ee="line",Ge="mesh";function Ce({rapidlyChangingMotionState:e,dhParameters:n,...r}){const s=new j.Matrix4,i=f.useRef([]),d=f.useRef([]);f.useEffect(()=>{i.current=new Array(n.length).fill(null),d.current=new Array(n.length).fill(null)},[n.length]);function c(a,p){const u=new j.Vector3,x=new j.Quaternion,m=new j.Vector3;s.decompose(u,x,m);const h=u.clone(),l=new j.Matrix4().makeRotationY(a.theta+p*(a.reverse_rotation_direction?-1:1)).multiply(new j.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new j.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new j.Matrix4().makeRotationX(a.alpha));return s.multiply(l),s.decompose(u,x,m),{a:h,b:u}}function o(a,p,u,x){if(!n)return;const m=n[a];if(!m)return;const{a:h,b:l}=c(m,x);p.geometry.setPositions([h.toArray(),l.toArray()].flat()),u.position.set(l.x,l.y,l.z)}function g(a,p){s.identity();for(let u=0;u<Math.min(a.length,p.length);u++){const x=i.current[u],m=d.current[u];x&&m&&o(u,x,m,p[u])}}return t.jsx(ne,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:g,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((a,p)=>{const{a:u,b:x}=c(a,e.joint_position[p]??0),m=`dhrobot_J0${p}`;return t.jsxs("group",{name:m,children:[t.jsx(w.Line,{ref:h=>{i.current[p]=h},name:Ee,points:[u,x],color:"white",lineWidth:5}),t.jsxs("mesh",{ref:h=>{d.current[p]=h},name:Ge,position:x,children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${p}`)]},m)})]})})}const Ae=console.warn;function oe(){return f.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ae(e)}},[]),null}function Ie(e){return e.type==="Mesh"}function Pe({url:e,flangeRef:n,postModelRender:r,...s}){const i=w.useGLTF(e),c=ke(i,"robot.glb").gltf,o=f.useCallback(a=>{a&&r&&r()},[r]);function g(a){try{return Ie(a)?a.geometry?t.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:te(a)?n:void 0,children:a.children.map(g)},a.uuid)}catch(p){return console.warn("Error rendering node",a.name,p),null}}return t.jsx("group",{...s,dispose:null,ref:o,children:g(c.scene)})}function se({modelURL:e,flangeRef:n,postModelRender:r,...s}){const[i,d]=f.useState(null);return f.useEffect(()=>{let c=!1;return(async()=>{try{const g=typeof e=="string"?e:await e;c||d(a=>a===g?a:g)}catch(g){console.error("Failed to resolve model URL:",g)}})(),()=>{c=!0}},[e]),i?t.jsx(Pe,{url:i,flangeRef:n,postModelRender:r,...s}):null}const ie=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof b.Mesh){r.material instanceof b.Material&&(r.material.colorWrite=!1);const s=r.clone(),i=r.clone();s.material=new b.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:b.DoubleSide}),s.userData.isGhost=!0,i.material=new b.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:b.DoubleSide}),i.userData.isGhost=!0,r.parent&&(r.parent.add(s),r.parent.add(i))}}),e.userData.isGhost=!0)},ae=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var s;r instanceof b.Mesh&&((s=r.userData)!=null&&s.isGhost?n.push(r):r.material instanceof b.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},U=v.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:s=E,flangeRef:i,postModelRender:d,transparentColor:c,instanceUrl:o,...g})=>{const[a,p]=f.useState(null),u=f.useRef(null),x=f.useCallback(y=>{p(y)},[]),m=f.useCallback(()=>{var y;(y=u.current)==null||y.recollectJoints(),d==null||d()},[d]);f.useEffect(()=>{a&&(c?ie(a,c):ae(a))},[a,c]);const h=f.useMemo(()=>{const y=s(n,o);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,o,s]),l=t.jsx(Ce,{rapidlyChangingMotionState:e,dhParameters:r,...g});return t.jsxs(z.ErrorBoundary,{fallback:l,onError:y=>{console.warn(y)},children:[t.jsx(f.Suspense,{fallback:l,children:t.jsx("group",{ref:x,children:t.jsx(ne,{ref:u,rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:h,postModelRender:m,flangeRef:i,...g})})})}),t.jsx(oe,{})]})}),ce=v.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const r=L.useSmoothedMotionState(e);return t.jsx(U,{rapidlyChangingMotionState:r,...n})});function ue({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:s,postModelRender:i,...d}){return e.dhParameters?t.jsx(ce,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:s,postModelRender:i,...d}):null}const Fe=v.externalizeComponent(ge.observer(({robotName:e,programState:n,safetyState:r,operationMode:s,driveToHomeEnabled:i=!1,onDriveToHomePress:d,onDriveToHomeRelease:c,connectedMotionGroup:o,robotComponent:g=ue,customContentComponent:a,className:p})=>{var W;const u=xe.useTheme(),{t:x}=je.useTranslation(),[m,h]=f.useState(!1),l=f.useRef(null),y=f.useRef(null),[M,T]=f.useState(!1),[k,F]=f.useState({width:400,height:600}),[Ue,me]=f.useState(0);f.useEffect(()=>{const I=()=>{if(y.current){const{offsetWidth:$,offsetHeight:Y}=y.current;T($>Y),F({width:$,height:Y})}};I();const H=new ResizeObserver(I);return y.current&&H.observe(y.current),()=>{H.disconnect()}},[]);const J=f.useCallback(()=>{me(I=>I+1)},[]),G=f.useCallback(()=>{!i||!d||(h(!0),d())},[i,d]),C=f.useCallback(()=>{!i||!c||(h(!1),c())},[i,c]),N=f.useCallback(()=>{m&&c&&(h(!1),c())},[m,c]),_=M?k.width<350:k.height<200,A=M?k.height<310:k.height<450;return t.jsx(ye,{ref:y,className:p,sx:{width:"100%",height:"100%",display:"flex",flexDirection:M?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:M?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${u.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((W=u.palette.backgroundPaperElevation)==null?void 0:W[8])||"#292B3F",backgroundImage:"none"},children:M?t.jsxs(t.Fragment,{children:[t.jsx(S,{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:_?"none":"block"},children:!_&&t.jsxs(P.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:u.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(V,{}),t.jsx(w.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(g,{connectedMotionGroup:o,postModelRender:J})})]})}),t.jsxs(S,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:_?"100%":"50%"},children:[t.jsxs(S,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsx(Z,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:s})]}),t.jsxs(S,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!A&&a&&t.jsxs(S,{children:[t.jsx(a,{}),t.jsx(X,{sx:{mt:1,mb:0,borderColor:u.palette.divider,opacity:.5}})]}),t.jsx(S,{sx:{mt:!A&&a?"auto":0},children:t.jsx(S,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Q,{ref:l,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:G,onMouseUp:C,onMouseLeave:N,onTouchStart:G,onTouchEnd:C,sx:{textTransform:"none",px:1.5,py:.5},children:x("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs(S,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs(S,{children:[t.jsx(Z,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:s})]}),t.jsx(S,{sx:{flex:_?0:1,position:"relative",minHeight:_?0:{xs:120,sm:150,md:200},height:_?0:"auto",borderRadius:1,overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(P.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:u.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(V,{}),t.jsx(w.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(g,{connectedMotionGroup:o,postModelRender:J})})]})}),t.jsxs(S,{children:[!A&&a&&t.jsxs(t.Fragment,{children:[t.jsx(a,{}),t.jsx(X,{sx:{mt:1,mb:0,borderColor:u.palette.divider,opacity:.5}})]}),t.jsx(S,{sx:{display:"flex",justifyContent:"flex-start",mt:!A&&a?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Q,{ref:l,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:G,onMouseUp:C,onMouseLeave:N,onTouchStart:G,onTouchEnd:C,sx:{textTransform:"none",px:1.5,py:.5},children:x("RobotCard.DriveToHome.bt")})})]})]})})})})),Oe=Array(6).fill(2*Math.PI);function le({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:s}){const i=f.useRef([]),d=f.useRef(e.joint_position.filter(u=>u!==void 0)),{invalidate:c}=P.useThree(),o=f.useRef(e);o.current=e;function g(u){u&&(i.current=ee(u),a(),c())}function a(){const u=d.current;if(r)r(i.current,u);else for(const[x,m]of i.current.entries()){const l=n[x].reverse_rotation_direction?-1:1;m.position.y=l*(u[x]||0)/1e3}}function p(u){d.current=u.joint_position.filter(x=>x!==void 0),a(),c()}return L.useAutorun(()=>{p(o.current)}),f.useEffect(()=>{p(e)},[e]),t.jsx("group",{ref:g,children:s})}function fe({rapidlyChangingMotionState:e,dhParameters:n,...r}){const s=new j.Matrix4,i=f.useRef(null),d=f.useRef(null);function c(a){const p=new j.Matrix4;for(let h=0;h<n.length;h++){const l=n[h],y=a[h]??0,M=new j.Matrix4().makeRotationY(l.theta).multiply(new j.Matrix4().makeTranslation(l.a/1e3,(l.d+y*(l.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new j.Matrix4().makeRotationX(l.alpha));p.multiply(M)}const u=new j.Vector3,x=new j.Quaternion,m=new j.Vector3;return p.decompose(u,x,m),u}const o=c(e.joint_position);function g(a,p){s.identity();let u=new j.Vector3;for(let l=0;l<n.length;l++){const y=p[l]??0,M=n[l],T=new j.Matrix4().makeRotationY(M.theta).multiply(new j.Matrix4().makeTranslation(M.a/1e3,(M.d+y*(M.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new j.Matrix4().makeRotationX(M.alpha));s.multiply(T)}const x=new j.Vector3,m=new j.Quaternion,h=new j.Vector3;if(s.decompose(x,m,h),u=x,i.current&&i.current.position.set(u.x,u.y,u.z),d.current){const l=d.current.geometry;l!=null&&l.setPositions&&l.setPositions([0,0,0,u.x,u.y,u.z])}}return t.jsx(le,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:g,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsx(w.Line,{ref:d,points:[new j.Vector3(0,0,0),o],color:"White",lineWidth:5}),t.jsxs("mesh",{ref:i,name:"TCP",position:o,children:[t.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const B=v.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:s=E,flangeRef:i,postModelRender:d,transparentColor:c,instanceUrl:o,...g})=>{const[a,p]=f.useState(null),u=f.useCallback(m=>{p(m)},[]);f.useEffect(()=>{a&&(c?ie(a,c):ae(a))},[a,c]);const x=t.jsx(fe,{rapidlyChangingMotionState:e,dhParameters:r,...g});return t.jsxs(z.ErrorBoundary,{fallback:x,onError:m=>{console.warn(m)},children:[t.jsx(f.Suspense,{fallback:x,children:t.jsx("group",{ref:u,children:t.jsx(le,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:(()=>{const m=s(n,o);if(!m){const h=new Blob([],{type:"model/gltf-binary"}),l=new File([h],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(l))}return m})(),postModelRender:d,flangeRef:i,...g})})})}),t.jsx(oe,{})]})}),de=v.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const r=L.useSmoothedMotionState(e);return t.jsx(B,{rapidlyChangingMotionState:r,...n})});function De({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:s,postModelRender:i,...d}){if(!e.dhParameters)return null;const c=e.modelFromController||"";return c&&n(c)?t.jsx(de,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:c,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:s,postModelRender:i,...d}):t.jsx(fe,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...d})}const q={[R.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[R.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[R.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0],[R.Manufacturer.Staubli]:[0,-Math.PI/2,Math.PI/2,0,0,0,0]};function pe(e){const[n]=e.split("_");switch(n){case"ABB":return R.Manufacturer.Abb;case"FANUC":return R.Manufacturer.Fanuc;case"YASKAWA":return R.Manufacturer.Yaskawa;case"KUKA":return R.Manufacturer.Kuka;case"UniversalRobots":return R.Manufacturer.Universalrobots;case"STAUBLI":return R.Manufacturer.Staubli;default:return null}}function Ve(e,n){const r=pe(e);return r&&r in q?q[r]:n||null}const he=v.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:r,...s}=e,[i,d]=f.useState(R.JointTypeEnum.RevoluteJoint);f.useEffect(()=>{r.length&&d(r[0].type??R.JointTypeEnum.RevoluteJoint)},[r]);const c=f.useMemo(()=>n===null&&i===R.JointTypeEnum.RevoluteJoint,[n,i]),o=f.useMemo(()=>n===null&&i===R.JointTypeEnum.PrismaticJoint,[n,i]);return f.useMemo(()=>!!n,[n])||c?t.jsx(U,{dhParameters:r,...s}):o?t.jsx(B,{dhParameters:r,...s}):null}),qe=v.externalizeComponent(e=>{const n=L.useSmoothedMotionState(e.rapidlyChangingMotionState);return t.jsx(he,{...e,rapidlyChangingMotionState:n})});exports.CollisionSceneRenderer=Se;exports.LinearAxis=De;exports.MANUFACTURER_HOME_CONFIGS=q;exports.MotionGroupVisualizer=qe;exports.MotionGroupVisualizerExact=he;exports.PresetEnvironment=V;exports.Robot=ue;exports.RobotCard=Fe;exports.SafetyZonesRenderer=Te;exports.SupportedLinearAxis=de;exports.SupportedLinearAxisExact=B;exports.SupportedRobot=ce;exports.SupportedRobotExact=U;exports.TrajectoryRenderer=Le;exports.defaultAxisConfig=Oe;exports.defaultGetModel=E;exports.extractManufacturer=pe;exports.getDefaultHomeConfig=Ve;
|