大网数据广告活动
Web 标准与前端开发

XRMediaBinding: createEquirectLayer() method

· 52CE 我爱测

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.

WebXR Device API

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 HTMLVideoElement to display.
  • options
    • : An object to configure the XREquirectLayer. The object can have the following properties and space is required:
      • centralHorizontalAngle
        • : A number indicating the central horizontal angle in radians for the sphere. Default value: 6.28318 (2π).
      • invertStereo
        • : A boolean specifying if the natural location of each view in the video should be inverted. By default false.
      • layout
        • : A string indicating the layout of the video. Possible values:
          • default
            • : The layer accommodates all views of the session.
          • mono
            • : A single XRSubImage is allocated and presented to both eyes.
          • 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 the texture-array texture type for stereo layouts.
          • stereo-left-right
            • : A single XRSubImage is 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 single XRSubImage is 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 is mono.
      • lowerVerticalAngle
        • : A number indicating the lower vertical angle in radians for the sphere. Default value: -1.570795 (-π/2).
      • radius
        • : A number indicating the radius of the sphere. Default value 0.0.
      • space Required
        • : An XRSpace object defining the layer's spatial relationship with the user's physical environment.
      • transform
        • : An XRRigidTransform object defining the offset and orientation relative to space.
      • upperVerticalAngle
        • : A number indicating the upper vertical angle in radians for the sphere. Default value: 1.570795 (π/2).

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 XRSession.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

Browser compatibility

See also

  • XREquirectLayer

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。