how can i add entity on cursor position using aFrame

五迷三道 提交于 2019-12-11 17:53:30

问题


i need to know how i can add entity on position cursor using aFrame

on click i want to add entity far from camera 2 meter away or something like that

or i need to know how can i get position on click event (x,y,z)

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);

for Example see this photo


回答1:


The sky is very far away so the raycaster won't reach (default far value is 1000`).

You could do something like:

<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();


来源:https://stackoverflow.com/questions/49435591/how-can-i-add-entity-on-cursor-position-using-aframe

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