SWAppDev
SWAppDev

Reputation: 248

How to follow raycaster intersection coordinates on an entity?

I'm trying to use the raycaster to draw on a plane.

I know how to be notified when the raycaster and the plane intersect but after that i don't know how to get updated coordinates of the intersection while the raycaster is moving acrosse the plane.

Upvotes: 0

Views: 101

Answers (1)

ngokevin
ngokevin

Reputation: 13233

AFRAME.registerComponent('raycaster-listen', {
  init: function () {
    this.raycaster = document.querySelector('#myRay');
  },

  tick: function () {
    var intersection = this.raycaster.components.raycaster.getIntersection(this.el);
    if (!intersection) { return; }
    console.log(intersection);
  }
});

<a-entity geometry material raycaster-listen></a-entity>

Upvotes: 1

Related Questions