-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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: Update camera's local matrix and transform properties. #19085
Conversation
@mrdoob can we get also this small PR in r116? 🙏🙏🙏 |
Another user stumbled across a similar issue today: |
Hiding content for another issueI just started on some WebXR development and I think the current behavior is very confusing, though I understand why it was done that way. Either way it would be nice to have some public way to get the parameters of the VR camera including the position, rotation, and union frustum. If the matrix and local properties are going to be updated perhaps the frustum, fov, etc can be, too? Generally parenting something like UI in VR is bad practice so you need the transform of the camera to float UI elements into place with the frustum being useful for placement. My use case was for implementing a VR example in the 3dTilesRendererJS project which requires the transform and frustum of the camera to compute custom frustum culling and error calculations to determine tile visibility. My workaround right now is to call let currentCamera = camera;
if ( renderer.xr.isPresenting ) {
// this camera has the correct transform and frustum information
currentCamera = renderer.xr.getCamera( camera );
} Perhaps updating the VR camera should be an explicit action? For the use cases I listed above you want to get the new VR, perform some kind of operation (culling, UI updatesm, etc), then render. An renderer.xr.autoUpdate = false;
renderer.xr.updateVRCamera( camera );
const vrCamera = renderer.xr.getVRCameraInstance();
// update stuff...
renderer.render( scene, camera ); |
That is correct. It's an internal method. TBH, I don't think your post belongs to this PR. If you want to propose a new API in context of WebXR, please make a separate issue for this. The PR fixes an obvious bug in |
Yup, also it is very confusing accessing My use case was shooting a ball from the camera in AR. |
Oh I definitely agree and I think this is an improvement. I didn't mean to detract from this PR just that there are other related use cases still not covered that could be tackled, as well, but I understand they expand the scope. |
Thanks! |
One side effect of this change is that when we the user leaves the XR experience, the camera will be the last place where the user head was at. Should the |
TBH, I always felt this is the expected behavior. But I guess the "ideal" camera behavior depends on personal preferences. |
Okay, we'll see what people say. |
My use-case was exactly the one of model-viewer, I had a simple 3d scene with OrbitControls and an AR button. |
Isn't that what model-viewer does? |
Yeah but my AR scene was dynamic 😉 |
Ah, right... Okay. |
I'm dealing with this issue as well in a VR app using Three.js. In my view, it would make sense if the camera remained in the headset's last position and rotation when the user exits the XR experience. |
Try today's release. I think it should behave like that. |
Works great, thanks! |
Fixed #18448.
Fixed #20920.
This would potentially overwrite user-defined values but since the world matrix is also set, I think this approach is more consistent and avoids side effects like in the above issue.