Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the coordinates of a raycaster intersection point on an object in a-frame?

Tags:

aframe

I have an entity with the geometry set as plane primitive. How can I know the coordinates of the point on which I clicked (on the entity) using the raycaster/cursor component?

The best would be to the know the coordinates in the system in which the vertices of the geometry were defined at the intersection point.

like image 271
shaabhishek Avatar asked Oct 27 '16 20:10

shaabhishek


1 Answers

Check the click event detail for intersection data.

el.addEventListener('click', function (evt) {
  console.log(evt.detail.intersection);
});

This object will contain (https://threejs.org/docs/#api/en/core/Raycaster):

[ { distance, point, face, faceIndex, indices, object }, ... ]

So you can use point to see where you clicked.

like image 170
ngokevin Avatar answered Oct 06 '22 10:10

ngokevin