mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-16 08:55:52 +00:00
Fix meshes with number suffixes
This commit is contained in:
parent
f9bd7c3bb5
commit
7ba58e6a5b
1 changed files with 18 additions and 0 deletions
|
|
@ -15,12 +15,30 @@ export function getActualResourcePath(resourcePath: string) {
|
||||||
}
|
}
|
||||||
const resourcePaths = getResourceList();
|
const resourcePaths = getResourceList();
|
||||||
const lowerCased = resourcePath.toLowerCase();
|
const lowerCased = resourcePath.toLowerCase();
|
||||||
|
|
||||||
|
// First, try exact case-insensitive match
|
||||||
const foundLowerCase = resourcePaths.find(
|
const foundLowerCase = resourcePaths.find(
|
||||||
(s) => s.toLowerCase() === lowerCased
|
(s) => s.toLowerCase() === lowerCased
|
||||||
);
|
);
|
||||||
if (foundLowerCase) {
|
if (foundLowerCase) {
|
||||||
return foundLowerCase;
|
return foundLowerCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For paths with numeric suffixes (e.g., "generator0.png"), strip the number and try again
|
||||||
|
// e.g., "generator0.png" -> "generator.png"
|
||||||
|
const pathWithoutNumber = resourcePath.replace(/\d+(\.(png))$/i, "$1");
|
||||||
|
const lowerCasedWithoutNumber = pathWithoutNumber.toLowerCase();
|
||||||
|
|
||||||
|
if (pathWithoutNumber !== resourcePath) {
|
||||||
|
// If we stripped a number, try to find the version without it
|
||||||
|
const foundWithoutNumber = resourcePaths.find(
|
||||||
|
(s) => s.toLowerCase() === lowerCasedWithoutNumber
|
||||||
|
);
|
||||||
|
if (foundWithoutNumber) {
|
||||||
|
return foundWithoutNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isTexture = resourcePath.startsWith("textures/");
|
const isTexture = resourcePath.startsWith("textures/");
|
||||||
if (isTexture) {
|
if (isTexture) {
|
||||||
const foundNested = resourcePaths.find(
|
const foundNested = resourcePaths.find(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue