简体   繁体   中英

Aframe Ray caster Intersection

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>

with the Registered Component :

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);

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM