Skip to content

fix: hand mesh not visible after tracking lost/restored #227

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

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

bodo22
Copy link

@bodo22 bodo22 commented Dec 22, 2022

This should fix issue #213, but it might be a workaround for a more fundamental bug.

I recreated the problem without all the XR hand input event hassle. The issue currently arises when 2 array items are reversed in their order and the react key prop of the array is used. An example of that is here.

The root of the Problem seems to be with switchInstance in react-three-fiber. In the specific buggy scenario, switchInstance removes the second element from the parent and adds as it the first. (in the first switch), then it removes that element from the parent in the second switch (which it shouldn't). So it kind of has an old state? Maybe switchInstance should only remove elements when the position in the parent is the same?

This fix (not relying on array index anymore) causes switchInstance to not be called anymore.

For more info on why this "swapping" happens with the Quest 2:
When the Quest 2 fires an inputsourceschange event when you move a hand out of the hand tracked area, there is the removed tracked hand in the "removed" array, but also an inputsource in the "added" array. I am not sure why, maybe this is a fallback? Nonetheless, this causes 2 immediate sync events in three.js: [disconnect, connect]. In the listeners in XR.js, zustand (rightfully) swaps the order of the 2 XRControllers.

Hand mesh not visible after tracking lost/restored
@CodyJasonBennett
Copy link
Member

Awesome investigation. I'll have to look more into the switchInstance case, I'm not sure I fully understand but I'm able to recreate the behavior.

@CodyJasonBennett CodyJasonBennett changed the title fix: #213 fix: hand mesh not visible after tracking lost/restored Dec 22, 2022
@CodyJasonBennett CodyJasonBennett merged commit 351bcde into pmndrs:master Dec 22, 2022
@bodo22 bodo22 deleted the fix-hand-mesh-gone-213 branch December 22, 2022 14:18
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