如何在a帧中找到对象上光线投射器相交点的坐标? [英] How to find the coordinates of a raycaster intersection point on an object in a-frame?

查看:82
本文介绍了如何在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.

这篇关于如何在a帧中找到对象上光线投射器相交点的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆