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

寵の児 提交于 2019-12-23 10:09:30

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/40294039/how-to-find-the-coordinates-of-a-raycaster-intersection-point-on-an-object-in-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!