minecraft-renderer 0.1.13 → 0.1.15

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.
Files changed (110) hide show
  1. package/dist/mesher.js.map +2 -2
  2. package/dist/metafile.json +1 -1
  3. package/dist/minecraft-renderer.js +58 -58
  4. package/dist/threeWorker.js +413 -413
  5. package/package.json +1 -1
  6. package/src/graphicsBackend/appViewer.ts +1 -0
  7. package/src/graphicsBackend/config.ts +1 -0
  8. package/src/graphicsBackend/index.ts +1 -0
  9. package/src/graphicsBackend/playerState.ts +1 -0
  10. package/src/graphicsBackend/types.ts +1 -0
  11. package/src/index.ts +1 -0
  12. package/src/lib/DebugGui.ts +1 -0
  13. package/src/lib/animationController.ts +1 -0
  14. package/src/lib/cameraBobbing.ts +1 -0
  15. package/src/lib/canvas2DOverlay.example.ts +1 -0
  16. package/src/lib/canvas2DOverlay.quickstart.ts +1 -0
  17. package/src/lib/canvas2DOverlay.ts +1 -0
  18. package/src/lib/cleanupDecorator.ts +1 -0
  19. package/src/lib/createPlayerObject.ts +1 -0
  20. package/src/lib/frameTimingCollector.ts +1 -0
  21. package/src/lib/guiRenderer.ts +1 -0
  22. package/src/lib/items.ts +1 -0
  23. package/src/lib/mesherlogReader.ts +1 -0
  24. package/src/lib/simpleUtils.ts +1 -0
  25. package/src/lib/smoothSwitcher.ts +1 -0
  26. package/src/lib/spiral.ts +1 -0
  27. package/src/lib/ui/newStats.ts +1 -0
  28. package/src/lib/utils/proxy.ts +1 -0
  29. package/src/lib/utils/skins.ts +1 -0
  30. package/src/lib/utils.ts +1 -0
  31. package/src/lib/workerProxy.ts +1 -0
  32. package/src/lib/worldrendererCommon.ts +1 -0
  33. package/src/mesher/mesher.ts +1 -0
  34. package/src/mesher/models.ts +1 -0
  35. package/src/mesher/modelsGeometryCommon.ts +1 -0
  36. package/src/mesher/shared.ts +1 -0
  37. package/src/mesher/standaloneRenderer.ts +1 -0
  38. package/src/mesher/test/a.ts +1 -0
  39. package/src/mesher/test/mesherTester.ts +1 -0
  40. package/src/mesher/test/playground.ts +1 -0
  41. package/src/mesher/test/test-perf.ts +1 -0
  42. package/src/mesher/test/tests.test.ts +1 -0
  43. package/src/mesher/world.ts +1 -0
  44. package/src/mesher/worldConstants.ts +1 -0
  45. package/src/playerState/playerState.ts +1 -0
  46. package/src/playerState/types.ts +1 -0
  47. package/src/playground/allEntitiesDebug.ts +1 -0
  48. package/src/playground/baseScene.ts +1 -0
  49. package/src/playground/playground.ts +1 -0
  50. package/src/playground/reactUtils.ts +1 -0
  51. package/src/playground/scenes/allEntities.ts +1 -0
  52. package/src/playground/scenes/floorRandom.ts +1 -0
  53. package/src/playground/scenes/geometryExport.ts +1 -0
  54. package/src/playground/scenes/index.ts +1 -0
  55. package/src/playground/scenes/main.ts +1 -0
  56. package/src/playground/scenes/railsCobweb.ts +1 -0
  57. package/src/playground/scenes/rotationIssue.ts +1 -0
  58. package/src/playground/scenes/slabsOptimization.ts +1 -0
  59. package/src/playground/scenes/transparencyIssue.ts +1 -0
  60. package/src/playground/shared.ts +1 -0
  61. package/src/resourcesManager/index.ts +1 -0
  62. package/src/resourcesManager/resourcesManager.ts +1 -0
  63. package/src/shims/minecraftData.ts +1 -0
  64. package/src/sign-renderer/index.ts +1 -0
  65. package/src/sign-renderer/playground.ts +1 -0
  66. package/src/sign-renderer/tests.test.ts +1 -0
  67. package/src/sign-renderer/vite.config.ts +1 -0
  68. package/src/three/appShared.ts +1 -0
  69. package/src/three/bannerRenderer.ts +1 -0
  70. package/src/three/cameraShake.ts +1 -0
  71. package/src/three/cinimaticScript.ts +1 -0
  72. package/src/three/documentRenderer.ts +1 -0
  73. package/src/three/entities.ts +150 -42
  74. package/src/three/entity/EntityMesh.ts +1 -0
  75. package/src/three/entity/animations.js +248 -133
  76. package/src/three/entity/armorModels.ts +1 -0
  77. package/src/three/fireworks.ts +1 -0
  78. package/src/three/fireworksRenderer.ts +1 -0
  79. package/src/three/globals.d.ts +1 -0
  80. package/src/three/graphicsBackendBase.ts +1 -0
  81. package/src/three/graphicsBackendOffThread.ts +1 -0
  82. package/src/three/graphicsBackendSingleThread.ts +1 -0
  83. package/src/three/hand.ts +1 -0
  84. package/src/three/holdingBlock.ts +1 -0
  85. package/src/three/itemMesh.ts +1 -0
  86. package/src/three/modules/index.ts +1 -0
  87. package/src/three/modules/sciFiWorldReveal.ts +1 -0
  88. package/src/three/modules/starfield.ts +1 -0
  89. package/src/three/modules.d.ts +1 -0
  90. package/src/three/panorama.ts +1 -0
  91. package/src/three/panoramaShared.ts +1 -0
  92. package/src/three/renderSlot.ts +1 -0
  93. package/src/three/rendererModuleSystem.ts +1 -0
  94. package/src/three/skyboxRenderer.ts +1 -0
  95. package/src/three/threeJsMedia.ts +1 -0
  96. package/src/three/threeJsMethods.ts +1 -0
  97. package/src/three/threeJsParticles.ts +1 -0
  98. package/src/three/threeJsSound.ts +1 -0
  99. package/src/three/threeJsUtils.ts +1 -0
  100. package/src/three/threeWorker.ts +1 -0
  101. package/src/three/waypointSprite.ts +1 -0
  102. package/src/three/waypoints.ts +1 -0
  103. package/src/three/world/cursorBlock.ts +1 -0
  104. package/src/three/world/vr.ts +1 -0
  105. package/src/three/worldBlockGeometry.ts +1 -0
  106. package/src/three/worldGeometryExport.ts +1 -0
  107. package/src/three/worldRendererThree.ts +1 -0
  108. package/src/worldView/index.ts +1 -0
  109. package/src/worldView/types.ts +1 -0
  110. package/src/worldView/worldView.ts +1 -0
@@ -1,6 +1,51 @@
1
1
  //@ts-check
2
2
  import { PlayerAnimation } from 'skinview3d'
3
3
 
4
+ const clamp01 = (v) => Math.max(0, Math.min(1, v))
5
+ const clamp = (v, a, b) => Math.max(a, Math.min(b, v))
6
+ const mix = (a, b, t) => a + (b - a) * t
7
+ const wrapPi = (a) => {
8
+ a = (a + Math.PI) % (Math.PI * 2)
9
+ if (a < 0) a += Math.PI * 2
10
+ return a - Math.PI
11
+ }
12
+
13
+ /**
14
+ * @typedef {{
15
+ * playerRot: any,
16
+ * bodyPos: any, bodyRot: any,
17
+ * leftArmPos: any, leftArmRot: any,
18
+ * rightArmPos: any, rightArmRot: any,
19
+ * leftLegPos: any, leftLegRot: any,
20
+ * rightLegPos: any, rightLegRot: any,
21
+ * headPos: any, headRot: any,
22
+ * capePos: any, capeRot: any,
23
+ * elytraPos: any, elytraRot: any,
24
+ * }} Defaults
25
+ */
26
+
27
+ function updateElytraRightWing(player) {
28
+ const elytra = player?.elytra
29
+ if (!elytra) return
30
+
31
+ if (typeof elytra.updateRightWing === 'function') {
32
+ elytra.updateRightWing()
33
+ return
34
+ }
35
+ if (typeof elytra.updateRightWingRotation === 'function') {
36
+ elytra.updateRightWingRotation()
37
+ return
38
+ }
39
+
40
+ const left = elytra.leftWing
41
+ const right = elytra.rightWing
42
+ if (!left?.rotation || !right?.rotation) return
43
+ if (typeof right.rotation.copy === 'function') {
44
+ right.rotation.copy(left.rotation)
45
+ right.rotation.z *= -1
46
+ }
47
+ }
48
+
4
49
  export class WalkingGeneralSwing extends PlayerAnimation {
5
50
  switchAnimationCallback
6
51
 
@@ -8,24 +53,32 @@ export class WalkingGeneralSwing extends PlayerAnimation {
8
53
  isMoving = true
9
54
  isCrouched = false
10
55
 
56
+ /** @type {number} 0..1 */
57
+ moveAmount = 0
58
+ /** @type {number} 0..1 */
59
+ runAmount = 0
60
+
61
+ /** @type {number} radians */
62
+ lookYaw = 0
63
+ /** @type {number} radians */
64
+ lookPitch = 0
65
+
11
66
  _dt = 0
12
67
  _phase = 0
68
+ _idlePhase = 0
69
+
13
70
  _moveBlend = 0
71
+ _runBlend = 0
72
+ _crouchBlend = 0
73
+
74
+ _lookYawBlend = 0
75
+ _lookPitchBlend = 0
14
76
 
15
77
  /** @type {number | null} */
16
78
  _swingTime = null
17
79
  _swingDuration = 0.25
18
80
 
19
- /** @type {{
20
- bodyPos: any, bodyRot: any,
21
- leftArmPos: any, leftArmRot: any,
22
- rightArmPos: any, rightArmRot: any,
23
- leftLegPos: any, leftLegRot: any,
24
- rightLegPos: any, rightLegRot: any,
25
- headPos: any, headRot: any,
26
- capePos: any, capeRot: any,
27
- elytraPos: any, elytraRot: any,
28
- } | null} */
81
+ /** @type {Defaults | null} */
29
82
  _defaults = null
30
83
 
31
84
  update(player, delta) {
@@ -37,29 +90,39 @@ export class WalkingGeneralSwing extends PlayerAnimation {
37
90
  this._swingTime = 0
38
91
  }
39
92
 
93
+ resetLocomotion() {
94
+ this._moveBlend = 0
95
+ this._runBlend = 0
96
+ this._crouchBlend = 0
97
+ this._phase = 0
98
+ }
99
+
40
100
  _captureDefaults(player) {
101
+ const skin = player?.skin
41
102
  this._defaults = {
42
- bodyPos: player.skin.body.position.clone(),
43
- bodyRot: player.skin.body.rotation.clone(),
103
+ playerRot: player?.rotation?.clone?.(),
104
+
105
+ bodyPos: skin?.body?.position?.clone?.(),
106
+ bodyRot: skin?.body?.rotation?.clone?.(),
44
107
 
45
- leftArmPos: player.skin.leftArm.position.clone(),
46
- leftArmRot: player.skin.leftArm.rotation.clone(),
47
- rightArmPos: player.skin.rightArm.position.clone(),
48
- rightArmRot: player.skin.rightArm.rotation.clone(),
108
+ leftArmPos: skin?.leftArm?.position?.clone?.(),
109
+ leftArmRot: skin?.leftArm?.rotation?.clone?.(),
110
+ rightArmPos: skin?.rightArm?.position?.clone?.(),
111
+ rightArmRot: skin?.rightArm?.rotation?.clone?.(),
49
112
 
50
- leftLegPos: player.skin.leftLeg.position.clone(),
51
- leftLegRot: player.skin.leftLeg.rotation.clone(),
52
- rightLegPos: player.skin.rightLeg.position.clone(),
53
- rightLegRot: player.skin.rightLeg.rotation.clone(),
113
+ leftLegPos: skin?.leftLeg?.position?.clone?.(),
114
+ leftLegRot: skin?.leftLeg?.rotation?.clone?.(),
115
+ rightLegPos: skin?.rightLeg?.position?.clone?.(),
116
+ rightLegRot: skin?.rightLeg?.rotation?.clone?.(),
54
117
 
55
- headPos: player.skin.head.position.clone(),
56
- headRot: player.skin.head.rotation.clone(),
118
+ headPos: skin?.head?.position?.clone?.(),
119
+ headRot: skin?.head?.rotation?.clone?.(),
57
120
 
58
- capePos: player.cape.position.clone(),
59
- capeRot: player.cape.rotation.clone(),
121
+ capePos: player?.cape?.position?.clone?.(),
122
+ capeRot: player?.cape?.rotation?.clone?.(),
60
123
 
61
- elytraPos: player.elytra.position.clone(),
62
- elytraRot: player.elytra.rotation.clone(),
124
+ elytraPos: player?.elytra?.position?.clone?.(),
125
+ elytraRot: player?.elytra?.rotation?.clone?.(),
63
126
  }
64
127
  }
65
128
 
@@ -67,110 +130,163 @@ export class WalkingGeneralSwing extends PlayerAnimation {
67
130
  const d = this._defaults
68
131
  if (!d) return
69
132
 
70
- player.skin.body.position.copy(d.bodyPos)
71
- player.skin.body.rotation.copy(d.bodyRot)
133
+ const skin = player?.skin
134
+ const cape = player?.cape
135
+ const elytra = player?.elytra
136
+
137
+ if (d.playerRot && player?.rotation) player.rotation.copy(d.playerRot)
138
+
139
+ if (d.bodyPos && skin?.body?.position) skin.body.position.copy(d.bodyPos)
140
+ if (d.bodyRot && skin?.body?.rotation) skin.body.rotation.copy(d.bodyRot)
72
141
 
73
- player.skin.leftArm.position.copy(d.leftArmPos)
74
- player.skin.leftArm.rotation.copy(d.leftArmRot)
75
- player.skin.rightArm.position.copy(d.rightArmPos)
76
- player.skin.rightArm.rotation.copy(d.rightArmRot)
142
+ if (d.leftArmPos && skin?.leftArm?.position) skin.leftArm.position.copy(d.leftArmPos)
143
+ if (d.leftArmRot && skin?.leftArm?.rotation) skin.leftArm.rotation.copy(d.leftArmRot)
77
144
 
78
- player.skin.leftLeg.position.copy(d.leftLegPos)
79
- player.skin.leftLeg.rotation.copy(d.leftLegRot)
80
- player.skin.rightLeg.position.copy(d.rightLegPos)
81
- player.skin.rightLeg.rotation.copy(d.rightLegRot)
145
+ if (d.rightArmPos && skin?.rightArm?.position) skin.rightArm.position.copy(d.rightArmPos)
146
+ if (d.rightArmRot && skin?.rightArm?.rotation) skin.rightArm.rotation.copy(d.rightArmRot)
82
147
 
83
- player.skin.head.position.copy(d.headPos)
84
- player.skin.head.rotation.copy(d.headRot)
148
+ if (d.leftLegPos && skin?.leftLeg?.position) skin.leftLeg.position.copy(d.leftLegPos)
149
+ if (d.leftLegRot && skin?.leftLeg?.rotation) skin.leftLeg.rotation.copy(d.leftLegRot)
85
150
 
86
- player.cape.position.copy(d.capePos)
87
- player.cape.rotation.copy(d.capeRot)
151
+ if (d.rightLegPos && skin?.rightLeg?.position) skin.rightLeg.position.copy(d.rightLegPos)
152
+ if (d.rightLegRot && skin?.rightLeg?.rotation) skin.rightLeg.rotation.copy(d.rightLegRot)
88
153
 
89
- player.elytra.position.copy(d.elytraPos)
90
- player.elytra.rotation.copy(d.elytraRot)
154
+ if (d.headPos && skin?.head?.position) skin.head.position.copy(d.headPos)
155
+ if (d.headRot && skin?.head?.rotation) skin.head.rotation.copy(d.headRot)
156
+
157
+ if (d.capePos && cape?.position) cape.position.copy(d.capePos)
158
+ if (d.capeRot && cape?.rotation) cape.rotation.copy(d.capeRot)
159
+
160
+ if (d.elytraPos && elytra?.position) elytra.position.copy(d.elytraPos)
161
+ if (d.elytraRot && elytra?.rotation) elytra.rotation.copy(d.elytraRot)
91
162
  }
92
163
 
93
164
  animate(player) {
94
165
  const dt = this._dt || 0
95
-
96
166
  if (!this._defaults) this._captureDefaults(player)
97
167
  this._applyDefaults(player)
98
168
 
99
- const targetMove = this.isMoving ? 1 : 0
100
- const kMove = Math.min(1, dt * 20)
169
+ const externalMove = typeof this.moveAmount === 'number' ? this.moveAmount : (this.isMoving ? 1 : 0)
170
+ const externalRun = typeof this.runAmount === 'number' ? this.runAmount : (this.isRunning ? 1 : 0)
171
+
172
+ const targetMove = clamp01(externalMove)
173
+ const targetRun = clamp01(externalRun)
174
+ const targetCrouch = this.isCrouched ? 1 : 0
175
+
176
+ const kMove = Math.min(1, dt * 8)
177
+ const kRun = Math.min(1, dt * 6)
178
+ const kCrouch = Math.min(1, dt * 7)
179
+
101
180
  this._moveBlend += (targetMove - this._moveBlend) * kMove
181
+ this._runBlend += (targetRun - this._runBlend) * kRun
182
+ this._crouchBlend += (targetCrouch - this._crouchBlend) * kCrouch
102
183
 
103
- const speed = this.isRunning ? 10 : 8
104
- this._phase += dt * speed * this._moveBlend
184
+ const moveBlend = clamp01(this._moveBlend)
185
+ const runBlend = clamp01(this._runBlend)
186
+ const crouchBlend = clamp01(this._crouchBlend)
105
187
 
106
- const t = this._phase + (this.isRunning ? Math.PI * 0.5 : 0)
107
- let reset = false
188
+ const baseSpeed = mix(8, 10, runBlend)
189
+ const crouchSpeedMul = mix(1, 0.55, crouchBlend)
190
+ const speed = baseSpeed * crouchSpeedMul
108
191
 
109
- croughAnimation(player, this.isCrouched)
192
+ this._phase += dt * speed * moveBlend
110
193
 
111
- const boundary = this.isRunning ? Math.cos(t) : Math.sin(t)
112
- if (Math.abs(boundary) < 0.02) {
113
- if (this.switchAnimationCallback) {
114
- reset = true
194
+ this._phase += dt * speed * moveBlend
195
+ this._idlePhase += dt * 1.15
196
+
197
+ const t = this._phase + (runBlend > 0.5 ? Math.PI * 0.5 : 0)
198
+
199
+ if (this.switchAnimationCallback) {
200
+ const boundary = Math.abs(Math.sin(t))
201
+ if (boundary < 0.02) {
202
+ const cb = this.switchAnimationCallback
203
+ this.switchAnimationCallback = null
204
+ cb?.()
115
205
  }
116
206
  }
117
207
 
118
- if (this.isRunning) {
119
- player.skin.leftLeg.rotation.x = Math.cos(t + Math.PI) * 1.3
120
- player.skin.rightLeg.rotation.x = Math.cos(t) * 1.3
121
- } else {
122
- player.skin.leftLeg.rotation.x = Math.sin(t) * 0.5
123
- player.skin.rightLeg.rotation.x = Math.sin(t + Math.PI) * 0.5
124
- }
208
+ applyCrouchPose(player, crouchBlend)
125
209
 
126
- if (this.isRunning) {
127
- player.skin.leftArm.rotation.x = Math.cos(t) * 1.5
128
- player.skin.rightArm.rotation.x = Math.cos(t + Math.PI) * 1.5
210
+ const maxYaw = (80 * Math.PI) / 180
211
+ const maxPitch = (75 * Math.PI) / 180
212
+ const targetLookYaw = clamp(wrapPi(this.lookYaw || 0), -maxYaw, maxYaw)
213
+ const targetLookPitch = clamp(this.lookPitch || 0, -maxPitch, maxPitch)
129
214
 
130
- const basicArmRotationZ = Math.PI * 0.1
131
- player.skin.leftArm.rotation.z = Math.cos(t) * 0.1 + basicArmRotationZ
132
- player.skin.rightArm.rotation.z = Math.cos(t + Math.PI) * 0.1 - basicArmRotationZ
133
- } else {
134
- player.skin.leftArm.rotation.x = Math.sin(t + Math.PI) * 0.5
135
- player.skin.rightArm.rotation.x = Math.sin(t) * 0.5
215
+ const kLook = Math.min(1, dt * 14)
216
+ this._lookYawBlend += (targetLookYaw - this._lookYawBlend) * kLook
217
+ this._lookPitchBlend += (targetLookPitch - this._lookPitchBlend) * kLook
136
218
 
137
- const basicArmRotationZ = Math.PI * 0.02
138
- player.skin.leftArm.rotation.z = Math.cos(t) * 0.03 + basicArmRotationZ
139
- player.skin.rightArm.rotation.z = Math.cos(t + Math.PI) * 0.03 - basicArmRotationZ
219
+ if (player?.skin?.head?.rotation) {
220
+ player.skin.head.rotation.y += this._lookYawBlend
221
+ player.skin.head.rotation.x += this._lookPitchBlend
140
222
  }
141
223
 
142
- // swing overlay (doesn't depend on progress)
143
- if (this._swingTime !== null) {
144
- this._swingTime += dt
145
- const p = Math.min(this._swingTime / this._swingDuration, 1)
146
- HitAnimation.animate(p, player, this.isMoving)
147
- if (p >= 1) this._swingTime = null
224
+ const idleStrength = (1 - moveBlend) * (1 - 0.25 * runBlend)
225
+ if (idleStrength > 0.0001 && player?.skin) {
226
+ const b = Math.sin(this._idlePhase)
227
+ player.skin.body.rotation.x += b * 0.02 * idleStrength
228
+ player.skin.head.rotation.x += -b * 0.015 * idleStrength
229
+ player.skin.leftArm.rotation.x += b * 0.03 * idleStrength
230
+ player.skin.rightArm.rotation.x += -b * 0.03 * idleStrength
231
+ if (player?.cape?.rotation) player.cape.rotation.x += Math.sin(this._idlePhase * 0.7) * 0.03 * idleStrength
148
232
  }
149
233
 
150
- if (this.isRunning) {
151
- player.rotation.z = Math.cos(t + Math.PI) * 0.01
152
- }
234
+ if (moveBlend > 0.0001 && player?.skin) {
235
+ const legAmp = mix(1, 0.85, crouchBlend)
236
+ const armAmp = mix(1, 0.7, crouchBlend)
237
+
238
+ const walkLegL = Math.sin(t) * 0.5
239
+ const walkLegR = Math.sin(t + Math.PI) * 0.5
240
+ const runLegL = Math.cos(t + Math.PI) * 1.3
241
+ const runLegR = Math.cos(t) * 1.3
242
+
243
+ player.skin.leftLeg.rotation.x += mix(walkLegL, runLegL, runBlend) * moveBlend * legAmp
244
+ player.skin.rightLeg.rotation.x += mix(walkLegR, runLegR, runBlend) * moveBlend * legAmp
245
+
246
+ const walkArmL = Math.sin(t + Math.PI) * 0.5
247
+ const walkArmR = Math.sin(t) * 0.5
248
+ const runArmL = Math.cos(t) * 1.5
249
+ const runArmR = Math.cos(t + Math.PI) * 1.5
250
+
251
+ player.skin.leftArm.rotation.x += mix(walkArmL, runArmL, runBlend) * moveBlend * armAmp
252
+ player.skin.rightArm.rotation.x += mix(walkArmR, runArmR, runBlend) * moveBlend * armAmp
253
+
254
+ const walkArmZBase = Math.PI * 0.02
255
+ const runArmZBase = Math.PI * 0.1
256
+ const armZBase = mix(walkArmZBase, runArmZBase, runBlend)
257
+
258
+ const walkArmZL = Math.cos(t) * 0.03 + walkArmZBase
259
+ const walkArmZR = Math.cos(t + Math.PI) * 0.03 - walkArmZBase
260
+ const runArmZL = Math.cos(t) * 0.1 + runArmZBase
261
+ const runArmZR = Math.cos(t + Math.PI) * 0.1 - runArmZBase
262
+
263
+ player.skin.leftArm.rotation.z += (mix(walkArmZL, runArmZL, runBlend) * moveBlend + armZBase * 0.15 * moveBlend) * armAmp
264
+ player.skin.rightArm.rotation.z += (mix(walkArmZR, runArmZR, runBlend) * moveBlend - armZBase * 0.15 * moveBlend) * armAmp
265
+
266
+ if (this._defaults?.playerRot) {
267
+ player.rotation.z = this._defaults.playerRot.z + Math.cos(t + Math.PI) * 0.01 * runBlend * moveBlend
268
+ }
153
269
 
154
- if (this.isRunning) {
155
- const basicCapeRotationX = Math.PI * 0.3
156
- player.cape.rotation.x = Math.sin(t * 2) * 0.1 + basicCapeRotationX
157
- } else {
158
- const basicCapeRotationX = Math.PI * 0.06
159
- player.cape.rotation.x = Math.sin(t / 1.5) * 0.06 + basicCapeRotationX
270
+ const capeBase = mix(Math.PI * 0.06, Math.PI * 0.3, runBlend)
271
+ const capeWave = mix(Math.sin(t / 1.5) * 0.06, Math.sin(t * 2) * 0.1, runBlend)
272
+ if (player?.cape?.rotation) player.cape.rotation.x += (capeBase + capeWave) * moveBlend
160
273
  }
161
274
 
162
- if (reset) {
163
- const cb = this.switchAnimationCallback
164
- this.switchAnimationCallback = null
165
- cb?.()
275
+ if (this._swingTime !== null) {
276
+ this._swingTime += dt
277
+ const p = Math.min(this._swingTime / this._swingDuration, 1)
278
+ HitAnimation.animate(p, player, moveBlend > 0.2)
279
+ if (p >= 1) this._swingTime = null
166
280
  }
167
281
  }
168
282
  }
169
283
 
170
284
  const HitAnimation = {
171
285
  animate(progress, player, isMovingOrRunning) {
286
+ if (!player?.skin?.rightArm?.rotation) return
287
+
172
288
  const t = progress * 18
173
- player.skin.rightArm.rotation.x = -0.453_786_055_2 * 2 + 2 * Math.sin(t + Math.PI) * 0.3
289
+ player.skin.rightArm.rotation.x = -0.4537860552 * 2 + 2 * Math.sin(t + Math.PI) * 0.3
174
290
 
175
291
  if (!isMovingOrRunning) {
176
292
  const basicArmRotationZ = 0.01 * Math.PI + 0.06
@@ -184,50 +300,49 @@ const HitAnimation = {
184
300
  },
185
301
  }
186
302
 
187
- const croughAnimation = (player, isCrouched) => {
188
- let pr = isCrouched ? 1 : 0
189
-
190
- player.skin.body.rotation.x = 0.453_786_055_2 * Math.abs(Math.sin((pr * Math.PI) / 2))
191
- player.skin.body.position.z =
192
- 1.325_618_1 * Math.abs(Math.sin((pr * Math.PI) / 2)) - 3.450_031_037_7 * Math.abs(Math.sin((pr * Math.PI) / 2))
193
- player.skin.body.position.y = -6 - 2.103_677_462 * Math.abs(Math.sin((pr * Math.PI) / 2))
194
-
195
- player.cape.position.y = 8 - 1.851_236_166_577_372 * Math.abs(Math.sin((pr * Math.PI) / 2))
196
- player.cape.rotation.x = (10.8 * Math.PI) / 180 + 0.294_220_265_771 * Math.abs(Math.sin((pr * Math.PI) / 2))
197
- player.cape.position.z =
198
- -2 + 3.786_619_432 * Math.abs(Math.sin((pr * Math.PI) / 2)) - 3.450_031_037_7 * Math.abs(Math.sin((pr * Math.PI) / 2))
199
-
200
- player.elytra.position.x = player.cape.position.x
201
- player.elytra.position.y = player.cape.position.y
202
- player.elytra.position.z = player.cape.position.z
203
- player.elytra.rotation.x = player.cape.rotation.x - (10.8 * Math.PI) / 180
204
-
205
- const pr1 = 1
206
- if (Math.abs(Math.sin((pr * Math.PI) / 2)) === 1) {
207
- player.elytra.leftWing.rotation.z =
208
- 0.261_799_44 + 0.458_200_6 * Math.abs(Math.sin((Math.min(pr1, 1) * Math.PI) / 2))
209
- player.elytra.updateRightWing()
210
- } else if (isCrouched !== undefined) {
211
- player.elytra.leftWing.rotation.z =
212
- 0.72 - 0.458_200_6 * Math.abs(Math.sin((Math.min(pr1, 1) * Math.PI) / 2))
213
- player.elytra.updateRightWing()
214
- }
303
+ function applyCrouchPose(player, crouchBlend) {
304
+ const skin = player?.skin
305
+ const cape = player?.cape
306
+ const elytra = player?.elytra
307
+ if (!skin || !cape) return
308
+
309
+ const pr = clamp01(crouchBlend)
310
+ const s = Math.abs(Math.sin((pr * Math.PI) / 2))
311
+ if (s <= 0.000001) return
312
+
313
+ skin.body.rotation.x += 0.4537860552 * s
314
+ skin.body.position.z += (1.3256181 - 3.4500310377) * s
315
+ skin.body.position.y += -2.103677462 * s
316
+
317
+ cape.position.y += -1.851236166577372 * s
318
+ cape.rotation.x += 0.294220265771 * s
319
+ cape.position.z += (3.786619432 - 3.4500310377) * s
320
+
321
+ if (elytra?.position) elytra.position.copy(cape.position)
322
+ if (elytra?.rotation) elytra.rotation.copy(cape.rotation)
323
+ if (elytra?.rotation) elytra.rotation.x -= (10.8 * Math.PI) / 180
324
+
325
+ if (elytra?.leftWing?.rotation) elytra.leftWing.rotation.z = mix(0.72, 0.26179944 + 0.4582006, s)
326
+ updateElytraRightWing(player)
327
+
328
+ skin.head.position.y += -3.618325234674 * s
215
329
 
216
- player.skin.head.position.y = -3.618_325_234_674 * Math.abs(Math.sin((pr * Math.PI) / 2))
330
+ const armZ = 0.1 * s
331
+ const armPosZ = (3.618325234674 - 3.4500310377) * s
332
+ const armPosY = -2.53943318 * s
217
333
 
218
- player.skin.leftArm.position.z =
219
- 3.618_325_234_674 * Math.abs(Math.sin((pr * Math.PI) / 2)) - 3.450_031_037_7 * Math.abs(Math.sin((pr * Math.PI) / 2))
220
- player.skin.rightArm.position.z = player.skin.leftArm.position.z
334
+ skin.leftArm.position.z += armPosZ
335
+ skin.rightArm.position.z += armPosZ
221
336
 
222
- player.skin.leftArm.rotation.x = 0.410_367_746_202 * Math.abs(Math.sin((pr * Math.PI) / 2))
223
- player.skin.rightArm.rotation.x = player.skin.leftArm.rotation.x
337
+ skin.leftArm.rotation.x += 0.410367746202 * s
338
+ skin.rightArm.rotation.x += 0.410367746202 * s
224
339
 
225
- player.skin.leftArm.rotation.z = 0.1
226
- player.skin.rightArm.rotation.z = -player.skin.leftArm.rotation.z
340
+ skin.leftArm.rotation.z += armZ
341
+ skin.rightArm.rotation.z += -armZ
227
342
 
228
- player.skin.leftArm.position.y = -2 - 2.539_433_18 * Math.abs(Math.sin((pr * Math.PI) / 2))
229
- player.skin.rightArm.position.y = player.skin.leftArm.position.y
343
+ skin.leftArm.position.y += armPosY
344
+ skin.rightArm.position.y += armPosY
230
345
 
231
- player.skin.rightLeg.position.z = -3.450_031_037_7 * Math.abs(Math.sin((pr * Math.PI) / 2))
232
- player.skin.leftLeg.position.z = player.skin.rightLeg.position.z
346
+ skin.rightLeg.position.z += -3.4500310377 * s
347
+ skin.leftLeg.position.z += -3.4500310377 * s
233
348
  }
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import { default as chainmailLayer1 } from 'mc-assets/dist/other-textures/latest/models/armor/chainmail_layer_1.png'
2
3
  import { default as chainmailLayer2 } from 'mc-assets/dist/other-textures/latest/models/armor/chainmail_layer_2.png'
3
4
  import { default as diamondLayer1 } from 'mc-assets/dist/other-textures/latest/models/armor/diamond_layer_1.png'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { createCanvas } from '../lib/utils'
3
4
 
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { Vec3 } from 'vec3'
3
4
  import type { WorldRendererThree } from './worldRendererThree'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  interface ObjectConstructor {
2
3
  keys<T extends object>(obj: T): Array<StringKeys<T>>
3
4
  entries<T extends object>(obj: T): Array<[StringKeys<T>, T[keyof T]]>
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  /**
2
3
  * Graphics Backend Base - Shared functionality for Three.js backends.
3
4
  *
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { GraphicsBackend, GraphicsBackendLoader } from '../graphicsBackend'
3
4
  import { useWorkerProxy, deepPrepareForTransfer, findProblemTransfer } from '../lib/workerProxy'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  /**
2
3
  * Single-Thread Graphics Backend - Main thread Three.js implementation.
3
4
  *
package/src/three/hand.ts CHANGED
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { loadSkinFromUsername, loadSkinImage } from '../lib/utils/skins'
3
4
  import { steveTexture } from './entities'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import * as tweenJs from '@tweenjs/tween.js'
3
4
  import PrismarineItem from 'prismarine-item'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
 
3
4
  export interface Create3DItemMeshOptions {
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import { sciFiWorldRevealManifest } from './sciFiWorldReveal'
2
3
  import { starfieldManifest } from './starfield'
3
4
 
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import type { WorldRendererThree } from '../worldRendererThree'
3
4
  import type { RendererModuleController, RendererModuleManifest } from '../rendererModuleSystem'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import type { WorldRendererThree } from '../worldRendererThree'
3
4
  import type { RendererModuleController, RendererModuleManifest } from '../rendererModuleSystem'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  declare module '*.png' {
2
3
  const content: string
3
4
  export default content
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import { join } from 'path'
2
3
  import * as THREE from 'three'
3
4
  import { getSyncWorld } from '../playground/shared'
@@ -1 +1,2 @@
1
+ //@ts-nocheck
1
2
  export const PANORAMA_VERSION = '1.21.4'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import { getRenamedData } from 'mineflayer-mouse/dist/blockRenames'
2
3
  import { BlockModel } from 'mc-assets'
3
4
  import { versionToNumber } from 'mc-assets/dist/utils'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import { WorldRendererThree } from './worldRendererThree'
2
3
 
3
4
  /**
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { DebugGui } from '../lib/DebugGui'
3
4
 
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { WorldRendererThree } from './worldRendererThree'
3
4
  import { ThreeJsSound } from './threeJsSound'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import { AppViewer } from '../graphicsBackend'
2
3
  import { ThreeJsBackendMethods } from './graphicsBackendBase'
3
4
 
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
 
3
4
  interface ParticleMesh extends THREE.Mesh {
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { WorldRendererThree } from './worldRendererThree'
3
4
  import { SoundSystem } from '../graphicsBackend/types'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { getLoadedImage } from 'mc-assets/dist/utils'
3
4
  import { createCanvas, loadImageFromUrl } from '../lib/utils'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  // Three.js Worker Entry Point
2
3
  // This worker handles three.js rendering in an offscreen canvas
3
4
 
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { createCanvas } from '../lib/utils'
3
4
 
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { WorldRendererThree } from './worldRendererThree'
3
4
  import { createWaypointSprite, type WaypointSprite } from './waypointSprite'
@@ -1,3 +1,4 @@
1
+ //@ts-nocheck
1
2
  import * as THREE from 'three'
2
3
  import { LineMaterial, LineSegmentsGeometry, Wireframe } from 'three-stdlib'
3
4
  import { Vec3 } from 'vec3'