@@ -183,20 +183,22 @@ private void OnHandUpdate(WebXRHandData handData)
183
183
transform . localPosition = handData . joints [ 0 ] . position ;
184
184
transform . localRotation = handData . joints [ 0 ] . rotation ;
185
185
186
+ Quaternion rotationOffset = Quaternion . Inverse ( handData . joints [ 0 ] . rotation ) ;
187
+
186
188
for ( int i = 0 ; i <= WebXRHandData . LITTLE_PHALANX_TIP ; i ++ )
187
189
{
188
190
if ( handData . joints [ i ] . enabled )
189
191
{
190
192
if ( handJoints . ContainsKey ( i ) )
191
193
{
192
- handJoints [ i ] . localPosition = GetJointLocalPosition ( handData . joints [ i ] . position , handData . joints [ 0 ] . position , handData . joints [ 0 ] . rotation ) ;
193
- handJoints [ i ] . localRotation = GetJointLocalRotation ( handData . joints [ i ] . rotation , handData . joints [ 0 ] . rotation ) ;
194
+ handJoints [ i ] . localPosition = rotationOffset * ( handData . joints [ i ] . position - handData . joints [ 0 ] . position ) ;
195
+ handJoints [ i ] . localRotation = rotationOffset * handData . joints [ i ] . rotation ;
194
196
}
195
197
else
196
198
{
197
199
var clone = Instantiate ( handJointPrefab ,
198
- GetJointLocalPosition ( handData . joints [ i ] . position , handData . joints [ 0 ] . position , handData . joints [ 0 ] . rotation ) ,
199
- GetJointLocalRotation ( handData . joints [ i ] . rotation , handData . joints [ 0 ] . rotation ) ,
200
+ rotationOffset * ( handData . joints [ i ] . position - handData . joints [ 0 ] . position ) ,
201
+ rotationOffset * handData . joints [ i ] . rotation ,
200
202
transform ) ;
201
203
if ( handData . joints [ i ] . radius > 0f )
202
204
{
@@ -213,16 +215,6 @@ private void OnHandUpdate(WebXRHandData handData)
213
215
}
214
216
}
215
217
216
- private Vector3 GetJointLocalPosition ( Vector3 position , Vector3 originPosition , Quaternion originRotation )
217
- {
218
- return Quaternion . Inverse ( originRotation ) * ( position - originPosition ) ;
219
- }
220
-
221
- private Quaternion GetJointLocalRotation ( Quaternion rotation , Quaternion originRotation )
222
- {
223
- return Quaternion . Inverse ( originRotation ) * rotation ;
224
- }
225
-
226
218
private WebXRControllerHand handFromString ( string handValue )
227
219
{
228
220
WebXRControllerHand handParsed = WebXRControllerHand . NONE ;
0 commit comments