Client side chunk sections

This commit is contained in:
2026-11-07 10:39:16 -03:00
parent 8e14e9842a
commit 71cbf901a5
19 changed files with 162 additions and 116 deletions
+6 -3
View File
@@ -10,6 +10,7 @@ import { Frustum } from "@/client/rendering/frustum.ts";
import { group_faces_camera } from "@/client/rendering/level_renderer.ts";
import { FACE_GROUPS, type LayerMesh, TERRAIN_VERTEX_BYTES } from "@/client/workers/chunk_messages.ts";
import { decode_level_chunk } from "@/common/chunk_streaming.ts";
import type { Section } from "@/common/section.ts";
import { test_game } from "./helpers.ts";
// the matrix the renderer makes for a camera, see update_camera in client/renderer/core.ts
@@ -62,10 +63,10 @@ async function mesh_chunks(radius: number) {
visuals: [],
});
const generated = new Map<string, Uint32Array>();
const generated = new Map<string, Section[]>();
for (let x = -radius - 1; x <= radius + 1; x++) {
for (let z = -radius - 1; z <= radius + 1; z++) {
generated.set(`${x},${z}`, decode_level_chunk(game.world.level_chunk(x, z)).blocks);
generated.set(`${x},${z}`, decode_level_chunk(game.world.level_chunk(x, z)).sections);
}
}
const meshes = [];
@@ -73,7 +74,9 @@ async function mesh_chunks(radius: number) {
for (let z = -radius; z <= radius; z++) {
const chunks = [];
for (let dz = -1; dz <= 1; dz++) {
for (let dx = -1; dx <= 1; dx++) chunks.push(generated.get(`${x + dx},${z + dz}`)!.slice());
for (let dx = -1; dx <= 1; dx++) {
chunks.push(generated.get(`${x + dx},${z + dz}`)!.map((section) => section.data));
}
}
meshes.push(
await ask({