|
1 | 1 | import { WorldDataEmitter, WorldDataEmitterWorker } from 'renderer/viewer/lib/worldDataEmitter' |
2 | | -import { PlayerStateRenderer } from 'renderer/viewer/lib/basePlayerState' |
| 2 | +import { getInitialPlayerState, PlayerStateRenderer } from 'renderer/viewer/lib/basePlayerState' |
3 | 3 | import { subscribeKey } from 'valtio/utils' |
4 | 4 | import { defaultWorldRendererConfig, WorldRendererConfig } from 'renderer/viewer/lib/worldrendererCommon' |
5 | 5 | import { Vec3 } from 'vec3' |
@@ -281,19 +281,31 @@ const initialMenuStart = async () => { |
281 | 281 | if (appViewer.currentDisplay === 'world') { |
282 | 282 | appViewer.resetBackend(true) |
283 | 283 | } |
284 | | - appViewer.startPanorama() |
| 284 | + const demo = new URLSearchParams(window.location.search).get('demo') |
| 285 | + if (!demo) { |
| 286 | + appViewer.startPanorama() |
| 287 | + return |
| 288 | + } |
285 | 289 |
|
286 | 290 | // const version = '1.18.2' |
287 | | - // const version = '1.21.4' |
288 | | - // await appViewer.resourcesManager.loadMcData(version) |
289 | | - // const world = getSyncWorld(version) |
290 | | - // world.setBlockStateId(new Vec3(0, 64, 0), loadedData.blocksByName.water.defaultState) |
291 | | - // appViewer.resourcesManager.currentConfig = { version } |
292 | | - // await appViewer.resourcesManager.updateAssetsData({}) |
293 | | - // appViewer.playerState = new BasePlayerState() as any |
294 | | - // await appViewer.startWorld(world, 3) |
295 | | - // appViewer.backend?.updateCamera(new Vec3(0, 64, 2), 0, 0) |
296 | | - // void appViewer.worldView!.init(new Vec3(0, 64, 0)) |
| 291 | + const version = '1.21.4' |
| 292 | + const { loadMinecraftData } = await import('./connect') |
| 293 | + const { getSyncWorld } = await import('../renderer/playground/shared') |
| 294 | + await loadMinecraftData(version) |
| 295 | + const world = getSyncWorld(version) |
| 296 | + world.setBlockStateId(new Vec3(0, 64, 0), loadedData.blocksByName.water.defaultState) |
| 297 | + world.setBlockStateId(new Vec3(1, 64, 0), loadedData.blocksByName.water.defaultState) |
| 298 | + world.setBlockStateId(new Vec3(1, 64, 1), loadedData.blocksByName.water.defaultState) |
| 299 | + world.setBlockStateId(new Vec3(0, 64, 1), loadedData.blocksByName.water.defaultState) |
| 300 | + world.setBlockStateId(new Vec3(-1, 64, -1), loadedData.blocksByName.water.defaultState) |
| 301 | + world.setBlockStateId(new Vec3(-1, 64, 0), loadedData.blocksByName.water.defaultState) |
| 302 | + world.setBlockStateId(new Vec3(0, 64, -1), loadedData.blocksByName.water.defaultState) |
| 303 | + appViewer.resourcesManager.currentConfig = { version } |
| 304 | + appViewer.playerState.reactive = getInitialPlayerState() |
| 305 | + await appViewer.resourcesManager.updateAssetsData({}) |
| 306 | + await appViewer.startWorld(world, 3) |
| 307 | + appViewer.backend!.updateCamera(new Vec3(0, 65.7, 0), 0, -Math.PI / 2) // Y+1 and pitch = PI/2 to look down |
| 308 | + void appViewer.worldView!.init(new Vec3(0, 64, 0)) |
297 | 309 | } |
298 | 310 | window.initialMenuStart = initialMenuStart |
299 | 311 |
|
|
0 commit comments