I'm trying to make a light-switch on the wall in A-Frame control ambient lighting.
I placed actual lights in the scene so I could name them, and use javascript to make the changes.
Since I could not get the game-controler gamepadbuttondown:0 (or 5) to register as an onClick event, I added an animation to the a-entity of the switch itself, and I have an event listener ready to fire off and make the changes.
Everything works on the desktop PC with an actual mouse and an onClick event programmed, but when trying on a phone in a VR headmount with a cheap $5 Mocute controler, I'm stuck.
<a-entity id="lightswitch" onclick="WorksFineOnPC();" >
<a-box geometry="height:4.5; depth:4.5; width:.25" position="143 48 14" material="src:https://www.myWebsite/pic.jpg;">
<a-animation id="LightAnimation" attribute="rotation" to="0 360 0" dur="100" begin="gamepadbuttondown:0"></a-animation>
</a-box>
</a-entity>
Replacing "gamepadbuttondown:0" with "click" works fine on PC, but the onClick function worked fine to start with, and still gives no control with the remote.
The gamepadbuttondown:0 works fine for sounds, as in this example:
<a-entity gamepad-controls
sound="src: pew-pew.wav;
on: gamepadbuttondown:7">
Which worked fine with this controller, and others, so the error is somewhere in the animation triggering event.
I plan on shortining the animation to 1 milisecond instead of 100 once it is working. I only included it as a way of starting the event so I could use the event listener to see when "animationend" was emitted anyway. And want it invisible to the user.
I tried using an empty animation, but the box failed to render if I left the type and direction out.
I would like to skip the animation completely if possible, if anyone knows how to trigger an onclick event from the controler using button[x] instead of using the actual mouse. Is there a raycaster solution maybe? Accessing the Three.js under the hood directly?