File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 354354
355355 peerConnection . open = true ;
356356
357+ if ( landState ) {
358+ // emit owned xr-iframes
359+
360+ const landXrIframe = root . childNodes [ 0 ] ;
361+ const ownedXrIframes = _getOwnedXrIframes ( landXrIframe ) ;
362+ const state = parse5 . parseFragment ( `<xr-site>${ ownedXrIframes . map ( xrIframe => xrIframe . outerHTML ) . join ( '' ) } </xr-site>` ) ;
363+ sendChannel . send ( JSON . stringify ( {
364+ method : 'initState' ,
365+ state,
366+ } ) ) ;
367+ }
368+
357369 pingInterval = setInterval ( ( ) => {
358370 sendChannel . send ( JSON . stringify ( {
359371 method : 'ping' ,
425437 const { hmd, gamepads} = data ;
426438 skinMesh . setState ( hmd , gamepads ) ;
427439 }
428- } else if ( method === 'editState' ) {
440+ } else if ( landState && method === 'initState' ) {
441+ const { state} = data ;
442+ const stateXrSite = state . childNodes . find ( node => node . tagName === 'xr-site' ) ;
443+ const stateXrIframes = stateXrSite ? stateXrSite . childNodes . filter ( node => node . tagName === 'xr-iframe' ) : [ ] ;
444+
445+ for ( let i = 0 ; i < stateXrIframes . length ; i ++ ) {
446+ const xrIframe = document . createElement ( 'xr-iframe' ) ;
447+ root . appendChild ( xrIframe ) ;
448+ const htmlString = parse5 . serialize ( state ) ;
449+ xrIframe . outerHTML = htmlString ;
450+ }
451+ } else if ( landState && method === 'editState' ) {
429452 _applyEditState ( data . spec ) ;
430453 } else if ( method === 'ping' ) {
431454 // nothing
You can’t perform that action at this time.
0 commit comments