Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
b1ff9598d9
1 değiştirilmiş dosya ile 7 ekleme ve 5 silme
  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 {