34 lines
947 B
TypeScript
34 lines
947 B
TypeScript
import { Chunk, Dimension } from "$/client/components/dimension.ts";
|
|
import { Camera } from "$/client/components/camera.ts";
|
|
import { flush_buffer, set_current_texture } from "$/client/renderer/mod.ts";
|
|
|
|
export function render_dimension(dimension: Dimension, _camera: Camera) {
|
|
dimension.request_meshes();
|
|
|
|
set_current_texture(dimension.image.tex);
|
|
|
|
for (const chunk of dimension.chunks.values()) {
|
|
render_chunk_opaque(chunk);
|
|
}
|
|
|
|
for (const chunk of dimension.chunks.values()) {
|
|
render_chunk_transparent(chunk);
|
|
}
|
|
}
|
|
|
|
function render_chunk_opaque(chunk: Chunk) {
|
|
if (!chunk.opaque_vertex_buffer || !chunk.opaque_vertex_count) {
|
|
return;
|
|
}
|
|
|
|
flush_buffer(chunk.opaque_vertex_buffer, chunk.opaque_vertex_count);
|
|
}
|
|
|
|
function render_chunk_transparent(chunk: Chunk) {
|
|
if (!chunk.transparent_vertex_buffer || !chunk.transparent_vertex_count) {
|
|
return;
|
|
}
|
|
|
|
flush_buffer(chunk.transparent_vertex_buffer, chunk.transparent_vertex_count);
|
|
}
|