|
@@ -1,6 +1,6 @@
|
|
class VRButton {
|
|
class VRButton {
|
|
|
|
|
|
- static createButton( renderer ) {
|
|
|
|
|
|
+ static createButton( renderer, sessionInit = {} ) {
|
|
|
|
|
|
const button = document.createElement( 'button' );
|
|
const button = document.createElement( 'button' );
|
|
|
|
|
|
@@ -46,7 +46,15 @@ class VRButton {
|
|
// ('local' is always available for immersive sessions and doesn't need to
|
|
// ('local' is always available for immersive sessions and doesn't need to
|
|
// be requested separately.)
|
|
// 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 () {
|
|
button.onmouseenter = function () {
|
|
|
|
|
|
@@ -64,7 +72,7 @@ class VRButton {
|
|
|
|
|
|
if ( currentSession === null ) {
|
|
if ( currentSession === null ) {
|
|
|
|
|
|
- navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
|
|
|
|
|
|
+ navigator.xr.requestSession( 'immersive-vr', sessionOptions ).then( onSessionStarted );
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
@@ -72,7 +80,7 @@ class VRButton {
|
|
|
|
|
|
if ( navigator.xr.offerSession !== undefined ) {
|
|
if ( navigator.xr.offerSession !== undefined ) {
|
|
|
|
|
|
- navigator.xr.offerSession( 'immersive-vr', sessionInit )
|
|
|
|
|
|
+ navigator.xr.offerSession( 'immersive-vr', sessionOptions )
|
|
.then( onSessionStarted )
|
|
.then( onSessionStarted )
|
|
.catch( ( err ) => {
|
|
.catch( ( err ) => {
|
|
|
|
|
|
@@ -88,7 +96,7 @@ class VRButton {
|
|
|
|
|
|
if ( navigator.xr.offerSession !== undefined ) {
|
|
if ( navigator.xr.offerSession !== undefined ) {
|
|
|
|
|
|
- navigator.xr.offerSession( 'immersive-vr', sessionInit )
|
|
|
|
|
|
+ navigator.xr.offerSession( 'immersive-vr', sessionOptions )
|
|
.then( onSessionStarted )
|
|
.then( onSessionStarted )
|
|
.catch( ( err ) => {
|
|
.catch( ( err ) => {
|
|
|
|
|