0
votes

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
You want to place an object in a 2m radius on a sphere around you, or just in front of you ?Piotr Adam Milewski
Thank you for comment.. I want on sphere. You can check this photo i.stack.imgur.com/nUttI.pngAmr Yousry Osary00
I want to import object On sphere when i click with cursor on sphereAmr Yousry Osary00

1 Answers

1
votes

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