Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebXR: Provide way to get XR viewport resolution when presenting #21188

Closed
gkjohnson opened this issue Feb 1, 2021 · 3 comments · Fixed by #26160 or #26905
Closed

WebXR: Provide way to get XR viewport resolution when presenting #21188

gkjohnson opened this issue Feb 1, 2021 · 3 comments · Fixed by #26160 or #26905

Comments

@gkjohnson
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

The 3DTilesRenderJS project requires information about the screen resolution in order to derive screen error and determine which 3d tiles data to render. Right now WebGLRenderer.getResolution and WebGLRenderer.getViewport both provide the resolution of the canvas rather than the render resolution of the VR device.

Describe the solution you'd like

I would like a supported way to read the viewport or resolution of the XR device when XRManager is presenting or for WebGLRenderer.getResolution to return the resolution of the XR device when presenting. This information is already available on the camera.viewport vector for each eye camera but is not exposed in any documented way.

Describe alternatives you've considered

Related to #21002 to work around this I use the undocumented WebXRManager.getCamera( camera ) and wait until the list of cameras is populated in order to read the viewport of one of the eye cameras. The viewport is not available for the first frame after beginning presenting.

@dbuck
Copy link
Contributor

dbuck commented Apr 13, 2021

Is the framebuffer resolution useful there, that's a documented property of the baseLayer? (At least in the webxr api, if not in the three xrframe? I haven't looked since that was added.)

    if (session.renderState.baseLayer) {
      const { framebufferWidth, framebufferHeight } = session.renderState.baseLayer;
      console.log(`Session framebuffer`, { framebufferWidth, framebufferHeight });
    }

A couple other non documented routes:

Stash the XRFrame, which is the second arg to setAnimationLoop when xr is presenting, and use getViewerPose / reference spaces to read the viewports from there :|

Another is hackily checking in a scene.onBeforeRender whether the camera is an ArrayCamera && xr.isPresenting and reading them from there heh.

@CodyJasonBennett
Copy link
Contributor

CodyJasonBennett commented Oct 6, 2023

This will need to be re-opened unless you pick changes to WebXRManager from #26160 which was reverted.

@Mugen87 Mugen87 reopened this Oct 6, 2023
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 6, 2023

It would be great if you could file a separate PR with the code related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants