修正识别问题
This commit is contained in:
1 parent
d02370d6bd
commit
e7f800aa8d
8 files changed
+128
-2
No files matched your search
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
const utils = require('../js/spine-utils');
|
||||
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'spine-mixed-atlas-'));
|
||||
try {
|
||||
const images = path.join(root, 'images');
|
||||
fs.mkdirSync(images);
|
||||
fs.writeFileSync(path.join(root, 'metadata.json'), JSON.stringify({ folders: [] }));
|
||||
const makeItem = (id, name, body) => {
|
||||
const directory = path.join(images, id + '.info');
|
||||
fs.mkdirSync(directory);
|
||||
fs.writeFileSync(path.join(directory, name), body);
|
||||
fs.writeFileSync(path.join(directory, 'metadata.json'), JSON.stringify({ folders: [] }));
|
||||
return path.join(directory, name);
|
||||
};
|
||||
const png = makeItem('png', 'hero.png', 'png');
|
||||
const atlas = makeItem('atlas', 'hero.atlas', [
|
||||
'hero.png',
|
||||
'size: 64,64',
|
||||
'format: RGBA8888',
|
||||
'filter: Linear,Linear',
|
||||
'repeat: none',
|
||||
'',
|
||||
'hero.jpeg',
|
||||
'size: 32,32',
|
||||
'format: RGBA8888',
|
||||
'filter: Linear,Linear',
|
||||
'repeat: none',
|
||||
'',
|
||||
].join('\n'));
|
||||
const jpeg = makeItem('jpg', 'hero.jpg', 'jpg');
|
||||
const assets = utils.discoverAssets(atlas, {
|
||||
strictStem: true,
|
||||
searchRoots: [path.dirname(png), path.dirname(atlas), path.dirname(jpeg)],
|
||||
});
|
||||
assert.equal(assets.texturePaths['hero.png'], png);
|
||||
assert.equal(assets.texturePaths['hero.jpeg'], jpeg, 'JPEG atlas page must prefer .jpg over same-stem .png');
|
||||
assert.equal(utils.textureFormatOf('photo.JPEG'), utils.textureFormatOf('photo.jpg'));
|
||||
console.log('PASS: mixed PNG/JPEG atlas pages resolve to matching texture formats');
|
||||
} finally {
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
Reference in new issue
Block a user