load near chunks first
This commit is contained in:
parent
6e47e9cd0a
commit
5175232b6d
29
index.js
29
index.js
@ -445,25 +445,28 @@ function updateWorldGeometry(gl, world, z, x, timeLimit = 10000) {
|
|||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
|
|
||||||
// k. Now, generate buffers for all chunks
|
// k. Now, generate buffers for all chunks
|
||||||
for (let i = ic - 8; i < ic + 8; i++) {
|
for (let radius = 0; radius < 8; radius++) {
|
||||||
for (let j = jc - 8; j < jc + 8; j++) {
|
for (let i = ic - radius; i < ic + radius; i++) {
|
||||||
const chunk = world.chunkMap.get(i, j);
|
for (let j = jc - radius; j < jc + radius; j++) {
|
||||||
|
const chunk = world.chunkMap.get(i, j);
|
||||||
|
|
||||||
if (chunk.buffer !== undefined) {
|
if (chunk.buffer !== undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunkz = 16 * i;
|
const chunkz = 16 * i;
|
||||||
const chunkx = 16 * j;
|
const chunkx = 16 * j;
|
||||||
const lookup = (i, j, k) => blockLookup(world, j + chunkx, k, i + chunkz);
|
const lookup = (i, j, k) => blockLookup(world, j + chunkx, k, i + chunkz);
|
||||||
|
|
||||||
chunk.buffer = makeChunkBuffer(gl, chunk.data, chunk.position.z, chunk.position.x, lookup);
|
chunk.buffer = makeChunkBuffer(gl, chunk.data, chunk.position.z, chunk.position.x, lookup);
|
||||||
|
|
||||||
// throttle this for fluidity
|
// throttle this for fluidity
|
||||||
if (performance.now() - start > timeLimit) {
|
if (performance.now() - start > timeLimit) {
|
||||||
throw 'timesup';
|
throw 'timesup';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user