Skip to content

Commit

Permalink
fix nametag positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
nikk15 committed Jun 9, 2023
1 parent 4a6f013 commit 6986ec1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
22 changes: 7 additions & 15 deletions src/components/name-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/hub.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
position="0 0.025 0.001"></a-entity>
<a-entity class="pronouns-text"
text="side: double; textAlign: center; color: #ddd; fontSize: 0.06;" text-raycast-hack
position="0 1.025 0.001"></a-entity>
position="0 -0.06 0.001"></a-entity>
</a-entity>
<a-entity is-not-remote-hover-target class="recordingBadge" sprite="name: recording-badge.png"
scale="0.10 0.10 0.10" position="0 0.25 0.001" visible="false"></a-entity>
Expand Down

0 comments on commit 6986ec1

Please sign in to comment.