Browse Source

[XR] Teleportation fix and optional required features (#8499)

* reset controller id by attach and detach

* adding required features to the UI
Raanan Weber 5 years ago
parent
commit
ed0021fdb6
2 changed files with 10 additions and 1 deletions
  1. 4 0
      src/XR/features/WebXRControllerTeleportation.ts
  2. 6 1
      src/XR/webXREnterExitUI.ts

+ 4 - 0
src/XR/features/WebXRControllerTeleportation.ts

@@ -237,6 +237,9 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
             return false;
         }
 
+        // Safety reset
+        this._currentTeleportationControllerId = '';
+
         this._options.xrInput.controllers.forEach(this._attachController);
         this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController);
         this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (controller) => {
@@ -257,6 +260,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
         });
 
         this._setTargetMeshVisibility(false);
+        this._currentTeleportationControllerId = '';
 
         return true;
     }

+ 6 - 1
src/XR/webXREnterExitUI.ts

@@ -58,6 +58,11 @@ export class WebXREnterExitUIOptions {
      * A list of optional features to init the session with
      */
     optionalFeatures?: string[];
+
+    /**
+     * A list of optional features to init the session with
+     */
+    requiredFeatures?: string[];
 }
 /**
  * UI to allow the user to enter/exit XR mode
@@ -157,7 +162,7 @@ export class WebXREnterExitUI implements IDisposable {
                         } else if (helper.state == WebXRState.NOT_IN_XR) {
                             if (options.renderTarget) {
                                 try {
-                                    await helper.enterXRAsync(ui._buttons[i].sessionMode, ui._buttons[i].referenceSpaceType, options.renderTarget, {optionalFeatures: options.optionalFeatures});
+                                    await helper.enterXRAsync(ui._buttons[i].sessionMode, ui._buttons[i].referenceSpaceType, options.renderTarget, {optionalFeatures: options.optionalFeatures, requiredFeatures: options.requiredFeatures});
                                     ui._updateButtons(ui._buttons[i]);
                                 } catch (e) {
                                     // make sure button is visible