Skip to content

Commit

Permalink
Further improvements to WebXR layers feature testing
Browse files Browse the repository at this point in the history
  • Loading branch information
toji committed Jan 7, 2025
1 parent be84ecf commit 9dd259f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions examples/webxr_vr_layers.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,12 @@
const gl = renderer.getContext();

// Init layers once in immersive mode and video is ready.
const useLayers = session.enabledFeatures !== undefined && session.enabledFeatures.includes('layers');
const useLayers = session &&
session.enabledFeatures !== undefined &&
session.enabledFeatures.includes('layers') &&
XRMediaBinding !== undefined;

if ( session && ! useLayers ) {
if ( ! useLayers ) {

errorMesh.visible = true;

Expand Down
6 changes: 5 additions & 1 deletion src/renderers/webxr/WebXRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ class WebXRManager extends EventDispatcher {
currentPixelRatio = renderer.getPixelRatio();
renderer.getSize( currentSize );

const useLayers = session.enabledFeatures !== undefined && session.enabledFeatures.includes( 'layers' );
// Check that the browser implements all the necessary APIs to use an
// XRProjectionLayer rather than an XRWebGLLayer
const useLayers = XRWebGLBinding !== undefined &&
'createProjectionLayer' in XRWebGLBinding.prototype &&
session.renderState.layers !== undefined;

if ( ! useLayers ) {

Expand Down

0 comments on commit 9dd259f

Please sign in to comment.