@@ -210,6 +210,11 @@ void main()
210
210
this . bufferJointIndex = 0 ;
211
211
this . handValuesType = 0 ;
212
212
this . hasRadii = false ;
213
+ this . pinchSelectDistanceStart = 0.014 ;
214
+ this . pinchSelectDistanceEnd = 0.015 ;
215
+ this . pinchDistance = 1 ;
216
+ this . thumbTip = 4 * 16 ;
217
+ this . indexTip = 9 * 16 ;
213
218
214
219
this . setIndices = function ( index ) {
215
220
this . frameIndex = index ++ ;
@@ -546,10 +551,8 @@ void main()
546
551
}
547
552
548
553
if ( hand == 0 || hand == 2 ) {
549
- Module . HEAPF32 [ xrData . handRight . triggerIndex ] = Module . HEAPF32 [ controller . triggerIndex ] ; // XRHandData.trigger
550
554
Module . HEAPF32 [ xrData . handRight . squeezeIndex ] = Module . HEAPF32 [ controller . squeezeIndex ] ; // XRHandData.squeeze
551
555
} else {
552
- Module . HEAPF32 [ xrData . handLeft . triggerIndex ] = Module . HEAPF32 [ controller . triggerIndex ] ; // XRHandData.trigger
553
556
Module . HEAPF32 [ xrData . handLeft . squeezeIndex ] = Module . HEAPF32 [ controller . squeezeIndex ] ; // XRHandData.squeeze
554
557
}
555
558
} else {
@@ -804,6 +807,21 @@ void main()
804
807
Module . HEAPF32 [ xrHand . pointerRotationZIndex ] = orientation . z ; // XRHandData.pointerRotationZ
805
808
Module . HEAPF32 [ xrHand . pointerRotationWIndex ] = orientation . w ; // XRHandData.pointerRotationW
806
809
}
810
+ xrHand . pinchDistance = 1 ;
811
+ if ( ! isNaN ( xrHand . poses [ xrHand . thumbTip ] )
812
+ && ! isNaN ( xrHand . poses [ xrHand . indexTip ] ) ) {
813
+ xrHand . pinchDistance = this . vector3Distance ( xrHand . poses [ xrHand . thumbTip + 12 ] ,
814
+ xrHand . poses [ xrHand . thumbTip + 13 ] ,
815
+ xrHand . poses [ xrHand . thumbTip + 14 ] ,
816
+ xrHand . poses [ xrHand . indexTip + 12 ] ,
817
+ xrHand . poses [ xrHand . indexTip + 13 ] ,
818
+ xrHand . poses [ xrHand . indexTip + 14 ] ) ;
819
+ }
820
+ if ( Module . HEAPF32 [ xrHand . triggerIndex ] === 0 ) {
821
+ Module . HEAPF32 [ xrHand . triggerIndex ] = xrHand . pinchDistance <= xrHand . pinchSelectDistanceStart ? 1 : 0 ;
822
+ } else {
823
+ Module . HEAPF32 [ xrHand . triggerIndex ] = xrHand . pinchDistance > xrHand . pinchSelectDistanceEnd ? 0 : 1 ;
824
+ }
807
825
} else if ( inputSource . gripSpace ) {
808
826
var inputRayPose = frame . getPose ( inputSource . targetRaySpace , refSpace ) ;
809
827
if ( inputRayPose ) {
0 commit comments