【问题标题】:Raycaster camera with a-sky intersects with cursor带有天空的 Raycaster 相机与光标相交
【发布时间】:2019-05-24 18:18:02
【问题描述】:

我刚开始用a-frame开发,如果答案很明显,请原谅。 在我的项目中,我想获得用户正在观看的天空的位置。因此,我在相机中实现了一个光线投射器,到目前为止效果很好。

HTML

<a-camera listener>
    <a-entity raycaster="far: 1000" position="0 -0.9 0" rotation="0 0 0"></a-entity>
</a-camera>

<a-sky follow-intersection
     id="sky"
     src="#skybox-image">

</a-sky>

TS

AFRAME.registerComponent("follow-intersection", {
  init: function() {
    this.el.addEventListener("raycaster-intersected", evt => {
      this.intersectingRaycaster = evt.detail.el.components.raycaster;
    });
    this.el.addEventListener("raycaster-intersected-cleared", () => {
      this.intersectingRaycaster = null;
    });
  },
  tick: function(t) {

      if (!this.intersectingRaycaster) {
        return;
      }

      const intersection = this.intersectingRaycaster.getIntersection(this.el);

      if (intersection) {
        let point = intersection.uv;
        console.log(point.x, point.y);
      }

到目前为止这工作正常,问题是我在场景中设置光标后(这是项目所需要的)

<a-scene
  cursor="rayOrigin: listener"
>

我总是得到与光标的交叉点,这是不想要的。

我怎样才能只得到相机的交叉点?谢谢!

【问题讨论】:

    标签: aframe


    【解决方案1】:

    我认为不需要a-scene 中的光标。你可以这样做:

    <a-camera listener>
        <a-entity cursor raycaster="far: 1000" position="0 -0.9 0" rotation="0 0 0"></a-entity>
    </a-camera>
    

    【讨论】:

    • 感谢您的回答,但不幸的是项目中的其他交互需要光标
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 2013-04-14
    • 2018-11-16
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多