@@ -19,6 +19,7 @@ class XRSite extends HTMLElement {
1919 this . fakeXrDisplay = new FakeXRDisplay ( ) ;
2020 this . fakeXrDisplay . pushUpdate ( ) ;
2121 this . fakeXrDisplay . enable ( ) ;
22+ this . cameraEnabled = true ;
2223
2324 new MutationObserver ( async mutations => {
2425 await GlobalContext . loadPromise ;
@@ -53,33 +54,35 @@ class XRSite extends HTMLElement {
5354 console . log ( 'disconnected' , this ) ;
5455 }
5556 async attributeChangedCallback ( name , oldValue , newValue ) {
56- await GlobalContext . loadPromise ;
57+ if ( this . cameraEnabled ) {
58+ await GlobalContext . loadPromise ;
5759
58- if ( name === 'camera-position' ) {
59- let position = newValue . split ( ' ' ) ;
60- if ( position . length === 3 ) {
61- position = position . map ( s => parseFloat ( s ) ) ;
62- if ( position . every ( n => isFinite ( n ) ) ) {
63- this . fakeXrDisplay . position . fromArray ( position ) ;
64- this . fakeXrDisplay . pushUpdate ( ) ;
60+ if ( name === 'camera-position' ) {
61+ let position = newValue . split ( ' ' ) ;
62+ if ( position . length === 3 ) {
63+ position = position . map ( s => parseFloat ( s ) ) ;
64+ if ( position . every ( n => isFinite ( n ) ) ) {
65+ this . fakeXrDisplay . position . fromArray ( position ) ;
66+ this . fakeXrDisplay . pushUpdate ( ) ;
67+ }
6568 }
66- }
67- } else if ( name === 'camera-orientation' ) {
68- let orientation = newValue . split ( ' ' ) ;
69- if ( orientation . length === 4 ) {
70- orientation = orientation . map ( s => parseFloat ( s ) ) ;
71- if ( orientation . every ( n => isFinite ( n ) ) ) {
72- this . fakeXrDisplay . quaternion . fromArray ( orientation ) ;
73- this . fakeXrDisplay . pushUpdate ( ) ;
69+ } else if ( name === 'camera-orientation' ) {
70+ let orientation = newValue . split ( ' ' ) ;
71+ if ( orientation . length === 4 ) {
72+ orientation = orientation . map ( s => parseFloat ( s ) ) ;
73+ if ( orientation . every ( n => isFinite ( n ) ) ) {
74+ this . fakeXrDisplay . quaternion . fromArray ( orientation ) ;
75+ this . fakeXrDisplay . pushUpdate ( ) ;
76+ }
7477 }
75- }
76- } else if ( name === 'camera-scale' ) {
77- let scale = newValue . split ( ' ' ) ;
78- if ( scale . length === 3 ) {
79- scale = scale . map ( s => parseFloat ( s ) ) ;
80- if ( scale . every ( n => isFinite ( n ) ) ) {
81- this . fakeXrDisplay . scale . fromArray ( scale ) ;
82- this . fakeXrDisplay . pushUpdate ( ) ;
78+ } else if ( name === 'camera-scale' ) {
79+ let scale = newValue . split ( ' ' ) ;
80+ if ( scale . length === 3 ) {
81+ scale = scale . map ( s => parseFloat ( s ) ) ;
82+ if ( scale . every ( n => isFinite ( n ) ) ) {
83+ this . fakeXrDisplay . scale . fromArray ( scale ) ;
84+ this . fakeXrDisplay . pushUpdate ( ) ;
85+ }
8386 }
8487 }
8588 }
0 commit comments