Atlas png on f3 gui
This commit is contained in:
+14
-1
@@ -111,7 +111,9 @@ export async function build_atlas(textures: Map<string, Uint8Array>, texture_jso
|
||||
}
|
||||
|
||||
// which pixels of each texture can be seen, for the 3d models of dropped items (see item_model.ts)
|
||||
const pixels = ctx.getImageData(0, 0, size, size).data;
|
||||
const image_data = ctx.getImageData(0, 0, size, size);
|
||||
const pixels = image_data.data;
|
||||
built_atlas = image_data;
|
||||
opaque.clear();
|
||||
for (const [id, region] of Object.entries(regions)) {
|
||||
const mask = new Uint8Array(region.width * region.height);
|
||||
@@ -149,6 +151,17 @@ export function opaque_pixels(texture_id: string): OpaqueMask | undefined {
|
||||
return opaque.get(texture_id);
|
||||
}
|
||||
|
||||
// the last atlas built, before any animated texture moved on from its first frame
|
||||
let built_atlas: ImageData | undefined;
|
||||
|
||||
// the atlas as a png, undefined before one is built. for the f3 screen's copy button
|
||||
export function atlas_png(): Promise<Blob> | undefined {
|
||||
if (!built_atlas) return undefined;
|
||||
const canvas = new OffscreenCanvas(built_atlas.width, built_atlas.height);
|
||||
canvas.getContext("2d")!.putImageData(built_atlas, 0, 0);
|
||||
return canvas.convertToBlob({ type: "image/png" });
|
||||
}
|
||||
|
||||
// the engine's own textures, which come with the client instead of a mod. see build_engine_textures in build.ts
|
||||
export async function engine_textures(): Promise<Map<string, Uint8Array>> {
|
||||
const names: string[] = await (await fetch("/assets/textures/index.json")).json();
|
||||
|
||||
Reference in New Issue
Block a user