Skip to content

Commit f9c8adf

Browse files
authored
Merge pull request #1412 from cabanier/visibility-mask
add support for XRVisibilityMaskChangeEvent
2 parents 16ffa1e + 09a5e34 commit f9c8adf

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

index.bs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,16 +1238,19 @@ When this method is invoked, the user agent MUST run the following steps:
12381238
1. [=Populate the pose=] of |session|'s [=XRSession/viewer reference space=] in |referenceSpace| at the time represented by |frame| into |pose|, with `force emulation` set to `true`.
12391239
1. If |pose| is `null` return `null`.
12401240
1. Let |xrviews| be an empty [=/list=].
1241+
1. Let |offset| be `0`.
12411242
1. For each [=view/active=] [=view=] |view| in the [=XRSession/list of views=] on {{XRFrame/session}}, perform the following steps:
12421243
1. Let |xrview| be a new {{XRView}} object in the [=relevant realm=] of |session|.
12431244
1. Initialize |xrview|'s [=XRView/underlying view=] to |view|.
12441245
1. Initialize |xrview|'s {{XRView/eye}} to |view|'s [=view/eye=].
1246+
1. Initialize |xrview|'s {{XRView/index}} to |offset|.
12451247
1. Initialize |xrview|'s [=XRView/frame=] to |frame|.
12461248
1. Initialize |xrview|'s [=XRView/session=] to |session|.
12471249
1. Initialize |xrview|'s [=view/reference space=] to |referenceSpace|.
1248-
1. Let |offset| be an [=new=] {{XRRigidTransform}} object equal to the [=view offset=] of |view| in the [=relevant realm=] of |session|.
1249-
1. Set |xrview|'s {{XRViewGeometry/transform}} property to the result of [=multiply transforms|multiplying=] the {{XRViewerPose}}'s {{XRPose/transform}} by the |offset| transform in the relevant realm of |session|
1250-
1. [=list/Append=] |xrview| to |xrviews|
1250+
1. Let |viewtransform| be an [=new=] {{XRRigidTransform}} object equal to the [=view offset=] of |view| in the [=relevant realm=] of |session|.
1251+
1. Set |xrview|'s {{XRViewGeometry/transform}} property to the result of [=multiply transforms|multiplying=] the {{XRViewerPose}}'s {{XRPose/transform}} by the |viewtransform| transform in the relevant realm of |session|.
1252+
1. [=list/Append=] |xrview| to |xrviews|.
1253+
1. Increase |offset| by `1`.
12511254
1. Set |pose|'s {{XRViewerPose/views}} to |xrviews|
12521255
1. Return |pose|.
12531256

@@ -1574,6 +1577,7 @@ enum XREye {
15741577

15751578
[SecureContext, Exposed=Window] interface XRView {
15761579
readonly attribute XREye eye;
1580+
readonly attribute unsigned long index;
15771581
readonly attribute double? recommendedViewportScale;
15781582

15791583
undefined requestViewportScale(double? scale);
@@ -1586,6 +1590,8 @@ The {{XRViewGeometry/transform}} is given in it's [=view/reference space=].
15861590

15871591
The <dfn attribute for="XRView">eye</dfn> attribute describes the [=view/eye=] of the underlying [=view=]. This attribute's primary purpose is to ensure that pre-rendered stereo content can present the correct portion of the content to the correct eye.
15881592

1593+
The <dfn attribute for="XRView">index</dfn> attribute describes the offet of this {{XRView}} when it is return in the {{XRViewerPose/views}} array by {{XRFrame/getViewerPose()}}.
1594+
15891595
The optional <dfn attribute for="XRView">recommendedViewportScale</dfn> attribute contains a UA-recommended viewport scale value that the application can use for a {{XRView/requestViewportScale()}} call to configure dynamic viewport scaling. It is `null` if the system does not implement a heuristic or method for determining a recommended scale. If not null, the value MUST be a numeric value greater than 0.0 and less than or equal to 1.0, and MUST be [=quantization|quantized=] to avoid providing detailed performance or GPU utilization data.
15901596

15911597
Note: It is suggested to quantize the recommended viewport scale by rounding it to the nearest value from a short list of possible scale values, and using hysteresis to avoid instant changes when close to a boundary value. (This also helps avoid rapidly oscillating scale values which can be visually distracting or uncomfortable.)
@@ -2589,6 +2595,51 @@ The optional <dfn attribute for="XRReferenceSpaceEvent">transform</dfn> attribut
25892595

25902596
NOTE: situations where {{XRReferenceSpaceEvent/referenceSpace}} or {{XRReferenceSpaceEventInit/referenceSpace}} can be when the headset was doffed and donned between 2 seperate locations. In such cases, if the experience relies on world-locked content, it should warn the user and reset the scene.
25912597

2598+
XRVisibilityMaskChangeEvent {#xrvisibilitymaskchangeevent-interface}
2599+
--------------
2600+
2601+
Because the frustum does not intersect precisely with the rectangular display, the entire area of the {{XRLayer}} MAY not be displayed. This event will inform the experience about the region of the {{XRView}} that is displayed to the user.
2602+
2603+
The {{XRVisibilityMaskChangeEvent}} event is fired when the user agent wants to inform the experience that the displayed area of the {{XRLayer}} changed. The experience MAY choose to only draw that region which MAY help with performance.
2604+
2605+
NOTE: the experience MUST register this event during the promise resolution of {{XRSystem/requestSession}}. Otherwise, the event may fire and the mask will be lost to the experience.
2606+
2607+
<pre class="idl">
2608+
[SecureContext, Exposed=Window]
2609+
interface XRVisibilityMaskChangeEvent : Event {
2610+
constructor(DOMString type, XRVisibilityMaskChangeEventInit eventInitDict);
2611+
[SameObject] readonly attribute XRSession session;
2612+
readonly attribute XREye eye;
2613+
readonly attribute unsigned long index;
2614+
[SameObject] readonly attribute Float32Array vertices;
2615+
[SameObject] readonly attribute Uint32Array indices;
2616+
};
2617+
2618+
dictionary XRVisibilityMaskChangeEventInit : EventInit {
2619+
required XRSession session;
2620+
required XREye eye;
2621+
required unsigned long index;
2622+
required Float32Array vertices;
2623+
required Uint32Array indices;
2624+
};
2625+
</pre>
2626+
2627+
The <dfn attribute for="XRVisibilityMaskChangeEvent">session</dfn> attribute indicates the {{XRSession}} that generated the event.
2628+
2629+
The <dfn attribute for="XRVisibilityMaskChangeEvent">eye</dfn> attribute indicates which {{XREye}} the mask applies to.
2630+
2631+
The <dfn attribute for="XRVisibilityMaskChangeEvent">index</dfn> attribute indicates the offset into the [=XRSession/list of views=] of the {{XRView}} that this mask applies to.
2632+
2633+
The <dfn attribute for="XRVisibilityMaskChangeEvent">vertices</dfn> attribute is a [=/list=] of <code>X</code>, <code>Y</code> coordinates. The experience MUST assume that the <code>Z</code> coordinate is <code>-1</code>. Each <code>X</code>, <code>Y</code>, <code>Z</code> coordinate describes a vertex.
2634+
If this array is empty, the whole region of the {{XRView}} SHOULD be drawn.
2635+
2636+
The <dfn attribute for="XRVisibilityMaskChangeEvent">indices</dfn> attribute is a [=/list=] of indices that describe the index into the vertex list described by {{XRVisibilityMaskChangeEvent/vertices}}. These indices will describe the region of the eye's {{XRView}} that SHOULD be drawn.
2637+
If this array is empty, the whole region of the {{XRView}} SHOULD be drawn.
2638+
2639+
The area MUST be drawn using the {{XRViewGeometry/projectionMatrix}} of the {{XRView}} of {{XRVisibilityMaskChangeEvent/eye}} and a default {{XRRigidTransform}}.
2640+
2641+
NOTE: this means that the area MUST NOT use the {{XRRigidTransform}} of the current {{XRView}} of {{XRVisibilityMaskChangeEvent/eye}}.
2642+
25922643
Event Types {#event-types}
25932644
-----------
25942645

0 commit comments

Comments
 (0)