hand-tracking-controls component detaches children (+fix & ideas)
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
onModelLoadedof hand-tracking-controls - introduce an attribute
<a-entity hand-tracking-controls="children: 'wrist'">which iswristby default e.g. - introduce an component
hand-attach="wrist: #foo; index: #barwhich allows for finer-grained parenting
One remaining question is how to deal with switching between hands/laser-controllers.
Hope this helps!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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