Ver código fonte

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 ano atrás
pai
commit
b1ff9598d9
1 arquivos alterados com 7 adições e 5 exclusões
  1. 7 5
      examples/jsm/webxr/XRButton.js

+ 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 {