stewdio / THREE.VRController

Support hand controllers for Oculus, Vive, Windows Mixed Reality, Daydream, GearVR, and more by adding VRController to your existing Three.js-based WebVR project.
https://stewdio.github.io/THREE.VRController/
MIT License
229 stars 32 forks source link

Support xbox controller, gear vr touchpad and controller, and oculus remote #1

Closed davidlyons closed 6 years ago

davidlyons commented 7 years ago

While the xbox controller isn't necessarily a VR specific controller, it is a gamepad that you might still use in VR, so it would make sense to me to include it here since it's handled the same way. Although, it has two axes, but the state is only stored for the first one right now. Also, I think it has a different id in Firefox (xinput?), but need to double check.

stewdio commented 7 years ago

Hi David. Thanks for your interest! Does the Xbox controller return a pose object with an orientation property? Right now I’m only aiming to support controllers that can be located in space. (With a 6DOF controller that’s easy, with a 3DOF we can make reasonable guesses using the OrientationArmModel.)

I see you’ve also included Gear VR Controller, Gear VR Touchpad, and Oculus Remote. I don’t have a Rift or GearVR handy so I can’t verify. But the style properties should definitely match the controller device so that a developer can make decisions based on these simple strings (rather than the gamepad.id which in cases like the Vive doesn’t match what the device is!) and also so in the future visuals can be loaded based on this. (So Gear VR Controller’s style should probably be gearvr-controller instead of daydream. Gear VR Touchpad might be gearvr-touchpad. Oculus Remote as oculus-remote instead of just remote, etc.

davidlyons commented 7 years ago

Oh, no, the Xbox controller doesn't have a pose object. Neither does the Gear VR Touchpad or Oculus Remote. Their poses are either null or undefined, which is why I moved the listenForButtonEvents above the pose check in update. But both are technically VR controllers, made for and also included with their VR displays. Assuming their locations isn't far off from guessing the location of a 3DOF controller with OrientationArmModel. I can keep my hand at about the same orientation while moving it around and the visual won't move. With a 0DOF controller, I'm probably going to be holding it out in front of me, with my elbow at my sides at a ~90 degree angle. And with GearVR Touchpad, while it doesn't have a pose, it's built into the VR display, which does have a pose with an orientation. So I left the controller support in, but I'll let you decide if you want to merge it. :) I also updated the style properties to match the device.

Thanks!

stewdio commented 7 years ago

Huh. You bring up a really good point with the GearVR Touchpad. (And thanks for those other edits, btw!) Ok... I should probably get my hands on the latest GearVR stuff and wrap my head around what’s going on. You’ve given me something new to think about!