Skip to content

Commit

Permalink
Merge pull request #99 from Armored-Dragon/fix/nametags
Browse files Browse the repository at this point in the history
Fix nametag positions
  • Loading branch information
JulianGro authored Jan 3, 2025
2 parents eceacce + 4e35d25 commit 74f064e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion applications/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var metadata = { "applications":
"caption": "REFRESH"
},
{
"isActive": false,
"isActive": true,
"directory": "nametags",
"name": "Nametags",
"description": "Display users' display names above their heads.",
Expand Down
7 changes: 4 additions & 3 deletions applications/nametags/nametags.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
text: display_name,
backgroundAlpha: 0.0,
billboardMode: "full",
dimensions: { x: 0.8, y: 0.2, z: 0.1 },
unlit: true,
parentID: user_uuid,
position: Vec3.sum(user.position, { x: 0, y: 0.4 + jointInObjectFrame.y, z: 0 }),
Expand Down Expand Up @@ -109,9 +110,9 @@
// https://apidocs.overte.org/Entities.html#.textSize
Script.setTimeout(() => {
let textSize = Entities.textSize(user_nametags[user_uuid].text, display_name);
Entities.editEntity(user_nametags[user_uuid].text, { dimensions: { x: textSize.width + 0.25, y: textSize.height - 0.05, z: 0.1 } });
Entities.editEntity(user_nametags[user_uuid].text, { dimensions: { x: textSize.width + 0.25, y: textSize.height + 0.07, z: 0.1 } });
Entities.editEntity(user_nametags[user_uuid].background, {
dimensions: { x: Math.max(textSize.width + 0.25, 0.6), y: textSize.height - 0.05, z: 0.1 },
dimensions: { x: Math.max(textSize.width + 0.25, 0.6), y: textSize.height + 0.05, z: 0.1 },
});
}, 100);
}
Expand All @@ -138,7 +139,7 @@
const headJointIndex = user.getJointIndex("Head");
const jointInObjectFrame = user.getAbsoluteJointTranslationInObjectFrame(headJointIndex);
Entities.editEntity(user_nametags[user_uuid].text, {
position: Vec3.sum(user.position, { x: 0, y: jointInObjectFrame.y + Math.abs(user.scale - 1) + 0.4, z: 0 }),
position: Vec3.sum(user.position, { x: 0.01, y: jointInObjectFrame.y + Math.abs(user.scale - 1) + 0.4, z: 0 }),
text: display_name,
});
});
Expand Down

0 comments on commit 74f064e

Please # to comment.