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