@@ -25,14 +25,6 @@ setTimeout(function () {
25
25
'use strict' ;
26
26
27
27
function XRData ( ) {
28
- this . leftProjectionMatrix = [ 1 , 0 , 0 , 0 ,
29
- 0 , 1 , 0 , 0 ,
30
- 0 , 0 , 1 , 0 ,
31
- 0 , 0 , 0 , 1 ] ;
32
- this . rightProjectionMatrix = [ 1 , 0 , 0 , 0 ,
33
- 0 , 1 , 0 , 0 ,
34
- 0 , 0 , 1 , 0 ,
35
- 0 , 0 , 0 , 1 ] ;
36
28
this . leftViewRotation = [ 0 , 0 , 0 , 1 ] ;
37
29
this . rightViewRotation = [ 0 , 0 , 0 , 1 ] ;
38
30
this . leftViewPosition = [ 0 , 0 , 0 ] ;
@@ -831,21 +823,25 @@ setTimeout(function () {
831
823
var view = pose . views [ i ] ;
832
824
var transformMatrix = view . transform . matrix ;
833
825
if ( view . eye === "left" || view . eye === "none" ) {
834
- xrData . leftProjectionMatrix = view . projectionMatrix ;
826
+ Module . HEAPF32 . set ( view . projectionMatrix , Module . XRSharedArrayOffset ) ; // leftProjectionMatrix
835
827
this . quaternionFromMatrix ( 0 , transformMatrix , xrData . leftViewRotation ) ;
836
828
xrData . leftViewRotation [ 0 ] = - xrData . leftViewRotation [ 0 ] ;
837
829
xrData . leftViewRotation [ 1 ] = - xrData . leftViewRotation [ 1 ] ;
838
830
xrData . leftViewPosition [ 0 ] = transformMatrix [ 12 ] ;
839
831
xrData . leftViewPosition [ 1 ] = transformMatrix [ 13 ] ;
840
832
xrData . leftViewPosition [ 2 ] = - transformMatrix [ 14 ] ;
833
+ Module . HEAPF32 . set ( xrData . leftViewRotation , Module . XRSharedArrayOffset + 32 ) ; // leftViewRotation
834
+ Module . HEAPF32 . set ( xrData . leftViewPosition , Module . XRSharedArrayOffset + 40 ) ; // leftViewPosition
841
835
} else if ( view . eye === 'right' ) {
842
- xrData . rightProjectionMatrix = view . projectionMatrix ;
836
+ Module . HEAPF32 . set ( view . projectionMatrix , Module . XRSharedArrayOffset + 16 ) ; // rightProjectionMatrix
843
837
this . quaternionFromMatrix ( 0 , transformMatrix , xrData . rightViewRotation ) ;
844
838
xrData . rightViewRotation [ 0 ] = - xrData . rightViewRotation [ 0 ] ;
845
839
xrData . rightViewRotation [ 1 ] = - xrData . rightViewRotation [ 1 ] ;
846
840
xrData . rightViewPosition [ 0 ] = transformMatrix [ 12 ] ;
847
841
xrData . rightViewPosition [ 1 ] = transformMatrix [ 13 ] ;
848
842
xrData . rightViewPosition [ 2 ] = - transformMatrix [ 14 ] ;
843
+ Module . HEAPF32 . set ( xrData . rightViewRotation , Module . XRSharedArrayOffset + 36 ) ; // rightViewRotation
844
+ Module . HEAPF32 . set ( xrData . rightViewPosition , Module . XRSharedArrayOffset + 43 ) ; // rightViewPosition
849
845
}
850
846
}
851
847
@@ -886,16 +882,6 @@ setTimeout(function () {
886
882
this . gameModule . WebXR . OnInputProfiles ( JSON . stringify ( inputProfiles ) ) ;
887
883
}
888
884
889
- // Dispatch event with headset data to be handled in webxr.jslib
890
- this . updateUnityXRData ( {
891
- leftProjectionMatrix : xrData . leftProjectionMatrix ,
892
- rightProjectionMatrix : xrData . rightProjectionMatrix ,
893
- leftViewRotation : xrData . leftViewRotation ,
894
- rightViewRotation : xrData . rightViewRotation ,
895
- leftViewPosition : xrData . leftViewPosition ,
896
- rightViewPosition : xrData . rightViewPosition
897
- } ) ;
898
-
899
885
if ( ! this . didNotifyUnity )
900
886
{
901
887
var eyeCount = 1 ;
@@ -943,21 +929,6 @@ setTimeout(function () {
943
929
return this . didNotifyUnity ;
944
930
}
945
931
946
- XRManager . prototype . updateUnityXRData = function ( data ) {
947
- var index = 0 ;
948
- if ( Module . XRSharedArray . byteLength == 0 ) {
949
- Module . XRSharedArray = new Float32Array ( buffer , Module . XRSharedArrayOffset , Module . XRSharedArrayLength ) ;
950
- }
951
- Object . keys ( data ) . forEach ( function ( key , i ) {
952
- var dataLength = data [ key ] . length ;
953
- if ( dataLength ) {
954
- for ( var x = 0 ; x < dataLength ; x ++ ) {
955
- Module . XRSharedArray [ index ++ ] = data [ key ] [ x ] ;
956
- }
957
- }
958
- } ) ;
959
- }
960
-
961
932
function initWebXRManager ( ) {
962
933
var xrManager = window . xrManager = new XRManager ( ) ;
963
934
return xrManager ;
0 commit comments