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

Restore original camera FOV and Zoom after XR presentation ends #30374

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

ramonmata
Copy link

Related issue: #XXXX

Description

This change restores the fov value of the camera before entering a WebXR session.

Copy link

github-actions bot commented Jan 22, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.27
78.29
336.42
78.36
+151 B
+69 B
WebGPU 511.96
142.14
511.96
142.14
+0 B
+0 B
WebGPU Nodes 511.43
142.03
511.43
142.03
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.25
112.13
465.4
112.19
+151 B
+67 B
WebGPU 585.91
158.79
585.91
158.79
+0 B
+0 B
WebGPU Nodes 541.29
148.37
541.29
148.37
+0 B
+0 B

@ramonmata
Copy link
Author

Hi,
I wanted to share a very small enhancement I made to the source code.
I have this Three.js scene with a camera, and after ending the WebXR session, the scene appeared smaller.

I noticed that the camera FOV had changed from 50 to 74.999.

So I made this changes in case you find it useful.

Best regards

Comment on lines 636 to 641
if ( camera.userData.previousFov === undefined ) {

camera.userData.previousFov = camera.fov;

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camera fov and zoom should be memoized at the top-level of this class and overriden/restored on sessionstart and sessionend. You will find this for renderer properties, and it would be the same here.

WebGLRender has been restored, now it is not involved at all.
@ramonmata
Copy link
Author

Code has been updated as per comments

@ramonmata ramonmata changed the title Restore original camera FOV after XR presentation ends Restore original camera FOV and Zoom after XR presentation ends Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants