Rename engine to cubi

This commit is contained in:
2026-11-03 17:17:37 -03:00
parent 68b78f053a
commit 98fa45ebd1
109 changed files with 643 additions and 788 deletions
+7 -7
View File
@@ -25,10 +25,10 @@ export interface TextureSize {
export const ATLAS_BORDER = 1;
// shelves, tallest first so each row wastes little, and by id when they're the same size so the same textures always
// give the same atlas. engine:missing is 16×16 and always there
// give the same atlas. cubi:missing is 16×16 and always there
export function atlas_layout(sizes: Map<string, TextureSize>): AtlasLayout {
const entries = [...sizes].filter(([id]) => id !== "engine:missing");
entries.push(["engine:missing", { width: TEXTURE_SIZE, height: TEXTURE_SIZE }]);
const entries = [...sizes].filter(([id]) => id !== "cubi:missing");
entries.push(["cubi:missing", { width: TEXTURE_SIZE, height: TEXTURE_SIZE }]);
entries.sort(([a, sa], [b, sb]) => sb.height - sa.height || sb.width - sa.width || a.localeCompare(b));
const area = entries.reduce(
@@ -76,8 +76,8 @@ export async function build_atlas(textures: Map<string, Uint8Array>, texture_jso
console.warn(`Texture ${id} isn't a png that can be shown, it will show as missing`);
}
}));
images.get("engine:missing")?.close();
images.delete("engine:missing");
images.get("cubi:missing")?.close();
images.delete("cubi:missing");
const animations = new Map<string, Animation>();
for (const [id, image] of images) {
@@ -95,7 +95,7 @@ export async function build_atlas(textures: Map<string, Uint8Array>, texture_jso
const ctx = canvas.getContext("2d")!;
// magenta and black checker
const missing = regions["engine:missing"];
const missing = regions["cubi:missing"];
const half = TEXTURE_SIZE / 2;
ctx.fillStyle = "magenta";
ctx.fillRect(missing.x, missing.y, half, half);
@@ -208,7 +208,7 @@ export async function engine_textures(): Promise<Map<string, Uint8Array>> {
const textures = new Map<string, Uint8Array>();
await Promise.all(names.map(async (name) => {
const response = await fetch(`/assets/textures/${name}.png`);
textures.set(`engine:${name}`, new Uint8Array(await response.arrayBuffer()));
textures.set(`cubi:${name}`, new Uint8Array(await response.arrayBuffer()));
}));
return textures;
}
+1 -1
View File
@@ -19,7 +19,7 @@ const SWING_TICKS = 6;
// an entity the server simulates, like a mob. this only follows where it's told it is and keeps what it was told
// it looks like, for drawing it
export class RemoteEntity extends Entity {
// the entity type, like "bworld:item"
// the entity type, like "cubi:item"
readonly type: string;
// synced data, see EntityData
data: EntityData;
+1 -1
View File
@@ -409,7 +409,7 @@ export function fluid_rgb(fluid: FluidVariant): Vec3 {
export function fluid_look(fluid: FluidVariant): { texture: string; tint: Vec3 } {
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)) };
return { texture: json.texture ?? "cubi:missing", tint: fluid_rgb(structuredClone(fluid)) };
}
// where a model's uv in pixels (0-16) is in the atlas. the atlas's border around each sprite (see ATLAS_BORDER) keeps
+1 -1
View File
@@ -204,7 +204,7 @@ export class LevelRenderer {
return;
}
const tex = AssetManager.instance.get<Texture>("bworld:textures");
const region = get_sprite_region(`engine:break_${stage}`);
const region = get_sprite_region(`cubi:break_${stage}`);
for (const quad of this.#destroy_quads(info, value)) {
push_decal_quad(tex, quad, x, y, z, region);
}
+1 -1
View File
@@ -487,7 +487,7 @@ export function fluid_box(texture: string, tint: number[], from: number[], to: n
for (let at = (Math.floor(from[axis] / 16) + 1) * 16; at < to[axis]; at += 16) points.push(at);
return [...points, to[axis]];
});
const model: ModelJson = { id: "engine:fluid_box", textures: { fluid: texture }, elements: [] };
const model: ModelJson = { id: "cubi:fluid_box", textures: { fluid: texture }, elements: [] };
const quads: InstanceQuad[] = [];
for (let i = 0; i < cuts[0].length - 1; i++) {
for (let j = 0; j < cuts[1].length - 1; j++) {
+1 -1
View File
@@ -8,6 +8,6 @@ type TexturesInfo = Record<string, SpriteRegion>;
export function get_sprite_region(id: string): SpriteRegion {
const textures_info = AssetManager.instance.get<TexturesInfo>("bworld:textures_info");
return textures_info?.[id] ?? textures_info?.["engine:missing"] ??
return textures_info?.[id] ?? textures_info?.["cubi:missing"] ??
{ x: 0, y: 0, width: TEXTURE_SIZE, height: TEXTURE_SIZE };
}
+4 -4
View File
@@ -473,7 +473,7 @@ function block_quads(value: number): MeshQuad[] {
flush: quad.flush,
group: quad.aligned ? quad.face : UNALIGNED_GROUP,
shade: quad.shade ? FACE_SHADE[quad.face] : 1,
sprite: textures_info[quad.texture] ?? textures_info["engine:missing"],
sprite: textures_info[quad.texture] ?? textures_info["cubi:missing"],
light_weights: light_weights(quad.face, quad.positions),
tint: quad_tint(block, quad.variables),
}));
@@ -595,8 +595,8 @@ function fill_fluid_cells(chunks: (Uint32Array | null)[], nid: number, index: nu
function flowing_scale(block: BlockRegistry): number | undefined {
const textures = fluid_textures(block.textures);
if (textures.flowing === textures.still) return undefined;
const still = textures_info[textures.still] ?? textures_info["engine:missing"];
const flowing = textures_info[textures.flowing] ?? textures_info["engine:missing"];
const still = textures_info[textures.still] ?? textures_info["cubi:missing"];
const flowing = textures_info[textures.flowing] ?? textures_info["cubi:missing"];
return Math.min(1, still.width / flowing.width);
}
@@ -619,7 +619,7 @@ function fluid_mesh_quad(
flush: true,
group: flat ? face : UNALIGNED_GROUP,
shade: FACE_SHADE[face],
sprite: textures_info[still ? textures.still : textures.flowing] ?? textures_info["engine:missing"],
sprite: textures_info[still ? textures.still : textures.flowing] ?? textures_info["cubi:missing"],
light_weights: light_weights(face, positions),
tint: quad_tint(block, [still ? "still" : "flowing"]),
};