From 41f73b59cf5d62f2da198e1b9b3378914dc867a4 Mon Sep 17 00:00:00 2001
From: joni <johnfshaughnessy@gmail.com>
Date: Thu, 8 Mar 2018 15:35:37 -0800
Subject: [PATCH] Render the line on top of the geometry.

---
 src/components/in-world-hud.js |  4 +++-
 src/room.html                  | 19 ++++++++++---------
 src/systems/app-mode.js        |  4 +++-
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/components/in-world-hud.js b/src/components/in-world-hud.js
index b3bf2418f..0475c6981 100644
--- a/src/components/in-world-hud.js
+++ b/src/components/in-world-hud.js
@@ -1,6 +1,7 @@
 AFRAME.registerComponent("in-world-hud", {
   schema: {
-    haptic: { type: "selector" }
+    haptic: { type: "selector" },
+    raycaster: { type: "selector" }
   },
   init() {
     this.bg = this.el.querySelector(".bg");
@@ -8,6 +9,7 @@ AFRAME.registerComponent("in-world-hud", {
     this.nametag = this.el.querySelector(".nametag");
     this.nametag.object3DMap.text.material.depthTest = false;
     this.avatar = this.el.querySelector(".avatar");
+    this.data.raycaster.components.line.material.depthTest = false;
 
     const muted = this.el.sceneEl.is("muted");
     this.mic.setAttribute("src", muted ? "#muted" : "#unmuted");
diff --git a/src/room.html b/src/room.html
index 435e8f553..a746813c2 100644
--- a/src/room.html
+++ b/src/room.html
@@ -104,15 +104,6 @@
             mode-responder-toggle__character-controller="mode: hud; invert: true;"
             ik-root
         >
-            <a-entity id="player-hud">
-                <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>
-                    <a-image src="#avatar" scale="0.1 0.1 0.1" position="0.2 0 0.001" class="hud avatar" material="depthTest:false;" geometry=""></a-image>
-                </a-entity>
-            </a-entity>
-
             <a-entity
                 id="player-camera"
                 class="camera"
@@ -134,6 +125,16 @@
                 haptic-feedback
             ></a-entity>
 
+
+            <a-entity id="player-hud">
+                <a-entity in-world-hud="haptic:#player-right-controller;raycaster:#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>
+                    <a-image src="#avatar" scale="0.1 0.1 0.1" position="0.2 0 0.001" class="hud avatar" material="depthTest:false;" geometry=""></a-image>
+                </a-entity>
+            </a-entity>
+
             <a-entity
                 id="player-right-controller"
                 class="right-controller"
diff --git a/src/systems/app-mode.js b/src/systems/app-mode.js
index ffeccbc04..136028251 100644
--- a/src/systems/app-mode.js
+++ b/src/systems/app-mode.js
@@ -97,7 +97,7 @@ AFRAME.registerComponent("hud-detector", {
   schema: {
     hud: { type: "selector" },
     offset: { default: 1 }, // distance from hud below head,
-    lookCutoff: { default: -20 }, // angle at which the hud should be "on",
+    lookCutoff: { default: -25 }, // angle at which the hud should be "on",
     animRange: { default: 30 } // degrees over which to animate the hud into view
   },
   init() {
@@ -144,8 +144,10 @@ AFRAME.registerComponent("hud-detector", {
     const AppModeSystem = this.el.sceneEl.systems["app-mode"];
     if (pitch < lookCutoff && AppModeSystem.mode !== AppModes.HUD) {
       AppModeSystem.setMode(AppModes.HUD);
+      this.el.sceneEl.renderer.sortObjects = true;
     } else if (pitch > lookCutoff && AppModeSystem.mode === AppModes.HUD) {
       AppModeSystem.setMode(AppModes.DEFAULT);
+      this.el.sceneEl.renderer.sortObjects = false;
     }
   }
 });
-- 
GitLab