fix: preserve colliding exported texture variants
This commit is contained in:
@@ -21,7 +21,7 @@ interface PrepareGitAssetsResult {
|
|||||||
|
|
||||||
function getTextureFilenameMap(parsedFiles: ParsedFile[]) {
|
function getTextureFilenameMap(parsedFiles: ParsedFile[]) {
|
||||||
const filenameMap = new Map<string, string>()
|
const filenameMap = new Map<string, string>()
|
||||||
const normalizedOwners = new Map<string, string>()
|
const normalizedGroups = new Map<string, Array<{ original: string; normalized: string }>>()
|
||||||
|
|
||||||
for (const file of parsedFiles) {
|
for (const file of parsedFiles) {
|
||||||
const ext = extname(file.filename).toLowerCase()
|
const ext = extname(file.filename).toLowerCase()
|
||||||
@@ -31,14 +31,16 @@ function getTextureFilenameMap(parsedFiles: ParsedFile[]) {
|
|||||||
if (!normalizedFilename) continue
|
if (!normalizedFilename) continue
|
||||||
|
|
||||||
const normalizedKey = normalizedFilename.toLowerCase()
|
const normalizedKey = normalizedFilename.toLowerCase()
|
||||||
const existingOwner = normalizedOwners.get(normalizedKey)
|
const group = normalizedGroups.get(normalizedKey) || []
|
||||||
|
group.push({ original: file.filename, normalized: normalizedFilename })
|
||||||
if (existingOwner && existingOwner.toLowerCase() !== file.filename.toLowerCase()) {
|
normalizedGroups.set(normalizedKey, group)
|
||||||
throw new Error(`Textures en conflit apres normalisation : ${existingOwner} et ${file.filename} deviennent ${normalizedFilename}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filenameMap.set(file.filename.toLowerCase(), normalizedFilename)
|
for (const group of normalizedGroups.values()) {
|
||||||
normalizedOwners.set(normalizedKey, file.filename)
|
if (group.length > 1) continue
|
||||||
|
|
||||||
|
const [{ original, normalized }] = group
|
||||||
|
filenameMap.set(original.toLowerCase(), normalized)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filenameMap
|
return filenameMap
|
||||||
@@ -104,7 +106,8 @@ export async function prepareGitAssets({
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
filename = textureFilenameMap.get(pf.filename.toLowerCase()) || pf.filename
|
filename = textureFilenameMap.get(pf.filename.toLowerCase()) || pf.filename
|
||||||
const category = classifyAssetCategory(filename)
|
const categoryFilename = textureFilenameMap.get(pf.filename.toLowerCase()) || normalizeTextureFilename(pf.filename) || pf.filename
|
||||||
|
const category = classifyAssetCategory(categoryFilename)
|
||||||
|
|
||||||
const textureResult = await compressTextureBuffer(filename, pf.buffer)
|
const textureResult = await compressTextureBuffer(filename, pf.buffer)
|
||||||
content = textureResult.buffer
|
content = textureResult.buffer
|
||||||
|
|||||||
Reference in New Issue
Block a user