修复pma 皮肤渲染
This commit is contained in:
1 parent
02358b8d4c
commit
11b1c95d98
6 files changed
+105
-13
No files matched your search
+21
-7
@@ -690,7 +690,7 @@
|
||||
if (skeletonData.animations.length > 0) sel.value = '0';
|
||||
}
|
||||
|
||||
function fillSkins() {
|
||||
function fillSkins(selectedSkin) {
|
||||
const sel = document.getElementById('skinSelect');
|
||||
sel.innerHTML = '';
|
||||
(skeletonData.skins || []).forEach((s, i) => {
|
||||
@@ -699,6 +699,10 @@
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
sel.disabled = (skeletonData.skins || []).length <= 1;
|
||||
if (selectedSkin) {
|
||||
const index = (skeletonData.skins || []).indexOf(selectedSkin);
|
||||
if (index >= 0) sel.value = String(index);
|
||||
}
|
||||
}
|
||||
|
||||
function setAnimationByName(name) {
|
||||
@@ -783,8 +787,13 @@
|
||||
|
||||
function applySkinByName(name) {
|
||||
if (!skeleton) return;
|
||||
if (skeleton.setSkinByName) skeleton.setSkinByName(name);
|
||||
else if (skeleton.setSkin && skeleton.data.findSkin) skeleton.setSkin(skeleton.data.findSkin(name));
|
||||
const skin = skeleton.data && skeleton.data.findSkin ? skeleton.data.findSkin(name)
|
||||
: (skeletonData.skins || []).find((item) => item.name === name);
|
||||
if (!utils.applySkin(skeleton, skin)) return;
|
||||
currentSkin = skin;
|
||||
if (state) state.apply(skeleton);
|
||||
updateWorld(skeleton);
|
||||
draw();
|
||||
}
|
||||
|
||||
// ---------- 非 Spine 图片回退:直接显示图片 ----------
|
||||
@@ -852,13 +861,12 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
let savedPma;
|
||||
try {
|
||||
const settings = require('../js/spine-preview-settings.js');
|
||||
const userData = await settings.resolveDataPath(typeof eagle !== 'undefined' ? eagle.app : null);
|
||||
previewSettings = settings.createStore(userData, filePath, urlParams.get('id'));
|
||||
const saved = previewSettings.read();
|
||||
if (saved !== undefined) premultipliedAlpha = saved;
|
||||
document.getElementById('pmaCheck').checked = premultipliedAlpha;
|
||||
savedPma = previewSettings.read();
|
||||
} catch (e) { log('读取预乘设置失败: ' + e.message); }
|
||||
|
||||
// 检测版本并选择运行时
|
||||
@@ -891,6 +899,10 @@
|
||||
let atlas;
|
||||
try {
|
||||
const atlasText = fs.readFileSync(assets.atlasPath, 'utf8');
|
||||
const atlasPma = utils.parseAtlasPma(atlasText);
|
||||
// 用户明确切换过的设置用于下次预览;没有用户设置时,以 Atlas 为准。
|
||||
premultipliedAlpha = savedPma !== undefined ? savedPma : (atlasPma !== undefined ? atlasPma : false);
|
||||
document.getElementById('pmaCheck').checked = premultipliedAlpha;
|
||||
atlas = await buildBrowserAtlas(spine, atlasText, assets);
|
||||
} catch (e) {
|
||||
showError('Atlas 加载失败', (e && e.message) || String(e));
|
||||
@@ -918,6 +930,8 @@
|
||||
|
||||
// 创建骨架与动画状态
|
||||
skeleton = new spine.Skeleton(skeletonData);
|
||||
currentSkin = utils.preferredSkin(skeletonData);
|
||||
utils.applySkin(skeleton, currentSkin);
|
||||
stateData = new spine.AnimationStateData(skeletonData);
|
||||
stateData.defaultMix = 0.2;
|
||||
state = new spine.AnimationState(stateData);
|
||||
@@ -927,7 +941,7 @@
|
||||
document.getElementById('pmaCheck').disabled = false;
|
||||
|
||||
fillAnimations();
|
||||
fillSkins();
|
||||
fillSkins(currentSkin);
|
||||
|
||||
// 默认使用导出顺序中的第一个动画;duration=0 的动画按静帧处理。
|
||||
if (skeletonData.animations.length > 0) {
|
||||
|
||||
Reference in new issue
Block a user