Animated textures !

This commit is contained in:
2026-10-07 19:11:44 -03:00
parent b6b10e35e2
commit fbc9266936
20 changed files with 555 additions and 25 deletions
+9 -2
View File
@@ -6,11 +6,14 @@ import { Options } from "./options.ts";
import { connect, HandshakeError, is_trusted, join, remember_trust, ServerAddress } from "./handshake.ts";
import { build_atlas, engine_textures } from "./atlas.ts";
import { confirm_mods } from "./confirm_mods.ts";
import { set_texture_animations } from "./texture_animations.ts";
import type { TextureJson } from "$/common/texture_animation.ts";
import { ModLoadError } from "$/common/mod_loader.ts";
import {
begin_drawing,
canvas,
clear_background,
device,
end_drawing,
init_font,
init_window,
@@ -136,12 +139,16 @@ async function join_server(address: ServerAddress, name: string, status: (text:
status("Downloading the server's mods...");
const bmods = await download_mods(welcome.mods, address.base);
const textures = await engine_textures();
const texture_json = new Map<string, TextureJson>();
for (const bmod of bmods) {
for (const [id, png] of bmod.textures) textures.set(id, png);
for (const [id, json] of bmod.texture_json ?? []) texture_json.set(id, json);
}
const atlas = await build_atlas(textures);
const atlas = await build_atlas(textures, texture_json);
loaded_mods = true;
AssetManager.instance.assets["bworld:textures"] = load_texture(atlas.image);
const atlas_texture = load_texture(atlas.image);
set_texture_animations(atlas_texture.tex, device.queue, atlas.animated);
AssetManager.instance.assets["bworld:textures"] = atlas_texture;
AssetManager.instance.assets["bworld:textures_info"] = atlas.regions;
await load_client_mods(welcome.mods, bmods);
console.log(`Mods: ${welcome.mods.map((mod) => `${mod.id} ${mod.version}`).join(", ") || "none"}`);