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

hand-controls: also emit the raw gesture event #4722

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Elettrotecnica
Copy link
Contributor

In my use case, I have created a custom component that is just a pair of hands that receive their position and gesture from a network backend. My need is that of mirroring whatever gesture has been emitted by a hand-control enabled entity, send it through the network and let my avatar's "remote hands" play the gesture to my peers.

I could immagine though, that other people might find useful to handle any kind of supported gesture, and in the code I have realized there is sometimes the need to know from which gesture we come from, therefore I have also added the lastGesture in the event payload.

All the best

@dmarcos
Copy link
Member

dmarcos commented Nov 15, 2020

Thanks. Not sure yet if this should be part of hand-controls. It looks like it can be handled on the application side as you did. I understand the convenience in your case. I would like to see though where this is useful beyond that.

@dmarcos
Copy link
Member

dmarcos commented Nov 15, 2020

Another note. This is emitting a new event gesture on top of the gesture event. If we were to merge this I would add last gesture to the existing event.

@Elettrotecnica
Copy link
Contributor Author

Thanks for your feedback.

Something that would work out for me is also that the events triggered inside hand-controls would span through the whole set of supported gestures. Right now 3 gestures would emit (at least) an event:

// Map animation to public events for the API.                                                                                                                                                                                                                                           
var EVENTS = {};
EVENTS[ANIMATIONS.fist] = 'grip';
EVENTS[ANIMATIONS.thumbUp] = 'pistol';
EVENTS[ANIMATIONS.point] = 'pointing';

But the total number of gestures is 6:

// Poses.                                                                                                                                                                                                                                                                                 
var ANIMATIONS = {
  open: 'Open',
  // point: grip active, trackpad surface active, trigger inactive.                                                                                                                                                                                                                       
  point: 'Point',
  // pointThumb: grip active, trigger inactive, trackpad surface inactive.                                                                                                                                                                                                                
  pointThumb: 'Point + Thumb',
  // fist: grip active, trigger active, trackpad surface active.                                                                                                                                                                                                                          
  fist: 'Fist',
  // hold: trigger active, grip inactive.                                                                                                                                                                                                                                                 
  hold: 'Hold',
  // thumbUp: grip active, trigger active, trackpad surface inactive.                                                                                                                                                                                                                     
  thumbUp: 'Thumb Up'
};

The mention of "public events" makes me think there might be a reason for it, but I am no expert.

Of course I would then need to retranslate the event name to the original gesture (e.g. "pistol" -> "thumb up"), hence the original idea of emitting just the raw gesture.

For my use case I am not actually interested in the lastGesture, the current one is enough (and I can always get the last one from my custom component).

Depending on what you prefer I could come with a change that removes the lastGesture from the event, or a proposal for emitting also the remaining gestures.

All the best

@Elettrotecnica
Copy link
Contributor Author

Just checking on this PR as I am trying to move away from maintaining a fork of aframe just for a couple of features. Most of them are already in custom components, but this one in particular would be tricky to rework that way without loads of duplication.

I suggest to further simplify the commit so that the one line becomes this:

el.emit('gesture', gesture);

This enables my use case and IMHO makes sense in general, as gives the developer a chance to react to the full spectrum of gesture events.

Any contraindication you see with this?

All the best

@Elettrotecnica
Copy link
Contributor Author

Elettrotecnica commented Jul 26, 2021

Just to comment that also #4883 and #4887 acknowledge the issue that not every gesture for hand-controls is currently emitting an event.

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.

2 participants