Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions src/renderers/webvr/WebVRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,14 @@ function WebVRManager( renderer ) {

function onVRDisplayPresentChange() {

if ( isPresenting() ) {

var eyeParameters = device.getEyeParameters( 'left' );
var renderWidth = eyeParameters.renderWidth * framebufferScaleFactor;
var renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;
updateDrawingBufferSize();
Copy link
Contributor Author

@dmarcos dmarcos Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factor out drawing buffer resizing logic and call it.


currentPixelRatio = renderer.getPixelRatio();
renderer.getSize( currentSize );

renderer.setDrawingBufferSize( renderWidth * 2, renderHeight, 1 );
if ( isPresenting() ) {

animation.start();

} else {

if ( scope.enabled ) {

renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );

}

animation.stop();

}
Expand Down Expand Up @@ -119,6 +106,31 @@ function WebVRManager( renderer ) {

}

function updateDrawingBufferSize() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same logic previously contained in the onVRDisplayPresentChange handler


if ( isPresenting() ) {

var eyeParameters = device.getEyeParameters( 'left' );
var renderWidth = eyeParameters.renderWidth * framebufferScaleFactor;
var renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;

renderer.setDrawingBufferSize( renderWidth * 2, renderHeight, 1 );

} else {

if ( scope.enabled ) {

currentPixelRatio = renderer.getPixelRatio();
renderer.getSize( currentSize );

renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );

}

}

}

function updateControllers() {

for ( var i = 0; i < controllers.length; i ++ ) {
Expand Down Expand Up @@ -210,6 +222,10 @@ function WebVRManager( renderer ) {

animation.setContext( value );

updateDrawingBufferSize();

if ( isPresenting() ) animation.start();
Copy link
Contributor Author

@dmarcos dmarcos Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start animation. If vrdisplaypresentchange fires after requestPresent and no device has been set the render loop never kicks off.


};

this.setFramebufferScaleFactor = function ( value ) {
Expand Down