A-Frame Super Hands rotate grabbed object

Viewed 443

I'm working with A-Frame, A-Frame Physics, and Super Hands. I have a simple scene where I can place an object (just a-box for now) and some controllers. When I view this scene in VR I can grab the box, move it around, and resize it, but I cannot rotate or spin the object.

I want the rotation to match the rotation of the hand that is holding the object. So if I grab an object with my right hand, then turn that hand, the object should rotate the same amount.

<a-scene
      style="height: calc(100vh - 5rem)"
      embedded
      physics="debug: true; gravity: 0;"
    >
      <a-entity>
        <a-camera></a-camera>
        <a-entity
          sphere-collider="objects: a-box"
          super-hands
          hand-controls="hand: left"
        ></a-entity>
        <a-entity
          sphere-collider="objects: a-box"
          super-hands
          hand-controls="hand: right"
        ></a-entity>
      </a-entity>

      <a-box
        color="blue"
        position="0 1.4 -1"
        depth="0.1"
        height="0.8"
        width="1"
        grabbable
        stretchable
        draggable
        dynamic-body
      >
      </a-box>
    </a-scene>```
1 Answers

For rotation, superhands uses aframe-physics-system constraints.

To bind a constraint between the hand and the target object, they both need to be physics bodies.

Adding a static-body component to the hands is sufficient to get this all working.

E.g.

static-body="shape: sphere; sphereRadius: 0.02"

So the full hand entity looks like:

    <a-entity
      sphere-collider="objects: a-box"
      super-hands
      static-body="shape: sphere; sphereRadius: 0.02"
      hand-controls="hand: left"
    ></a-entity>

Here's a glitch that shows this working:

https://foul-pointy-collard.glitch.me/

Related