Browse Source

XRSessionInit interface

Raanan Weber 5 năm trước cách đây
mục cha
commit
c4dcfb91ad

+ 1 - 1
src/Cameras/XR/webXRExperienceHelper.ts

@@ -103,7 +103,7 @@ export class WebXRExperienceHelper implements IDisposable {
             throw "XR not available";
         }
         this._setState(WebXRState.ENTERING_XR);
-        let sessionCreationOptions = {
+        let sessionCreationOptions: XRSessionInit = {
             optionalFeatures: (referenceSpaceType !== "viewer" && referenceSpaceType !== "local") ? [referenceSpaceType] : []
         };
         // make sure that the session mode is supported

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

@@ -128,11 +128,11 @@ export class WebXRSessionManager implements IDisposable {
     /**
      * Initializes an xr session
      * @param xrSessionMode mode to initialize
-     * @param optionalFeatures defines optional values to pass to the session builder
+     * @param xrSessionInit defines optional and required values to pass to the session builder
      * @returns a promise which will resolve once the session has been initialized
      */
-    public initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures: any = {}): Promise<XRSession> {
-        return this._xrNavigator.xr.requestSession(xrSessionMode, optionalFeatures).then((session: XRSession) => {
+    public initializeSessionAsync(xrSessionMode: XRSessionMode, xrSessionInit: XRSessionInit = {}): Promise<XRSession> {
+        return this._xrNavigator.xr.requestSession(xrSessionMode, xrSessionInit).then((session: XRSession) => {
             this.session = session;
             this.onXRSessionInit.notifyObservers(session);
             this._sessionEnded = false;

+ 5 - 0
src/LibDeclarations/webxr.d.ts

@@ -55,6 +55,11 @@ interface XRInputSource {
     profiles: Array<string>;
 }
 
+interface XRSessionInit {
+    optionalFeatures?: XRReferenceSpaceType[];
+    requiredFeatures?: XRReferenceSpaceType[];
+}
+
 interface XRSession extends XRAnchorCreator {
     addEventListener: Function;
     removeEventListener: Function;