Meshing and lighting per section
This commit is contained in:
@@ -40,17 +40,24 @@ export type ToChunkWorker =
|
||||
// the numeric ids of blocks with visuals, and whether each visual replaces the block's model, see
|
||||
// ctx.render.register_visual
|
||||
visuals: [number, boolean][];
|
||||
// the dimension's height and sky light. the chunks meshed hold all of its height
|
||||
// the dimension's height and sky light
|
||||
shape: WorldShapeJson;
|
||||
}
|
||||
// sections of one chunk to mesh, sent together so they're lit together
|
||||
| {
|
||||
type: "mesh";
|
||||
chunk_x: number;
|
||||
chunk_z: number;
|
||||
version: number;
|
||||
// the sections to mesh, by index from the bottom of the world, and the mesh_version each is meshed for
|
||||
sections: { index: number; version: number }[];
|
||||
// the index of the lowest section in chunks
|
||||
first: number;
|
||||
// the blocks of the 3x3 chunks around it, going +x then +z from -x -z, for lighting. each one's sections from the
|
||||
// bottom of the world up, null for a chunk that isn't loaded
|
||||
// one below the lowest to mesh to the one above the highest, as far as the world goes. null for a chunk that
|
||||
// isn't loaded
|
||||
chunks: (SectionData[] | null)[];
|
||||
// the same chunks' sky heights, see column_heights in common/section.ts
|
||||
sky: (Int16Array | null)[];
|
||||
// the same chunks' biome colors (see Chunk.biome_colors in client_level.ts), blended across their edges
|
||||
biome_colors: (Uint32Array | null)[];
|
||||
// where the camera is, to sort the translucent quads
|
||||
@@ -60,6 +67,8 @@ export type ToChunkWorker =
|
||||
type: "sort";
|
||||
chunk_x: number;
|
||||
chunk_z: number;
|
||||
// the section's index in its chunk
|
||||
index: number;
|
||||
version: number;
|
||||
sort_version: number;
|
||||
centers: Float32Array;
|
||||
@@ -78,36 +87,45 @@ export interface LayerMesh {
|
||||
groups?: FaceGroup[];
|
||||
}
|
||||
|
||||
// a section the worker meshed
|
||||
export interface SectionMesh {
|
||||
index: number;
|
||||
version: number;
|
||||
// the lowest and highest y of the section's quads and visuals in the world, for frustum culling. Infinity and
|
||||
// -Infinity when it has none
|
||||
min_y: number;
|
||||
max_y: number;
|
||||
solid: LayerMesh;
|
||||
cutout: LayerMesh;
|
||||
translucent: LayerMesh & {
|
||||
// sorted back to front for the camera the mesh was requested with
|
||||
indices: Uint32Array;
|
||||
sort_type: SortType;
|
||||
// what resorting needs, see translucent_sort.ts
|
||||
centers: Float32Array;
|
||||
planes: [Float32Array, Float32Array, Float32Array];
|
||||
};
|
||||
// entities are lit from it
|
||||
light: SectionLight;
|
||||
// the blocks in it with visuals, as pairs of the block's index in the section (see section_index) and its value
|
||||
visuals: Uint32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
export type FromChunkWorker =
|
||||
| {
|
||||
type: "meshed";
|
||||
chunk_x: number;
|
||||
chunk_z: number;
|
||||
version: number;
|
||||
// the lowest and highest y of the chunk's quads in the world, for frustum culling
|
||||
min_y: number;
|
||||
max_y: number;
|
||||
solid: LayerMesh;
|
||||
cutout: LayerMesh;
|
||||
translucent: LayerMesh & {
|
||||
// sorted back to front for the camera the mesh was requested with
|
||||
indices: Uint32Array;
|
||||
sort_type: SortType;
|
||||
// what resorting needs, see translucent_sort.ts
|
||||
centers: Float32Array;
|
||||
planes: [Float32Array, Float32Array, Float32Array];
|
||||
};
|
||||
// the sections asked for, in the same order
|
||||
sections: SectionMesh[];
|
||||
// what the translucent quads were sorted for
|
||||
camera: number[];
|
||||
// the chunk's light by section, from the bottom of the world up, see SectionLight. entities are lit from it
|
||||
light: SectionLight[];
|
||||
// the blocks in it with visuals, as pairs of the block's index in the chunk (y from the bottom of the world, then
|
||||
// z, then x) and its value
|
||||
visuals: Uint32Array<ArrayBuffer>;
|
||||
}
|
||||
| {
|
||||
type: "sorted";
|
||||
chunk_x: number;
|
||||
chunk_z: number;
|
||||
index: number;
|
||||
version: number;
|
||||
sort_version: number;
|
||||
indices: Uint32Array;
|
||||
|
||||
Reference in New Issue
Block a user