我如何使用aFrame在光标位置添加实体 [英] how can i add entity on cursor position using aFrame
问题描述
我需要知道如何使用aFrame在位置光标上添加实体
i need to know how i can add entity on position cursor using aFrame
点击我想添加距离2米远的摄像机或类似物体的实体
on click i want to add entity far from camera 2 meter away or something like that
或我需要知道如何获得点击事件(x,y,z)的位置
or i need to know how can i get position on click event (x,y,z)
但是这里的问题是我要在360照片上添加实体,我使用a-sky标签,并且尝试使用js来定位,但是我失败了,它仅在实体上起作用
but the problem here i what to add entity on 360 photo and i using a-sky tag and i tried to get position using js but i Failed it's working on entity only
this.el.addEventListener('click', function (evt) {
console.log('I was clicked at: ', evt.detail.intersection.point);
例如看到这张照片
推荐答案
天空距离很远,因此光线投射器无法到达(defau lt far
的值是1000`)。
The sky is very far away so the raycaster won't reach (default far
value is 1000`).
您可以执行以下操作:
<a-camera>
<a-entity id="clickPosition" position="0 0 -100"></a-entity>
</a-camera>
然后您可以通过以下方式获得添加实体的位置:
And then you can get the position to add entity via:
document.getElementById('clickPosition').getWorldPosition();
这篇关于我如何使用aFrame在光标位置添加实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!