Make max block select ditance a param
This commit is contained in:
parent
fff1fe89a2
commit
f045a8fff1
6
index.js
6
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(),
|
||||
|
Loading…
Reference in New Issue
Block a user