浏览代码

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 年之前
父节点
当前提交
b1ff9598d9
共有 1 个文件被更改,包括 7 次插入5 次删除
  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 {