瀏覽代碼

Request optional features in session init when not using viewer or local reference space types.

Justin Murray 5 年之前
父節點
當前提交
1936ac569c

+ 1 - 1
dist/preview release/what's new.md

@@ -168,7 +168,7 @@
 - A scene's input manager not adding key listeners when the canvas is already focused ([Poolminer](https://github.com/Poolminer))
 - Runtime animation `goToFrame` when going back in time now correctly triggers future events when reached ([zakhenry](https://github.com/zakhenry))
 - Fixed bug in `Ray.intersectsTriangle` where the barycentric coordinates `bu` and `bv` being returned is actually `bv` and `bw`. ([bghgary](https://github.com/bghgary))
-- Do not call onError when creating a texture when falling back to another loader ([TrevorDev](https://github.com/TrevorDev))
+- Do not call `onError` when creating a texture when falling back to another loader ([TrevorDev](https://github.com/TrevorDev))
 - Context loss should not cause PBR materials to render black or instances to stop rendering ([TrevorDev](https://github.com/TrevorDev))
 - Only cast pointer ray input when pointer is locked in webVR ([TrevorDev](https://github.com/TrevorDev))
 - Fix Right Hand coordinates with directional lights and shadows, hemispheric lights and spot lights ([CedricGuillemet](https://github.com/CedricGuillemet))

+ 5 - 2
src/Cameras/XR/webXRExperienceHelper.ts

@@ -93,12 +93,15 @@ export class WebXRExperienceHelper implements IDisposable {
      * @param renderTarget the output canvas that will be used to enter XR mode
      * @returns promise that resolves after xr mode has entered
      */
-    public enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget) {
+    public enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget) {
         if (!this._supported) {
             throw "XR session not supported by this browser";
         }
         this._setState(WebXRState.ENTERING_XR);
-        return this.sessionManager.initializeSessionAsync(sessionCreationOptions).then(() => {
+        let sessionCreationOptions = {
+            optionalFeatures: (referenceSpaceType !== "viewer" && referenceSpaceType !== "local") ? [referenceSpaceType] : []
+        };
+        return this.sessionManager.initializeSessionAsync(sessionMode, sessionCreationOptions).then(() => {
             return this.sessionManager.setReferenceSpaceAsync(referenceSpaceType);
         }).then(() => {
             return renderTarget.initializeXRLayerAsync(this.sessionManager.session);

+ 2 - 2
src/Cameras/XR/webXRSessionManager.ts

@@ -86,8 +86,8 @@ export class WebXRSessionManager implements IDisposable {
      * @param xrSessionMode mode to initialize
      * @returns a promise which will resolve once the session has been initialized
      */
-    public initializeSessionAsync(xrSessionMode: XRSessionMode) {
-        return this._xrNavigator.xr.requestSession(xrSessionMode).then((session: XRSession) => {
+    public initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures: any = {}) {
+        return this._xrNavigator.xr.requestSession(xrSessionMode, optionalFeatures).then((session: XRSession) => {
             this.session = session;
             this._sessionEnded = false;