XRSession.updateRenderState() - Web APIs 编辑

Draft

This page is not complete.

Secure context

This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The updateRenderState() method of the XRSession interface of WebXR API schedules changes to be applied to the active render state prior to rendering of the next frame.

Syntax

xrSession.updateRenderState(newState)

Parameters

newState
An object conforming to the XRRenderStateInit dictionary specifying the properties of the session's renderState to update before rendering the next frame.

The specified object may have any combination of the following fields.

baseLayer Optional
An XRWebGLLayer object from which the WebXR compositor will obtain imagery. This is null by default.
depthFar Optional
A floating-point value specifying the distance in meters from the viewer to the far clip plane, which is a plane parallel to the display surface beyond which no further rendering will occur. All rendering will take place between the distances specified by depthNear and depthFar. This is 1000 meters (1 kilometer) by default.
depthNear Optional
A floating-point value indicating the distance in meters from the viewer to a plane parallel to the display surface to be the near clip plane. No part of the scene on the viewer's side of this plane will be rendered. This is 0.1 meters (10 centimeters) by default.
inlineVerticalFieldOfView Optional
A floating-point value indicating the default field of view, in radians, to be used when computing the projection matrix for an inline XRSession. The projection matrix calculation also takes into account the output canvas's aspect ratio. This property must not be specified for immersive sessions, so the value is null by default for immersive sessions. The default value is otherwise π * 0.5 (half of the value of pi).

Return value

None.

Exceptions

This method may throw any of the following exceptions. These are true exceptions, since this method does not return a promise.

InvalidStateError

This may occur for one of the following reasons:

  • The XRSession has already ended, so you cannot change its render state.
  • The baseLayer specified in newState was created by an XRSession other than the one on which updateRenderState() was called.
  • The inlineVerticalFieldOfView property was set, but the session is immersive and therefore does not allow this property to be used.

Examples

This example creates a WebGL context that is compatible with an immersive XR device and then uses it to create an XRWebGLLayerupdateRenderState() is then called to associate the new XRWebGLLayer.

function onXRSessionStarted(xrSession) {
  let glCanvas = document.createElement("canvas");
  let gl = glCanvas.getContext("webgl", { xrCompatible: true });

  loadWebGLResources();

  xrSession.updateRenderState({ baseLayer: new XRWebGLLayer(xrSession, gl) });
}

Specifications

SpecificationStatusComment
WebXR Device API
The definition of 'XRSession.updateRenderState()' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:92 次

字数:6222

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文