gabor aron gabor aron - 19 days ago 9
Javascript Question

How to get click event with javascript from an A-frame element

UPDATE:
You can use

onclick= function();
in the HTML.

For example:
<a-box onclick="myFunction()"></a-box>


I want to get click event of cursor with javascript from an A-frame element, like a box for example, how can I do it?

Answer

If you are using the cursor component:

box.addEventListener('click', function (evt) { // ... });

If you want to use the mouse cursor, try https://www.npmjs.com/package/aframe-mouse-cursor-component

Comments