A形框超手旋转抓取物体 [英] A-Frame Super Hands rotate grabbed object

查看:14
本文介绍了A形框超手旋转抓取物体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用A-Frame、A-Frame物理和Super Hands。我有一个简单的场景,在那里我可以放置一个对象(现在只是一个盒子)和一些控制器。当我在VR中查看此场景时,我可以抓住框、移动框并调整其大小,但不能旋转或旋转对象。

我希望旋转与握住对象的手的旋转相匹配。所以,如果我用右手抓住一个物体,然后转动那只手,这个物体应该旋转相同的量。

<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>```

推荐答案

对于旋转,SuperHand使用帧物理系统约束。

若要在手和目标对象之间绑定约束,它们都需要是物理实体。

在手中添加一个静态体组件就足以使这一切正常工作。

例如

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

因此,完整的手实体如下所示:

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

这里有一个小故障,说明这是可行的:

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

这篇关于A形框超手旋转抓取物体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆