From 6986ec1b2ce54bd1cca1171dea565edeb6347af0 Mon Sep 17 00:00:00 2001 From: Nikki Sharpley Date: Fri, 9 Jun 2023 16:02:05 -0400 Subject: [PATCH] fix nametag positioning --- src/components/name-tag.js | 22 +++++++--------------- src/hub.html | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/components/name-tag.js b/src/components/name-tag.js index 446c48a447..d434b1ffb5 100644 --- a/src/components/name-tag.js +++ b/src/components/name-tag.js @@ -245,35 +245,27 @@ AFRAME.registerComponent("name-tag", { }, updatePronouns() { - console.log(this.pronouns); - if (this.pronouns && this.pronouns !== this.prevPronouns) { - console.log(this.nametagBackground, this.pronounsText); - // this.nametagBackground.el.setAttribute( - // "slice9", - // "width: 1; height: 0.7; left: 64; top: 64; right: 66; bottom: 66; opacity: 0.5; alphaTest: 0.1; src: nametag;" - // ); - // this.nametagStatusBorder.el.setAttribute( - // "slice9", - // "width: 0.45; height: 0.7; left: 64; top: 64; right: 66; bottom: 66; transparent: false; alphaTest: 0.1; src: nametag-border;" - // ); - console.log(this.nametagBackground, this.pronounsText); + if ((this.pronouns && this.pronouns !== this.prevPronouns) || (this.prevPronouns && !this.pronouns)) { this.pronounsText.el.addEventListener( "text-updated", () => { - if (this.pronounsText.el) { + if (this.pronounsText.el && this.nameTagText.el) { this.pronounsText.el.components["text"].getSize(this.size); + this.nameTagText.el.components["text"].getSize(this.size); this.size.x = Math.max(this.size.x, NAMETAG_MIN_WIDTH); this.resizeNameTag(); } }, { once: true } ); - if (this.pronouns.length > DISPLAY_NAME_LENGTH) { + if (this.pronouns.length > this.displayName.length && this.pronouns.length > DISPLAY_NAME_LENGTH) { this.pronouns = this.pronouns.slice(0, DISPLAY_NAME_LENGTH).concat("..."); } + this.pronounsText.el.setAttribute("text", { - value: this.pronouns + value: this.pronouns ? `(${this.pronouns})` : "" }); + this.prevPronouns = this.pronouns; } }, diff --git a/src/hub.html b/src/hub.html index 59b98d88c3..ef4ed34a87 100644 --- a/src/hub.html +++ b/src/hub.html @@ -110,7 +110,7 @@ position="0 0.025 0.001"> + position="0 -0.06 0.001">