Fully working implementation
This commit is contained in:
@@ -97,7 +97,8 @@
|
||||
// the mob has several). Blockbench + the bundled plugins UV-wrap and apply
|
||||
// them, so we don't worry about per-bone assignment here.
|
||||
async function resolveTextures(geo, entity, opts, index) {
|
||||
const textures = [];
|
||||
const featureTextures = [];
|
||||
const baseTextures = [];
|
||||
const afw = geo['afw_bone_textures'] || {};
|
||||
|
||||
// 1. Feature overlays — from afw_bone_textures, or the conventional
|
||||
@@ -116,13 +117,13 @@
|
||||
for (const m of members) {
|
||||
try {
|
||||
const img = await loadImage(assetUrl(opts.baseUrl, m));
|
||||
textures.push({ name: m.split('/').pop(), dataUrl: imageDataUrl(img) });
|
||||
featureTextures.push({ name: m.split('/').pop(), dataUrl: imageDataUrl(img) });
|
||||
} catch (e) {
|
||||
console.warn('packs: skip feature texture', m, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Vanilla skin — a random variant when several exist, else the
|
||||
// 2. Vanilla base skin — a random variant when several exist, else the
|
||||
// server-matched pack skin, else none.
|
||||
let rel = null;
|
||||
const ent = index && index[entity];
|
||||
@@ -133,19 +134,20 @@
|
||||
if (rel) {
|
||||
try {
|
||||
const img = await loadImage(assetUrl(opts.vanillaBaseUrl, 'entity/' + rel));
|
||||
textures.push({ name: rel.split('/').pop(), dataUrl: imageDataUrl(img) });
|
||||
baseTextures.push({ name: rel.split('/').pop(), dataUrl: imageDataUrl(img) });
|
||||
} catch (e) {
|
||||
console.warn('packs: skip vanilla skin', e);
|
||||
}
|
||||
} else if (opts.defaultTexture) {
|
||||
try {
|
||||
const img = await loadImage(assetUrl(opts.baseUrl, opts.defaultTexture));
|
||||
textures.push({ name: opts.defaultTexture.split('/').pop(), dataUrl: imageDataUrl(img) });
|
||||
baseTextures.push({ name: opts.defaultTexture.split('/').pop(), dataUrl: imageDataUrl(img) });
|
||||
} catch (e) {
|
||||
console.warn('packs: skip default texture', e);
|
||||
}
|
||||
}
|
||||
return textures;
|
||||
// The vanilla/base texture must always be loaded first, then features.
|
||||
return baseTextures.concat(featureTextures);
|
||||
}
|
||||
|
||||
async function open(btn) {
|
||||
|
||||
Reference in New Issue
Block a user