Skip to content

Commit

Permalink
fix event handling to support webvr and webxr controller apis
Browse files Browse the repository at this point in the history
  • Loading branch information
dbradleyfl committed Jan 13, 2020
1 parent 671fc34 commit b41625f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ AFRAME.registerComponent('teleport-controls', {
})(),

handleAxis: function (evt) {
const axisX = parseInt(evt.detail.axis[2] * 10)
const axisY = parseInt(evt.detail.axis[3] * 10)
if (!evt.detail.axis || !evt.detail.axis.length) return
const xr = evt.detail.axis.length === 4
const axisX = parseInt(evt.detail.axis[xr ? 2 : 0] * 10)
const axisY = parseInt(evt.detail.axis[xr ? 3 : 1] * 10)
if (axisX === 0 && axisY === 0) {
this.onButtonUp(evt)
} else if (Math.abs(axisX) <= 1 && axisY === -9) {
Expand Down

0 comments on commit b41625f

Please sign in to comment.