-
Notifications
You must be signed in to change notification settings - Fork 19
Description
According to the WebXR Layers API spec the width and height of an XRQuadLayer are the dimension of the layer in meters. In practice however it seems that they are "half" width and height. From the center position of the layer, the quad extends width to the left and right, and height up and down. Resulting in a 2 * width by 2 * height quad.
This can be observed with the Meta Quest Browser on Quest devices, as well as with the webxr-layers-polyfill. Not sure if there are other XR devices/browsers implementing it this way or if they implement it according to the spec.
Spec
The width and height attributes set and return the width and height of the layer in meters.
(Source: https://www.w3.org/TR/webxrlayers-1/#dom-xrquadlayer-width)
Usages
Various libraries and frameworks already account for this discrepancy when creating layers:
- Three.js: https://github.com/mrdoob/three.js/blob/dev/src/renderers/common/XRManager.js#L1523-L1524
- A-Frame: https://github.com/aframevr/aframe/blob/master/src/components/layer.js#L258-L262
- webxr-layers-polyfill: https://github.com/immersive-web/webxr-layers-polyfill/blob/main/src/gl/quad-renderer.ts#L32-L57
- WebXR Samples > Layer Samples > Layer VS Non-Layer
- Quad layer is created with
width = 1andheight = 1: https://github.com/immersive-web/webxr-samples/blob/main/layers-samples/quad-ab-test.html#L173-L174 - Non-layer quad is created with size 2 (= 2x2): https://github.com/immersive-web/webxr-samples/blob/main/layers-samples/quad-ab-test.html#L88
- Quad layer is created with
Ideally the implementation(s) would be fixed so that the width and height properties match the actual dimensions. Though, given the above list, it might be easier to change the wording in the spec instead.