Skip to content

Commit e575e6f

Browse files
committed
fix haptics for webxr
1 parent 37a6f1c commit e575e6f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

components/haptics/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,25 @@ AFRAME.registerComponent('haptics', {
3030

3131
if (this.el.components['tracked-controls'].controller) {
3232
this.gamepad = this.el.components['tracked-controls'].controller;
33+
34+
if (this.gamepad.gamepad) {
35+
// WebXR.
36+
this.gamepad = this.gamepad.gamepad;
37+
}
38+
3339
if (!this.gamepad || !this.gamepad.hapticActuators ||
3440
!this.gamepad.hapticActuators.length) { return; }
3541
this.addEventListeners();
3642
} else {
3743
this.el.addEventListener('controllerconnected', function init () {
3844
setTimeout(function () {
3945
self.gamepad = self.el.components['tracked-controls'].controller;
46+
47+
if (self.gamepad.gamepad) {
48+
// WebXR.
49+
self.gamepad = self.gamepad.gamepad;
50+
}
51+
4052
if (!self.gamepad || !self.gamepad.hapticActuators ||
4153
!self.gamepad.hapticActuators.length) { return; }
4254
self.addEventListeners();

components/haptics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aframe-haptics-component",
3-
"version": "1.5.1",
3+
"version": "1.6.0",
44
"description": "A controller haptics (vibrations) component for A-Frame.",
55
"main": "index.js",
66
"cdn": "dist/aframe-haptics-component.min.js",

0 commit comments

Comments
 (0)