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 ori = se3.inverse(se3.rotxyz(-camori[0], -camori[1], -camori[2]));
|
||||||
const viewDirection = se3.apply(ori, dir).slice(0, 3);
|
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) {
|
if (face === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -368,8 +368,7 @@ function castRay(world, origin, direction, maxDistance) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function markBlock(world, cameraPosition, direction) {
|
function markBlock(world, cameraPosition, direction, maxDistance) {
|
||||||
const maxDistance = 10;
|
|
||||||
const hit = castRay(world, cameraPosition, direction, maxDistance);
|
const hit = castRay(world, cameraPosition, direction, maxDistance);
|
||||||
|
|
||||||
if (hit === undefined) {
|
if (hit === undefined) {
|
||||||
@ -507,6 +506,7 @@ async function main() {
|
|||||||
keys: new Set(),
|
keys: new Set(),
|
||||||
lightDirection: [-0.2, -0.5, 0.4],
|
lightDirection: [-0.2, -0.5, 0.4],
|
||||||
ambiantLight: 0.7,
|
ambiantLight: 0.7,
|
||||||
|
blockSelectDistance: 8,
|
||||||
flying: false,
|
flying: false,
|
||||||
isOnGround: false,
|
isOnGround: false,
|
||||||
world: makeWorld(),
|
world: makeWorld(),
|
||||||
|
Loading…
Reference in New Issue
Block a user