Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
fix: await chunk cache loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed Jan 9, 2024
1 parent 619e4f3 commit 794a7ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/modules/main_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,15 @@ export default function () {
lerp_factor = 0
})

for (let x = -3; x < 3; x++)
for (let z = -3; z < 3; z++) {
CHUNK_CACHE.get(make_chunk_key({ x, z })).forEach(volume =>
instanced_volume.add_volume(volume),
)
}
// @ts-ignore
CHUNK_CACHE.loading.then(() => {
for (let x = -3; x < 3; x++)
for (let z = -3; z < 3; z++) {
CHUNK_CACHE.get(make_chunk_key({ x, z })).forEach(volume =>
instanced_volume.add_volume(volume),
)
}
})

scene.add(instanced_volume)

Expand Down
3 changes: 2 additions & 1 deletion src/utils/import_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ async function import_chunks() {
const time = Date.now()
logger.ASSET('Loading heights..')

fetch(heights)
// @ts-ignore
CHUNK_CACHE.loading = fetch(heights)
.then(response => response.arrayBuffer())
.then(async heights_buffer => {
new Int16Array(HEIGHTS).set(new Int16Array(heights_buffer))
Expand Down

0 comments on commit 794a7ff

Please sign in to comment.