Skip to content
Snippets Groups Projects
Commit 6d2d9682 authored by johnshaughnessy's avatar johnshaughnessy
Browse files

Fix controller offsets.

parent d5f2a4a5
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,13 @@ AFRAME.registerComponent("hand-controls2", { ...@@ -50,6 +50,13 @@ AFRAME.registerComponent("hand-controls2", {
init() { init() {
this.pose = POSES.open; this.pose = POSES.open;
this.el.setAttribute("visible", false); this.el.setAttribute("visible", false);
this.connectedController = null;
this.onControllerConnected = this.onControllerConnected.bind(this);
this.onControllerDisconnected = this.onControllerDisconnected.bind(this);
this.el.addEventListener("controllerconnected", this.onControllerConnected);
this.el.addEventListener("controllerdisconnected", this.onControllerDisconnected);
}, },
update(prevData) { update(prevData) {
...@@ -109,5 +116,17 @@ AFRAME.registerComponent("hand-controls2", { ...@@ -109,5 +116,17 @@ AFRAME.registerComponent("hand-controls2", {
this.pose = pose; this.pose = pose;
} }
this.el.setAttribute("visible", hasPose); this.el.setAttribute("visible", hasPose);
},
// Show controller when connected
onControllerConnected(e) {
this.connectedController = e.detail.name;
this.el.setAttribute("visible", true);
},
// Hide controller on disconnect
onControllerDisconnected() {
this.connectedController = null;
this.el.setAttribute("visible", false);
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment