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