Add panorama previews and repair beta export rendering
This commit is contained in:
35
renderer/block-colors.mjs
Normal file
35
renderer/block-colors.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
// Properties such as waterlogged=false must never determine the block's tint.
|
||||
export function blockTint(state, biome = "minecraft:plains") {
|
||||
const name = state.split("[")[0].replace(/^minecraft:/, "");
|
||||
if (name === "water") return biome.includes("swamp") ? "#617b64" : "#3f76e4";
|
||||
if (name === "spruce_leaves") return "#619961";
|
||||
if (name === "birch_leaves") return "#80a755";
|
||||
if (name === "redstone_wire") {
|
||||
const power = Number(state.match(/power=(\d+)/)?.[1] || 0);
|
||||
return power ? "#ff3300" : "#4c0000";
|
||||
}
|
||||
const leaves = name.endsWith("_leaves") || name === "vine";
|
||||
if (biome.includes("swamp")) return "#6a7039";
|
||||
if (/savanna|badlands|desert/.test(biome))
|
||||
return leaves ? "#aea42a" : "#bfb755";
|
||||
if (/snow|frozen|taiga/.test(biome)) return leaves ? "#60a17b" : "#80b497";
|
||||
if (/jungle/.test(biome)) return leaves ? "#30bb0b" : "#59c93c";
|
||||
return leaves ? "#77ab2f" : "#91bd59";
|
||||
}
|
||||
|
||||
export function firstTextureFrame(width, height, animation) {
|
||||
if (!animation) return { x: 0, y: 0, width, height };
|
||||
const w =
|
||||
animation.width || (animation.height ? width : Math.min(width, height));
|
||||
const h =
|
||||
animation.height || (animation.width ? height : Math.min(width, height));
|
||||
const first = animation.frames?.[0] ?? 0;
|
||||
const index = typeof first === "number" ? first : first.index;
|
||||
const columns = Math.floor(width / w);
|
||||
return {
|
||||
x: (index % columns) * w,
|
||||
y: Math.floor(index / columns) * h,
|
||||
width: w,
|
||||
height: h,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user