Search code examples
aframewebvr

How can I pin an entity or primitive to a vive controller in a-frame?


I'm using the Vive Controls component in A-Frame: https://aframe.io/docs/0.3.0/components/vive-controls.html

I'm trying to figure out how to "pin" an object to the vive controller in VR, so the user sees an object next to their controller at all times. This could be used to construct a menu or have an object float nearby.

Here's what I tried:

<a-entity id="leftController" vive-controls="hand: left" grab>
  <a-entity id="leftItem" scale="0.01 0.01 0.01" ply-model="src: url(/assets/plate-streetv1.ply);"></a-entity>
</a-entity>

I tried an even worse JavaScript hack to try to update the "leftItem" every 60th of a second but that was clearly the wrong way to do it.


Solution

  • Making the entity a child of the controller should work. The problem might be with the model you're loading. Try with a simple geometry:

    <a-entity id="leftController" vive-controls="hand: left" grab>
      <a-entity geometry="primitive: box; depth: 0.3; height: 0.3; width: 0.3"></a-entity>
    </a-entity>