I add an eventListener at click and a raycaster for an object, but when I click on the object nothing happens. If I open the aframe-inspector and I inspect the object without to do any changes, I’m going back to scene and I click again the object, it shows me the console.log from the eventListener. Somebody knows why and how can I fix it?
Here is my code:
AFRAME.registerComponent('dinning-options', {
init: function () {
console.log('Registered');
this.el.addEventListener('click', function (evt) {
console.log('I was clicked at: ', evt.detail.target);
});
}
});
<a-entity
dinning-options
raycaster="showLine: false; far: 100"
obj-model="obj: #dinning-obj; mtl: #dinning-mtl;"
id="dinning"
position="7.430 0 -6.35"
scale="0.003 0.003 0.003"
></a-entity>
Thank you!