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.
- package/dist/mesher.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/dist/minecraft-renderer.js +58 -58
- package/dist/threeWorker.js +413 -413
- package/package.json +1 -1
- package/src/graphicsBackend/appViewer.ts +1 -0
- package/src/graphicsBackend/config.ts +1 -0
- package/src/graphicsBackend/index.ts +1 -0
- package/src/graphicsBackend/playerState.ts +1 -0
- package/src/graphicsBackend/types.ts +1 -0
- package/src/index.ts +1 -0
- package/src/lib/DebugGui.ts +1 -0
- package/src/lib/animationController.ts +1 -0
- package/src/lib/cameraBobbing.ts +1 -0
- package/src/lib/canvas2DOverlay.example.ts +1 -0
- package/src/lib/canvas2DOverlay.quickstart.ts +1 -0
- package/src/lib/canvas2DOverlay.ts +1 -0
- package/src/lib/cleanupDecorator.ts +1 -0
- package/src/lib/createPlayerObject.ts +1 -0
- package/src/lib/frameTimingCollector.ts +1 -0
- package/src/lib/guiRenderer.ts +1 -0
- package/src/lib/items.ts +1 -0
- package/src/lib/mesherlogReader.ts +1 -0
- package/src/lib/simpleUtils.ts +1 -0
- package/src/lib/smoothSwitcher.ts +1 -0
- package/src/lib/spiral.ts +1 -0
- package/src/lib/ui/newStats.ts +1 -0
- package/src/lib/utils/proxy.ts +1 -0
- package/src/lib/utils/skins.ts +1 -0
- package/src/lib/utils.ts +1 -0
- package/src/lib/workerProxy.ts +1 -0
- package/src/lib/worldrendererCommon.ts +1 -0
- package/src/mesher/mesher.ts +1 -0
- package/src/mesher/models.ts +1 -0
- package/src/mesher/modelsGeometryCommon.ts +1 -0
- package/src/mesher/shared.ts +1 -0
- package/src/mesher/standaloneRenderer.ts +1 -0
- package/src/mesher/test/a.ts +1 -0
- package/src/mesher/test/mesherTester.ts +1 -0
- package/src/mesher/test/playground.ts +1 -0
- package/src/mesher/test/test-perf.ts +1 -0
- package/src/mesher/test/tests.test.ts +1 -0
- package/src/mesher/world.ts +1 -0
- package/src/mesher/worldConstants.ts +1 -0
- package/src/playerState/playerState.ts +1 -0
- package/src/playerState/types.ts +1 -0
- package/src/playground/allEntitiesDebug.ts +1 -0
- package/src/playground/baseScene.ts +1 -0
- package/src/playground/playground.ts +1 -0
- package/src/playground/reactUtils.ts +1 -0
- package/src/playground/scenes/allEntities.ts +1 -0
- package/src/playground/scenes/floorRandom.ts +1 -0
- package/src/playground/scenes/geometryExport.ts +1 -0
- package/src/playground/scenes/index.ts +1 -0
- package/src/playground/scenes/main.ts +1 -0
- package/src/playground/scenes/railsCobweb.ts +1 -0
- package/src/playground/scenes/rotationIssue.ts +1 -0
- package/src/playground/scenes/slabsOptimization.ts +1 -0
- package/src/playground/scenes/transparencyIssue.ts +1 -0
- package/src/playground/shared.ts +1 -0
- package/src/resourcesManager/index.ts +1 -0
- package/src/resourcesManager/resourcesManager.ts +1 -0
- package/src/shims/minecraftData.ts +1 -0
- package/src/sign-renderer/index.ts +1 -0
- package/src/sign-renderer/playground.ts +1 -0
- package/src/sign-renderer/tests.test.ts +1 -0
- package/src/sign-renderer/vite.config.ts +1 -0
- package/src/three/appShared.ts +1 -0
- package/src/three/bannerRenderer.ts +1 -0
- package/src/three/cameraShake.ts +1 -0
- package/src/three/cinimaticScript.ts +1 -0
- package/src/three/documentRenderer.ts +1 -0
- package/src/three/entities.ts +150 -42
- package/src/three/entity/EntityMesh.ts +1 -0
- package/src/three/entity/animations.js +248 -133
- package/src/three/entity/armorModels.ts +1 -0
- package/src/three/fireworks.ts +1 -0
- package/src/three/fireworksRenderer.ts +1 -0
- package/src/three/globals.d.ts +1 -0
- package/src/three/graphicsBackendBase.ts +1 -0
- package/src/three/graphicsBackendOffThread.ts +1 -0
- package/src/three/graphicsBackendSingleThread.ts +1 -0
- package/src/three/hand.ts +1 -0
- package/src/three/holdingBlock.ts +1 -0
- package/src/three/itemMesh.ts +1 -0
- package/src/three/modules/index.ts +1 -0
- package/src/three/modules/sciFiWorldReveal.ts +1 -0
- package/src/three/modules/starfield.ts +1 -0
- package/src/three/modules.d.ts +1 -0
- package/src/three/panorama.ts +1 -0
- package/src/three/panoramaShared.ts +1 -0
- package/src/three/renderSlot.ts +1 -0
- package/src/three/rendererModuleSystem.ts +1 -0
- package/src/three/skyboxRenderer.ts +1 -0
- package/src/three/threeJsMedia.ts +1 -0
- package/src/three/threeJsMethods.ts +1 -0
- package/src/three/threeJsParticles.ts +1 -0
- package/src/three/threeJsSound.ts +1 -0
- package/src/three/threeJsUtils.ts +1 -0
- package/src/three/threeWorker.ts +1 -0
- package/src/three/waypointSprite.ts +1 -0
- package/src/three/waypoints.ts +1 -0
- package/src/three/world/cursorBlock.ts +1 -0
- package/src/three/world/vr.ts +1 -0
- package/src/three/worldBlockGeometry.ts +1 -0
- package/src/three/worldGeometryExport.ts +1 -0
- package/src/three/worldRendererThree.ts +1 -0
- package/src/worldView/index.ts +1 -0
- package/src/worldView/types.ts +1 -0
- 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
|
-
|
|
43
|
-
|
|
103
|
+
playerRot: player?.rotation?.clone?.(),
|
|
104
|
+
|
|
105
|
+
bodyPos: skin?.body?.position?.clone?.(),
|
|
106
|
+
bodyRot: skin?.body?.rotation?.clone?.(),
|
|
44
107
|
|
|
45
|
-
leftArmPos:
|
|
46
|
-
leftArmRot:
|
|
47
|
-
rightArmPos:
|
|
48
|
-
rightArmRot:
|
|
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:
|
|
51
|
-
leftLegRot:
|
|
52
|
-
rightLegPos:
|
|
53
|
-
rightLegRot:
|
|
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:
|
|
56
|
-
headRot:
|
|
118
|
+
headPos: skin?.head?.position?.clone?.(),
|
|
119
|
+
headRot: skin?.head?.rotation?.clone?.(),
|
|
57
120
|
|
|
58
|
-
capePos: player
|
|
59
|
-
capeRot: player
|
|
121
|
+
capePos: player?.cape?.position?.clone?.(),
|
|
122
|
+
capeRot: player?.cape?.rotation?.clone?.(),
|
|
60
123
|
|
|
61
|
-
elytraPos: player
|
|
62
|
-
elytraRot: player
|
|
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
|
|
71
|
-
player
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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
|
|
100
|
-
const
|
|
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
|
|
104
|
-
|
|
184
|
+
const moveBlend = clamp01(this._moveBlend)
|
|
185
|
+
const runBlend = clamp01(this._runBlend)
|
|
186
|
+
const crouchBlend = clamp01(this._crouchBlend)
|
|
105
187
|
|
|
106
|
-
const
|
|
107
|
-
|
|
188
|
+
const baseSpeed = mix(8, 10, runBlend)
|
|
189
|
+
const crouchSpeedMul = mix(1, 0.55, crouchBlend)
|
|
190
|
+
const speed = baseSpeed * crouchSpeedMul
|
|
108
191
|
|
|
109
|
-
|
|
192
|
+
this._phase += dt * speed * moveBlend
|
|
110
193
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
138
|
-
player.skin.
|
|
139
|
-
player.skin.
|
|
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
|
-
|
|
143
|
-
if (
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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 (
|
|
151
|
-
|
|
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
|
-
|
|
155
|
-
const
|
|
156
|
-
player.cape.rotation.x
|
|
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 (
|
|
163
|
-
|
|
164
|
-
this.
|
|
165
|
-
|
|
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.
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
330
|
+
const armZ = 0.1 * s
|
|
331
|
+
const armPosZ = (3.618325234674 - 3.4500310377) * s
|
|
332
|
+
const armPosY = -2.53943318 * s
|
|
217
333
|
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
223
|
-
|
|
337
|
+
skin.leftArm.rotation.x += 0.410367746202 * s
|
|
338
|
+
skin.rightArm.rotation.x += 0.410367746202 * s
|
|
224
339
|
|
|
225
|
-
|
|
226
|
-
|
|
340
|
+
skin.leftArm.rotation.z += armZ
|
|
341
|
+
skin.rightArm.rotation.z += -armZ
|
|
227
342
|
|
|
228
|
-
|
|
229
|
-
|
|
343
|
+
skin.leftArm.position.y += armPosY
|
|
344
|
+
skin.rightArm.position.y += armPosY
|
|
230
345
|
|
|
231
|
-
|
|
232
|
-
|
|
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'
|
package/src/three/fireworks.ts
CHANGED
package/src/three/globals.d.ts
CHANGED
package/src/three/hand.ts
CHANGED
package/src/three/itemMesh.ts
CHANGED
package/src/three/modules.d.ts
CHANGED
package/src/three/panorama.ts
CHANGED
package/src/three/renderSlot.ts
CHANGED
package/src/three/threeWorker.ts
CHANGED
package/src/three/waypoints.ts
CHANGED