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

AFrame: Don't render any controllers or hands in AR #8

Open
AdaRoseCannon opened this issue Mar 6, 2022 · 1 comment
Open

AFrame: Don't render any controllers or hands in AR #8

AdaRoseCannon opened this issue Mar 6, 2022 · 1 comment

Comments

@AdaRoseCannon
Copy link
Owner

Don't render controllers or hands in AR since the user can see the physical hardware/wetware anyway

@diarmidmackenzie
Copy link

diarmidmackenzie commented Aug 10, 2023

Ideally in AR you'd render the hands using a "hider material" so that they occlude any rendered objects they are in front of. Otherwise distant rendered objects mask out the hands, which breaks immersion.

Without modifying these components, it's possible to implement this using 2 small additional components like this:

AFRAME.registerComponent('hider-material', {

  dependencies: ['material'],

  init() {
    const material = this.el.components.material.material
    material.colorWrite = false
  }
})

AFRAME.registerComponent('handy-render-order', {

  dependencies: ['handy-controls'],

  init() {

    this.el.addEventListener('model-loaded', () => {

      const hands = ['hand-mesh-left', 'hand-mesh-right']
      hands.forEach((hand) => {
        const model = this.el.getObject3D(hand)
        if (model) {
          model.renderOrder = -1
        }
      })
    })
  }
})

and then in the HTML:

    <a-scene renderer="sortObjects: true">

and

<a-entity handy-controls="materialOverride: both" material hider-material handy-render-order>

Might be nice to roll this capability into handy-work as a native feature at some point.

Works pretty well, except that the hand models seem a bit too small (for my hands, at least), so the occlusion isn't quite perfect.

I'm not yet sure why the hand meshes are coming out on the small side, but probably best tracked as a seoarate issue.

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