Skip to content

Commit b41625f

Browse files
committed
fix event handling to support webvr and webxr controller apis
1 parent 671fc34 commit b41625f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ AFRAME.registerComponent('teleport-controls', {
230230
})(),
231231

232232
handleAxis: function (evt) {
233-
const axisX = parseInt(evt.detail.axis[2] * 10)
234-
const axisY = parseInt(evt.detail.axis[3] * 10)
233+
if (!evt.detail.axis || !evt.detail.axis.length) return
234+
const xr = evt.detail.axis.length === 4
235+
const axisX = parseInt(evt.detail.axis[xr ? 2 : 0] * 10)
236+
const axisY = parseInt(evt.detail.axis[xr ? 3 : 1] * 10)
235237
if (axisX === 0 && axisY === 0) {
236238
this.onButtonUp(evt)
237239
} else if (Math.abs(axisX) <= 1 && axisY === -9) {

0 commit comments

Comments
 (0)