@@ -259,12 +259,23 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
259
259
publicAPI . startVR = ( ) => {
260
260
if ( model . vrDisplay . isConnected ) {
261
261
model . vrDisplay . requestPresent ( [ { source : model . canvas } ] ) . then ( ( ) => {
262
- model . oldCanvasSize = [ model . canvas . width , model . canvas . height ] ;
262
+ model . oldCanvasSize = model . size . slice ( ) ;
263
+
264
+ if ( model . el && model . hideInVR ) {
265
+ model . el . style . display = 'none' ;
266
+ }
267
+ if ( model . queryVRSize ) {
268
+ const leftEye = model . vrDisplay . getEyeParameters ( 'left' ) ;
269
+ const rightEye = model . vrDisplay . getEyeParameters ( 'right' ) ;
270
+ const width = Math . floor ( leftEye . renderWidth + rightEye . renderWidth ) ;
271
+ const height = Math . floor (
272
+ Math . max ( leftEye . renderHeight , rightEye . renderHeight )
273
+ ) ;
274
+ publicAPI . setSize ( width , height ) ;
275
+ } else {
276
+ publicAPI . setSize ( model . vrResolution ) ;
277
+ }
263
278
264
- // const leftEye = model.vrDisplay.getEyeParameters('left');
265
- // const rightEye = model.vrDisplay.getEyeParameters('right');
266
- // model.canvas.width = Math.max(leftEye.renderWidth, rightEye.renderWidth) * 2;
267
- // model.canvas.height = Math.max(leftEye.renderHeight, rightEye.renderHeight);
268
279
const ren = model . renderable . getRenderers ( ) [ 0 ] ;
269
280
ren . resetCamera ( ) ;
270
281
model . vrFrameData = new VRFrameData ( ) ;
@@ -282,8 +293,10 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
282
293
model . vrDisplay . exitPresent ( ) ;
283
294
model . vrDisplay . cancelAnimationFrame ( model . vrSceneFrame ) ;
284
295
285
- model . canvas . width = model . oldCanvasSize [ 0 ] ;
286
- model . canvas . height = model . oldCanvasSize [ 1 ] ;
296
+ publicAPI . setSize ( ...model . oldCanvasSize ) ;
297
+ if ( model . el && model . hideInVR ) {
298
+ model . el . style . display = 'block' ;
299
+ }
287
300
288
301
const ren = model . renderable . getRenderers ( ) [ 0 ] ;
289
302
ren . getActiveCamera ( ) . setProjectionMatrix ( null ) ;
@@ -487,6 +500,9 @@ const DEFAULT_VALUES = {
487
500
notifyImageReady : false ,
488
501
webgl2 : false ,
489
502
defaultToWebgl2 : false , // turned off by default
503
+ vrResolution : [ 2160 , 1200 ] ,
504
+ queryVRSize : false ,
505
+ hideInVR : true ,
490
506
} ;
491
507
492
508
// ----------------------------------------------------------------------------
@@ -536,9 +552,11 @@ export function extend(publicAPI, model, initialValues = {}) {
536
552
'notifyImageReady' ,
537
553
'defaultToWebgl2' ,
538
554
'cursor' ,
555
+ 'hideInVR' ,
556
+ 'queryVRSize' ,
539
557
] ) ;
540
558
541
- macro . setGetArray ( publicAPI , model , [ 'size' ] , 2 ) ;
559
+ macro . setGetArray ( publicAPI , model , [ 'size' , 'vrResolution' ] , 2 ) ;
542
560
543
561
// Object methods
544
562
vtkOpenGLRenderWindow ( publicAPI , model ) ;
0 commit comments