Skip to content

Public events from the hand-controls component are not extensive and do not all have accurate names #4883

@Clicky02

Description

@Clicky02

Description: The hand-controls component emits events on certain animation triggers; however, the event name for the thumbUp animation is not accurate to the animation. There are also not events for each of the animation states, making it difficult to know the state of the hand.

  • A-Frame Version: 1.2.0
  • Platform / Device: Should apply to all platforms/devices, but tested in Firefox 89
  • Reproducible Code Snippet or URL:

The only truly relevant code is from the top of hand-controls.js

image

The event for starting/ending thumbUp animation (described in the comments above) is called pistol, but pistol would seem to fit the pointThumb animation much better. Additionally, there is no event at all for the pointThumb, open, or hold animations. Instead, lines 31-33 should be replaced with something like:

EVENTS[ANIMATIONS.fist] = 'grip';
EVENTS[ANIMATIONS.thumbUp] = 'thumb';
EVENTS[ANIMATIONS.point] = 'pointing';
EVENTS[ANIMATIONS.pointThumb] = 'pistol';
EVENTS[ANIMATIONS.hold] = 'hold';

And the get getGestureEventName function (hand-controls.js, lines 397-412) should be

function getGestureEventName (gesture, active) {
  var eventName;

  if (!gesture) { return; }

  eventName = EVENTS[gesture];
  if (eventName === 'grip') {
    return eventName + (active ? 'close' : 'open');
  }
  if (eventName === 'thumb') {
    return eventName + (active ? 'up' : 'down');
  }
  if (eventName === 'pointing' || eventName === 'pistol' || eventName === 'hold') {
    return eventName + (active ? 'start' : 'end');
  }
}

Or alternatively, getGestureEventName could always return the eventName with 'start' or 'end' concatenated at the end, since (with this change) switching from thumbUp to pointThumb would emit a thumbdown event despite the thumb staying up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions