From 6a2400341a525281451189173fb8c9f42efe91ee Mon Sep 17 00:00:00 2001 From: joni <johnfshaughnessy@gmail.com> Date: Wed, 7 Mar 2018 17:16:58 -0800 Subject: [PATCH] Add haptic feedback to hover events. --- src/components/in-world-hud.js | 7 +++++++ src/room.html | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/in-world-hud.js b/src/components/in-world-hud.js index ef28c0236..b3bf2418f 100644 --- a/src/components/in-world-hud.js +++ b/src/components/in-world-hud.js @@ -1,4 +1,7 @@ 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" }); } }; diff --git a/src/room.html b/src/room.html index cb539a638..435e8f553 100644 --- a/src/room.html +++ b/src/room.html @@ -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> -- GitLab