Skip to content
Snippets Groups Projects
Commit 7fa5fad4 authored by joni's avatar joni
Browse files

Fix mute state indicator event listener.

parent 5c6153cf
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ AFRAME.registerComponent("2d-mute-state-indicator", {
},
onStateToggled(e) {
if (!e.detail.state === "muted") return;
if (e.detail !== "muted") return;
this.updateMuteState();
},
......
......@@ -59,14 +59,19 @@ AFRAME.registerComponent("in-world-hud", {
this.mic.setAttribute("src", muted ? "#unmuted" : "#muted");
};
this.showCorrectMuteState = () => {
const muted = this.el.sceneEl.is("muted");
this.mic.setAttribute("src", muted ? "#muted" : "#unmuted");
};
this.onStateChange = evt => {
if (evt.detail.state !== "muted") return;
if (evt.detail !== "muted") return;
this.showCorrectMuteState();
};
this.showCorrectMuteState = () => {
this.onMicHoverExit = () => {
this.hoveredOnMic = false;
const muted = this.el.sceneEl.is("muted");
this.mic.setAttribute("src", muted ? "#muted" : "#unmuted");
this.showCorrectMuteState();
};
this.onSelect = evt => {
......@@ -82,7 +87,7 @@ AFRAME.registerComponent("in-world-hud", {
play() {
this.mic.addEventListener("raycaster-intersected", this.onMicHover);
this.mic.addEventListener("raycaster-intersected-cleared", this.showCorrectMuteState);
this.mic.addEventListener("raycaster-intersected-cleared", this.onMicHoverExit);
this.nametag.addEventListener("raycaster-intersected", this.addBlue);
this.nametag.addEventListener("raycaster-intersected-cleared", this.removeBlue);
......@@ -102,7 +107,7 @@ AFRAME.registerComponent("in-world-hud", {
this.nametag.removeEventListener("raycaster-intersected-cleared", this.removeBlue);
this.mic.removeEventListener("raycaster-intersected", this.onMicHover);
this.mic.removeEventListener("raycaster-intersected-cleared", this.showCorrectMuteState);
this.mic.removeEventListener("raycaster-intersected-cleared", this.onMicHoverExit);
this.avatar.removeEventListener("raycaster-intersected", this.flipX);
this.avatar.removeEventListener("raycaster-intersected-cleared", this.unflipX);
......
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