mirror of
https://github.com/exogen/t2-model-skinner.git
synced 2026-01-19 19:24:44 +00:00
Update skin import to handle animations
This commit is contained in:
parent
044d9886fb
commit
911eecd4c3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
self.__BUILD_MANIFEST=function(s){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,"static/chunks/e21e5bbe-b28e0079b469d4e8.js","static/chunks/ebc70433-4eccd1cb3af29a3e.js","static/chunks/6eb5140f-31a2b2da7903b885.js","static/chunks/85d7bc83-1ca530d7d3f44153.js","static/chunks/3a17f596-9aeae038dfa51955.js","static/chunks/f580fadb-2911e2fbf64aae5a.js","static/chunks/515-13ff0773d41722ae.js","static/chunks/pages/index-5b5a7028e5a18507.js"],"/_error":["static/chunks/pages/_error-54b9fcf45cb5bc62.js"],"/gallery":[s,"static/chunks/737a5600-aea383aaa2061cc6.js","static/chunks/918-3c6747f76df39072.js","static/css/922e89893536f2f9.css","static/chunks/pages/gallery-af1406fdc1af13f5.js"],sortedPages:["/","/_app","/_error","/gallery"]}}("static/chunks/cb355538-dbf1c108320fc6a1.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
||||
self.__BUILD_MANIFEST=function(s){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,"static/chunks/e21e5bbe-b28e0079b469d4e8.js","static/chunks/ebc70433-4eccd1cb3af29a3e.js","static/chunks/6eb5140f-31a2b2da7903b885.js","static/chunks/85d7bc83-1ca530d7d3f44153.js","static/chunks/3a17f596-9aeae038dfa51955.js","static/chunks/f580fadb-2911e2fbf64aae5a.js","static/chunks/515-13ff0773d41722ae.js","static/chunks/pages/index-4060c642ab2f1a1b.js"],"/_error":["static/chunks/pages/_error-54b9fcf45cb5bc62.js"],"/gallery":[s,"static/chunks/737a5600-aea383aaa2061cc6.js","static/chunks/918-3c6747f76df39072.js","static/css/922e89893536f2f9.css","static/chunks/pages/gallery-af1406fdc1af13f5.js"],sortedPages:["/","/_app","/_error","/gallery"]}}("static/chunks/cb355538-dbf1c108320fc6a1.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
||||
2
docs/_next/static/chunks/pages/index-4060c642ab2f1a1b.js
Normal file
2
docs/_next/static/chunks/pages/index-4060c642ab2f1a1b.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -8,18 +8,13 @@ type MaterialDefinition = {
|
|||
hidden?: boolean;
|
||||
selectable?: boolean;
|
||||
optional?: boolean;
|
||||
frameCount?: number;
|
||||
};
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
const materialMap: Record<string, MaterialDefinition[]> =
|
||||
publicRuntimeConfig.materials;
|
||||
|
||||
const importedSkinsByModel = new Map();
|
||||
|
||||
export function clearImportedSkins() {
|
||||
importedSkinsByModel.clear();
|
||||
}
|
||||
|
||||
const ignoreFilePattern = /^(\.|__MACOSX)/;
|
||||
|
||||
export function modelToModelType(modelName: string) {
|
||||
|
|
@ -169,9 +164,30 @@ let pathToModelMap: Map<
|
|||
modelName: string;
|
||||
material: MaterialDefinition;
|
||||
index: number;
|
||||
frameIndex?: number;
|
||||
}>
|
||||
>;
|
||||
|
||||
function getFrameInfo(nameWithoutExtension: string) {
|
||||
const match = /^(.+[^\d])(\d{2,})$/.exec(nameWithoutExtension);
|
||||
if (match) {
|
||||
const head = match[1];
|
||||
const tail = match[2];
|
||||
const frameIndex = parseInt(tail, 10);
|
||||
const frameZeroFile = `${head}${"0".padStart(tail.length, "0")}`;
|
||||
const models = pathToModelMap.get(frameZeroFile) ?? [];
|
||||
return models
|
||||
.filter((model) => typeof model.material.frameCount === "number")
|
||||
.map((model) => {
|
||||
return {
|
||||
...model,
|
||||
frameIndex,
|
||||
};
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function pathToModels(path: string, skinName: string | null = null) {
|
||||
if (!pathToModelMap) {
|
||||
pathToModelMap = createReverseFileMap();
|
||||
|
|
@ -195,17 +211,28 @@ function pathToModels(path: string, skinName: string | null = null) {
|
|||
};
|
||||
}
|
||||
} else {
|
||||
const key = parts[0];
|
||||
const models = pathToModelMap.get(key);
|
||||
if (models) {
|
||||
const frameInfo = getFrameInfo(parts[0]);
|
||||
if (frameInfo.length) {
|
||||
return {
|
||||
path,
|
||||
basename,
|
||||
nameWithoutExtension,
|
||||
extension: match[2],
|
||||
skinName,
|
||||
models,
|
||||
models: frameInfo,
|
||||
};
|
||||
} else {
|
||||
const models = pathToModelMap.get(parts[0]);
|
||||
if (models) {
|
||||
return {
|
||||
path,
|
||||
basename,
|
||||
nameWithoutExtension,
|
||||
extension: match[2],
|
||||
skinName,
|
||||
models,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -233,10 +260,10 @@ export function fileArrayToModels(
|
|||
isComplete: null,
|
||||
materials: new Map(),
|
||||
};
|
||||
skinMaterials.materials.set(
|
||||
model.material.file ?? model.material.name,
|
||||
[file.imageUrl]
|
||||
);
|
||||
const key = model.material.file ?? model.material.name;
|
||||
const materialFrames = skinMaterials.materials.get(key) ?? [];
|
||||
materialFrames[model.frameIndex ?? 0] = file.imageUrl;
|
||||
skinMaterials.materials.set(key, materialFrames);
|
||||
skinsByName.set(fileInfo.skinName, skinMaterials);
|
||||
foundModels.set(model.modelName, skinsByName);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue