Fluid rendering in graphics
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
import { mat4, vec3 } from "gl-matrix";
|
||||
import type {
|
||||
FluidInstance,
|
||||
FluidVariant,
|
||||
Instances,
|
||||
ItemStack as ApiItemStack,
|
||||
ModelRef,
|
||||
@@ -30,7 +29,7 @@ import {
|
||||
states_of,
|
||||
} from "$/common/block_models.ts";
|
||||
import { CHUNK_AREA, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
|
||||
import type { FluidJson, ModelFace } from "$/common/mod_data.ts";
|
||||
import type { ModelFace } from "$/common/mod_data.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import { chunk_key, item_texture } from "$/common/utils.ts";
|
||||
import {
|
||||
@@ -43,7 +42,7 @@ import {
|
||||
write_buffer,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import { fluid_rgb, ground_transform, item_layers, push_item, sprite_u, sprite_v } from "./item_renderer.ts";
|
||||
import { fluid_look, ground_transform, item_layers, push_item, sprite_u, sprite_v } from "./item_renderer.ts";
|
||||
|
||||
export interface VisualRegistration {
|
||||
mod: string;
|
||||
@@ -466,13 +465,6 @@ function item_quads(item: ItemStack): InstanceQuad[] {
|
||||
return quads;
|
||||
}
|
||||
|
||||
// a fluid's texture and its color by its rules, for a box of it
|
||||
function fluid_look(fluid: FluidVariant) {
|
||||
const json = EverythingRegistry.get<FluidJson>("fluids", fluid?.id);
|
||||
if (!json) throw new Error(`there's no fluid ${fluid?.id}`);
|
||||
return { texture: json.texture ?? "engine:missing", tint: fluid_rgb(structuredClone(fluid)) };
|
||||
}
|
||||
|
||||
// a box's faces, by the axis they're across and whether they're at its high end or its low one
|
||||
const BOX_FACES: { face: ModelFace; axis: number; high: boolean }[] = [
|
||||
{ face: "west", axis: 0, high: false },
|
||||
|
||||
Reference in New Issue
Block a user