douglascomet
douglascomet

Reputation: 13

How do to setup button input for A-Frame

I am currently trying to get button input from the Oculus Touch buttons. I was able to attach a laser-controls to the control but I would like to be able to toggle the laser on and off. Not sure if this possible but I'm currently working with this setup that yields no response:

<script>
AFRAME.registerComponent('x-button-listener', {
    init: function() {
        var el = this.el;
        el.addEventListener('xbuttondown', function(evt) {
            var cameraEl = document.querySelector('#cameraRig[#left-hand]');
            cameraEl.removeAttribute('laser-controls');
        });
     }
 });
</script>

and

<a-entity id="cameraRig">
    <a-entity x-button-listener id="left-hand" teleport-controls="button: trigger; collision-entities: #ground" laser-controls="hand: left"></a-entity>
</a-entity>

Any help would be greatly appreciated.

Upvotes: 1

Views: 222

Answers (2)

ngokevin
ngokevin

Reputation: 13233

You want to do .setAttribute('raycaster', 'showLine', false), not remove laser-controls.

Upvotes: 0

oha
oha

Reputation: 79

Your query looks odd. Don't you mean

document.querySelector('#left-hand')

or

document.querySelector('#cameraRig > #left-hand')

(see MDN for more information)

Upvotes: 1

Related Questions