I'm creating a VR Editor using AFRAME...
I need to create an event when the user clicks on an element by mouse and to do deferent action when clicking by Aframe camera cursor.
I found the <a-scene cursor="rayOrigin: mouse">
but this would do the same click event on both mouse and cursor click.
is that possible in AFRAME?
Discriminate by the cursor element:
AFRAME.registerComponent('on-click', {
init: function () {
var self = this;
this.el.addEventListener('click', function (evt) {
if (self.el.sceneEl === evt.detail.cursorEl) {
console.log("MOUSE");
} else {
console.log("CURSOR");
}
});
}
});
Example: https://glitch.com/edit/#!/winter-sagittarius