Optimize renderer
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import type { BlockRegistry } from "$/common/everything_registry.ts";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
|
||||
// messages between the main thread and the chunk workers
|
||||
|
||||
export type ToChunkWorker =
|
||||
| {
|
||||
type: "init";
|
||||
// the blocks registry without its functions, indexed by numeric id
|
||||
blocks_registry: BlockRegistry[];
|
||||
block_ids: Record<string, number>;
|
||||
textures_info: Record<string, SpriteRegion>;
|
||||
image: { width: number; height: number };
|
||||
}
|
||||
| { type: "generate"; chunk_x: number; chunk_z: number; seed: string }
|
||||
| { type: "mesh"; chunk_x: number; chunk_z: number; version: number; padded_chunk: Uint32Array };
|
||||
|
||||
export type FromChunkWorker =
|
||||
| {
|
||||
type: "generated";
|
||||
chunk_x: number;
|
||||
chunk_z: number;
|
||||
blocks: Uint32Array;
|
||||
// blocks that landed in other chunks (tree leaves), flattened as x, y, z, numeric id
|
||||
spills: Int32Array;
|
||||
}
|
||||
| {
|
||||
type: "meshed";
|
||||
chunk_x: number;
|
||||
chunk_z: number;
|
||||
version: number;
|
||||
opaque_vertices: Float32Array;
|
||||
opaque_count: number;
|
||||
transparent_vertices: Float32Array;
|
||||
transparent_count: number;
|
||||
};
|
||||
Reference in New Issue
Block a user