minecraft-renderer 0.1.98 → 0.1.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecraft-renderer",
3
- "version": "0.1.98",
3
+ "version": "0.1.99",
4
4
  "description": "The most Modular Minecraft world renderer with Three.js WebGL backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -240,12 +240,18 @@ function getUsernameTexture(
240
240
  const iconSize = fontSize * 0.85
241
241
  const iconAreaWidth = voiceState ? iconSize + padding * 2.5 : 0
242
242
 
243
- const canvas = createCanvas(iconAreaWidth + textWidth, height)
243
+ // The nametag sprite is anchored (and thus centered above the player) at the
244
+ // midpoint of this canvas. Mirroring the icon's width as a second, unpainted
245
+ // margin on the right moves that midpoint to align with the *text's* own
246
+ // center instead of the icon+text bounding box's center — otherwise the
247
+ // icon's extra width on the left alone drags the whole sprite's anchor left,
248
+ // which visually reads as the text drifting right of the player.
249
+ const canvas = createCanvas(iconAreaWidth * 2 + textWidth, height)
244
250
  const ctx = canvas.getContext('2d')
245
251
  if (!ctx) throw new Error('Could not get 2d context')
246
252
 
247
253
  ctx.fillStyle = nameTagBackgroundColor
248
- ctx.fillRect(0, 0, canvas.width, canvas.height)
254
+ ctx.fillRect(0, 0, iconAreaWidth + textWidth, canvas.height)
249
255
  if (voiceState) {
250
256
  drawVoiceStateIcon(ctx, voiceState, iconAreaWidth / 2, canvas.height / 2, iconSize)
251
257
  }