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
230 stars 33 forks source link

GearVR Controller Support? #5

Open jbroberg opened 7 years ago

jbroberg commented 7 years ago

I know this is not specifically mentioned as supported, but I tried out the GearVR Controller with a GearVR and a Samsung S6.

Trying the demo page on this project, I got the following results:

Let me know if there is any useful debugging info I can provide for this controller.

Cheers! - James

stewdio commented 6 years ago

I would love to support the GearVR controller! This may be a bit of a pain, but can you download and open Chrome on your phone, plug your phone into your computer, then connect your phone’s open Chrome tab to your computer’s like so: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

Once you do that you can interact with the JavaScript console. Load up the demo site and then in your console paste and enter this to enable full verbose mode: THREE.VRController.verbosity = 1

Now when you interact with the trackpad or buttons you should get a lot of output in the console. What you need to do is interact with each piece of the controller and see what button index # is receiving that interaction. My guess is the thumpad has a touch, a press, and axes and is index #0. See if that’s what’s showing up in the console and also check out the other buttons. We can use that info to add in explicit support :wink:

Try to be thorough and keep notes. It’s the subtleties that make all the difference! (Does this button have a press state? A touch state? An analog value—and if so at what point does a press begin and is that the same threshold for ending a press? Does +1 on the Y axis mean top or bottom? And so on.) Here’s what I did as an example: https://github.com/stewdio/THREE.VRController/blob/master/VRController.js#L451

stewdio commented 6 years ago

I also just made a super tiny update that should allow your GearVR primary button to work with the example’s "primary press began" event listener even though we haven’t explicitly mapped the buttons yet: https://github.com/stewdio/THREE.VRController/blob/master/VRController.js#L95

If you can, give that a go and tell me if it works. It makes a pretty big assumption that the primary button is going to be at index === 0 in the buttons array but that’s what I’m seeing with the Vive, Oculus, and Daydream ... so I’m hoping that’s the norm!

jbroberg commented 6 years ago

I haven't done the full logging yet, but I can confirm I can now:

The button does not work outside VR mode but this is probably expected.

stewdio commented 6 years ago

Wow that is awesome! (Thank you for testing it out!)

When you say the button does not work outside VR mode, are you able to see the controller at all before entering VR? If you don’t see it at all then I think what might be happening is that prior to calling vrDisplay.requestPresent() the GearVR does not engage its VR internals and connect to the controller. (But this is just a guess! It would be similar to how Daydream seems to operate.)

jbroberg commented 6 years ago

I can see the controller outside the VR mode, but what I am seeing is the GearVR interface and their rendered representation of the controller. The browser is just a floating window inside the GearVR interface/UI.

I can point to items in the scene, they highlight the item I am pointing at them (e.g. the dat.guiVR floating menu) but the click is ineffective on the scene - I can't click the elements, drag the UI, etc - when outside VR mode.

Within VR mode everything works as expected. I guess the above is not that surprising but just an observation.

mkeblx commented 6 years ago

I'll check this out presently.

danrossi commented 6 years ago

I had to fork this project to start working on GearVR support. it should work like the DayDream one. So this makes the thumbpad the primary not the trigger.

'Gear VR Controller': {

        style: 'gearvr',

        //  THUMBPAD
        //  Both a 2D trackpad and a button with both touch and press. 
        //  The Y-axis is “Regular”.
        //
        //              Top: Y = -1
        //                   ↑
        //    Left: X = -1 ←─┼─→ Right: X = +1
        //                   ↓
        //           Bottom: Y = +1

        axes: [{ name: 'thumbpad', indexes: [ 0, 1 ]}],
        buttons: [ 'thumbpad' ],
        primary: 'thumbpad'
    },
danrossi commented 6 years ago

Should I do a PR for this change ? It is working with GearVR

https://github.com/danrossi/THREE.VRController/blob/master/VRController.js#L864

paulmasson commented 5 years ago

@danrossi are you still planning to do a PR to add this support? I added Oculus Go yesterday and can do this as well if you no longer want to do so.

whatisor commented 5 years ago

@paulmasson I am using Oculus Go with this controller: https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrinput/#unity-ovrinput-go-controller However, I cannot find which event for touchpad event (touch position or swipe action?)

paulmasson commented 5 years ago

@whatisor if you have the Go connected to your computer and have set THREE.VRController.verbosity = 1 in the Chrome JavaScript console, then you'll see all the events. You're probably looking for thumbpad axes changed.

danrossi commented 5 years ago

Another one to add support for ! I will look at adding a PR. However I think I may have made more modifications to mine and looking at complete refactor to Es6 so I can import it property into a three.js bundle !

whatisor commented 5 years ago

@paulmasson Thank you, I found it as "axes changed" from aframe sample.