aframevr / aframevr/aframe

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

Open
#4,883 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
17.6k
Forks
4.4k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in hand-controls.js, especially the EVENTS definitions near the top and getGestureEventName around lines 397-412. Compare the emitted names with the animation states described in the issue and verify behavior for fist, thumbUp, point, pointThumb, and hold. Done means each relevant animation has an accurate, consistent start/end event behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
ar-vr-xr, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.