Skip to content

Commit 858c29a

Browse files
authored
Merge pull request #562 from Kitware/various-vr-fix
Various vr fix
2 parents 0e4d284 + 34261d5 commit 858c29a

File tree

2 files changed

+37
-10
lines changed
  • Sources
    • Interaction/Style/InteractorStyleManipulator
    • Rendering/OpenGL/RenderWindow

2 files changed

+37
-10
lines changed

Sources/Interaction/Style/InteractorStyleManipulator/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,13 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
348348

349349
//-------------------------------------------------------------------------
350350
publicAPI.onButtonUp = (button) => {
351-
if (model.currentManipulator === null) {
351+
if (!model.currentManipulator) {
352352
return;
353353
}
354-
if (model.currentManipulator.getButton() === button) {
354+
if (
355+
model.currentManipulator.getButton &&
356+
model.currentManipulator.getButton() === button
357+
) {
355358
publicAPI.setAnimationStateOff();
356359
model.currentManipulator.onButtonUp(model.interactor);
357360
model.currentManipulator.endInteraction();
@@ -374,6 +377,7 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
374377
publicAPI.handleAnimation = () => {
375378
if (
376379
model.currentManipulator &&
380+
model.currentManipulator.onAnimation &&
377381
(model.currentRenderer || updateCurrentRenderer())
378382
) {
379383
model.currentManipulator.onAnimation(
@@ -416,6 +420,11 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
416420
manipulator.onKeyUp(model.interactor);
417421
});
418422
};
423+
424+
//-------------------------------------------------------------------------
425+
publicAPI.resetCurrentManipulator = () => {
426+
model.currentManipulator = null;
427+
};
419428
}
420429

421430
// ----------------------------------------------------------------------------

Sources/Rendering/OpenGL/RenderWindow/index.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,23 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
259259
publicAPI.startVR = () => {
260260
if (model.vrDisplay.isConnected) {
261261
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+
}
263278

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);
268279
const ren = model.renderable.getRenderers()[0];
269280
ren.resetCamera();
270281
model.vrFrameData = new VRFrameData();
@@ -282,8 +293,10 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
282293
model.vrDisplay.exitPresent();
283294
model.vrDisplay.cancelAnimationFrame(model.vrSceneFrame);
284295

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+
}
287300

288301
const ren = model.renderable.getRenderers()[0];
289302
ren.getActiveCamera().setProjectionMatrix(null);
@@ -487,6 +500,9 @@ const DEFAULT_VALUES = {
487500
notifyImageReady: false,
488501
webgl2: false,
489502
defaultToWebgl2: false, // turned off by default
503+
vrResolution: [2160, 1200],
504+
queryVRSize: false,
505+
hideInVR: true,
490506
};
491507

492508
// ----------------------------------------------------------------------------
@@ -536,9 +552,11 @@ export function extend(publicAPI, model, initialValues = {}) {
536552
'notifyImageReady',
537553
'defaultToWebgl2',
538554
'cursor',
555+
'hideInVR',
556+
'queryVRSize',
539557
]);
540558

541-
macro.setGetArray(publicAPI, model, ['size'], 2);
559+
macro.setGetArray(publicAPI, model, ['size', 'vrResolution'], 2);
542560

543561
// Object methods
544562
vtkOpenGLRenderWindow(publicAPI, model);

0 commit comments

Comments
 (0)