XRMediaBinding.createQuadLayer()
The createQuadLayer() method of the XRMediaBinding interface returns an XRQuadLayer object which is a layer that takes up a flat rectangular space in the virtual environment.
Syntax
createQuadLayer(video, options)
Parameters
video-
An
HTMLVideoElementto display. options-
An object to configure the
XRQuadLayer. The object can have the following properties andspaceis required:-
height: Optional. A number specifying the height of the layer. -
invertStereo: Optional. A boolean specifying if the natural location of each view in the video should be inverted. By defaultfalse. -
layout: Optional. A string indicating the layout of the video. Possible values:-
default: The layer accommodates all views of the session. -
mono: A singleXRSubImageis allocated and presented to both eyes. -
stereo: The user agent decides how it allocates theXRSubImage(one or two) and the layout (top/bottom or left/right). It is recommended to use thetexture-arraytexture type forstereolayouts. -
stereo-left-right: A singleXRSubImageis allocated. Left eye gets the left area of the texture, right eye the right. This layout is designed to minimize draw calls for content that is already in stereo (for example stereo videos or images). -
stereo-top-bottom: A singleXRSubImageis allocated. Left eye gets the top area of the texture, right eye the bottom. This layout is designed to minimize draw calls for content that is already in stereo (for example stereo videos or images).
mono. -
-
space: Required. AnXRSpaceobject defining the layer's spatial relationship with the user’s physical environment. -
transform: Optional. AnXRRigidTransformobject defining the offset and orientation relative tospace. -
width: Optional. A number specifying the width of the layer.
-
Return value
An XRQuadLayer object.
Examples
Creating an XRQuadLayer to display a video
Create an XRMediaBinding and use an HTMLVideoElement that is passed into createQuadLayer(). Configure the quad layer using the options listed above and present the layer to the XR device by adding it to the layers render state in XRSession.updateRenderState().
function onXRSessionStarted(xrSession) { const xrMediaBinding = new XRMediaBinding(xrSession); const video = document.createElement('video'); video.src = 'just-fascination.mp4'; const videoLayer = xrMediaBinding.createQuadLayer(video, { space: xrReferenceSpace }); xrSession.updateRenderState({ layers: [videoLayer] }); }
Specifications
No specification data found for api.XRMediaBinding.createQuadLayer.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.
Browser compatibility
No compatibility data found for api.XRMediaBinding.createQuadLayer.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRMediaBinding/createQuadLayer