Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "controllermove" event to WebXRController #20790

Merged
merged 1 commit into from
Apr 22, 2021
Merged

Added "controllermove" event to WebXRController #20790

merged 1 commit into from
Apr 22, 2021

Conversation

arodic
Copy link
Sponsor Contributor

@arodic arodic commented Nov 30, 2020

This is a requirement to make #20720 work in WebXR.

The problem it solves:

Right now WebXRControllers emit various events such as select, selectstart, selectend, squeeze, squeezestart, squeezeend, pinchend, pinchstart, connected and disconnected. But no event is fired when controllers move. The only way to get controller movement is to continuously pull transformation from rAF.

I would like to be able to use controllers in a similar fashion as other input devices (mouse, touch, pen, keyboard...) strictly via event listeners. I think this PR will enable that at least for simple click (select) and drag gesture.

@arodic arodic closed this Dec 25, 2020
@mrdoob
Copy link
Owner

mrdoob commented Dec 26, 2020

Closed?

@arodic
Copy link
Sponsor Contributor Author

arodic commented Dec 26, 2020

Closed?

I merged into it to #20720 source branch. Do you prefer to keep it in a separate PR?

@mrdoob
Copy link
Owner

mrdoob commented Dec 27, 2020

There's another PR enhancing WebXRManager: #20696
The more complex the PR = the more conflicts there will be = the longer will take to be merged.

@arodic
Copy link
Sponsor Contributor Author

arodic commented Dec 27, 2020

Ok, closing #20949 in favor of this one.

@arodic arodic reopened this Dec 27, 2020
@arodic arodic mentioned this pull request Dec 27, 2020
8 tasks
@mrdoob
Copy link
Owner

mrdoob commented Dec 30, 2020

Realistically, don't vr controllers move all the time?

@arodic
Copy link
Sponsor Contributor Author

arodic commented Jan 2, 2021

Realistically, don't vr controllers move all the time?

Yes @mrdoob, while they are active in the session they do move on every frame.

In the context of XR support for TransformControls, I am trying to get XR controller input events, exactly like pointer and keyboard input. We already have events selectstart and selectend which are equivalent to pointerdown and pointerup from UX perspective. However, there is no equivalent to 'pointermove`. The problem is that without that event, TransformControls would need to do one of the following:

  1. Run internal XR-rAF all the time to get controller movement.
  2. Start internal XR-rAF on selectstart to get movement values and stop it on selectend.
  3. Require application to call updateXRControllers() externally from the application rAF.

Options 1 and 2 are not ideal because suddenly it requires internal animation loop to get user input. Option 3 is the other side of the same coin, it requires application to continuously update() controls which was not necessary for pointers.

I'm not that familiar with WebXR APIs but I find the design of the event system somewhat incomplete. We have some events for two primary (special) controller buttons - selectend, selectstart, squeeze, squeezeend and squeezestart - which nicely maps to familiar pointer/keyboard down/up events but it is missing the key *move event. At the same time, all other buttons are mapped to the GamePad API which afaik does not have button events at all and requires continuous pulling of buttons states.

Ideally, I would love to be able to use XR Controllers and their GamePads exactly like mouse and keyboard, by attaching event listeners. Would that ever be possible? Was that discussed for the WebXR spec? Ping @toji

@gkjohnson gkjohnson mentioned this pull request Jan 16, 2021
@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 19, 2021

I understand the motivation but continuously firing controllermove while in XR seems not right to me. As mentioned by @mrdoob in #20790 (comment), controllers in XR move all the time so it seems confusing to fire an event for something which is always happening.

I am trying to get XR controller input events, exactly like pointer and keyboard input.

I'm not sure this approach is right considering the difference in interaction between XR and classic mouse/keyboard and touch. To me, the concept of pointermove makes sense in this context but not in XR.

@arodic
Copy link
Sponsor Contributor Author

arodic commented Apr 9, 2021

Realistically, don't vr controllers move all the time?

Yes @mrdoob, whenever they are being tracked. If turn off a controller or move it outside the tracking are it will stop emitting this event. This is similar behavior as pointer with stylus devices.

Without this event, XR controls would need to either:

  1. Implement internal rAF(WebXR) to continuously read controller positions.
  2. Rely on applications calling update() from within their own rAF.

If event mechanism is not an option, personally I lean towards former.

Closing due to no traction on this PR.

@arodic arodic closed this Apr 9, 2021
@mrdoob mrdoob reopened this Apr 22, 2021
@mrdoob
Copy link
Owner

mrdoob commented Apr 22, 2021

Now that I'm trying to get DAT.GUI working inside VR I can see why this is needed 😇

@mrdoob
Copy link
Owner

mrdoob commented Apr 22, 2021

I think I'm going to rename it to move though.

@mrdoob mrdoob added this to the r128 milestone Apr 22, 2021
@mrdoob mrdoob merged commit 1578a2f into mrdoob:dev Apr 22, 2021
@mrdoob
Copy link
Owner

mrdoob commented Apr 22, 2021

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Apr 22, 2021

Oh, hold on... Still not sure about this.
Don't we just need a single event being dispatched from controller?

mrdoob added a commit that referenced this pull request Apr 22, 2021
mrdoob added a commit that referenced this pull request Apr 22, 2021
@mrdoob mrdoob removed this from the r128 milestone Apr 22, 2021
@mrdoob
Copy link
Owner

mrdoob commented Apr 22, 2021

@arodic does this work for you? a63ff05

@arodic
Copy link
Sponsor Contributor Author

arodic commented Apr 22, 2021

I think it should work @mrdoob. Let me check...

@arodic arodic deleted the xrControllerMove branch April 19, 2022 06:54
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.

None yet

3 participants