2525 left : 0 ;
2626 width : 100vw ;
2727 height : 100vh ;
28- //background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
2928 background : linear-gradient (135deg , # 0a0a0a 0% , # 202020 100% );
3029 display : flex;
3130 flex-direction : column;
114113 const progressBar = document . getElementById ( 'progress-bar' ) ;
115114 const progressText = document . getElementById ( 'progress-text' ) ;
116115 const loadingScreen = document . getElementById ( 'loading-screen' ) ;
116+ let progs = { }
117117
118118 function updateProgress ( progress , text ) {
119119 progressBar . style . width = ( progress * 100 ) + '%' ;
125125 setTimeout ( ( ) => { loadingScreen . style . display = 'none' ; } , 500 ) ;
126126 }
127127
128- async function fetchBlock ( url , text , startProgress , stepProgress ) {
128+ async function fetchBlock ( url , text ) {
129129 let response = await fetch ( url ) ;
130130 const reader = response . body . getReader ( ) ;
131131 const contentLength = + response . headers . get ( 'Content-Length' ) ;
136136 break ;
137137 }
138138 receivedLength += value . length ;
139- const progress = startProgress + ( receivedLength / contentLength ) * stepProgress ;
140- updateProgress ( progress , text )
139+ progs [ url ] = receivedLength / contentLength ;
140+ const minimalProgress = Math . min ( ...Object . values ( progs ) )
141+ updateProgress ( minimalProgress , text )
141142 }
142143 }
143144
144145 updateProgress ( 0 , 'Loading kool...' ) ;
145146
146147 // Fetch essential files tracking progress before actually loading them - will be loaded from cache afterwards
147- await fetchBlock ( 'kool-demo.js ' , 'Loading kool...' , 0 , 0.4 )
148- await fetchBlock ( 'assets/fonts/fira-sans-regular.png ' , 'Loading fonts ...' , 0.4 , 0.6 )
149- await fetchBlock ( '4ab48fc16bcbc6611bb2.wasm ' , 'Loading PhysX ...' , 0.6 , 1.0 )
148+ fetchBlock ( 'assets/fonts/fira-sans-regular.png ' , 'Loading kool...' )
149+ fetchBlock ( '4ab48fc16bcbc6611bb2.wasm ' , 'Loading kool ...' )
150+ await fetchBlock ( 'kool-demo.js ' , 'Loading kool ...' )
150151
151152 const script = document . createElement ( 'script' ) ;
152153 script . src = 'kool-demo.js' ;
160161 document . head . appendChild ( script ) ;
161162 </ script >
162163</ body >
163- </ html >
164+ </ html >
0 commit comments