Skip to content

Added squeeze* input events for WebVR and WebXR Managers#17938

Merged
mrdoob merged 2 commits intomrdoob:devfrom
fernandojsg:squeeze
Nov 21, 2019
Merged

Added squeeze* input events for WebVR and WebXR Managers#17938
mrdoob merged 2 commits intomrdoob:devfrom
fernandojsg:squeeze

Conversation

@fernandojsg
Copy link
Collaborator

@fernandojsg fernandojsg commented Nov 15, 2019

The new WebXR API introduces a set of new events for input: squeezestart, squeezeend, and squeeze when using the grip (https://immersive-web.github.io/webxr/#eventdef-xrsession-squeezestart) similar to the previously existing selectstart, selectend, and select.
Added them to the WebXRManager, and a fallback to the WebVRManager, using the grip button 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.

@mrdoob mrdoob added this to the r111 milestone Nov 19, 2019

// Grip

buttonId = gamepad.buttons.length > 2 ? 2 : 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this line?

Copy link
Collaborator Author

@fernandojsg fernandojsg Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well it could also be gamepad.buttons[2] ? 2 : 0

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@mrdoob
Copy link
Owner

mrdoob commented Nov 21, 2019

Looks good now 👌

@mrdoob mrdoob merged commit 3f16519 into mrdoob:dev Nov 21, 2019
@mrdoob
Copy link
Owner

mrdoob commented Nov 21, 2019

Thanks!

@fernandojsg fernandojsg deleted the squeeze branch November 21, 2019 09:09
@Manishearth
Copy link

Would be nice to update the shapes dragging demo to use this!

@mrdoob
Copy link
Owner

mrdoob commented Nov 21, 2019

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.

@Manishearth
Copy link

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.

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.

3 participants