minecraft-renderer 0.1.60 → 0.1.62

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.60",
3
+ "version": "0.1.62",
4
4
  "description": "The most Modular Minecraft world renderer with Three.js WebGL backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -903,8 +903,13 @@ export class Entities {
903
903
  // TODO CLEANUP!
904
904
  // Handle special player entity ID for bot entity in third person
905
905
  const key = String(entityPlayerId)
906
- if (this.playerPerAnimation[key] === animation) return
907
- this.playerPerAnimation[key] = animation
906
+ // `oneSwing` is a one-shot event, not a persistent state: two swings in a row
907
+ // are both 'oneSwing', so deduping by name would swallow every repeat swing
908
+ // while standing still. Only dedupe the persistent state animations.
909
+ if (animation !== 'oneSwing') {
910
+ if (this.playerPerAnimation[key] === animation) return
911
+ this.playerPerAnimation[key] = animation
912
+ }
908
913
 
909
914
  if (entityPlayerId === 'player_entity' && this.playerEntity?.playerObject) {
910
915
  const { playerObject } = this.playerEntity
@@ -87,7 +87,13 @@ export class WalkingGeneralSwing extends PlayerAnimation {
87
87
  }
88
88
 
89
89
  swingArm() {
90
- this._swingTime = 0
90
+ // Only (re)start once we're past the halfway point of the current swing, like
91
+ // vanilla EntityLiving.swingArm. Otherwise a burst of `animation` packets
92
+ // (rapid clicks / digging) keeps resetting _swingTime and the arm never
93
+ // completes an arc, looking like a stutter of fast partial swings.
94
+ if (this._swingTime === null || this._swingTime >= this._swingDuration / 2) {
95
+ this._swingTime = 0
96
+ }
91
97
  }
92
98
 
93
99
  resetLocomotion() {
@@ -189,8 +195,6 @@ export class WalkingGeneralSwing extends PlayerAnimation {
189
195
  const crouchSpeedMul = mix(1, 0.55, crouchBlend)
190
196
  const speed = baseSpeed * crouchSpeedMul
191
197
 
192
- this._phase += dt * speed * moveBlend
193
-
194
198
  this._phase += dt * speed * moveBlend
195
199
  this._idlePhase += dt * 1.15
196
200
 
@@ -285,17 +289,22 @@ const HitAnimation = {
285
289
  animate(progress, player, isMovingOrRunning) {
286
290
  if (!player?.skin?.rightArm?.rotation) return
287
291
 
288
- const t = progress * 18
289
- player.skin.rightArm.rotation.x = -0.4537860552 * 2 + 2 * Math.sin(t + Math.PI) * 0.3
292
+ // One swing = one arc. `swing` rises to its peak at the middle of the swing
293
+ // (progress 0.5) and returns to rest at both ends, matching vanilla's
294
+ // `sin(swingProgress * PI)` and the first-person hand. Driving the trig with
295
+ // `progress * 18` previously ran ~3 sine cycles per click, which made other
296
+ // players' arms look like they were swinging several times per hit.
297
+ const swing = Math.sin(progress * Math.PI)
298
+ player.skin.rightArm.rotation.x = -0.4537860552 * 2 - 2 * swing * 0.3
290
299
 
291
300
  if (!isMovingOrRunning) {
292
301
  const basicArmRotationZ = 0.01 * Math.PI + 0.06
293
- player.skin.rightArm.rotation.z = -Math.cos(t) * 0.403 + basicArmRotationZ
294
- player.skin.body.rotation.y = -Math.cos(t) * 0.06
295
- player.skin.leftArm.rotation.x = Math.sin(t + Math.PI) * 0.077
296
- player.skin.leftArm.rotation.z = -Math.cos(t) * 0.015 + 0.13 - 0.05
297
- player.skin.leftArm.position.z = Math.cos(t) * 0.3
298
- player.skin.leftArm.position.x = 5 - Math.cos(t) * 0.05
302
+ player.skin.rightArm.rotation.z = -swing * 0.403 + basicArmRotationZ
303
+ player.skin.body.rotation.y = -swing * 0.06
304
+ player.skin.leftArm.rotation.x = -swing * 0.077
305
+ player.skin.leftArm.rotation.z = -swing * 0.015 + 0.13 - 0.05
306
+ player.skin.leftArm.position.z = swing * 0.3
307
+ player.skin.leftArm.position.x = 5 - swing * 0.05
299
308
  }
300
309
  },
301
310
  }
@@ -142,9 +142,9 @@ void main() {
142
142
  } else if (faceId == 2u || faceId == 3u) {
143
143
  v_uv = vec2(v, u);
144
144
  } else if (faceId == 4u) {
145
- v_uv = vec2(u, 1.0 - v);
145
+ v_uv = vec2(u, v);
146
146
  } else { // faceId == 5u
147
- v_uv = vec2(1.0 - u, 1.0 - v);
147
+ v_uv = vec2(1.0 - u, v);
148
148
  }
149
149
 
150
150
  // --- Position: section base (multiples of 16) + face quad + block-local 0..15 ---