Search code examples
aframevirtual-realitywebvr

how can i add entity on cursor position using aFrame


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


Solution

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