Aframe射线脚轮交叉点 [英] Aframe Ray caster Intersection

查看:132
本文介绍了Aframe射线脚轮交叉点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

切换到Aframe的主版本后,尽管我保留了完全相同的代码,但raycaster相交事件似乎变为空:

After Switching to Master build of Aframe The raycaster intersection event seems to become null although i kept the exact same code :

<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@efcc8a0a919811fe5bd4ab6fd60bfbb8e85a98a1/dist/aframe-master.min.js"></script>

具有注册组件:

AFRAME.registerComponent('collider-check', {
  dependencies: ['raycaster'],
  init: function () {
    this.el.addEventListener('raycaster-intersected', function (evt) {
      console.log(evt.detail.intersection);//this returns null
      var intersection=evt.detail.intersection.point;
      startTimer(intersection.x,intersection.y,intersection.z);
    });
  }
});

和我放置对撞机支票的相机

and the camera where i put the collider-check

<a-entity id="cameraParent"  position="0 0 0" >
        <a-entity id="cam" camera="zoom:1;"  look-controls collider-check position="0 0 0" >
          <a-entity cursor=" rayOrigin: mouse"
            geometry="primitive: ring; radiusInner: 0; radiusOuter: 0"
            material="color: black; shader: flat"></a-entity>

          <a-entity raycaster="showLine:true; far: 1000" line="color:orange; opacity:1" ></a-entity>
        </a-entity>
      </a-entity>

我想在空中捕捉十字路口的天空

My a-sky where i want to catch intersections

 <a-sky  class="collidable" id="image-360" radius="200"  src="#{{$tour_images[0][0]->name}}" data-image-id="{{$tour_images[0][0]->id}}"></a-sky>


推荐答案

您现在必须手动获取相交数据,它

You now have to grab the intersection data manually, it was to prevent memory garbage in the event details.

事件详细信息为获取交叉点的方法提供了方便的参考。

The event detail provides a convenient references to the method to grab the intersection.

evt.detail.getIntersection(this.el);

raycaster-intersected 事件已不再是垃圾邮件。交点开始仅调用一次。如果您需要发送垃圾邮件,请监听事件,存储变量,然后使用勾号

Also the raycaster-intersected event is no longer spammed. It is only called once on intersection start. If you need to spam it, listen for the event, store a variable, and use tick.

这篇关于Aframe射线脚轮交叉点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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