Переглянути джерело

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

* VRButton: Add `sessionInit` parameter.

* WebXR: Don't request `hand-tracking` feature by default.
Michael Herzog 1 рік тому
батько
коміт
477bff714e

+ 13 - 5
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 ) => {
 

+ 0 - 1
examples/jsm/webxr/XRButton.js

@@ -45,7 +45,6 @@ class XRButton {
 				optionalFeatures: [
 					'local-floor',
 					'bounded-floor',
-					'hand-tracking',
 					'layers',
 					...( sessionInit.optionalFeatures || [] )
 				],

+ 5 - 1
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
 

+ 5 - 1
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
 

+ 5 - 1
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 );

+ 5 - 1
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 );

+ 5 - 1
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 );

+ 5 - 1
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