aframear.jsclicklistener

Have problem to get touch or mouseclick trigger the click event of aframe objects


I can't get my code to work to trigger a function upon a click event. Both on desktop or mobile chrome browser it doesn't work. If I enter to inspector mode I recognize that in a small area of the object I can click it and it will triggered, but if I leave the inspector (strg+alt+i) it doesn't work. it seems to me that something will not hit the right point to trigger the event. This makes me crazy. I hope someone could give me a good hint to solve my problem. thanks in advance. My code is online testable under https://glitch.com/~ede21-arjslocationtutorial


Solution

  • I did not try to edit the code but I think the problem comes from your cursor and raycaster properties. They should be on a camera entity, not on the a-scene entity. A-Frame creates a default one but you can create it yourself and set this properties. The cursor will change when you hover the entities, then it should work properly ;)