minecraft-renderer 0.1.63 → 0.1.65
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/README.md +1 -1
- package/dist/mesherWasm.js +22 -22
- package/dist/minecraft-renderer.js +59 -59
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +415 -415
- package/package.json +1 -1
- package/src/graphicsBackend/rendererDefaultOptions.ts +41 -24
- package/src/graphicsBackend/rendererOptionsSync.ts +23 -23
- package/src/index.ts +8 -8
- package/src/lib/worldrendererCommon.removeColumn.test.ts +182 -0
- package/src/lib/worldrendererCommon.ts +16 -6
- package/src/three/entities.ts +54 -170
- package/src/three/entity/animations.js +92 -185
- package/src/three/menuBackground/activeView.ts +1 -1
- package/src/three/menuBackground/config.ts +9 -9
- package/src/three/menuBackground/index.ts +10 -10
- package/src/three/menuBackground/renderer.ts +12 -12
- package/src/three/menuBackground/types.ts +9 -9
- package/src/three/menuBackground/{futuristic.ts → v2.ts} +110 -59
- package/src/three/menuBackground/{futuristicMeta.ts → v2Meta.ts} +6 -6
- package/src/wasm-mesher/tests/mesherWasmRequestTracker.test.ts +29 -0
- package/src/wasm-mesher/worker/mesherWasm.ts +7 -0
- package/src/wasm-mesher/worker/mesherWasmRequestTracker.ts +10 -0
- package/src/worldView/worldView.spiral.test.ts +38 -0
- package/src/worldView/worldView.ts +2 -0
|
@@ -2,27 +2,7 @@
|
|
|
2
2
|
import { PlayerAnimation } from 'skinview3d'
|
|
3
3
|
|
|
4
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
5
|
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
6
|
|
|
27
7
|
function updateElytraRightWing(player) {
|
|
28
8
|
const elytra = player?.elytra
|
|
@@ -53,32 +33,24 @@ export class WalkingGeneralSwing extends PlayerAnimation {
|
|
|
53
33
|
isMoving = true
|
|
54
34
|
isCrouched = false
|
|
55
35
|
|
|
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
|
-
|
|
66
36
|
_dt = 0
|
|
67
37
|
_phase = 0
|
|
68
|
-
_idlePhase = 0
|
|
69
|
-
|
|
70
38
|
_moveBlend = 0
|
|
71
|
-
_runBlend = 0
|
|
72
|
-
_crouchBlend = 0
|
|
73
|
-
|
|
74
|
-
_lookYawBlend = 0
|
|
75
|
-
_lookPitchBlend = 0
|
|
76
39
|
|
|
77
40
|
/** @type {number | null} */
|
|
78
41
|
_swingTime = null
|
|
79
42
|
_swingDuration = 0.25
|
|
80
43
|
|
|
81
|
-
/** @type {
|
|
44
|
+
/** @type {{
|
|
45
|
+
bodyPos: any, bodyRot: any,
|
|
46
|
+
leftArmPos: any, leftArmRot: any,
|
|
47
|
+
rightArmPos: any, rightArmRot: any,
|
|
48
|
+
leftLegPos: any, leftLegRot: any,
|
|
49
|
+
rightLegPos: any, rightLegRot: any,
|
|
50
|
+
headPos: any, headRot: any,
|
|
51
|
+
capePos: any, capeRot: any,
|
|
52
|
+
elytraPos: any, elytraRot: any,
|
|
53
|
+
} | null} */
|
|
82
54
|
_defaults = null
|
|
83
55
|
|
|
84
56
|
update(player, delta) {
|
|
@@ -96,39 +68,29 @@ export class WalkingGeneralSwing extends PlayerAnimation {
|
|
|
96
68
|
}
|
|
97
69
|
}
|
|
98
70
|
|
|
99
|
-
resetLocomotion() {
|
|
100
|
-
this._moveBlend = 0
|
|
101
|
-
this._runBlend = 0
|
|
102
|
-
this._crouchBlend = 0
|
|
103
|
-
this._phase = 0
|
|
104
|
-
}
|
|
105
|
-
|
|
106
71
|
_captureDefaults(player) {
|
|
107
|
-
const skin = player?.skin
|
|
108
72
|
this._defaults = {
|
|
109
|
-
|
|
73
|
+
bodyPos: player.skin.body.position.clone(),
|
|
74
|
+
bodyRot: player.skin.body.rotation.clone(),
|
|
110
75
|
|
|
111
|
-
|
|
112
|
-
|
|
76
|
+
leftArmPos: player.skin.leftArm.position.clone(),
|
|
77
|
+
leftArmRot: player.skin.leftArm.rotation.clone(),
|
|
78
|
+
rightArmPos: player.skin.rightArm.position.clone(),
|
|
79
|
+
rightArmRot: player.skin.rightArm.rotation.clone(),
|
|
113
80
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
81
|
+
leftLegPos: player.skin.leftLeg.position.clone(),
|
|
82
|
+
leftLegRot: player.skin.leftLeg.rotation.clone(),
|
|
83
|
+
rightLegPos: player.skin.rightLeg.position.clone(),
|
|
84
|
+
rightLegRot: player.skin.rightLeg.rotation.clone(),
|
|
118
85
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
rightLegPos: skin?.rightLeg?.position?.clone?.(),
|
|
122
|
-
rightLegRot: skin?.rightLeg?.rotation?.clone?.(),
|
|
86
|
+
headPos: player.skin.head.position.clone(),
|
|
87
|
+
headRot: player.skin.head.rotation.clone(),
|
|
123
88
|
|
|
124
|
-
|
|
125
|
-
|
|
89
|
+
capePos: player.cape.position.clone(),
|
|
90
|
+
capeRot: player.cape.rotation.clone(),
|
|
126
91
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
elytraPos: player?.elytra?.position?.clone?.(),
|
|
131
|
-
elytraRot: player?.elytra?.rotation?.clone?.(),
|
|
92
|
+
elytraPos: player.elytra.position.clone(),
|
|
93
|
+
elytraRot: player.elytra.rotation.clone(),
|
|
132
94
|
}
|
|
133
95
|
}
|
|
134
96
|
|
|
@@ -136,152 +98,102 @@ export class WalkingGeneralSwing extends PlayerAnimation {
|
|
|
136
98
|
const d = this._defaults
|
|
137
99
|
if (!d) return
|
|
138
100
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const elytra = player?.elytra
|
|
142
|
-
|
|
143
|
-
if (d.playerRot && player?.rotation) player.rotation.copy(d.playerRot)
|
|
101
|
+
player.skin.body.position.copy(d.bodyPos)
|
|
102
|
+
player.skin.body.rotation.copy(d.bodyRot)
|
|
144
103
|
|
|
145
|
-
|
|
146
|
-
|
|
104
|
+
player.skin.leftArm.position.copy(d.leftArmPos)
|
|
105
|
+
player.skin.leftArm.rotation.copy(d.leftArmRot)
|
|
106
|
+
player.skin.rightArm.position.copy(d.rightArmPos)
|
|
107
|
+
player.skin.rightArm.rotation.copy(d.rightArmRot)
|
|
147
108
|
|
|
148
|
-
|
|
149
|
-
|
|
109
|
+
player.skin.leftLeg.position.copy(d.leftLegPos)
|
|
110
|
+
player.skin.leftLeg.rotation.copy(d.leftLegRot)
|
|
111
|
+
player.skin.rightLeg.position.copy(d.rightLegPos)
|
|
112
|
+
player.skin.rightLeg.rotation.copy(d.rightLegRot)
|
|
150
113
|
|
|
151
|
-
|
|
152
|
-
|
|
114
|
+
player.skin.head.position.copy(d.headPos)
|
|
115
|
+
player.skin.head.rotation.copy(d.headRot)
|
|
153
116
|
|
|
154
|
-
|
|
155
|
-
|
|
117
|
+
player.cape.position.copy(d.capePos)
|
|
118
|
+
player.cape.rotation.copy(d.capeRot)
|
|
156
119
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (d.headPos && skin?.head?.position) skin.head.position.copy(d.headPos)
|
|
161
|
-
if (d.headRot && skin?.head?.rotation) skin.head.rotation.copy(d.headRot)
|
|
162
|
-
|
|
163
|
-
if (d.capePos && cape?.position) cape.position.copy(d.capePos)
|
|
164
|
-
if (d.capeRot && cape?.rotation) cape.rotation.copy(d.capeRot)
|
|
165
|
-
|
|
166
|
-
if (d.elytraPos && elytra?.position) elytra.position.copy(d.elytraPos)
|
|
167
|
-
if (d.elytraRot && elytra?.rotation) elytra.rotation.copy(d.elytraRot)
|
|
120
|
+
player.elytra.position.copy(d.elytraPos)
|
|
121
|
+
player.elytra.rotation.copy(d.elytraRot)
|
|
168
122
|
}
|
|
169
123
|
|
|
170
124
|
animate(player) {
|
|
171
125
|
const dt = this._dt || 0
|
|
126
|
+
|
|
172
127
|
if (!this._defaults) this._captureDefaults(player)
|
|
173
128
|
this._applyDefaults(player)
|
|
174
129
|
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
const targetMove = clamp01(externalMove)
|
|
179
|
-
const targetRun = clamp01(externalRun)
|
|
180
|
-
const targetCrouch = this.isCrouched ? 1 : 0
|
|
181
|
-
|
|
182
|
-
const kMove = Math.min(1, dt * 8)
|
|
183
|
-
const kRun = Math.min(1, dt * 6)
|
|
184
|
-
const kCrouch = Math.min(1, dt * 7)
|
|
185
|
-
|
|
130
|
+
const targetMove = this.isMoving ? 1 : 0
|
|
131
|
+
const kMove = Math.min(1, dt * 20)
|
|
186
132
|
this._moveBlend += (targetMove - this._moveBlend) * kMove
|
|
187
|
-
this._runBlend += (targetRun - this._runBlend) * kRun
|
|
188
|
-
this._crouchBlend += (targetCrouch - this._crouchBlend) * kCrouch
|
|
189
133
|
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
const crouchBlend = clamp01(this._crouchBlend)
|
|
134
|
+
const speed = this.isRunning ? 10 : 8
|
|
135
|
+
this._phase += dt * speed * this._moveBlend
|
|
193
136
|
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
const speed = baseSpeed * crouchSpeedMul
|
|
137
|
+
const t = this._phase + (this.isRunning ? Math.PI * 0.5 : 0)
|
|
138
|
+
let reset = false
|
|
197
139
|
|
|
198
|
-
this.
|
|
199
|
-
this._idlePhase += dt * 1.15
|
|
140
|
+
applyCrouchPose(player, this.isCrouched ? 1 : 0)
|
|
200
141
|
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (boundary < 0.02) {
|
|
206
|
-
const cb = this.switchAnimationCallback
|
|
207
|
-
this.switchAnimationCallback = null
|
|
208
|
-
cb?.()
|
|
142
|
+
const boundary = this.isRunning ? Math.cos(t) : Math.sin(t)
|
|
143
|
+
if (Math.abs(boundary) < 0.02) {
|
|
144
|
+
if (this.switchAnimationCallback) {
|
|
145
|
+
reset = true
|
|
209
146
|
}
|
|
210
147
|
}
|
|
211
148
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const kLook = Math.min(1, dt * 14)
|
|
220
|
-
this._lookYawBlend += (targetLookYaw - this._lookYawBlend) * kLook
|
|
221
|
-
this._lookPitchBlend += (targetLookPitch - this._lookPitchBlend) * kLook
|
|
222
|
-
|
|
223
|
-
if (player?.skin?.head?.rotation) {
|
|
224
|
-
player.skin.head.rotation.y += this._lookYawBlend
|
|
225
|
-
player.skin.head.rotation.x += this._lookPitchBlend
|
|
149
|
+
if (this.isRunning) {
|
|
150
|
+
player.skin.leftLeg.rotation.x = Math.cos(t + Math.PI) * 1.3
|
|
151
|
+
player.skin.rightLeg.rotation.x = Math.cos(t) * 1.3
|
|
152
|
+
} else {
|
|
153
|
+
player.skin.leftLeg.rotation.x = Math.sin(t) * 0.5
|
|
154
|
+
player.skin.rightLeg.rotation.x = Math.sin(t + Math.PI) * 0.5
|
|
226
155
|
}
|
|
227
156
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
player.skin.body.rotation.x += b * 0.02 * idleStrength
|
|
232
|
-
player.skin.head.rotation.x += -b * 0.015 * idleStrength
|
|
233
|
-
player.skin.leftArm.rotation.x += b * 0.03 * idleStrength
|
|
234
|
-
player.skin.rightArm.rotation.x += -b * 0.03 * idleStrength
|
|
235
|
-
if (player?.cape?.rotation) player.cape.rotation.x += Math.sin(this._idlePhase * 0.7) * 0.03 * idleStrength
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (moveBlend > 0.0001 && player?.skin) {
|
|
239
|
-
const legAmp = mix(1, 0.85, crouchBlend)
|
|
240
|
-
const armAmp = mix(1, 0.7, crouchBlend)
|
|
241
|
-
|
|
242
|
-
const walkLegL = Math.sin(t) * 0.5
|
|
243
|
-
const walkLegR = Math.sin(t + Math.PI) * 0.5
|
|
244
|
-
const runLegL = Math.cos(t + Math.PI) * 1.3
|
|
245
|
-
const runLegR = Math.cos(t) * 1.3
|
|
246
|
-
|
|
247
|
-
player.skin.leftLeg.rotation.x += mix(walkLegL, runLegL, runBlend) * moveBlend * legAmp
|
|
248
|
-
player.skin.rightLeg.rotation.x += mix(walkLegR, runLegR, runBlend) * moveBlend * legAmp
|
|
249
|
-
|
|
250
|
-
const walkArmL = Math.sin(t + Math.PI) * 0.5
|
|
251
|
-
const walkArmR = Math.sin(t) * 0.5
|
|
252
|
-
const runArmL = Math.cos(t) * 1.5
|
|
253
|
-
const runArmR = Math.cos(t + Math.PI) * 1.5
|
|
254
|
-
|
|
255
|
-
player.skin.leftArm.rotation.x += mix(walkArmL, runArmL, runBlend) * moveBlend * armAmp
|
|
256
|
-
player.skin.rightArm.rotation.x += mix(walkArmR, runArmR, runBlend) * moveBlend * armAmp
|
|
257
|
-
|
|
258
|
-
const walkArmZBase = Math.PI * 0.02
|
|
259
|
-
const runArmZBase = Math.PI * 0.1
|
|
260
|
-
const armZBase = mix(walkArmZBase, runArmZBase, runBlend)
|
|
157
|
+
if (this.isRunning) {
|
|
158
|
+
player.skin.leftArm.rotation.x = Math.cos(t) * 1.5
|
|
159
|
+
player.skin.rightArm.rotation.x = Math.cos(t + Math.PI) * 1.5
|
|
261
160
|
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
161
|
+
const basicArmRotationZ = Math.PI * 0.1
|
|
162
|
+
player.skin.leftArm.rotation.z = Math.cos(t) * 0.1 + basicArmRotationZ
|
|
163
|
+
player.skin.rightArm.rotation.z = Math.cos(t + Math.PI) * 0.1 - basicArmRotationZ
|
|
164
|
+
} else {
|
|
165
|
+
player.skin.leftArm.rotation.x = Math.sin(t + Math.PI) * 0.5
|
|
166
|
+
player.skin.rightArm.rotation.x = Math.sin(t) * 0.5
|
|
266
167
|
|
|
267
|
-
|
|
268
|
-
player.skin.
|
|
269
|
-
|
|
270
|
-
if (this._defaults?.playerRot) {
|
|
271
|
-
player.rotation.z = this._defaults.playerRot.z + Math.cos(t + Math.PI) * 0.01 * runBlend * moveBlend
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const capeBase = mix(Math.PI * 0.06, Math.PI * 0.3, runBlend)
|
|
275
|
-
const capeWave = mix(Math.sin(t / 1.5) * 0.06, Math.sin(t * 2) * 0.1, runBlend)
|
|
276
|
-
if (player?.cape?.rotation) player.cape.rotation.x += (capeBase + capeWave) * moveBlend
|
|
168
|
+
const basicArmRotationZ = Math.PI * 0.02
|
|
169
|
+
player.skin.leftArm.rotation.z = Math.cos(t) * 0.03 + basicArmRotationZ
|
|
170
|
+
player.skin.rightArm.rotation.z = Math.cos(t + Math.PI) * 0.03 - basicArmRotationZ
|
|
277
171
|
}
|
|
278
172
|
|
|
279
173
|
if (this._swingTime !== null) {
|
|
280
174
|
this._swingTime += dt
|
|
281
175
|
const p = Math.min(this._swingTime / this._swingDuration, 1)
|
|
282
|
-
HitAnimation.animate(p, player,
|
|
176
|
+
HitAnimation.animate(p, player, this.isMoving)
|
|
283
177
|
if (p >= 1) this._swingTime = null
|
|
284
178
|
}
|
|
179
|
+
|
|
180
|
+
if (this.isRunning) {
|
|
181
|
+
player.rotation.z = Math.cos(t + Math.PI) * 0.01
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (this.isRunning) {
|
|
185
|
+
const basicCapeRotationX = Math.PI * 0.3
|
|
186
|
+
player.cape.rotation.x = Math.sin(t * 2) * 0.1 + basicCapeRotationX
|
|
187
|
+
} else {
|
|
188
|
+
const basicCapeRotationX = Math.PI * 0.06
|
|
189
|
+
player.cape.rotation.x = Math.sin(t / 1.5) * 0.06 + basicCapeRotationX
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (reset) {
|
|
193
|
+
const cb = this.switchAnimationCallback
|
|
194
|
+
this.switchAnimationCallback = null
|
|
195
|
+
cb?.()
|
|
196
|
+
}
|
|
285
197
|
}
|
|
286
198
|
}
|
|
287
199
|
|
|
@@ -289,11 +201,6 @@ const HitAnimation = {
|
|
|
289
201
|
animate(progress, player, isMovingOrRunning) {
|
|
290
202
|
if (!player?.skin?.rightArm?.rotation) return
|
|
291
203
|
|
|
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
204
|
const swing = Math.sin(progress * Math.PI)
|
|
298
205
|
player.skin.rightArm.rotation.x = -0.4537860552 * 2 - 2 * swing * 0.3
|
|
299
206
|
|
|
@@ -354,4 +261,4 @@ function applyCrouchPose(player, crouchBlend) {
|
|
|
354
261
|
|
|
355
262
|
skin.rightLeg.position.z += -3.4500310377 * s
|
|
356
263
|
skin.leftLeg.position.z += -3.4500310377 * s
|
|
357
|
-
}
|
|
264
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import * as THREE from 'three'
|
|
3
3
|
|
|
4
|
-
/** Contract for a main-menu background implementation (classic cubemap,
|
|
4
|
+
/** Contract for a main-menu background implementation (classic cubemap, v2 scene, etc.). */
|
|
5
5
|
export interface MenuBackgroundView {
|
|
6
6
|
readonly scene: THREE.Scene
|
|
7
7
|
readonly camera: THREE.PerspectiveCamera
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import type { MenuBackgroundMode } from './types'
|
|
3
|
-
import type {
|
|
3
|
+
import type { V2CameraId, V2SceneId, MinecraftBlockGroupId } from './v2'
|
|
4
4
|
|
|
5
5
|
/** Single source of truth for menu-background defaults (settings + runtime fallbacks). */
|
|
6
6
|
export const MENU_BACKGROUND_OPTION_DEFAULTS = {
|
|
7
|
-
mode: '
|
|
7
|
+
mode: 'v2' as MenuBackgroundMode,
|
|
8
8
|
minecraftTextures: true as boolean,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
v2Scene: 'light' as V2SceneId,
|
|
10
|
+
v2Camera: 'dive' as V2CameraId,
|
|
11
|
+
v2BlockGroup: 'stainedGlass' as MinecraftBlockGroupId,
|
|
12
12
|
/** 0–200 (%). 100 = 1× motion. */
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
v2CameraSpeedPercent: 80,
|
|
14
|
+
v2BlockSpeedPercent: 40
|
|
15
15
|
} as const
|
|
16
16
|
|
|
17
17
|
export const menuBackgroundSpeedToMultiplier = (percent: number) => percent / 100
|
|
18
18
|
|
|
19
19
|
/** Default camera / block motion multipliers (1 = 100%). */
|
|
20
20
|
export const MENU_BACKGROUND_MOTION_DEFAULTS = {
|
|
21
|
-
camera: menuBackgroundSpeedToMultiplier(MENU_BACKGROUND_OPTION_DEFAULTS.
|
|
22
|
-
block: menuBackgroundSpeedToMultiplier(MENU_BACKGROUND_OPTION_DEFAULTS.
|
|
21
|
+
camera: menuBackgroundSpeedToMultiplier(MENU_BACKGROUND_OPTION_DEFAULTS.v2CameraSpeedPercent),
|
|
22
|
+
block: menuBackgroundSpeedToMultiplier(MENU_BACKGROUND_OPTION_DEFAULTS.v2BlockSpeedPercent)
|
|
23
23
|
} as const
|
|
@@ -6,21 +6,21 @@ export type { MenuBackgroundMode, MenuBackgroundOptions } from './types'
|
|
|
6
6
|
export { resolveMenuBackgroundMode } from './types'
|
|
7
7
|
export { ClassicMenuBackground } from './classic'
|
|
8
8
|
export type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
V2SceneId,
|
|
10
|
+
V2CameraId,
|
|
11
|
+
V2MenuBackgroundOptions,
|
|
12
12
|
MinecraftBlockGroupId
|
|
13
|
-
} from './
|
|
13
|
+
} from './v2'
|
|
14
14
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
V2MenuBackground,
|
|
16
|
+
V2_SCENE_IDS,
|
|
17
|
+
V2_CAMERA_IDS,
|
|
18
|
+
V2_SCENE_LABELS,
|
|
19
|
+
V2_CAMERA_LABELS,
|
|
20
20
|
MINECRAFT_BLOCK_GROUPS,
|
|
21
21
|
MINECRAFT_BLOCK_GROUP_IDS,
|
|
22
22
|
MINECRAFT_BLOCK_GROUP_LABELS
|
|
23
|
-
} from './
|
|
23
|
+
} from './v2'
|
|
24
24
|
export { WorldBlocksMenuBackground } from './worldBlocks'
|
|
25
25
|
export { MenuBackgroundRenderer } from './renderer'
|
|
26
26
|
export {
|
|
@@ -3,14 +3,14 @@ import * as THREE from 'three'
|
|
|
3
3
|
import type { GraphicsInitOptions } from '../../graphicsBackend/types'
|
|
4
4
|
import type { DocumentRenderer } from '../documentRenderer'
|
|
5
5
|
import { ClassicMenuBackground } from './classic'
|
|
6
|
-
import {
|
|
6
|
+
import { V2MenuBackground } from './v2'
|
|
7
7
|
import { WorldBlocksMenuBackground } from './worldBlocks'
|
|
8
8
|
import type { MenuBackgroundView } from './activeView'
|
|
9
9
|
import type { MenuBackgroundOptions } from './types'
|
|
10
10
|
import { resolveMenuBackgroundMode } from './types'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Orchestrates main-menu background rendering (dispatches to classic /
|
|
13
|
+
* Orchestrates main-menu background rendering (dispatches to classic / v2 / world-blocks).
|
|
14
14
|
*/
|
|
15
15
|
export class MenuBackgroundRenderer {
|
|
16
16
|
private active?: MenuBackgroundView
|
|
@@ -27,9 +27,9 @@ export class MenuBackgroundRenderer {
|
|
|
27
27
|
this.mode = resolveMenuBackgroundMode(menuBackgroundOptions, singleFileBuild)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/** Active
|
|
31
|
-
get
|
|
32
|
-
return this.active instanceof
|
|
30
|
+
/** Active v2 instance when that style is running. */
|
|
31
|
+
get v2(): V2MenuBackground | undefined {
|
|
32
|
+
return this.active instanceof V2MenuBackground ? this.active : undefined
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
get scene(): THREE.Scene | undefined {
|
|
@@ -64,16 +64,16 @@ export class MenuBackgroundRenderer {
|
|
|
64
64
|
|
|
65
65
|
private createImplementation(options: MenuBackgroundOptions): MenuBackgroundView {
|
|
66
66
|
switch (this.mode) {
|
|
67
|
-
case '
|
|
68
|
-
return new
|
|
67
|
+
case 'v2':
|
|
68
|
+
return new V2MenuBackground(
|
|
69
69
|
this.documentRenderer,
|
|
70
70
|
{
|
|
71
71
|
useMinecraftTextures: options.useMinecraftTextures,
|
|
72
|
-
initialScene: options.
|
|
73
|
-
initialCamera: options.
|
|
74
|
-
initialBlockGroup: options.
|
|
75
|
-
initialCameraSpeed: options.
|
|
76
|
-
initialBlockSpeed: options.
|
|
72
|
+
initialScene: options.v2Scene,
|
|
73
|
+
initialCamera: options.v2Camera,
|
|
74
|
+
initialBlockGroup: options.v2BlockGroup,
|
|
75
|
+
initialCameraSpeed: options.v2CameraSpeed,
|
|
76
|
+
initialBlockSpeed: options.v2BlockSpeed,
|
|
77
77
|
resourcesManager: options.resourcesManager
|
|
78
78
|
},
|
|
79
79
|
this.abortController.signal
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import type { ResourcesManager } from '../../resourcesManager/resourcesManager'
|
|
3
|
-
import type {
|
|
3
|
+
import type { V2CameraId, V2SceneId, MinecraftBlockGroupId } from './v2'
|
|
4
4
|
import { MENU_BACKGROUND_OPTION_DEFAULTS } from './config'
|
|
5
5
|
|
|
6
|
-
export type {
|
|
6
|
+
export type { V2CameraId, V2SceneId, MinecraftBlockGroupId } from './v2'
|
|
7
7
|
|
|
8
|
-
export type MenuBackgroundMode = 'classic' | '
|
|
8
|
+
export type MenuBackgroundMode = 'classic' | 'v2' | 'worldBlocks'
|
|
9
9
|
|
|
10
10
|
export interface MenuBackgroundOptions {
|
|
11
11
|
/** Visual style. Defaults to {@link MENU_BACKGROUND_OPTION_DEFAULTS.mode}, or `worldBlocks` in single-file build. */
|
|
12
12
|
mode?: MenuBackgroundMode
|
|
13
|
-
/**
|
|
13
|
+
/** V2 style: load block atlas and render textured cubes (requires assets / mcData). */
|
|
14
14
|
useMinecraftTextures?: boolean
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
v2Scene?: V2SceneId
|
|
16
|
+
v2Camera?: V2CameraId
|
|
17
17
|
/** Block pool when {@link useMinecraftTextures} is enabled. */
|
|
18
|
-
|
|
18
|
+
v2BlockGroup?: MinecraftBlockGroupId
|
|
19
19
|
/** Camera path speed (1 = 100%). */
|
|
20
|
-
|
|
20
|
+
v2CameraSpeed?: number
|
|
21
21
|
/** Block fly-through + sky drift speed (1 = 100%). */
|
|
22
|
-
|
|
22
|
+
v2BlockSpeed?: number
|
|
23
23
|
/**
|
|
24
24
|
* Optional shared resource manager (e.g. appViewer.resourcesManager).
|
|
25
25
|
* Caller should run `updateAssetsData` after mcData is loaded when using textured cubes.
|