-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add nomip tag to avoid mipmaps being generated (#120)
* feat: add nomip tag to avoid mipmaps being generated * add nomip to texture packer and spine * fix tests * update docs
- Loading branch information
Showing
12 changed files
with
312 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,7 +214,45 @@ describe('Mipmap', () => | |
entry: inputDir, cacheLocation: getCacheDir(pkg, testName), | ||
output: outputDir, | ||
cache: false, | ||
pipes: [mipmap()] | ||
pipes: [mipmap({ fixedResolution: 'low' })] | ||
}); | ||
|
||
await assetpack.run(); | ||
|
||
expect(existsSync(`${outputDir}/assets/test.png`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(true); | ||
}); | ||
|
||
it('should prevent mipmaps', async () => | ||
{ | ||
const testName = 'mip-nomip'; | ||
const inputDir = getInputDir(pkg, testName); | ||
const outputDir = getOutputDir(pkg, testName); | ||
|
||
createFolder( | ||
pkg, | ||
{ | ||
name: testName, | ||
files: [], | ||
folders: [ | ||
{ | ||
name: 'assets{nomip}', | ||
files: [ | ||
{ | ||
name: 'test.png', | ||
content: assetPath('image/png-1.png'), | ||
}, | ||
], | ||
folders: [], | ||
}, | ||
], | ||
}); | ||
|
||
const assetpack = new AssetPack({ | ||
entry: inputDir, cacheLocation: getCacheDir(pkg, testName), | ||
output: outputDir, | ||
cache: false, | ||
pipes: [mipmap({ fixedResolution: 'low' })] | ||
}); | ||
|
||
await assetpack.run(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,9 +171,9 @@ describe('Atlas Mipmap', () => | |
expect(existsSync(`${outputDir}/[email protected]`)).toBe(true); | ||
}); | ||
|
||
it('should prevent mipmaps on file when tagged with fix', async () => | ||
it('should resize atlas to fixed resolution when tagged with fix', async () => | ||
{ | ||
const testName = 'mip-fixed'; | ||
const testName = 'mip-fixed-prevent'; | ||
const inputDir = getInputDir(pkg, testName); | ||
const outputDir = getOutputDir(pkg, testName); | ||
|
||
|
@@ -190,6 +190,14 @@ describe('Atlas Mipmap', () => | |
name: 'dragon{spine}{fix}.atlas', | ||
content: assetPath('spine/dragon.atlas'), | ||
}, | ||
{ | ||
name: 'dragon{fix}.png', | ||
content: assetPath('spine/dragon.png'), | ||
}, | ||
{ | ||
name: 'dragon2{fix}.png', | ||
content: assetPath('spine/dragon2.png'), | ||
}, | ||
], | ||
folders: [], | ||
}, | ||
|
@@ -210,5 +218,115 @@ describe('Atlas Mipmap', () => | |
|
||
expect(existsSync(`${outputDir}/assets/dragon.atlas`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/dragon.png`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/dragon2.png`)).toBe(true); | ||
}); | ||
|
||
it('should resize atlas to low fixed resolution when tagged with fix', async () => | ||
{ | ||
const testName = 'mip-fixed-res'; | ||
const inputDir = getInputDir(pkg, testName); | ||
const outputDir = getOutputDir(pkg, testName); | ||
|
||
createFolder( | ||
pkg, | ||
{ | ||
name: testName, | ||
files: [], | ||
folders: [ | ||
{ | ||
name: 'assets', | ||
files: [ | ||
{ | ||
name: 'dragon{spine}{fix}.atlas', | ||
content: assetPath('spine/dragon.atlas'), | ||
}, | ||
{ | ||
name: 'dragon{fix}.png', | ||
content: assetPath('spine/dragon.png'), | ||
}, | ||
{ | ||
name: 'dragon2{fix}.png', | ||
content: assetPath('spine/dragon2.png'), | ||
}, | ||
], | ||
folders: [], | ||
}, | ||
], | ||
}); | ||
|
||
const assetpack = new AssetPack({ | ||
entry: inputDir, cacheLocation: getCacheDir(pkg, testName), | ||
output: outputDir, | ||
cache: false, | ||
pipes: [ | ||
mipmap({ fixedResolution: 'low' }), | ||
spineAtlasMipmap({ fixedResolution: 'low' }), | ||
] | ||
}); | ||
|
||
await assetpack.run(); | ||
|
||
expect(existsSync(`${outputDir}/assets/dragon.atlas`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/dragon.png`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/dragon2.png`)).toBe(false); | ||
}); | ||
|
||
it('should create no mipmaps', async () => | ||
{ | ||
const testName = 'mip-nomip'; | ||
const inputDir = getInputDir(pkg, testName); | ||
const outputDir = getOutputDir(pkg, testName); | ||
|
||
createFolder( | ||
pkg, | ||
{ | ||
name: testName, | ||
files: [], | ||
folders: [ | ||
{ | ||
name: 'assets', | ||
files: [ | ||
{ | ||
name: 'dragon{spine}{nomip}.atlas', | ||
content: assetPath('spine/dragon.atlas'), | ||
}, | ||
{ | ||
name: 'dragon{nomip}.png', | ||
content: assetPath('spine/dragon.png'), | ||
}, | ||
{ | ||
name: 'dragon2{nomip}.png', | ||
content: assetPath('spine/dragon2.png'), | ||
}, | ||
], | ||
folders: [], | ||
}, | ||
], | ||
}); | ||
|
||
const assetpack = new AssetPack({ | ||
entry: inputDir, cacheLocation: getCacheDir(pkg, testName), | ||
output: outputDir, | ||
cache: false, | ||
pipes: [ | ||
mipmap({ fixedResolution: 'low' }), | ||
spineAtlasMipmap({ fixedResolution: 'low' }), | ||
] | ||
}); | ||
|
||
await assetpack.run(); | ||
|
||
expect(existsSync(`${outputDir}/assets/dragon.atlas`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/[email protected]`)).toBe(false); | ||
expect(existsSync(`${outputDir}/assets/dragon.png`)).toBe(true); | ||
expect(existsSync(`${outputDir}/assets/dragon2.png`)).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.