Skip to content
Snippets Groups Projects
Commit 6a240034 authored by joni's avatar joni
Browse files

Add haptic feedback to hover events.

parent a0228d78
No related branches found
No related tags found
No related merge requests found
AFRAME.registerComponent("in-world-hud", {
schema: {
haptic: { type: "selector" }
},
init() {
this.bg = this.el.querySelector(".bg");
this.mic = this.el.querySelector(".mic");
......@@ -18,12 +21,14 @@ AFRAME.registerComponent("in-world-hud", {
this.onNametagHovered = () => {
this.nametag.setAttribute("color", "cyan");
this.data.haptic.emit("haptic_pulse", { intensity: "low" });
};
this.onNametagUnhovered = () => {
this.nametag.setAttribute("color", "white");
};
this.onAvatarHovered = () => {
this.avatar.setAttribute("scale", flipXAvatarScale);
this.data.haptic.emit("haptic_pulse", { intensity: "low" });
};
this.onAvatarUnhovered = () => {
this.avatar.setAttribute("scale", avatarScale);
......@@ -32,6 +37,7 @@ AFRAME.registerComponent("in-world-hud", {
this.hoveredOnMic = true;
const muted = scene.is("muted");
this.mic.setAttribute("src", muted ? "#unmuted" : "#muted");
this.data.haptic.emit("haptic_pulse", { intensity: "low" });
};
this.showCorrectMuteState = () => {
......@@ -52,6 +58,7 @@ AFRAME.registerComponent("in-world-hud", {
this.onSelect = evt => {
if (this.hoveredOnMic) {
this.el.emit("action_mute");
this.data.haptic.emit("haptic_pulse", { intensity: "low" });
}
};
......
......@@ -105,7 +105,7 @@
ik-root
>
<a-entity id="player-hud">
<a-entity in-world-hud rotation="-39.01000608674482 0 0">
<a-entity in-world-hud="haptic:#player-right-controller" rotation="-39.01000608674482 0 0">
<a-box geometry="height:0.13;width:0.6;depth:0.001" material="depthTest:false; color:#000000;opacity:0.35" class="hud bg"></a-box>
<a-image src="#unmuted" scale="-0.1 0.1 0.1" position="-0.2 0 0.001" class="hud mic" material="alphaTest:0.1;depthTest:false;" geometry=""></a-image>
<a-text scale="0.3 0.3 0.3" position="-0.12 0 0.001" class="hud nametag" text="width:6;alphaTest:0.1"></a-text>
......
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