2
0
Эх сурвалжийг харах

XRButton: allow specifying optional and required features (#27030)

* Update WebXRManager and XRButton to offer light estimation

Update the XRButton so that it can be passed optional and required
features to be enabled on the XRSession. This is useful for enabling
light estimation.

Update the WebXRManager interface to offer light estimation.

Also update the English documentation to document the new light
estimation method.

* Fix lightprobe variable type

* Fix linting in WebXRManager

* Rm changes to WebXRManager and WebXRmanager docs
Alberto Taiuti 1 жил өмнө
parent
commit
b1ff9598d9

+ 7 - 5
examples/jsm/webxr/XRButton.js

@@ -1,6 +1,6 @@
 class XRButton {
 
-	static createButton( renderer ) {
+	static createButton( renderer, sessionInit = {} ) {
 
 		const button = document.createElement( 'button' );
 
@@ -56,16 +56,18 @@ class XRButton {
 
 				if ( currentSession === null ) {
 
-					const sessionInit = {
+					const sessionOptions = {
+						...sessionInit,
 						optionalFeatures: [
 							'local-floor',
 							'bounded-floor',
 							'hand-tracking',
-							'layers'
-						]
+							'layers',
+							...( sessionInit.optionalFeatures || [] )
+						],
 					};
 
-					navigator.xr.requestSession( mode, sessionInit )
+					navigator.xr.requestSession( mode, sessionOptions )
 						.then( onSessionStarted );
 
 				} else {