@@ -65,7 +65,6 @@ setTimeout(function () {
65
65
}
66
66
67
67
function XRControllerData ( ) {
68
- this . bufferIndex = 0 ;
69
68
this . frameIndex = 0 ;
70
69
this . enabledIndex = 0 ;
71
70
this . handIndex = 0 ;
@@ -99,7 +98,6 @@ setTimeout(function () {
99
98
this . updatedProfiles = 0 ;
100
99
101
100
this . setIndices = function ( index ) {
102
- this . bufferIndex = index ;
103
101
this . frameIndex = index ++ ;
104
102
this . enabledIndex = index ++ ;
105
103
this . handIndex = index ++ ;
@@ -127,7 +125,7 @@ setTimeout(function () {
127
125
this . gripRotationXIndex = index ++ ;
128
126
this . gripRotationYIndex = index ++ ;
129
127
this . gripRotationZIndex = index ++ ;
130
- this . gripRotationWIndex = index ++ ;
128
+ this . gripRotationWIndex = index ;
131
129
}
132
130
}
133
131
@@ -143,7 +141,22 @@ setTimeout(function () {
143
141
}
144
142
145
143
function XRHitPoseData ( ) {
146
- this . bufferIndex = 0 ;
144
+ this . frameIndex = 0 ;
145
+ this . availableIndex = 0 ;
146
+ this . positionIndices = [ 0 , 0 , 0 ] ;
147
+ this . rotationIndices = [ 0 , 0 , 0 , 0 ] ;
148
+
149
+ this . setIndices = function ( index ) {
150
+ this . frameIndex = index ++ ;
151
+ this . availableIndex = index ++ ;
152
+ this . positionIndices [ 0 ] = index ++ ;
153
+ this . positionIndices [ 1 ] = index ++ ;
154
+ this . positionIndices [ 2 ] = index ++ ;
155
+ this . rotationIndices [ 0 ] = index ++ ;
156
+ this . rotationIndices [ 1 ] = index ++ ;
157
+ this . rotationIndices [ 2 ] = index ++ ;
158
+ this . rotationIndices [ 3 ] = index ;
159
+ }
147
160
}
148
161
149
162
function lerp ( start , end , percentage )
@@ -811,15 +824,15 @@ setTimeout(function () {
811
824
this . xrData . controllerB . setIndices ( Module . ControllersArrayOffset + 28 ) ;
812
825
this . xrData . handLeft . bufferIndex = Module . HandsArrayOffset ;
813
826
this . xrData . handRight . bufferIndex = Module . HandsArrayOffset + 205 ;
814
- this . xrData . viewerHitTestPose . bufferIndex = Module . ViewerHitTestPoseArrayOffset ;
827
+ this . xrData . viewerHitTestPose . setIndices ( Module . ViewerHitTestPoseArrayOffset ) ;
815
828
this . xrData . controllerA . updatedProfiles = 0 ;
816
829
this . xrData . controllerB . updatedProfiles = 0 ;
817
830
this . xrData . controllerA . profiles = [ ] ;
818
831
this . xrData . controllerB . profiles = [ ] ;
819
832
Module . HEAPF32 [ this . xrData . controllerA . updatedGripIndex ] = 0 ; // XRControllerData.updatedGrip
820
833
Module . HEAPF32 [ this . xrData . controllerB . updatedGripIndex ] = 0 ; // XRControllerData.updatedGrip
821
- Module . HEAPF32 [ this . xrData . viewerHitTestPose . bufferIndex ] = - 1 ; // XRHitPoseData.frame
822
- Module . HEAPF32 [ this . xrData . viewerHitTestPose . bufferIndex + 1 ] = 0 ; // XRHitPoseData.available
834
+ Module . HEAPF32 [ this . xrData . viewerHitTestPose . frameIndex ] = - 1 ; // XRHitPoseData.frame
835
+ Module . HEAPF32 [ this . xrData . viewerHitTestPose . availableIndex ] = 0 ; // XRHitPoseData.available
823
836
}
824
837
var thisXRMananger = this ;
825
838
session . requestReferenceSpace ( refSpaceType ) . then ( function ( refSpace ) {
@@ -906,21 +919,21 @@ setTimeout(function () {
906
919
this . getXRControllersData ( frame , session . inputSources , session . refSpace , xrData ) ;
907
920
908
921
if ( session . isAR && this . viewerHitTestSource ) {
909
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex ] = xrData . frameNumber ; // XRHitPoseData.frame
922
+ Module . HEAPF32 [ xrData . viewerHitTestPose . frameIndex ] = xrData . frameNumber ; // XRHitPoseData.frame
910
923
var viewerHitTestResults = frame . getHitTestResults ( this . viewerHitTestSource ) ;
911
924
if ( viewerHitTestResults . length > 0 ) {
912
925
var hitTestPose = viewerHitTestResults [ 0 ] . getPose ( session . localRefSpace ) ;
913
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 1 ] = 1 ; // XRHitPoseData.available
914
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 2 ] = hitTestPose . transform . position . x ; // XRHitPoseData.position[0]
926
+ Module . HEAPF32 [ xrData . viewerHitTestPose . availableIndex ] = 1 ; // XRHitPoseData.available
927
+ Module . HEAPF32 [ xrData . viewerHitTestPose . positionIndices [ 0 ] ] = hitTestPose . transform . position . x ; // XRHitPoseData.position[0]
915
928
var hitTestPoseBase = viewerHitTestResults [ 0 ] . getPose ( session . refSpace ) ; // Ugly hack for y position on Samsung Internet
916
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 3 ] = hitTestPose . transform . position . y + Math . abs ( hitTestPose . transform . position . y - hitTestPoseBase . transform . position . y ) ; // XRHitPoseData.position[1]
917
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 4 ] = - hitTestPose . transform . position . z ; // XRHitPoseData.position[2]
918
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 5 ] = - hitTestPose . transform . orientation . x ; // XRHitPoseData.rotation[0]
919
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 6 ] = - hitTestPose . transform . orientation . y ; // XRHitPoseData.rotation[1]
920
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 7 ] = hitTestPose . transform . orientation . z ; // XRHitPoseData.rotation[2]
921
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 8 ] = hitTestPose . transform . orientation . w ; // XRHitPoseData.rotation[3]
929
+ Module . HEAPF32 [ xrData . viewerHitTestPose . positionIndices [ 1 ] ] = hitTestPose . transform . position . y + Math . abs ( hitTestPose . transform . position . y - hitTestPoseBase . transform . position . y ) ; // XRHitPoseData.position[1]
930
+ Module . HEAPF32 [ xrData . viewerHitTestPose . positionIndices [ 2 ] ] = - hitTestPose . transform . position . z ; // XRHitPoseData.position[2]
931
+ Module . HEAPF32 [ xrData . viewerHitTestPose . rotationIndices [ 0 ] ] = - hitTestPose . transform . orientation . x ; // XRHitPoseData.rotation[0]
932
+ Module . HEAPF32 [ xrData . viewerHitTestPose . rotationIndices [ 1 ] ] = - hitTestPose . transform . orientation . y ; // XRHitPoseData.rotation[1]
933
+ Module . HEAPF32 [ xrData . viewerHitTestPose . rotationIndices [ 2 ] ] = hitTestPose . transform . orientation . z ; // XRHitPoseData.rotation[2]
934
+ Module . HEAPF32 [ xrData . viewerHitTestPose . rotationIndices [ 3 ] ] = hitTestPose . transform . orientation . w ; // XRHitPoseData.rotation[3]
922
935
} else {
923
- Module . HEAPF32 [ xrData . viewerHitTestPose . bufferIndex + 1 ] = 0 ; // XRHitPoseData.available
936
+ Module . HEAPF32 [ xrData . viewerHitTestPose . availableIndex ] = 0 ; // XRHitPoseData.available
924
937
}
925
938
}
926
939
0 commit comments