diff --git a/index.js b/index.js index 1ff44de..0a84680 100644 --- a/index.js +++ b/index.js @@ -205,7 +205,7 @@ function tagABlock(gl, params, objects) { const ori = se3.inverse(se3.rotxyz(-camori[0], -camori[1], -camori[2])); const viewDirection = se3.apply(ori, dir).slice(0, 3); - const face = markBlock(params.world, params.camera.position, viewDirection); + const face = markBlock(params.world, params.camera.position, viewDirection, params.blockSelectDistance); if (face === undefined) { return; } @@ -368,8 +368,7 @@ function castRay(world, origin, direction, maxDistance) { } } -function markBlock(world, cameraPosition, direction) { - const maxDistance = 10; +function markBlock(world, cameraPosition, direction, maxDistance) { const hit = castRay(world, cameraPosition, direction, maxDistance); if (hit === undefined) { @@ -507,6 +506,7 @@ async function main() { keys: new Set(), lightDirection: [-0.2, -0.5, 0.4], ambiantLight: 0.7, + blockSelectDistance: 8, flying: false, isOnGround: false, world: makeWorld(),