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-tracking-controls component detaches children (+fix & ideas) #5517

Open
coderofsalvation opened this issue Apr 15, 2024 · 2 comments
Open

Comments

@coderofsalvation
Copy link

coderofsalvation commented Apr 15, 2024

  • 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!

@dmarcos
Copy link
Member

dmarcos commented Apr 22, 2024

What is the scenario you need to switch from laser-controls to hand tracking and viceversa?

@coderofsalvation
Copy link
Author

coderofsalvation commented May 2, 2024

It's more accessibility/flexibility in XR in general:

  • wear menu on your lasercontroller (if the user is holding controllers)
  • wear menu on your wrist (if the user is using hands)

I think it's important to offer experiences which works both with lasercontrols and hand-tracking (not all XR/VR endusers have handtracking).

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

No branches or pull requests

2 participants