aframevr / aframevr/aframe

hand-tracking-controls component detaches children (+fix & ideas)

Open
#5,517 4 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

  • A-Frame Version: 1.5.0
  • Platform / Device: Firefox/Brave

Normal/Expected behaviour:

<a-entity laser-controls="hand:left">
  <!-- adding objects here will attach it to the controller just fine -->
</a-entity>

however...after adding hand-tracking-controls

<a-entity laser-controls="hand:left" hand-tracking-controls="hand:left">
  <!-- here the objects no longer show up..neither with controller nor hand-tracking :/ -->
</a-entity>

Fix

This patch will re-attach the children to the wrist.

AFRAME.components['hand-tracking-controls'].Component.prototype.onModelLoaded = function(onModelLoaded){
  return function(e){
    onModelLoaded.apply(this);
    // re-attach children 
    ([...this.el.children]).map( (c) => {
      if( c.object3D ){
        this.el.object3D.getObjectByName("wrist").add(c.object3D)
      }
    })
  }
}(AFRAME.components['hand-tracking-controls'].Component.prototype.onModelLoaded)

I'm not really sure what the right solution is, as not every hand model might contain a 'wrist' object.

I played with several ideas:

  • add the code above directly to onModelLoaded of hand-tracking-controls
  • introduce an attribute <a-entity hand-tracking-controls="children: 'wrist'"> which is wrist by default e.g.
  • introduce an component hand-attach="wrist: #foo; index: #bar which allows for finer-grained parenting

One remaining question is how to deal with switching between hands/laser-controllers.

Hope this helps!

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 at the hand-tracking-controls component's onModelLoaded entry point and reproduce the child-detachment example in Firefox or Brave. Review the proposed wrist re-attachment and the alternatives in the issue; done requires a decided behavior for children across hand models and hand/controller switching, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.