@@ -8,13 +8,15 @@ import { proxy, subscribe } from 'valtio'
88import { getDefaultRendererState } from 'renderer/viewer/baseGraphicsBackend'
99import { getSyncWorld } from 'renderer/playground/shared'
1010import { MaybePromise } from 'contro-max/build/types/store'
11+ import { PANORAMA_VERSION } from 'renderer/viewer/three/panoramaShared'
1112import { playerState } from './mineflayer/playerState'
1213import { createNotificationProgressReporter , ProgressReporter } from './core/progressReporter'
1314import { setLoadingScreenStatus } from './appStatus'
1415import { activeModalStack , miscUiState } from './globalState'
1516import { options } from './optionsStorage'
1617import { ResourcesManager , ResourcesManagerTransferred } from './resourcesManager'
1718import { watchOptionsAfterWorldViewInit } from './watchOptions'
19+ import { loadMinecraftData } from './connect'
1820
1921export interface RendererReactiveState {
2022 world : {
@@ -112,7 +114,7 @@ export class AppViewer {
112114 inWorldRenderingConfig : WorldRendererConfig = proxy ( defaultWorldRendererConfig )
113115 lastCamUpdate = 0
114116 playerState = playerState
115- rendererState = proxy ( getDefaultRendererState ( ) . reactive )
117+ rendererState = getDefaultRendererState ( ) . reactive
116118 nonReactiveState : NonReactiveState = getDefaultRendererState ( ) . nonReactive
117119 worldReady : Promise < void >
118120 private resolveWorldReady : ( ) => void
@@ -162,11 +164,15 @@ export class AppViewer {
162164
163165 // Execute queued action if exists
164166 if ( this . currentState ) {
165- const { method, args } = this . currentState
166- this . backend [ method ] ( ...args )
167- if ( method === 'startWorld' ) {
168- void this . worldView ! . init ( bot . entity . position )
169- // void this.worldView!.init(args[0].playerState.getPosition())
167+ if ( this . currentState . method === 'startPanorama' ) {
168+ this . startPanorama ( )
169+ } else {
170+ const { method, args } = this . currentState
171+ this . backend [ method ] ( ...args )
172+ if ( method === 'startWorld' ) {
173+ void this . worldView ! . init ( bot . entity . position )
174+ // void this.worldView!.init(args[0].playerState.getPosition())
175+ }
170176 }
171177 }
172178
@@ -225,10 +231,16 @@ export class AppViewer {
225231
226232 startPanorama ( ) {
227233 if ( this . currentDisplay === 'menu' ) return
228- this . currentDisplay = 'menu'
229234 if ( options . disableAssets ) return
230- if ( this . backend ) {
231- this . backend . startPanorama ( )
235+ if ( this . backend && ! hasAppStatus ( ) ) {
236+ this . currentDisplay = 'menu'
237+ if ( process . env . SINGLE_FILE_BUILD_MODE ) {
238+ void loadMinecraftData ( PANORAMA_VERSION ) . then ( ( ) => {
239+ this . backend ?. startPanorama ( )
240+ } )
241+ } else {
242+ this . backend . startPanorama ( )
243+ }
232244 }
233245 this . currentState = { method : 'startPanorama' , args : [ ] }
234246 }
@@ -316,15 +328,16 @@ const initialMenuStart = async () => {
316328}
317329window . initialMenuStart = initialMenuStart
318330
331+ const hasAppStatus = ( ) => activeModalStack . some ( m => m . reactType === 'app-status' )
332+
319333const modalStackUpdateChecks = ( ) => {
320334 // maybe start panorama
321- if ( ! miscUiState . gameLoaded ) {
335+ if ( ! miscUiState . gameLoaded && ! hasAppStatus ( ) ) {
322336 void initialMenuStart ( )
323337 }
324338
325339 if ( appViewer . backend ) {
326- const hasAppStatus = activeModalStack . some ( m => m . reactType === 'app-status' )
327- appViewer . backend . setRendering ( ! hasAppStatus )
340+ appViewer . backend . setRendering ( ! hasAppStatus ( ) )
328341 }
329342
330343 appViewer . inWorldRenderingConfig . foreground = activeModalStack . length === 0
0 commit comments