diff --git a/index.js b/index.js index feff417..1067a69 100644 --- a/index.js +++ b/index.js @@ -377,8 +377,6 @@ async function main() { return; } - const worldGl = await initWorldGl(gl); - const params = { projMatrix: se3.perspective(Math.PI / 3, canvas.clientWidth / canvas.clientHeight, 0.1, 100.0), camera: { @@ -392,7 +390,7 @@ async function main() { flying: false, isOnGround: false, world: makeWorld(), - worldGl, + worldGl: await initWorldGl(gl), } document.querySelector('#lightx').oninput = e => { diff --git a/world.js b/world.js index 4ec2777..9bc25f2 100644 --- a/world.js +++ b/world.js @@ -98,7 +98,7 @@ export function blockLookup(world, x, y, z) { if (chunk === undefined) { return { type: BlockType.STONE, - x, y, z, + centerPosition: [x, y, z], }; } @@ -108,9 +108,11 @@ export function blockLookup(world, x, y, z) { return { type: chunk.data[256 * (16*i + j) + k], - x: j, - y: k, - z: i, + centerPosition: [ + Math.floor(midx), + k, + Math.floor(midz), + ], }; }