pmndrs / react-xr

🤳 VR/AR with react-three-fiber
https://npmjs.com/@react-three/xr
MIT License
1.98k stars 137 forks source link

fix: add controller immediately to available controllers if inputSource exists already #305

Closed kahlstrm closed 4 months ago

kahlstrm commented 5 months ago

Currently when starting up an application with Oculus Quest 3, the controllers don't come up until you make them disconnect and then reconnect (this means spamming the oculus button a couple of times and returning to the app), which then causes the connected eventListener to trigger.

Crude fix I found working for my case was to check during handler if inputSource already exists for specific id, and then just immediately add to the list of working controllers.

codesandbox-ci[bot] commented 5 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c6bd3ec13e7e9697f7d5a99afa4ea4fa4f42fcf0:

Sandbox Source
examples Configuration
kahlstrm commented 5 months ago

This has seemingly broken Controllers-component for me, will try to figure why this is.

kahlstrm commented 5 months ago

This has seemingly broken Controllers-component for me, will try to figure why this is.

Hmm, never mind? I'm running this locally against my project with npm link ../react-xr and this way the model breaks, but it breaks regardless of this change or not.

kahlstrm commented 5 months ago

Can confirm that specific bug occurred only due to the npm link behavior, no problems with Controllers if I manually edit the XR.js in node_modules

CodyJasonBennett commented 5 months ago

Does this app use StrictMode? That might explain the bug or multiple copies of React.

kahlstrm commented 5 months ago

Yeah I think it's running StrictMode, is it not supported? I can try to remove it and see if I can replicate the bug. I can also try and spin up a small example app

kahlstrm commented 4 months ago

Hmm, can confirm I don't experience the same behavior with the example app (even though it does have React.StrictMode in index.tsx). Will try to figure out what's wrong with my app.

kahlstrm commented 4 months ago

Yeah, this was due to us having code that tries to manage if vr is enabled with our own zustand store or not instead of using useXR. This code was not written by me so didn't have a good grasp on what to start debugging by. Sorry for bothering and thanks for the help!