pmndrs / react-xr

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

Improve UX by showing a hint if useHitTest returns negative #276

Open ThorstenBux opened 1 year ago

ThorstenBux commented 1 year ago

Hi,

I've successfully integrated react-xr and I love it. One thing I'd like to improve is adding feedback whenever useHitTest returns negative. In the current implementation of the hook, the callback won't be called if there isn't a hit. For an initial state that would be fine if I only set a state to scanning until the useHitTest hook is called. However, even after a successful hit result. It can happen that later hitTests fail. In that case, I wouldn't get a callback with the current implementation. For better UX I propose adding an else case to return an empty (undefined or null) hit property.

See PR https://github.com/pmndrs/react-xr/pull/275