@@ -38,6 +38,7 @@ setTimeout(function () {
38
38
this . frameNumber = 0 ;
39
39
this . touchIDs = [ ] ;
40
40
this . touches = [ ] ;
41
+ this . eventsNamesToIDs = { } ;
41
42
this . CreateTouch = function ( pageElement , xPercentage , yPercentage ) {
42
43
var touchID = 0 ;
43
44
while ( this . touchIDs . includes ( touchID ) )
@@ -58,9 +59,9 @@ setTimeout(function () {
58
59
return item !== touch
59
60
} ) ;
60
61
}
61
- this . SendTouchEvent = function ( JSEventsObject , eventID , eventName , target , changedTouches ) {
62
+ this . SendTouchEvent = function ( JSEventsObject , eventName , target , changedTouches ) {
62
63
var touchEvent = new XRTouchEvent ( eventName , target , this . touches , this . touches , changedTouches ) ;
63
- JSEventsObject . eventHandlers [ eventID ] . eventListenerFunc ( touchEvent ) ;
64
+ JSEventsObject . eventHandlers [ this . eventsNamesToIDs [ eventName ] ] . eventListenerFunc ( touchEvent ) ;
64
65
}
65
66
}
66
67
@@ -403,8 +404,9 @@ setTimeout(function () {
403
404
404
405
this . gameModule . WebXR . OnEndXR ( ) ;
405
406
this . didNotifyUnity = false ;
406
- this . canvas . width = this . canvas . parentElement . clientWidth * this . gameModule . asmLibraryArg . _JS_SystemInfo_GetPreferredDevicePixelRatio ( ) ;
407
- this . canvas . height = this . canvas . parentElement . clientHeight * this . gameModule . asmLibraryArg . _JS_SystemInfo_GetPreferredDevicePixelRatio ( ) ;
407
+ var pixelRatio = Module . devicePixelRatio || window . devicePixelRatio || 1 ;
408
+ this . canvas . width = this . canvas . parentElement . clientWidth * pixelRatio ;
409
+ this . canvas . height = this . canvas . parentElement . clientHeight * pixelRatio ;
408
410
409
411
if ( this . BrowserObject . pauseAsyncCallbacks ) {
410
412
this . BrowserObject . pauseAsyncCallbacks ( ) ;
@@ -426,7 +428,7 @@ setTimeout(function () {
426
428
{
427
429
var touch = this . xrData . touches [ 0 ] ;
428
430
this . xrData . RemoveTouch ( touch ) ;
429
- this . xrData . SendTouchEvent ( this . JSEventsObject , 8 , "touchend" , this . canvas , [ touch ] ) ;
431
+ this . xrData . SendTouchEvent ( this . JSEventsObject , "touchend" , this . canvas , [ touch ] ) ;
430
432
}
431
433
}
432
434
@@ -491,11 +493,11 @@ setTimeout(function () {
491
493
break ;
492
494
case "selectstart" : // 7 touchstart
493
495
inputSource . xrTouchObject = this . xrData . CreateTouch ( this . canvas , xPercentage , yPercentage ) ;
494
- this . xrData . SendTouchEvent ( this . JSEventsObject , 7 , "touchstart" , this . canvas , [ inputSource . xrTouchObject ] )
496
+ this . xrData . SendTouchEvent ( this . JSEventsObject , "touchstart" , this . canvas , [ inputSource . xrTouchObject ] )
495
497
break ;
496
498
case "selectend" : // 8 touchend
497
499
this . xrData . RemoveTouch ( inputSource . xrTouchObject ) ;
498
- this . xrData . SendTouchEvent ( this . JSEventsObject , 8 , "touchend" , this . canvas , [ inputSource . xrTouchObject ] ) ;
500
+ this . xrData . SendTouchEvent ( this . JSEventsObject , "touchend" , this . canvas , [ inputSource . xrTouchObject ] ) ;
499
501
inputSource . xrTouchObject = null ;
500
502
break ;
501
503
}
@@ -581,6 +583,9 @@ setTimeout(function () {
581
583
582
584
var thisXRMananger = this ;
583
585
this . JSEventsObject = this . gameModule . WebXR . GetJSEventsObject ( ) ;
586
+ for ( var i = 0 ; i < this . JSEventsObject . eventHandlers . length ; i ++ ) {
587
+ this . xrData . eventsNamesToIDs [ this . JSEventsObject . eventHandlers [ i ] . eventTypeString ] = i ;
588
+ }
584
589
this . BrowserObject = this . gameModule . WebXR . GetBrowserObject ( ) ;
585
590
this . BrowserObject . requestAnimationFrame = function ( func ) {
586
591
if ( thisXRMananger . xrSession && thisXRMananger . xrSession . isInSession ) {
@@ -818,7 +823,7 @@ setTimeout(function () {
818
823
}
819
824
}
820
825
if ( touchesToSend . length > 0 ) {
821
- this . xrData . SendTouchEvent ( this . JSEventsObject , 9 , "touchmove" , this . canvas , touchesToSend ) ;
826
+ this . xrData . SendTouchEvent ( this . JSEventsObject , "touchmove" , this . canvas , touchesToSend ) ;
822
827
for ( var i = 0 ; i < touchesToSend . length ; i ++ ) {
823
828
touchesToSend [ i ] . ResetMovement ( ) ;
824
829
}
0 commit comments