修复pma 皮肤渲染
This commit is contained in:
1 parent
02358b8d4c
commit
11b1c95d98
6 files changed
+105
-13
No files matched your search
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
const assert = require('node:assert/strict');
|
||||
const utils = require('../js/spine-utils');
|
||||
const render = require('../js/spine-render');
|
||||
|
||||
assert.equal(utils.parseAtlasPma('page.png\nsize:1,1\npma:true\nregion\n'), true);
|
||||
assert.equal(utils.parseAtlasPma('page.png\r\n pma : false \r\nregion\r\n'), false);
|
||||
assert.equal(utils.parseAtlasPma('page.png\nsize:1,1\nregion\n'), undefined);
|
||||
assert.equal(utils.parseAtlasPma('page.png\npma:trueish\n'), undefined);
|
||||
|
||||
const first = { name: 'first' }, namedDefault = { name: 'default' }, explicit = { name: 'custom' };
|
||||
assert.equal(utils.preferredSkin({ defaultSkin: explicit, skins: [first, namedDefault] }), explicit);
|
||||
assert.equal(utils.preferredSkin({ skins: [first, namedDefault] }), namedDefault);
|
||||
assert.equal(utils.preferredSkin({ skins: [first] }), first);
|
||||
assert.equal(utils.preferredSkin({ skins: [] }), null);
|
||||
|
||||
for (const version of ['3.4', '3.5', '3.6', '3.7', '3.8', '4.0', '4.1', '4.2', '4.3']) {
|
||||
const spine = render.loadRuntime(version);
|
||||
const skin = new spine.Skin('visible');
|
||||
const data = new spine.SkeletonData();
|
||||
data.bones.push(new spine.BoneData(0, 'root', null));
|
||||
data.slots.push(new spine.SlotData(0, 'slot', data.bones[0]));
|
||||
data.skins.push(skin);
|
||||
if ('defaultSkin' in data) data.defaultSkin = skin;
|
||||
const skeleton = new spine.Skeleton(data);
|
||||
assert.equal(utils.preferredSkin(data), skin, version + ' preferred skin');
|
||||
assert(utils.applySkin(skeleton, skin), version + ' apply skin');
|
||||
assert.equal(skeleton.skin, skin, version + ' active skin');
|
||||
}
|
||||
|
||||
console.log('PASS: Atlas PMA detection and default/first skin selection across Spine 3.4–4.3');
|
||||
Reference in new issue
Block a user