【问题标题】:A-Frame super-hands move grabbed objectA-Frame 超手移动抓取物体
【发布时间】:2018-07-25 21:37:13
【问题描述】:

我正在使用aframe-super-hands-component 制作一个 A-Frame 项目。为了添加一层控制,我试图让用户可以使用控制器的操纵杆使实体离控制器更近/更远,类似于 Oculus Dash 控件 (https://youtu.be/sMjlM5vFSA0?t=1m55s)。

但是,当我尝试更新模型的位置时,就像我在抓取模型时所做的那样,它会尝试移动,但会在发出 grab-start 时被设置的物理约束停止。有没有办法可以移动超级手抓模型或重置应用于模型的约束?

当我尝试更新抓取框的位置时,效果如下:https://imgur.com/a/AfzmwzL

就代码而言,我要做的就是用modelEl.object3D.position.sub(<direction vector>) 更新位置,同时将grab-start 事件绑定到控制器。

【问题讨论】:

    标签: javascript aframe oculus aframe-super-hands


    【解决方案1】:

    如果我正确理解了你的问题,那么如果你从这里的超级手页面查看物理示例的代码,就有解决方案;

    https://wmurphyrd.github.io/aframe-super-hands-component/examples/physics/

    您将看到有一个组件附加到控制器,如下所示;

    AFRAME.registerComponent('phase-shift', {
      init: function () {
        var el = this.el
        el.addEventListener('gripdown', function () {
          el.setAttribute('collision-filter', {collisionForces: true})
        })
        el.addEventListener('gripup', function () {
          el.setAttribute('collision-filter', {collisionForces: false})
        })
      }
    })
    

    这会在抓取时“切换”物理约束,我认为这就是你所追求的。

    很难知道你还在做什么,但如果你还没有,你需要包括aframe-physics-extras 组件以及超级手和物理。使该组件工作。

    希望对你有帮助。

    【讨论】:

    猜你喜欢
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多