Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRWebGLSubImage
  4. imageIndex

XRWebGLSubImage: imageIndex property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

The read-onlyimageIndex property of theXRWebGLSubImage interface is a number representing the offset into the texture array if the layer was requested withtexture-array;null otherwise.

Value

A number ornull if the layer wasn't requested withtexture-array.

UsingimageIndex

TheimageIndex property can be passedWebGL2RenderingContext.framebufferTextureLayer() to attach the depth and color textures to a framebuffer with the correct layer index.

js
const xrGlBinding = new XRWebGLBinding(xrSession, gl);const layer = xrGlBinding.createProjectionLayer({  textureType: "texture-array",});const framebuffer = gl.createFramebuffer();xrSession.updateRenderState({ layers: [layer] });xrSession.requestAnimationFrame(onXRFrame);function onXRFrame(time, xrFrame) {  xrSession.requestAnimationFrame(onXRFrame);  gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);  const viewport = xrGlBinding.getSubImage(layer, xrFrame).viewport;  gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);  for (const view in xrViewerPose.views) {    const subImage = xrGlBinding.getViewSubImage(layer, view);    gl.framebufferTextureLayer(      gl.FRAMEBUFFER,      gl.COLOR_ATTACHMENT0,      subImage.colorTexture,      0,      subImage.imageIndex,    );    gl.framebufferTextureLayer(      gl.FRAMEBUFFER,      gl.DEPTH_ATTACHMENT,      subImage.depthStencilTexture,      0,      subImage.imageIndex,    );    // Render from the viewpoint of xrView  }}

Specifications

Specification
WebXR Layers API Level 1
# dom-xrwebglsubimage-imageindex

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp