如何在a帧中找到对象上光线投射器相交点的坐标?

问题描述:

我有一个实体,其几何设置为平面图元。如何知道使用raycaster /光标组件在实体上单击的点的坐标?

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.

检查单击事件详细信息以获取交点数据。

Check the click event detail for intersection data.

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

该对象将包含( https://threejs.org/docs/#api/en/core/Raycaster ):

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

因此您可以使用 point 查看点击的位置。

So you can use point to see where you clicked.