@@ -171,6 +171,15 @@ class XRManager extends EventDispatcher {
171171 */
172172 this . _supportsLayers = false ;
173173
174+ /**
175+ * Whether the device supports binding gl objects.
176+ *
177+ * @private
178+ * @type {boolean }
179+ * @readonly
180+ */
181+ this . _supportsGlBinding = typeof XRWebGLBinding !== 'undefined' ;
182+
174183 this . _frameBufferTargets = null ;
175184
176185 /**
@@ -357,7 +366,7 @@ class XRManager extends EventDispatcher {
357366 * @type {boolean }
358367 * @readonly
359368 */
360- this . _useLayers = ( typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding . prototype ) ; // eslint-disable-line compat/compat
369+ this . _useLayers = ( this . _supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding . prototype ) ; // eslint-disable-line compat/compat
361370
362371 /**
363372 * Whether the usage of multiview has been requested by the application or not.
@@ -915,9 +924,18 @@ class XRManager extends EventDispatcher {
915924
916925 //
917926
927+ if ( this . _supportsGlBinding ) {
928+
929+ const glBinding = new XRWebGLBinding ( session , gl ) ;
930+ this . _glBinding = glBinding ;
931+
932+ }
933+
934+ //
935+
918936 if ( this . _useLayers === true ) {
919937
920- // default path using XRWebGLBinding/ XRProjectionLayer
938+ // default path using XRProjectionLayer
921939
922940 let depthFormat = null ;
923941 let depthType = null ;
@@ -945,11 +963,9 @@ class XRManager extends EventDispatcher {
945963
946964 }
947965
948- const glBinding = new XRWebGLBinding ( session , gl ) ;
949- const glProjLayer = glBinding . createProjectionLayer ( projectionlayerInit ) ;
966+ const glProjLayer = this . _glBinding . createProjectionLayer ( projectionlayerInit ) ;
950967 const layersArray = [ glProjLayer ] ;
951968
952- this . _glBinding = glBinding ;
953969 this . _glProjLayer = glProjLayer ;
954970
955971 renderer . setPixelRatio ( 1 ) ;
0 commit comments