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

How does the camera get updated when head is moving (HMD motion tracking) #306

Open
Truemedia opened this issue Feb 10, 2024 · 2 comments
Open

Comments

@Truemedia
Copy link

Hi, I'm currently writing some XR abstractions for vue and trying to use this library as a basis.

I have some base code working with entering VR immersive mode when clicking a button but not sure how to update the Three camera instance I have.

Looking in this codebase and with the lack of documentation it isn't obvious how that happens, I don't see anything like a setAnimationLoop for synching anything.

Could anyone divulge a bit more information on how this achieved would be a big help, thanks.

@CodyJasonBennett
Copy link
Member

setAnimationLoop is what you'll need so three.js runs its internal pose and controllers sync in WebXRManager. R3F manages this since it's a bit more complicated when rendering can be interrupted due to its frameloop API.

WebXRManager also creates an internal XRCamera where head pose is tracked; the normal camera is not mutated at all. https://threejs.org/docs/#api/en/renderers/webxr/WebXRManager.getCamera

I would familiarize yourself with the WebXR API, but also the WebXR internals of three.js. They're not super scary, just these two regions and know resizing in XR isn't supported (mrdoob/three.js#26905):

@Truemedia
Copy link
Author

Thanks i had no idea R3F had XR functionality at the core that's exactly the code I was missing.

Yeh I think I might of been messing around with cameras aswell instead of letting WebXR do some of the heavy lifting.

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

No branches or pull requests

2 participants