I'm quite new to AR, so the answer to this question may be simple. I've written a simple component that changes the colour of a box once clicked. This component works in VR mode however it doesn't work at all in AR mode when I tap the screen on the phone.
AFRAME.registerComponent('change-color', {
schema: {
color: {
type: 'string',
default: 'blue'
}
},
init: function () {
var data = this.data;
var el = this.el;
el.addEventListener('click', function () {
this.setAttribute('color', data.color);
})
}
});
<a-box id="box" position="0 1.6 3" scale="0.50 0.50 0.50" color="red" change-color></a-box>
I would investigate use of the mouse (and touch) cursor.
Here is a link to the documentation: https://aframe.io/docs/1.0.0/components/cursor.html#properties_rayorigin
Here is a simple glitch project that makes use of this: https://glitch.com/~aframe-grid-select
Note line 53 of index.html:
Here's another project that uses this same method: https://glitch.com/~aframe-building-ui
Note line 101 of index.html: