-2

I am exploring in Augmented reality using A-Frame and ar.js in that I am currently working with interactions part of 3d-models or primitives.My requirement is on every click of the object or primitive it has to increase its size.But the click events are not working with the current version of A-frame.

Code link for click events click .

A-Frame latest version cdn link.

My code glitch

1 Answers1

0

You need to include the cursor component and specify which objects will respond to the raycast, (in this case #button) and set this in the opening scene tag: ie.

<a-scene  cursor="rayOrigin: mouse" raycaster="objects: #button"> 

And set the "object" id (in our case '#button') in the script ie.

<script>
        var toggleEl = document.querySelector('#button')
        toggleEl.addEventListener('click', function (evt) {
            toggleEl.emit("clicked"); 
        });
    </script>

and finally trigger the event in the actual entity animation to respond to the emitted string in our case "clicked" startEvents: clicked (this used to be begin = "clicked")

In this case the id of your primitive or object will be set to id = "button"

adrianl3d
  • 13
  • 4