@@ -37,20 +37,18 @@ export class LinkManager {
3737
3838 this . _frameHelpers . children . forEach ( ( frameGroup : any ) => {
3939 const linkName = frameGroup . userData . linkName ;
40- if ( linkName ) {
41- this . _robot ?. traverse ( ( child : any ) => {
42- if ( child . isURDFLink && child . name === linkName ) {
43- const worldPosition = new THREE . Vector3 ( ) ;
44- const worldQuaternion = new THREE . Quaternion ( ) ;
45- child . matrixWorld . decompose (
46- worldPosition ,
47- worldQuaternion ,
48- new THREE . Vector3 ( )
49- ) ;
50- frameGroup . position . copy ( worldPosition ) ;
51- frameGroup . quaternion . copy ( worldQuaternion ) ;
52- }
53- } ) ;
40+ const link = this . _robot ?. links [ linkName ] ;
41+
42+ if ( link ) {
43+ const worldPosition = new THREE . Vector3 ( ) ;
44+ const worldQuaternion = new THREE . Quaternion ( ) ;
45+ link . matrixWorld . decompose (
46+ worldPosition ,
47+ worldQuaternion ,
48+ new THREE . Vector3 ( )
49+ ) ;
50+ frameGroup . position . copy ( worldPosition ) ;
51+ frameGroup . quaternion . copy ( worldQuaternion ) ;
5452 }
5553 } ) ;
5654 }
@@ -75,25 +73,25 @@ export class LinkManager {
7573 return ;
7674 }
7775
78- this . _robot . traverse ( ( child : any ) => {
79- if ( child . isURDFLink && child . name === linkName ) {
80- const axes = this . _createCustomAxesHelper ( size ) ;
81- axes . userData . linkName = linkName ;
76+ const link = this . _robot . links [ linkName ] ;
8277
83- const worldPosition = new THREE . Vector3 ( ) ;
84- const worldQuaternion = new THREE . Quaternion ( ) ;
85- child . matrixWorld . decompose (
86- worldPosition ,
87- worldQuaternion ,
88- new THREE . Vector3 ( )
89- ) ;
78+ if ( link ) {
79+ const axes = this . _createCustomAxesHelper ( size ) ;
80+ axes . userData . linkName = linkName ;
9081
91- axes . position . copy ( worldPosition ) ;
92- axes . quaternion . copy ( worldQuaternion ) ;
82+ const worldPosition = new THREE . Vector3 ( ) ;
83+ const worldQuaternion = new THREE . Quaternion ( ) ;
84+ link . matrixWorld . decompose (
85+ worldPosition ,
86+ worldQuaternion ,
87+ new THREE . Vector3 ( )
88+ ) ;
9389
94- this . _frameHelpers . add ( axes ) ;
95- }
96- } ) ;
90+ axes . position . copy ( worldPosition ) ;
91+ axes . quaternion . copy ( worldQuaternion ) ;
92+
93+ this . _frameHelpers . add ( axes ) ;
94+ }
9795
9896 this . _redrawCallback ( ) ;
9997 }
@@ -106,15 +104,15 @@ export class LinkManager {
106104 return ;
107105 }
108106
109- this . _robot . traverse ( ( child : any ) => {
110- if ( child . isURDFLink && child . name === linkName ) {
111- child . children . forEach ( ( linkChild : any ) => {
112- if ( ! linkChild . isURDFLink ) {
113- this . _setMeshOpacity ( linkChild , opacity ) ;
114- }
115- } ) ;
116- }
117- } ) ;
107+ const link = this . _robot . links [ linkName ] ;
108+
109+ if ( link ) {
110+ link . children . forEach ( ( linkChild : any ) => {
111+ if ( ! linkChild . isURDFLink ) {
112+ this . _setMeshOpacity ( linkChild , opacity ) ;
113+ }
114+ } ) ;
115+ }
118116
119117 this . _redrawCallback ( ) ;
120118 }
0 commit comments