@wandelbots/wandelbots-js-react-components 6.0.0 → 6.1.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/README.md +3 -8
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +2 -0
- package/dist/3d.js +19 -13
- package/dist/chunks/MotionGroupVisualizer-DSm6iyOs.cjs +1 -0
- package/dist/chunks/{MotionGroupVisualizer-BRec-k-p.js → MotionGroupVisualizer-cHohruur.js} +473 -471
- package/dist/chunks/{theming-B2dYJ4Ca.js → theming-DAGR3D4x.js} +1 -1
- package/dist/chunks/{theming-BwZXb5-H.cjs → theming-DfSy4-Ic.cjs} +1 -1
- package/dist/chunks/{interpolation-DG8VTxzS.js → useSmoothedMotionState-CpGsrwj4.js} +191 -146
- package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +1 -0
- package/dist/components/robots/LinearAxisAnimator.d.ts +7 -0
- package/dist/components/robots/MotionGroupVisualizer.d.ts +15 -0
- package/dist/components/robots/RobotAnimator.d.ts +7 -0
- package/dist/components/robots/SupportedLinearAxis.d.ts +18 -1
- package/dist/components/robots/SupportedRobot.d.ts +20 -1
- package/dist/components/utils/useSmoothedMotionState.d.ts +31 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +14 -13
- package/dist/index.cjs +1 -1
- package/dist/index.js +67 -63
- package/package.json +1 -1
- package/dist/chunks/MotionGroupVisualizer-zDM0Lgd-.cjs +0 -1
- package/dist/chunks/interpolation-C9sLsved.cjs +0 -1
package/README.md
CHANGED
|
@@ -48,8 +48,7 @@ You can also import from the top-level package, but then you'll need to provide
|
|
|
48
48
|
pnpm add @wandelbots/wandelbots-js-react-components \
|
|
49
49
|
react react-dom \
|
|
50
50
|
@mui/material @mui/icons-material @emotion/react @emotion/styled \
|
|
51
|
-
three @react-three/fiber @react-three/drei three-stdlib
|
|
52
|
-
@monaco-editor/react shiki @shikijs/monaco
|
|
51
|
+
three @react-three/fiber @react-three/drei three-stdlib
|
|
53
52
|
```
|
|
54
53
|
|
|
55
54
|
**Available Entry Points:**
|
|
@@ -58,9 +57,9 @@ pnpm add @wandelbots/wandelbots-js-react-components \
|
|
|
58
57
|
- **`/core`** — Base components (AppHeader, ProgramControl, SafetyBar, VelocitySlider, JoggingPanel, DataGrid, Timer, themes, i18n, etc.). Requires: React 18+, MUI v6/v7, @emotion/react, @emotion/styled, @mui/icons-material.
|
|
59
58
|
- **`/3d`** — 3D visualization (Robot, RobotCard, CollisionSceneRenderer, SafetyZonesRenderer, TrajectoryRenderer). Requires: all from `/core` + three, @react-three/fiber, @react-three/drei, three-stdlib.
|
|
60
59
|
|
|
61
|
-
##
|
|
60
|
+
## Migration & Breaking Changes
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
Breaking changes for each major version are documented in the [GitHub Releases](https://github.com/wandelbotsgmbh/wandelbots-js-react-components/releases).
|
|
64
63
|
|
|
65
64
|
## 4.x Core Changes
|
|
66
65
|
|
|
@@ -84,10 +83,6 @@ interface DHParameter {
|
|
|
84
83
|
}
|
|
85
84
|
```
|
|
86
85
|
|
|
87
|
-
## 2.x to 3.x Migration Guide
|
|
88
|
-
|
|
89
|
-
See section in [Migration Guide](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/migration-guide--docs) for assistance.
|
|
90
|
-
|
|
91
86
|
## Components
|
|
92
87
|
|
|
93
88
|
### Robot Control & Jogging
|
package/dist/3d.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/MotionGroupVisualizer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/MotionGroupVisualizer-DSm6iyOs.cjs"),o=require("./chunks/useSmoothedMotionState-VYxEIyfr.cjs");exports.CollisionSceneRenderer=e.CollisionSceneRenderer;exports.LinearAxis=e.LinearAxis;exports.MANUFACTURER_HOME_CONFIGS=e.MANUFACTURER_HOME_CONFIGS;exports.MotionGroupVisualizer=e.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=e.MotionGroupVisualizerExact;exports.PresetEnvironment=e.PresetEnvironment;exports.Robot=e.Robot;exports.RobotCard=e.RobotCard;exports.SafetyZonesRenderer=e.SafetyZonesRenderer;exports.SupportedLinearAxis=e.SupportedLinearAxis;exports.SupportedLinearAxisExact=e.SupportedLinearAxisExact;exports.SupportedRobot=e.SupportedRobot;exports.SupportedRobotExact=e.SupportedRobotExact;exports.TrajectoryRenderer=e.TrajectoryRenderer;exports.defaultAxisConfig=e.defaultAxisConfig;exports.defaultGetModel=e.defaultGetModel;exports.extractManufacturer=e.extractManufacturer;exports.getDefaultHomeConfig=e.getDefaultHomeConfig;exports.ValueInterpolator=o.ValueInterpolator;exports.useSmoothedMotionState=o.useSmoothedMotionState;
|
package/dist/3d.d.ts
CHANGED
|
@@ -11,3 +11,5 @@ export { defaultGetModel } from "./components/robots/robotModelLogic";
|
|
|
11
11
|
export * from "./components/robots/SupportedLinearAxis";
|
|
12
12
|
export * from "./components/robots/SupportedRobot";
|
|
13
13
|
export * from "./components/robots/MotionGroupVisualizer";
|
|
14
|
+
export * from "./components/utils/useSmoothedMotionState";
|
|
15
|
+
export { type InterpolationOptions, ValueInterpolator, } from "./components/utils/interpolation";
|
package/dist/3d.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { C as o, L as
|
|
1
|
+
import { C as o, L as t, M as r, k as s, j as i, P as n, b as u, R as d, S as p, f, c as l, i as x, h as R, T as S, a as c, d as M, e as C, g as A } from "./chunks/MotionGroupVisualizer-cHohruur.js";
|
|
2
|
+
import { V as b, u as m } from "./chunks/useSmoothedMotionState-CpGsrwj4.js";
|
|
2
3
|
export {
|
|
3
4
|
o as CollisionSceneRenderer,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
t as LinearAxis,
|
|
6
|
+
r as MANUFACTURER_HOME_CONFIGS,
|
|
7
|
+
s as MotionGroupVisualizer,
|
|
8
|
+
i as MotionGroupVisualizerExact,
|
|
7
9
|
n as PresetEnvironment,
|
|
8
|
-
|
|
10
|
+
u as Robot,
|
|
9
11
|
d as RobotCard,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
p as SafetyZonesRenderer,
|
|
13
|
+
f as SupportedLinearAxis,
|
|
14
|
+
l as SupportedLinearAxisExact,
|
|
15
|
+
x as SupportedRobot,
|
|
16
|
+
R as SupportedRobotExact,
|
|
17
|
+
S as TrajectoryRenderer,
|
|
18
|
+
b as ValueInterpolator,
|
|
19
|
+
c as defaultAxisConfig,
|
|
20
|
+
M as defaultGetModel,
|
|
21
|
+
C as extractManufacturer,
|
|
22
|
+
A as getDefaultHomeConfig,
|
|
23
|
+
m as useSmoothedMotionState
|
|
18
24
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|