@@ -33,9 +33,6 @@ const GodotWebXR = {
33
33
$GodotWebXR : {
34
34
gl : null ,
35
35
36
- texture_ids : [ null , null ] ,
37
- textures : [ null , null ] ,
38
-
39
36
session : null ,
40
37
space : null ,
41
38
frame : null ,
@@ -371,22 +368,6 @@ const GodotWebXR = {
371
368
. catch ( ( e ) => { } ) ;
372
369
}
373
370
374
- // Clean-up the textures we allocated for each view.
375
- const gl = GodotWebXR . gl ;
376
- for ( let i = 0 ; i < GodotWebXR . textures . length ; i ++ ) {
377
- const texture = GodotWebXR . textures [ i ] ;
378
- if ( texture !== null ) {
379
- gl . deleteTexture ( texture ) ;
380
- }
381
- GodotWebXR . textures [ i ] = null ;
382
-
383
- const texture_id = GodotWebXR . texture_ids [ i ] ;
384
- if ( texture_id !== null ) {
385
- GL . textures [ texture_id ] = null ;
386
- }
387
- GodotWebXR . texture_ids [ i ] = null ;
388
- }
389
-
390
371
GodotWebXR . session = null ;
391
372
GodotWebXR . space = null ;
392
373
GodotWebXR . frame = null ;
@@ -461,50 +442,9 @@ const GodotWebXR = {
461
442
return buf ;
462
443
} ,
463
444
464
- godot_webxr_get_external_texture_for_eye__proxy : 'sync' ,
465
- godot_webxr_get_external_texture_for_eye__sig : 'ii' ,
466
- godot_webxr_get_external_texture_for_eye : function ( p_eye ) {
467
- if ( ! GodotWebXR . session ) {
468
- return 0 ;
469
- }
470
-
471
- const view_index = ( p_eye === 2 /* ARVRInterface::EYE_RIGHT */ ) ? 1 : 0 ;
472
- if ( GodotWebXR . texture_ids [ view_index ] ) {
473
- return GodotWebXR . texture_ids [ view_index ] ;
474
- }
475
-
476
- // Check pose separately and after returning the cached texture id,
477
- // because we won't get a pose in some cases if we lose tracking, and
478
- // we don't want to return 0 just because tracking was lost.
479
- if ( ! GodotWebXR . pose ) {
480
- return 0 ;
481
- }
482
-
483
- const glLayer = GodotWebXR . session . renderState . baseLayer ;
484
- const view = GodotWebXR . pose . views [ view_index ] ;
485
- const viewport = glLayer . getViewport ( view ) ;
486
- const gl = GodotWebXR . gl ;
487
-
488
- const texture = gl . createTexture ( ) ;
489
- gl . bindTexture ( gl . TEXTURE_2D , texture ) ;
490
- gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , viewport . width , viewport . height , 0 , gl . RGBA , gl . UNSIGNED_BYTE , null ) ;
491
-
492
- gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_S , gl . CLAMP_TO_EDGE ) ;
493
- gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_T , gl . CLAMP_TO_EDGE ) ;
494
- gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , gl . NEAREST ) ;
495
- gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , gl . NEAREST ) ;
496
- gl . bindTexture ( gl . TEXTURE_2D , null ) ;
497
-
498
- const texture_id = GL . getNewId ( GL . textures ) ;
499
- GL . textures [ texture_id ] = texture ;
500
- GodotWebXR . textures [ view_index ] = texture ;
501
- GodotWebXR . texture_ids [ view_index ] = texture_id ;
502
- return texture_id ;
503
- } ,
504
-
505
445
godot_webxr_commit_for_eye__proxy : 'sync' ,
506
- godot_webxr_commit_for_eye__sig : 'vi ' ,
507
- godot_webxr_commit_for_eye : function ( p_eye ) {
446
+ godot_webxr_commit_for_eye__sig : 'vii ' ,
447
+ godot_webxr_commit_for_eye : function ( p_eye , p_texture_id ) {
508
448
if ( ! GodotWebXR . session || ! GodotWebXR . pose ) {
509
449
return ;
510
450
}
@@ -522,7 +462,7 @@ const GodotWebXR = {
522
462
gl . bindFramebuffer ( gl . FRAMEBUFFER , glLayer . framebuffer ) ;
523
463
gl . viewport ( viewport . x , viewport . y , viewport . width , viewport . height ) ;
524
464
525
- GodotWebXR . blitTexture ( gl , GodotWebXR . textures [ view_index ] ) ;
465
+ GodotWebXR . blitTexture ( gl , GL . textures [ p_texture_id ] ) ;
526
466
527
467
// Restore state.
528
468
gl . bindFramebuffer ( gl . FRAMEBUFFER , orig_framebuffer ) ;
0 commit comments