grechka-game/srcv3/entities/mob-tex3d.js

36 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// NN-текстуры мобов (нарисованы в anymodel/nano-banana, одобрены игроком).
// Фас/профиль/спина натягиваются на грани бокса в TDmobMesh.
// Героя НЕ трогаем — он оригинальная пиксель-экструзия из hero-rig.js.
// Верх/низ бокса — плоский средний цвет спрайта.
const MOB_TEX = {
zombie: { top: '#3da027' },
pig: { top: '#ea77a1' },
chicken: { top: '#dcc8bf' },
creeper: { top: '#4a7f3e' },
skeleton: { top: '#b5b3b1' },
scorpion: { top: '#37221a' },
polar_bear: { top: '#dcdcdb' },
slime: { top: '#7caa71' },
eagle: { top: '#806041' },
};
const MOB_TEX_V = '3';
const _mobTexCache = {};
function TDmobTex(kind, view, mirror) {
const key = kind + '_' + view + (mirror ? '_m' : '');
let t = _mobTexCache[key];
if (!t) {
t = new THREE.TextureLoader().load('tex/' + kind + '_' + view + '.png?v=' + MOB_TEX_V);
if (mirror) {
t.wrapS = THREE.RepeatWrapping;
t.repeat.x = -1;
}
_mobTexCache[key] = t;
}
return t;
}
export { MOB_TEX, MOB_TEX_V, TDmobTex };