File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change 152152orbitControls . enableKeys = false ;
153153orbitControls . update ( ) ;
154154
155- // Listen to messages from parent window
155+ const _cleanupRoot = ( ) => {
156+ while ( root . firstChild && root . firstChild . nodeType === Node . TEXT_NODE ) {
157+ root . removeChild ( root . firstChild ) ;
158+ }
159+ for ( let el = root . firstChild ; el ; el = el . nextSibling ) {
160+ while ( el . nextSibling && el . nextSibling . nodeType === Node . TEXT_NODE ) {
161+ el . parentNode . removeChild ( el . nextSibling ) ;
162+ }
163+ }
164+ const xrIframes = Array . from ( root . childNodes ) ;
165+ for ( let i = 0 ; i < xrIframes . length ; i ++ ) {
166+ root . insertBefore ( new Text ( '\n ' ) , xrIframes [ i ] ) ;
167+ }
168+ } ;
156169window . addEventListener ( 'message' , e => {
157170 const { data} = e ;
158171 const { method} = data ;
173186 const xrIframes = Array . from ( root . childNodes ) . filter ( childNode => childNode instanceof XRIFrame ) ;
174187 if ( xrIframes . length > 0 && xrIframes [ xrIframes . length - 1 ] === floorXrIframe ) {
175188 root . insertBefore ( xrIframe , floorXrIframe ) ;
176- root . insertBefore ( new Text ( '\n ' ) , floorXrIframe ) ;
177189 } else {
178- root . appendChild ( new Text ( '\n ' ) ) ;
179190 root . appendChild ( xrIframe ) ;
180- if ( root . lastChild . nodeType !== Node . TEXT_NODE ) {
181- root . appendChild ( new Text ( '\n' ) ) ;
182- }
183191 }
184-
192+ _cleanupRoot ( ) ;
185193 _postTabs ( ) ;
186194
187195 break ;
193201 xrIframe . parentNode . removeChild ( xrIframe . previousSibling ) ;
194202 }
195203 xrIframe . parentNode . removeChild ( xrIframe ) ;
196- if ( ! Array . from ( root . childNodes ) . some ( childNode => childNode instanceof XRIFrame ) ) {
197- root . innerHTML = '' ;
198- }
199-
204+ _cleanupRoot ( ) ;
200205 _postTabs ( ) ;
201206
202207 break ;
You can’t perform that action at this time.
0 commit comments