From b41625f0bc81def2789eef85dd8aa4f383c52395 Mon Sep 17 00:00:00 2001 From: Devon Bradley Date: Sun, 12 Jan 2020 17:25:23 -0800 Subject: [PATCH] fix event handling to support webvr and webxr controller apis --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 69eb352a..9d94582d 100644 --- a/index.js +++ b/index.js @@ -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) {