Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebXR: Don't request hand-tracking feature by default. #27699

Merged
merged 2 commits into from
Feb 8, 2024
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
18 changes: 13 additions & 5 deletions examples/jsm/webxr/VRButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class VRButton {

static createButton( renderer ) {
static createButton( renderer, sessionInit = {} ) {

const button = document.createElement( 'button' );

Expand Down Expand Up @@ -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 () {

Expand All @@ -64,15 +72,15 @@ class VRButton {

if ( currentSession === null ) {

navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
navigator.xr.requestSession( 'immersive-vr', sessionOptions ).then( onSessionStarted );

} else {

currentSession.end();

if ( navigator.xr.offerSession !== undefined ) {

navigator.xr.offerSession( 'immersive-vr', sessionInit )
navigator.xr.offerSession( 'immersive-vr', sessionOptions )
.then( onSessionStarted )
.catch( ( err ) => {

Expand All @@ -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 ) => {

Expand Down
1 change: 0 additions & 1 deletion examples/jsm/webxr/XRButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class XRButton {
optionalFeatures: [
'local-floor',
'bounded-floor',
'hand-tracking',
'layers',
...( sessionInit.optionalFeatures || [] )
],
Expand Down
6 changes: 5 additions & 1 deletion examples/webxr_vr_handinput.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@

container.appendChild( renderer.domElement );

document.body.appendChild( VRButton.createButton( renderer ) );
const sessionInit = {
optionalFeatures: [ 'hand-tracking' ]
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, yeah... I guess in the handinput examples it should be requiredFeatures?

};

document.body.appendChild( VRButton.createButton( renderer, sessionInit ) );

// controllers

Expand Down
6 changes: 5 additions & 1 deletion examples/webxr_vr_handinput_cubes.html
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion examples/webxr_vr_handinput_pointerclick.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 5 additions & 1 deletion examples/webxr_vr_handinput_pointerdrag.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 5 additions & 1 deletion examples/webxr_vr_handinput_pressbutton.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 5 additions & 1 deletion examples/webxr_vr_handinput_profiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down