Fix WebVR examples with WebXR API #15830
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
webvrexamples with WebXR API have been broken in dev branch.Renderer viewport is resized in
WebGLRenderer.render()when rendering object withArrayCamerain VR mode.https://github.com/mrdoob/three.js/blob/r101/src/renderers/WebGLRenderer.js#L1306-L1321
But viewport size isn't reset when user leaves VR mode.
In r101
.setRenderTarget()resetting viewport inside was called in each.render()call then viewport was automatically reset.https://github.com/mrdoob/three.js/blob/r101/src/renderers/WebGLRenderer.js#L1106
But with #15571
.setRenderTarget()is no longer called in.render()(unless you give deprecated third argumentrenderTarget). So we need to reset viewport size when session ends inWebXRManagerlikeWebVRManagerdoes.Probably adding
renderer.setRenderTarget( renderer.getRenderTarget() );inonSessionEnd()is the easiest solution. Let me know if there is any better ideas.Update: Plus, I think we need to re-bind framebuffer from
session.baseLayer.framebufferto regular one on session end so calling.setRenderTarget()seems a good solution.