草案
此页面不完整。

安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

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

句法

xrSession.updateRenderState(newState)
					

参数

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 可选
XRWebGLLayer object from which the WebXR compositor will obtain imagery. This is null 在默认情况下。
depthFar 可选
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 可选
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 可选
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 不必 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).

返回值

None.

异常

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:

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

范例

This example creates a WebGL context that is compatible with an immersive XR device and then uses it to create an XRWebGLLayer . updateRenderState() 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) });
}
					

规范

规范 状态 注释
WebXR 设备 API
The definition of 'XRSession.updateRenderState()' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
updateRenderState() Chrome 79 Edge 79 Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 79 Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 11.2

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: