@@ -130,14 +130,28 @@ setTimeout(function () {
130
130
}
131
131
132
132
function XRHandData ( ) {
133
- this . bufferIndex = 0 ;
133
+ this . frameIndex = 0 ;
134
+ this . enabledIndex = 0 ;
135
+ this . handIndex = 0 ;
136
+ this . triggerIndex = 0 ;
137
+ this . squeezeIndex = 0 ;
138
+ this . jointsStartIndex = 0 ;
134
139
this . poses = new Float32Array ( 16 * 25 ) ;
135
140
this . radii = new Float32Array ( 25 ) ;
136
141
this . jointQuaternion = new Float32Array ( 4 ) ;
137
142
this . jointIndex = 0 ;
138
- this . unityJointIndex = 0 ;
143
+ this . bufferJointIndex = 0 ;
139
144
this . handValuesType = 0 ;
140
145
this . hasRadii = false ;
146
+
147
+ this . setIndices = function ( index ) {
148
+ this . frameIndex = index ++ ;
149
+ this . enabledIndex = index ++ ;
150
+ this . handIndex = index ++ ;
151
+ this . triggerIndex = index ++ ;
152
+ this . squeezeIndex = index ++ ;
153
+ this . jointsStartIndex = index ;
154
+ }
141
155
}
142
156
143
157
function XRHitPoseData ( ) {
@@ -367,10 +381,10 @@ setTimeout(function () {
367
381
Module . HEAPF32 [ this . xrData . controllerA . enabledIndex ] = 0 ; // XRControllerData.enabled
368
382
Module . HEAPF32 [ this . xrData . controllerB . enabledIndex ] = 0 ; // XRControllerData.enabled
369
383
370
- Module . HEAPF32 [ this . xrData . handLeft . bufferIndex ] = - 1 ; // XRHandData.frame
371
- Module . HEAPF32 [ this . xrData . handRight . bufferIndex ] = - 1 ; // XRHandData.frame
372
- Module . HEAPF32 [ this . xrData . handLeft . bufferIndex + 1 ] = 0 ; // XRHandData.enabled
373
- Module . HEAPF32 [ this . xrData . handRight . bufferIndex + 1 ] = 0 ; // XRHandData.enabled
384
+ Module . HEAPF32 [ this . xrData . handLeft . frameIndex ] = - 1 ; // XRHandData.frame
385
+ Module . HEAPF32 [ this . xrData . handRight . frameIndex ] = - 1 ; // XRHandData.frame
386
+ Module . HEAPF32 [ this . xrData . handLeft . enabledIndex ] = 0 ; // XRHandData.enabled
387
+ Module . HEAPF32 [ this . xrData . handRight . enabledIndex ] = 0 ; // XRHandData.enabled
374
388
375
389
this . gameModule . WebXR . OnEndXR ( ) ;
376
390
this . didNotifyUnity = false ;
@@ -435,11 +449,11 @@ setTimeout(function () {
435
449
}
436
450
437
451
if ( hand == 0 || hand == 2 ) {
438
- Module . HEAPF32 [ xrData . handRight . bufferIndex + 3 ] = Module . HEAPF32 [ controller . triggerIndex ] ; // XRHandData.trigger
439
- Module . HEAPF32 [ xrData . handRight . bufferIndex + 4 ] = Module . HEAPF32 [ controller . squeezeIndex ] ; // XRHandData.squeeze
452
+ Module . HEAPF32 [ xrData . handRight . triggerIndex ] = Module . HEAPF32 [ controller . triggerIndex ] ; // XRHandData.trigger
453
+ Module . HEAPF32 [ xrData . handRight . squeezeIndex ] = Module . HEAPF32 [ controller . squeezeIndex ] ; // XRHandData.squeeze
440
454
} else {
441
- Module . HEAPF32 [ xrData . handLeft . bufferIndex + 3 ] = Module . HEAPF32 [ controller . triggerIndex ] ; // XRHandData.trigger
442
- Module . HEAPF32 [ xrData . handLeft . bufferIndex + 4 ] = Module . HEAPF32 [ controller . squeezeIndex ] ; // XRHandData.squeeze
455
+ Module . HEAPF32 [ xrData . handLeft . triggerIndex ] = Module . HEAPF32 [ controller . triggerIndex ] ; // XRHandData.trigger
456
+ Module . HEAPF32 [ xrData . handLeft . squeezeIndex ] = Module . HEAPF32 [ controller . squeezeIndex ] ; // XRHandData.squeeze
443
457
}
444
458
} else {
445
459
var xPercentage = 0.5 ;
@@ -610,10 +624,10 @@ setTimeout(function () {
610
624
}
611
625
612
626
XRManager . prototype . getXRControllersData = function ( frame , inputSources , refSpace , xrData ) {
613
- Module . HEAPF32 [ xrData . handLeft . bufferIndex ] = xrData . frameNumber ; // XRHandData.frame
614
- Module . HEAPF32 [ xrData . handRight . bufferIndex ] = xrData . frameNumber ; // XRHandData.frame
615
- Module . HEAPF32 [ xrData . handLeft . bufferIndex + 1 ] = 0 ; // XRHandData.enabled
616
- Module . HEAPF32 [ xrData . handRight . bufferIndex + 1 ] = 0 ; // XRHandData.enabled
627
+ Module . HEAPF32 [ xrData . handLeft . frameIndex ] = xrData . frameNumber ; // XRHandData.frame
628
+ Module . HEAPF32 [ xrData . handRight . frameIndex ] = xrData . frameNumber ; // XRHandData.frame
629
+ Module . HEAPF32 [ xrData . handLeft . enabledIndex ] = 0 ; // XRHandData.enabled
630
+ Module . HEAPF32 [ xrData . handRight . enabledIndex ] = 0 ; // XRHandData.enabled
617
631
Module . HEAPF32 [ xrData . controllerA . frameIndex ] = xrData . frameNumber ; // XRControllerData.frame
618
632
Module . HEAPF32 [ xrData . controllerB . frameIndex ] = xrData . frameNumber ; // XRControllerData.frame
619
633
Module . HEAPF32 [ xrData . controllerA . enabledIndex ] = 0 ; // XRControllerData.enabled
@@ -628,12 +642,12 @@ setTimeout(function () {
628
642
// Show the input source if it has a grip space
629
643
if ( inputSource . hand ) {
630
644
var xrHand = xrData . handLeft ;
631
- Module . HEAPF32 [ xrHand . bufferIndex + 2 ] = 1 ; // XRHandData.hand
645
+ Module . HEAPF32 [ xrHand . handIndex ] = 1 ; // XRHandData.hand
632
646
if ( inputSource . handedness == 'right' ) {
633
647
xrHand = xrData . handRight ;
634
- Module . HEAPF32 [ xrHand . bufferIndex + 2 ] = 2 ; // XRHandData.hand
648
+ Module . HEAPF32 [ xrHand . handIndex ] = 2 ; // XRHandData.hand
635
649
}
636
- Module . HEAPF32 [ xrHand . bufferIndex + 1 ] = 1 ; // XRHandData.enabled
650
+ Module . HEAPF32 [ xrHand . enabledIndex ] = 1 ; // XRHandData.enabled
637
651
638
652
if ( xrHand . handValuesType == 0 ) {
639
653
if ( inputSource . hand . values ) {
@@ -646,7 +660,7 @@ setTimeout(function () {
646
660
xrHand . handValuesType == 1 ? inputSource . hand . values ( ) : inputSource . hand ,
647
661
refSpace ,
648
662
xrHand . poses ) ) {
649
- Module . HEAPF32 [ xrHand . bufferIndex + 1 ] = 0 ; // XRHandData.enabled
663
+ Module . HEAPF32 [ xrHand . enabledIndex ] = 0 ; // XRHandData.enabled
650
664
continue ;
651
665
}
652
666
if ( ! xrHand . hasRadii )
@@ -655,21 +669,22 @@ setTimeout(function () {
655
669
xrHand . handValuesType == 1 ? inputSource . hand . values ( ) : inputSource . hand ,
656
670
xrHand . radii ) ;
657
671
}
672
+ xrHand . bufferJointIndex = xrHand . jointsStartIndex ;
658
673
for ( var j = 0 ; j < 25 ; j ++ ) {
659
674
xrHand . jointIndex = j * 16 ;
660
- xrHand . unityJointIndex = xrHand . bufferIndex + 5 + ( j * 8 ) ;
661
675
if ( ! isNaN ( xrHand . poses [ xrHand . jointIndex ] ) ) {
662
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = xrHand . poses [ xrHand . jointIndex + 12 ] ; // XRJointData.position.x
663
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = xrHand . poses [ xrHand . jointIndex + 13 ] ; // XRJointData.position.y
664
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = - xrHand . poses [ xrHand . jointIndex + 14 ] ; // XRJointData.position.z
676
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = xrHand . poses [ xrHand . jointIndex + 12 ] ; // XRJointData.position.x
677
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = xrHand . poses [ xrHand . jointIndex + 13 ] ; // XRJointData.position.y
678
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = - xrHand . poses [ xrHand . jointIndex + 14 ] ; // XRJointData.position.z
665
679
this . quaternionFromMatrix ( xrHand . jointIndex , xrHand . poses , xrHand . jointQuaternion ) ;
666
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = - xrHand . jointQuaternion [ 0 ] ; // XRJointData.rotation.x
667
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = - xrHand . jointQuaternion [ 1 ] ; // XRJointData.rotation.y
668
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = xrHand . jointQuaternion [ 2 ] ; // XRJointData.rotation.z
669
- Module . HEAPF32 [ xrHand . unityJointIndex ++ ] = xrHand . jointQuaternion [ 3 ] ; // XRJointData.rotation.w
680
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = - xrHand . jointQuaternion [ 0 ] ; // XRJointData.rotation.x
681
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = - xrHand . jointQuaternion [ 1 ] ; // XRJointData.rotation.y
682
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = xrHand . jointQuaternion [ 2 ] ; // XRJointData.rotation.z
683
+ Module . HEAPF32 [ xrHand . bufferJointIndex ++ ] = xrHand . jointQuaternion [ 3 ] ; // XRJointData.rotation.w
670
684
if ( ! isNaN ( xrHand . radii [ j ] ) ) {
671
- Module . HEAPF32 [ xrHand . unityJointIndex ] = xrHand . radii [ j ] ; // XRJointData.radius
685
+ Module . HEAPF32 [ xrHand . bufferJointIndex ] = xrHand . radii [ j ] ; // XRJointData.radius
672
686
}
687
+ xrHand . bufferJointIndex ++ ;
673
688
}
674
689
}
675
690
} else if ( inputSource . gripSpace ) {
@@ -822,8 +837,8 @@ setTimeout(function () {
822
837
823
838
this . xrData . controllerA . setIndices ( Module . ControllersArrayOffset ) ;
824
839
this . xrData . controllerB . setIndices ( Module . ControllersArrayOffset + 28 ) ;
825
- this . xrData . handLeft . bufferIndex = Module . HandsArrayOffset ;
826
- this . xrData . handRight . bufferIndex = Module . HandsArrayOffset + 205 ;
840
+ this . xrData . handLeft . setIndices ( Module . HandsArrayOffset ) ;
841
+ this . xrData . handRight . setIndices ( Module . HandsArrayOffset + 205 ) ;
827
842
this . xrData . viewerHitTestPose . setIndices ( Module . ViewerHitTestPoseArrayOffset ) ;
828
843
this . xrData . controllerA . updatedProfiles = 0 ;
829
844
this . xrData . controllerB . updatedProfiles = 0 ;
0 commit comments