@@ -41,7 +41,7 @@ let autoInit = true;
41
41
const cameraFocalPoint = userParams . direction || [ 0 , 0 , - 1 ] ;
42
42
const cameraViewUp = userParams . up || [ 0 , 1 , 0 ] ;
43
43
const cameraViewAngle = userParams . viewAngle || 100 ;
44
- const enableVR = ! ! userParams . vr ;
44
+ const enableXR = ! ! userParams . xr ;
45
45
const eyeSpacing = userParams . eye || 0.0 ;
46
46
const grid = userParams . debug || false ;
47
47
const autoIncrementTimer = userParams . timer || 0 ;
@@ -189,13 +189,7 @@ function createVisualization(container, mapReader) {
189
189
updateSkybox ( allPositions [ nextIdx ] ) ;
190
190
}
191
191
192
- if ( enableVR && vtkDeviceOrientationToCamera . isDeviceOrientationSupported ( ) ) {
193
- // vtkMobileVR.getVRHeadset().then((headset) => {
194
- // console.log('got headset');
195
- // console.log(headset);
196
- // console.log(vtkMobileVR.hardware);
197
- // });
198
-
192
+ if ( enableXR && navigator . xr . isSessionSupported ( 'immersive-vr' ) ) {
199
193
leftRenderer = vtkRenderer . newInstance ( ) ;
200
194
rightRenderer = vtkRenderer . newInstance ( ) ;
201
195
@@ -236,7 +230,7 @@ function createVisualization(container, mapReader) {
236
230
distPass . setCameraCenterX1 ( - eyeSpacing ) ;
237
231
distPass . setCameraCenterX2 ( eyeSpacing ) ;
238
232
distPass . setDelegates ( [ vtkForwardPass . newInstance ( ) ] ) ;
239
- fullScreenRenderer . getAPISpecificRenderWindow ( ) . setRenderPasses ( [ distPass ] ) ;
233
+ fullScreenRenderer . getApiSpecificRenderWindow ( ) . setRenderPasses ( [ distPass ] ) ;
240
234
241
235
// Hide any controller
242
236
fullScreenRenderer . setControllerVisibility ( false ) ;
@@ -278,29 +272,27 @@ function createVisualization(container, mapReader) {
278
272
mainRenderer . addActor ( actor ) ;
279
273
280
274
// add vr option button if supported
281
- fullScreenRenderer . getApiSpecificRenderWindow ( ) . onHaveVRDisplay ( ( ) => {
282
- if (
283
- fullScreenRenderer . getApiSpecificRenderWindow ( ) . getVrDisplay ( )
284
- . capabilities . canPresent
285
- ) {
286
- const button = document . createElement ( 'button' ) ;
287
- button . style . position = 'absolute' ;
288
- button . style . left = '10px' ;
289
- button . style . bottom = '10px' ;
290
- button . style . zIndex = 10000 ;
291
- button . textContent = 'Send To VR' ;
292
- document . querySelector ( 'body' ) . appendChild ( button ) ;
293
- button . addEventListener ( 'click' , ( ) => {
294
- if ( button . textContent === 'Send To VR' ) {
295
- fullScreenRenderer . getApiSpecificRenderWindow ( ) . startVR ( ) ;
296
- button . textContent = 'Return From VR' ;
297
- } else {
298
- fullScreenRenderer . getApiSpecificRenderWindow ( ) . stopVR ( ) ;
299
- button . textContent = 'Send To VR' ;
300
- }
301
- } ) ;
302
- }
303
- } ) ;
275
+ if (
276
+ navigator . xr !== undefined &&
277
+ navigator . xr . isSessionSupported ( 'immersive-vr' )
278
+ ) {
279
+ const button = document . createElement ( 'button' ) ;
280
+ button . style . position = 'absolute' ;
281
+ button . style . left = '10px' ;
282
+ button . style . bottom = '10px' ;
283
+ button . style . zIndex = 10000 ;
284
+ button . textContent = 'Send To VR' ;
285
+ document . querySelector ( 'body' ) . appendChild ( button ) ;
286
+ button . addEventListener ( 'click' , ( ) => {
287
+ if ( button . textContent === 'Send To VR' ) {
288
+ fullScreenRenderer . getApiSpecificRenderWindow ( ) . startXR ( ) ;
289
+ button . textContent = 'Return From VR' ;
290
+ } else {
291
+ fullScreenRenderer . getApiSpecificRenderWindow ( ) . stopXR ( ) ;
292
+ button . textContent = 'Send To VR' ;
293
+ }
294
+ } ) ;
295
+ }
304
296
}
305
297
306
298
renderWindow . render ( ) ;
0 commit comments