Added squeeze* input events for WebVR and WebXR Managers#17938
Added squeeze* input events for WebVR and WebXR Managers#17938mrdoob merged 2 commits intomrdoob:devfrom
Conversation
src/renderers/webvr/WebVRManager.js
Outdated
|
|
||
| // Grip | ||
|
|
||
| buttonId = gamepad.buttons.length > 2 ? 2 : 0; |
There was a problem hiding this comment.
@mrdoob On all the controllers (unless daydream) index=1 is the main button/trigger (the one used on the selecttart/end) and index=2 is the grip.
If the controller has enough buttons to have an index=2, let's use that as it will be the grip, otherwise use the index=0 that in the daydream controller will be sharing the same action as the selectstart/end, and on the other controllers will be using the button they have mapped on 0
There was a problem hiding this comment.
well it could also be gamepad.buttons[2] ? 2 : 0
There was a problem hiding this comment.
otherwise use the index=0 that in the daydream controller will be sharing the same action as the selectstart/end
Uh... Is that what Daydream does with WebXR? Using the same button for select and for squeeze?
There was a problem hiding this comment.
Ok, I have just checked it on daydream and it does not behave like that, it just doesn't support squeeze events at all. So I updated the code to prevent emitting events if grip is not present (buttons[2] === undefined)
|
Looks good now 👌 |
|
Thanks! |
|
Would be nice to update the shapes dragging demo to use this! |
|
I'm not sure that's a good idea. Normal select for dragging makes more sense to me. The only use case I'm aware of right now of squeeze is when you want to scale up/down a scene. |
|
It's both, it's intended to be for scaling things as well as "picking up" objects. E.g. in Superhot VR you use the squeeze to pick up objects. The dragging demo currently lets you point and shapes and kind of "puppet" them around, but it doesn't quite let you reach into a shape and pick it up with a squeeze. |
The new WebXR API introduces a set of new events for input:
squeezestart,squeezeend, andsqueezewhen using thegrip(https://immersive-web.github.io/webxr/#eventdef-xrsession-squeezestart) similar to the previously existingselectstart,selectend, andselect.Added them to the
WebXRManager, and a fallback to the WebVRManager, using thegripbutton ID that in the current controllers is on number 2 (Oculus, WMR, Vive) if the controller has enough buttons, otherwise use just the index 0 button.