diff --git a/index.bs b/index.bs index 42b2a758..a1f28101 100644 --- a/index.bs +++ b/index.bs @@ -231,7 +231,7 @@ XR {#xr-interface} [SecureContext, Exposed=Window] interface XR : EventTarget { // Methods Promise<void> supportsSession(XRSessionMode mode); - Promise<XRSession> requestSession(XRSessionMode mode); + Promise<XRSession> requestSession(XRSessionMode mode, optional XRSessionInit options); // Events attribute EventHandler ondevicechange; @@ -315,7 +315,7 @@ The {{XR}} object has a pending immersive session boolean, which MUST
-When the requestSession(|mode|) method is invoked, the user agent MUST run the following steps: +When the requestSession(|mode|, |options|) method is invoked, the user agent MUST run the following steps: 1. Let |promise| be [=a new Promise=]. 1. Let |immersive| be true if |mode| is {{XRSessionMode/"immersive-vr"}} or {{XRSessionMode/"immersive-ar"}}, and false otherwise. @@ -340,6 +340,11 @@ When the requestSession(|mode|) method is invoked, th 1. If |immersive| is true, set [=pending immersive session=] to false. 1. Abort these steps. 1. Let |session| be a new {{XRSession}} object. + 1. [=Resolve the requested features=] given by |options|' {{XRSessionInit/requiredFeatures}} and |options|' {{XRSessionInit/optionalFeatures}} values for |session|, and let |resolved| be the returned value. + 1. If |resolved| is false, run the following steps: + 1. [=Reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}}. + 1. If |immersive| is true, set [=pending immersive session=] to false. + 1. Abort these steps. 1. [=Initialize the session=] with |session|, |mode|, and |device|. 1. Potentially set the [=active immersive session=] based on the following:
@@ -388,6 +393,77 @@ NOTE: Examples of ways [=exclusive access=] may be presented include stereo cont NOTE: As an example of overlaid UI, the user-agent or operating system in an [=immersive session=] may show notifications over the rendered content. Similarly, in {{immersive-ar}} mode the user-agent or operating system may overlay mandatory "home" and navigational buttons over the user's wrist. +Session Features {#session-features} +---------------- + +Some features of {{XRSession}} may require the user's consent to access, and will be inaccessable by default unless the features are explicitly requested when calling {{XR/requestSession()}}. These features are passed via {{XRSessionInit}} object. + +
+dictionary XRSessionInit {
+  sequence<DOMString> requiredFeatures;
+  sequence<DOMString> optionalFeatures;
+};
+
+ +Requested features are split into two groups: + + - Required features are passed by via the requiredFeatures array. If any value in the list is not a recognized [=feature name=] the {{XRSession}} will not be created. All features listed in the {{XRSessionInit/requiredFeatures}} array MUST be supported by the [=XRSession/XR Device=] and, if necessary, consented to by the user or the {{XRSession}} will not be created. + - Optional features are passed via the optionalFeatures array. If any value in the list is not a recognized [=feature name=] it will be ignored. Features listed in the {{XRSessionInit/optionalFeatures}} array will be enabled if supported by the [=XRSession/XR Device=] and, if necessary, consented to by the user, but will not block creation of the {{XRSession}} if absent. + +The feature lists accept any string. However, in order to be a considered a valid feature name, the string must be a value from the following enums: + + - {{XRReferenceSpaceType}} + +Some {{XRSessionMode}}s request certain [=feature names=] as optional features by default. The following table described the default features associated with each {{XRSessionMode}}: + + + + + + + + + + + + + + +
Feature{{XRSessionMode}}
{{XRReferenceSpaceType/"local"}}{{XRSessionMode/"immersive-vr"}}
+ +ISSUE: Define what it means when a feature requires consent, how user agents can request user consent, and what it means when a user denied consent. + +
+ +To resolve the requested features given |requiredFeatures| and |optionalFeatures| for an {{XRSession}} |session|, the user agent MUST run the following steps: + + 1. Let |consentRequired| be an empty [=/list=] of {{DOMString}}. + 1. Let |consentOptional| be an empty [=/list=] of {{DOMString}}. + 1. For each |feature| in |requiredFeatures| perform the following steps: + 1. If |feature| is not a value in the {{XRReferenceSpaceType}} enum, return false. + 1. If the functionality described by |feature| is not supported by |session|'s [=XRSession/XR Device=], return false. + 1. If the functionality described by |feature| [=requires consent=], append it to |consentRequired|. + 1. Else append |feature| to |session|'s [=list of enabled features=]. + 1. For each |feature| in |optionalFeatures| perform the following steps: + 1. If |feature| is not a value in the {{XRReferenceSpaceType}} enum, continue to the next entry. + 1. If the functionality described by |feature| is not supported by |session|'s [=XRSession/XR Device=], continue to the next entry. + 1. If the functionality described by |feature| [=requires consent=], append it to |consentOptional|. + 1. Else append |feature| to |session|'s [=list of enabled features=]. + 1. For each |feature| in the [=default features=] table perform the following steps: + 1. If |session|'s [=XRSession/mode=] is not one of the modes associated with |feature| in the [=default features=], continue to the next entry. + 1. If the functionality described by |feature| is not supported by |session|'s [=XRSession/XR Device=], continue to the next entry. + 1. If the functionality described by |feature| [=requires consent=], append it to |consentOptional|. + 1. Else append |feature| to |session|'s [=list of enabled features=]. + 1. If |consentRequired| or |consentOptional| are not empty, [=request user consent=] to use the functionality described by those features. + 1. For each |feature| in |requiredFeatures| perform the following steps: + 1. If the user [=denied consent=] to use |feature|, return false. + 1. Else append |feature| to |session|'s [=list of enabled features=]. + 1. For each |feature| in |requiredFeatures| perform the following steps: + 1. If the user [=denied consent=] to use |feature|, continue to the next entry. + 1. Else append |feature| to |session|'s [=list of enabled features=]. + 1. Return true + +
Session {#session} ======= @@ -482,6 +558,8 @@ The end() method provides a way to manually sh
+Each {{XRSession}} has a list of enabled features, which is a [=/list=] of [=feature names=] which MUST be initially an empty [=/list=] + Each {{XRSession}} has an active render state which is a new {{XRRenderState}}, and a pending render state, which is an {{XRRenderState}} which is initially null. The renderState attribute returns the {{XRSession}}'s [=active render state=]. @@ -973,6 +1051,7 @@ When an {{XRReferenceSpace}} is requested, the user agent MUST create a ref To check if a reference space is supported for a given reference space type |type| and {{XRSession}} |session|, run the following steps: 1. If |type| is {{viewer}}, return true. + 1. If |type| is not [=list/contain|contained=] in |session|'s [=list of enabled features=] return false. 1. If |type| is {{local}} or {{local-floor}}, and |session| is an [=immersive session=], return true. 1. If |type| is {{local}} or {{local-floor}}, and the [=XRSession/XR device=] supports reporting orientation data, return true. 1. If |type| is {{bounded-floor}} and |session| is an [=immersive session=], return if [=bounded reference spaces are supported=] by the [=XRSession/XR device=].