Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 21 additions & 5 deletions src/renderers/common/XRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ class XRManager extends EventDispatcher {
*/
this._supportsLayers = false;

/**
* Whether the device supports binding gl objects.
*
* @private
* @type {boolean}
* @readonly
*/
this._supportsGlBinding = typeof XRWebGLBinding !== 'undefined';

this._frameBufferTargets = null;

/**
Expand Down Expand Up @@ -357,7 +366,7 @@ class XRManager extends EventDispatcher {
* @type {boolean}
* @readonly
*/
this._useLayers = ( typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype ); // eslint-disable-line compat/compat
this._useLayers = ( this._supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype ); // eslint-disable-line compat/compat

/**
* Whether the usage of multiview has been requested by the application or not.
Expand Down Expand Up @@ -915,9 +924,18 @@ class XRManager extends EventDispatcher {

//

if ( this._supportsGlBinding ) {

const glBinding = new XRWebGLBinding( session, gl );
this._glBinding = glBinding;

}

//

if ( this._useLayers === true ) {

// default path using XRWebGLBinding/XRProjectionLayer
// default path using XRProjectionLayer

let depthFormat = null;
let depthType = null;
Expand Down Expand Up @@ -945,11 +963,9 @@ class XRManager extends EventDispatcher {

}

const glBinding = new XRWebGLBinding( session, gl );
const glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
const glProjLayer = this._glBinding.createProjectionLayer( projectionlayerInit );
const layersArray = [ glProjLayer ];

this._glBinding = glBinding;
this._glProjLayer = glProjLayer;

renderer.setPixelRatio( 1 );
Expand Down
10 changes: 7 additions & 3 deletions src/renderers/webxr/WebXRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,15 @@ class WebXRManager extends EventDispatcher {
currentPixelRatio = renderer.getPixelRatio();
renderer.getSize( currentSize );

if ( typeof XRWebGLBinding !== 'undefined' ) {

glBinding = new XRWebGLBinding( session, gl );

}

// Check that the browser implements the necessary APIs to use an
// XRProjectionLayer rather than an XRWebGLLayer
const useLayers = typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype;
const useLayers = glBinding !== null && 'createProjectionLayer' in XRWebGLBinding.prototype;

if ( ! useLayers ) {

Expand Down Expand Up @@ -453,8 +459,6 @@ class WebXRManager extends EventDispatcher {
scaleFactor: framebufferScaleFactor
};

glBinding = new XRWebGLBinding( session, gl );

glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );

session.updateRenderState( { layers: [ glProjLayer ] } );
Expand Down