diff --git a/examples/jsm/webxr/VRButton.js b/examples/jsm/webxr/VRButton.js index 54d4c63a677e23..10c362eb86a867 100644 --- a/examples/jsm/webxr/VRButton.js +++ b/examples/jsm/webxr/VRButton.js @@ -1,6 +1,6 @@ class VRButton { - static createButton( renderer ) { + static createButton( renderer, sessionInit = {} ) { const button = document.createElement( 'button' ); @@ -46,7 +46,15 @@ class VRButton { // ('local' is always available for immersive sessions and doesn't need to // be requested separately.) - const sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor', 'hand-tracking', 'layers' ] }; + const sessionOptions = { + ...sessionInit, + optionalFeatures: [ + 'local-floor', + 'bounded-floor', + 'layers', + ...( sessionInit.optionalFeatures || [] ) + ], + }; button.onmouseenter = function () { @@ -64,7 +72,7 @@ class VRButton { if ( currentSession === null ) { - navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted ); + navigator.xr.requestSession( 'immersive-vr', sessionOptions ).then( onSessionStarted ); } else { @@ -72,7 +80,7 @@ class VRButton { if ( navigator.xr.offerSession !== undefined ) { - navigator.xr.offerSession( 'immersive-vr', sessionInit ) + navigator.xr.offerSession( 'immersive-vr', sessionOptions ) .then( onSessionStarted ) .catch( ( err ) => { @@ -88,7 +96,7 @@ class VRButton { if ( navigator.xr.offerSession !== undefined ) { - navigator.xr.offerSession( 'immersive-vr', sessionInit ) + navigator.xr.offerSession( 'immersive-vr', sessionOptions ) .then( onSessionStarted ) .catch( ( err ) => { diff --git a/examples/jsm/webxr/XRButton.js b/examples/jsm/webxr/XRButton.js index a43d5319c5a767..34e5d868057dd3 100644 --- a/examples/jsm/webxr/XRButton.js +++ b/examples/jsm/webxr/XRButton.js @@ -45,7 +45,6 @@ class XRButton { optionalFeatures: [ 'local-floor', 'bounded-floor', - 'hand-tracking', 'layers', ...( sessionInit.optionalFeatures || [] ) ], diff --git a/examples/webxr_vr_handinput.html b/examples/webxr_vr_handinput.html index 5fe18158c86881..effdbc7fad00e7 100644 --- a/examples/webxr_vr_handinput.html +++ b/examples/webxr_vr_handinput.html @@ -85,7 +85,11 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + const sessionInit = { + optionalFeatures: [ 'hand-tracking' ] + }; + + document.body.appendChild( VRButton.createButton( renderer, sessionInit ) ); // controllers diff --git a/examples/webxr_vr_handinput_cubes.html b/examples/webxr_vr_handinput_cubes.html index 0f1b120ed8cd30..bd794a196c2e4c 100644 --- a/examples/webxr_vr_handinput_cubes.html +++ b/examples/webxr_vr_handinput_cubes.html @@ -98,7 +98,11 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + const sessionInit = { + optionalFeatures: [ 'hand-tracking' ] + }; + + document.body.appendChild( VRButton.createButton( renderer, sessionInit ) ); // controllers diff --git a/examples/webxr_vr_handinput_pointerclick.html b/examples/webxr_vr_handinput_pointerclick.html index ad4d695358cc53..6960e286096049 100644 --- a/examples/webxr_vr_handinput_pointerclick.html +++ b/examples/webxr_vr_handinput_pointerclick.html @@ -320,7 +320,11 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + const sessionInit = { + optionalFeatures: [ 'hand-tracking' ] + }; + + document.body.appendChild( VRButton.createButton( renderer, sessionInit ) ); // controllers const controller1 = renderer.xr.getController( 0 ); diff --git a/examples/webxr_vr_handinput_pointerdrag.html b/examples/webxr_vr_handinput_pointerdrag.html index 39a297827a0ca3..914cc4b899096c 100644 --- a/examples/webxr_vr_handinput_pointerdrag.html +++ b/examples/webxr_vr_handinput_pointerdrag.html @@ -423,7 +423,11 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + const sessionInit = { + optionalFeatures: [ 'hand-tracking' ] + }; + + document.body.appendChild( VRButton.createButton( renderer, sessionInit ) ); // controllers const controller1 = renderer.xr.getController( 0 ); diff --git a/examples/webxr_vr_handinput_pressbutton.html b/examples/webxr_vr_handinput_pressbutton.html index fa632ebf8f29f9..a911a62a22781f 100644 --- a/examples/webxr_vr_handinput_pressbutton.html +++ b/examples/webxr_vr_handinput_pressbutton.html @@ -380,7 +380,11 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + const sessionInit = { + optionalFeatures: [ 'hand-tracking' ] + }; + + document.body.appendChild( VRButton.createButton( renderer, sessionInit ) ); // controllers const controller1 = renderer.xr.getController( 0 ); diff --git a/examples/webxr_vr_handinput_profiles.html b/examples/webxr_vr_handinput_profiles.html index 40c3407edfe7ca..7ac39420a7f29e 100644 --- a/examples/webxr_vr_handinput_profiles.html +++ b/examples/webxr_vr_handinput_profiles.html @@ -92,7 +92,11 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + const sessionInit = { + optionalFeatures: [ 'hand-tracking' ] + }; + + document.body.appendChild( VRButton.createButton( renderer, sessionInit ) ); // controllers