-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebXRManager: synchronize sizing with renderer #26905
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@gkjohnson Does the PR also look good to you? |
Just for context - in my use case I was using the the dimensions stored internally on the left eye camera: const xrCamera = renderer.xr.getCamera( camera );
const leftCam = xrCamera.cameras[ 0 ];
const width = leftCam.viewport.z;
const height = leftCam.viewport.w;
tiles.setResolution( xrCamera, width, height ); I assume the glProjLayer and glBaseLayer fields will give the same values, though. I don't know if overwriting the WebGLRenderer pixel ratio and internal canvas size is what I would do, though. Isn't it the case that things like window resize and other dom sizing events can still fire while WebXR is enabled? These are functions where people set the canvas dimensions. If this happens the renderer size and pixel ratio would become out of sync. Does it make sense to add let dpr = 1;
const resolution = new Vector2();
if ( renderer.xr.isPresenting ) {
renderer.xr.getSize( resolution );
dpr = 1;
} else {
renderer.getSize( resolution );
dpr = renderer.getPixelRatio();
} |
Resizing while presenting is currently blocked, but otherwise window events wouldn't come up for immersive sessions and only inline/emulator. three.js/src/renderers/WebGLRenderer.js Lines 424 to 431 in 3eec0e7
I would expect |
I didn't realize that - that behavior seems a bit odd to me. Is there an issue on why that was needed? What happens if the web browser is resized during an XR session (ie in desktop VR)? This must mean the canvas doesn't have the correct scale on exiting VR? Maybe I'm misunderstanding something.
This isn't how it works currently, though, I don't feel? When the draw target is set to a WebGLRenderTarget, for example, If everyone else thinks this approach is best, though, then we should merge it! |
I'm tracing that back to d981806 of r86 which was before WebXR -- WebVR. Looks to be related to #13225.
It is only when targeting the underlying drawing surface or the |
I'm having trouble setting up my oculus at the moment to test due to some account issues - but I'm still curious about what happens when you resize the page and then exit VR.
I understand why this is necessary. I'm just suggesting that it could be the apps responsibility to measure or pick what it's target drawing surface is and adjust accordingly - which could be the canvas, a render target, or XR layer. If you actually can't adjust the canvas during an XR session then this implementation makes sense. Either way this can be tested later or reevaluated if it causes an issue. Let's merge it. |
Fixed #21188.
Description
Ensures that
WebGLRenderer.getSize
andWebGLRenderer.getDrawingBufferSize
report correctly when in a WebXR session.