Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Update VRController.js to handle WMR controller's disconnected event correctly.#24

Open
lehoangphu wants to merge 1 commit intopuckey:masterfrom
lehoangphu:patch-2
Open

Update VRController.js to handle WMR controller's disconnected event correctly.#24
lehoangphu wants to merge 1 commit intopuckey:masterfrom
lehoangphu:patch-2

Conversation

@lehoangphu
Copy link

THREE.VRController.update needs to be awared when a controller is disconnected, else it will operate on a stale this.controllers[index] and never update it with the new gamepad object.

@stewdio
Copy link
Collaborator

stewdio commented Aug 3, 2018

Hi @lehoangphu. Can you provide some more detail? This is specifically for Windows Mixed Reality controllers? And that means it’s also specific to Microsoft Edge?

@lehoangphu
Copy link
Author

lehoangphu commented Aug 3, 2018

Yes, this is specific to Edge and Windows Mixed Reality. This is very easy to repro, all you need is to turn off the controller and turn it back on while in exclusive view (VR) and it will hit some exception and could not complete the RAF call.

The detail flow goes like this:
. When the controller is connected, the gamepad object is saved at this.controller[x]
. then when the controller is disconnected, the saved this.controller[x] is still in your array but the object is gone (all null)
. then when the controller is reconnected again, it see that both gamepads[x] and this.controller[x] are both non-null so it does not update, then goes on to consume this.controller[x] which is already stale.

@lehoangphu
Copy link
Author

Hi Stewart, is this (stew@rtsmith.io) a good email to reach you at?

@brandf
Copy link

brandf commented Aug 10, 2018

It looks like the code for VRController is in third_party but I don't see you contributing this patch upstream:

https://github.com/stewdio/THREE.VRController

I believe the correct thing to do is to contribute this patch there, and then do another patch in dance-tonight to pick up the latest drop. Otherwise you're just fixing one experience rather than all of the experiences that depend on VRController.

Bonus points would be to contribute npm support to VRController so dance-tonight could use an npm dependency instead of copying code into third_party.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants