【问题标题】:how to interact with obj or collada-model in AFrame如何与 AFrame 中的 obj 或 collada-model 交互
【发布时间】:2016-07-15 01:46:35
【问题描述】:
<a-assets>
        <a-mixin id="ring" geometry="primitive: ring; radiusOuter: 0.20;
                radiusInner: 0.15;"
                material="color: cyan; shader: flat"
                cursor=" fuse: true"></a-mixin>
        <a-asset-item id="mancloth" src="../models/man.obj"></a-asset-item>
        <a-asset-item id="manclothmtl" src="../models/man.mtl"></a-asset-item>
</a-assets>
<a-entity camera look-controls wasd-controls><a-entity mixin="ring" position="0 0 -3">
        <a-animation begin="cursor-click" easing="ease-in" attribute="scale"
               fill="backwards" from="0.3 0.3 0.3" to="1 1 1"></a-animation>
        <a-animation begin="cursor-fusing" easing="ease-in" attribute="scale"
               fill="forwards" from="1 1 1" to="0.3 0.3 0.3"></a-animation>
      </a-entity>
</a-entity>
<a-obj-model  scale="1 1 1" src="#mancloth" mtl="#manclothmtl"></a-obj-model>

我使用相机与 obj 交互,但 aframe.js 在 57766 行显示错误。如何在不更改 aframe.js 的情况下解决此问题。

var intersectedEl = intersection.object.el;
intersectedEl.emit('raycaster-intersected', {el: el,intersection:intersection});

intersection.object是一个THREE.Mesh,所以intersection.object.el是未定义的!

【问题讨论】:

    标签: webvr aframe


    【解决方案1】:

    此问题已在https://github.com/aframevr/aframe/pull/1497 处通过将 A-Frame 实体绑定到模型的每个子级来解决。

    您可以等待 A-Frame 0.3.0 或使用最新的 A-Frame master。现在,光标使用 raycaster 来查看相交的对象。使用 OBJ/COLLADA 模型,它会创建对象树。但是,A-Frame 只是将顶级对象视为一个实体。因此,当光线投射器返回对象时,它没有关联实体来发出事件。

    现在它应该可以工作了:

    <a-camera><a-cursor></a-cursor></a-camera>
    <a-obj-model></a-obj-model>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-17
      • 2011-04-11
      • 1970-01-01
      • 1970-01-01
      • 2015-06-01
      • 2017-06-12
      • 2023-04-08
      相关资源
      最近更新 更多