加入3.5 修复水印
This commit is contained in:
1 parent
ef01cdd6ee
commit
e82a62a9ad
19 files changed
+5894
-38
No files matched your search
+14
-10
@@ -24,30 +24,34 @@ function runtime(version) {
|
||||
vm.runInContext(fs.readFileSync(path.join(__dirname, '..', 'lib', version, 'spine-canvas.js'), 'utf8'), context);
|
||||
return install(context.spine, version);
|
||||
}
|
||||
const versions = process.argv[3] === '3.4' ? ['3.4'] : ['3.6', '3.7'];
|
||||
const versions = ['3.4', '3.5'].includes(process.argv[3]) ? [process.argv[3]] : ['3.6', '3.7'];
|
||||
let pairs = 0;
|
||||
for (const version of versions) {
|
||||
const spine = runtime(version);
|
||||
const oldNames = version === '3.4' || version === '3.5';
|
||||
// 3.4 JSON export truncates to two decimal places instead of rounding.
|
||||
const quantization = version === '3.4' ? 0.0102 : 0.0052;
|
||||
const quantization = oldNames ? 0.0102 : 0.0052;
|
||||
assert.equal(utils.chooseRuntimeDir(version + '.32', true), version);
|
||||
for (const name of version === '3.4' ? ['spineboy', 'spineboy-mesh', 'spineboy-hover', 'goblins', 'goblins-mesh', 'vine', 'stretchyman', 'tank', 'raptor'] : names) {
|
||||
const directory = path.join(fixtures, version, version === '3.4' ? name.split('-')[0] : name);
|
||||
const file = name + (version === '3.4' ? '' : '-pro');
|
||||
const oldExamples = ['spineboy', 'spineboy-mesh', 'spineboy-hover', 'goblins', 'goblins-mesh', 'vine', 'stretchyman', 'tank', 'raptor'];
|
||||
// The 3.5.51 tag keeps beta SKELs but newer 3.5.49 JSON for Tank/Raptor.
|
||||
// Those independent exports are smoke-tested separately, not used as parity oracles.
|
||||
for (const name of oldNames ? oldExamples.filter(n => version !== '3.5' || !['tank', 'raptor'].includes(n)) : names) {
|
||||
const directory = path.join(fixtures, version, oldNames ? name.split('-')[0] : name);
|
||||
const file = name + (oldNames ? '' : '-pro');
|
||||
const bytes = fs.readFileSync(path.join(directory, file + '.skel'));
|
||||
const json = JSON.parse(fs.readFileSync(path.join(directory, file + '.json'), 'utf8'));
|
||||
const decoded = decode(bytes, version);
|
||||
assert.equal(decoded.skeleton.hash, json.skeleton.hash);
|
||||
assert.equal(decoded.skeleton.spine, json.skeleton.spine);
|
||||
assert.equal(utils.detectVersion(path.join(directory, file + '.skel')), json.skeleton.spine);
|
||||
assert.equal(utils.detectVersion(path.join(directory, file + '.skel')), json.skeleton.spine.match(/^\d+\.\d+\.\d+/)[0]);
|
||||
// Region geometry uses a real official atlas; no native Canvas dependency
|
||||
// is needed to verify animation poses and renderer triangle output.
|
||||
const texture = { getImage: () => ({ width: 1024, height: 1024 }), setFilters() {}, setWraps() {} };
|
||||
const atlas = new spine.TextureAtlas(fs.readFileSync(path.join(directory, (version === '3.4' ? name.split('-')[0] : name) + '.atlas'), 'utf8'), () => texture);
|
||||
const atlas = new spine.TextureAtlas(fs.readFileSync(path.join(directory, (oldNames ? name.split('-')[0] : name) + '.atlas'), 'utf8'), () => texture);
|
||||
const attachmentLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||
// 3.4 Goblins binary optimizes three constant segments to linear;
|
||||
// JSON keeps stepped. Their equal endpoints produce identical poses.
|
||||
if (version === '3.4' && name.startsWith('goblins')) {
|
||||
if (oldNames && name.startsWith('goblins')) {
|
||||
for (const [bone, type, index] of [['left lower leg', 'translate', 2], ['right lower leg', 'translate', 0], ['hip', 'rotate', 0]]) {
|
||||
const timeline = json.animations.walk.bones[bone][type];
|
||||
assert.equal(timeline[index].curve, 'stepped');
|
||||
@@ -92,7 +96,7 @@ for (const version of versions) {
|
||||
}
|
||||
for (const animation of data.animations) {
|
||||
const refAnimation = expected.findAnimation(animation.name);
|
||||
near(animation.duration, refAnimation.duration, version === '3.4' ? 0.00011 : 0.00006, 'duration');
|
||||
near(animation.duration, refAnimation.duration, oldNames ? 0.00011 : 0.00006, 'duration');
|
||||
assert.equal(animation.timelines.length, refAnimation.timelines.length);
|
||||
// Older JSON and binary exports order independent slot timelines differently.
|
||||
const timelineKey = t => [t.constructor.name, t.slotIndex, t.boneIndex, t.ikConstraintIndex, t.transformConstraintIndex, t.pathConstraintIndex, t.attachment && t.attachment.name].join('/');
|
||||
@@ -122,7 +126,7 @@ for (const version of versions) {
|
||||
// Quantized JSON weights/curves compound along bone chains.
|
||||
// 3.4 truncates weights/scales by up to 0.01. Bound accumulated
|
||||
// world-position error by 1% of export size; local data is checked above.
|
||||
const tolerance = version === '3.4' && field.startsWith('world')
|
||||
const tolerance = oldNames && field.startsWith('world')
|
||||
? Math.max(2.1, Math.max(json.skeleton.width, json.skeleton.height) * scale * 0.01) : 2.1;
|
||||
near(pair[0].bones[i][field], pair[1].bones[i][field], tolerance, name + '/' + animation.name + '/' + field);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user