web api instance method
XRMediaBinding: createEquirectLayer() method
Limited availability
The createEquirectLayer() method of the XRMediaBinding interface returns an XREquirectLayer object which is a layer that maps an equirectangular coded data onto the inside of a sphere.
Syntax
createEquirectLayer(video, options)
Parameters
video- : An
HTMLVideoElementto display.
- : An
options- : An object to configure the
XREquirectLayer. The object can have the following properties andspaceis required:centralHorizontalAngleOptional- : A number indicating the central horizontal angle in radians for the sphere. Default value:
6.28318(2π).
- : A number indicating the central horizontal angle in radians for the sphere. Default value:
invertStereoOptional- : A boolean specifying if the natural location of each view in the video should be inverted. By default
false.
- : A boolean specifying if the natural location of each view in the video should be inverted. By default
layoutOptional- : A string indicating the layout of the video. Possible values:
default- : The layer accommodates all views of the session.
mono- : A single
XRSubImageis allocated and presented to both eyes.
- : A single
stereo- : The user agent decides how it allocates the
XRSubImage(one or two) and the layout (top/bottom or left/right). It is recommended to use thetexture-arraytexture type forstereolayouts.
- : The user agent decides how it allocates the
stereo-left-right- : A single
XRSubImageis 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).
- : A single
stereo-top-bottom- : A single
XRSubImageis 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). The default value ismono.
- : A single
- : A string indicating the layout of the video. Possible values:
lowerVerticalAngleOptional- : A number indicating the lower vertical angle in radians for the sphere. Default value:
-1.570795(-π/2).
- : A number indicating the lower vertical angle in radians for the sphere. Default value:
radiusOptional- : A number indicating the radius of the sphere. Default value
0.0.
- : A number indicating the radius of the sphere. Default value
spaceRequired- : An
XRSpaceobject defining the layer’s spatial relationship with the user’s physical environment.
- : An
transformOptional- : An
XRRigidTransformobject defining the offset and orientation relative tospace.
- : An
upperVerticalAngleOptional- : A number indicating the upper vertical angle in radians for the sphere. Default value:
1.570795(π/2).
- : A number indicating the upper vertical angle in radians for the sphere. Default value:
- : An object to configure the
Return value
An XREquirectLayer object.
Examples
Creating an XREquirectLayer to display a video
Create an XRMediaBinding and use an HTMLVideoElement that is passed into createEquirectLayer(). 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 updateRenderState().
function onXRSessionStarted(xrSession) {
const xrMediaBinding = new XRMediaBinding(xrSession);
const video = document.createElement("video");
video.src = "just-fascination.mp4";
const videoLayer = xrMediaBinding.createEquirectLayer(video, {
space: xrReferenceSpace,
});
xrSession.updateRenderState({
layers: [videoLayer],
});
}
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.