diff --git a/client/renderer/models.ts b/client/renderer/models.ts index db0e0a3..6f47bc9 100644 --- a/client/renderer/models.ts +++ b/client/renderer/models.ts @@ -26,16 +26,13 @@ function push_vertex( return i; } -export function pushFrontFace( +export function push_front_face( vertices: Float32Array, i: number, texture: Texture, x: number, y: number, z: number, - w: number, - h: number, - d: number, sx: number, sy: number, sw: number, @@ -45,9 +42,9 @@ export function pushFrontFace( b = 1, a = 1, ) { - const x2 = x + w; - const y2 = y + h; - const z2 = z + d; + const x2 = x + 1; + const y2 = y + 1; + const z2 = z + 1; const u0 = sx / texture.width; const v0 = sy / texture.height; @@ -65,16 +62,13 @@ export function pushFrontFace( return i; } -export function pushBackFace( +export function push_back_face( vertices: Float32Array, i: number, texture: Texture, x: number, y: number, z: number, - w: number, - h: number, - d: number, sx: number, sy: number, sw: number, @@ -84,7 +78,8 @@ export function pushBackFace( b = 1, a = 1, ) { - const x2 = x + w, y2 = y + h; + const x2 = x + 1; + const y2 = y + 1; const u0 = sx / texture.width; const v0 = sy / texture.height; @@ -102,16 +97,13 @@ export function pushBackFace( return i; } -export function pushLeftFace( +export function push_left_face( vertices: Float32Array, i: number, texture: Texture, x: number, y: number, z: number, - w: number, - h: number, - d: number, sx: number, sy: number, sw: number, @@ -121,8 +113,8 @@ export function pushLeftFace( b = 1, a = 1, ) { - const y2 = y + h; - const z2 = z + d; + const y2 = y + 1; + const z2 = z + 1; const u0 = sx / texture.width; const v0 = sy / texture.height; @@ -140,16 +132,13 @@ export function pushLeftFace( return i; } -export function pushRightFace( +export function push_right_face( vertices: Float32Array, i: number, texture: Texture, x: number, y: number, z: number, - w: number, - h: number, - d: number, sx: number, sy: number, sw: number, @@ -159,34 +148,33 @@ export function pushRightFace( b = 1, a = 1, ) { - const x2 = x + w, y2 = y + h; + const x2 = x + 1; + const y2 = y + 1; + const z2 = z + 1; const u0 = sx / texture.width; const v0 = sy / texture.height; const u1 = (sx + sw) / texture.width; const v1 = (sy + sh) / texture.height; - i = push_vertex(vertices, i, x2, y, z + d, u0, v1, r, g, b, a); + i = push_vertex(vertices, i, x2, y, z2, u0, v1, r, g, b, a); i = push_vertex(vertices, i, x2, y, z, u1, v1, r, g, b, a); i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a); - i = push_vertex(vertices, i, x2, y, z + d, u0, v1, r, g, b, a); + i = push_vertex(vertices, i, x2, y, z2, u0, v1, r, g, b, a); i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a); - i = push_vertex(vertices, i, x2, y2, z + d, u0, v0, r, g, b, a); + i = push_vertex(vertices, i, x2, y2, z2, u0, v0, r, g, b, a); return i; } -export function pushTopFace( +export function push_top_face( vertices: Float32Array, i: number, texture: Texture, x: number, y: number, z: number, - w: number, - h: number, - d: number, sx: number, sy: number, sw: number, @@ -196,7 +184,9 @@ export function pushTopFace( b = 1, a = 1, ) { - const x2 = x + w, z2 = z + d, y2 = y + h; + const x2 = x + 1; + const z2 = z + 1; + const y2 = y + 1; const u0 = sx / texture.width; const v0 = sy / texture.height; @@ -214,16 +204,13 @@ export function pushTopFace( return i; } -export function pushBottomFace( +export function push_bottom_face( vertices: Float32Array, i: number, texture: Texture, x: number, y: number, z: number, - w: number, - h: number, - d: number, sx: number, sy: number, sw: number, @@ -233,7 +220,8 @@ export function pushBottomFace( b = 1, a = 1, ) { - const x2 = x + w, z2 = z + d; + const x2 = x + 1; + const z2 = z + 1; const u0 = sx / texture.width; const v0 = sy / texture.height; diff --git a/client/systems/rendering/dimension.ts b/client/systems/rendering/dimension.ts index 8817217..4a584f2 100644 --- a/client/systems/rendering/dimension.ts +++ b/client/systems/rendering/dimension.ts @@ -5,12 +5,12 @@ import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry. import { flush_buffer, gl, - pushBackFace, - pushBottomFace, - pushFrontFace, - pushLeftFace, - pushRightFace, - pushTopFace, + push_back_face, + push_bottom_face, + push_front_face, + push_left_face, + push_right_face, + push_top_face, set_current_texture, } from "$/client/renderer/mod.ts"; import { Camera } from "$/client/components/camera.ts"; @@ -40,12 +40,12 @@ function render_chunk_opaque(chunk: Chunk) { } const FACE_PUSHING_FUNCTIONS = { - top: pushTopFace, - bottom: pushBottomFace, - front: pushFrontFace, - back: pushBackFace, - left: pushLeftFace, - right: pushRightFace, + top: push_top_face, + bottom: push_bottom_face, + front: push_front_face, + back: push_back_face, + left: push_left_face, + right: push_right_face, } as const; function make_chunk_mesh(chunk: Chunk, dimension: Dimension, camera: Camera) { @@ -139,9 +139,6 @@ function make_chunk_mesh(chunk: Chunk, dimension: Dimension, camera: Camera) { wx, y, wz, - 1, - 1, - 1, region.x * TEXTURE_SIZE, region.y * TEXTURE_SIZE, TEXTURE_SIZE,