diff --git a/editor/src/electron/assimp/assimpjs-worker.ts b/editor/src/electron/assimp/assimpjs-worker.ts index 321268e5d..0f90ef00a 100644 --- a/editor/src/electron/assimp/assimpjs-worker.ts +++ b/editor/src/electron/assimp/assimpjs-worker.ts @@ -3,11 +3,18 @@ import { workerData, parentPort } from "worker_threads"; const assimpjs = require("assimpjs")(); +const AssimpPostProcessFlags = { + aiProcess_LimitBoneWeights: 0x200000, +} as const; + assimpjs.then((ajs) => { const fileList = new ajs.FileList(); fileList.AddFile(basename(workerData.absolutePath), new Uint8Array(workerData.content)); - const result = ajs.ConvertFileList(fileList, "assjson"); + const postProcessFlags = + AssimpPostProcessFlags.aiProcess_LimitBoneWeights; + const result = ajs.ConvertFileList(fileList, "assjson", postProcessFlags); + if (!result.IsSuccess() || result.FileCount() === 0) { console.log(result.GetErrorCode()); return parentPort?.postMessage(null); diff --git a/editor/src/loader/animation.ts b/editor/src/loader/animation.ts index fcae156bc..140c71354 100644 --- a/editor/src/loader/animation.ts +++ b/editor/src/loader/animation.ts @@ -95,5 +95,12 @@ function getNodeFromContainerByName(container: AssetContainer, name: string): Tr return mesh; } + for (const skeleton of container.skeletons) { + const bone = skeleton.bones.find((b) => b.name === name); + if (bone) { + return bone; + } + } + return null; } diff --git a/editor/src/loader/mesh.ts b/editor/src/loader/mesh.ts index 0b15c0235..f6d635d99 100644 --- a/editor/src/loader/mesh.ts +++ b/editor/src/loader/mesh.ts @@ -61,7 +61,7 @@ export function parseMesh(runtime: AssimpJSRuntime, data: IAssimpJSNodeData): Me } // Bones - const hasBones = !meshes.find((m) => !m.bones); + const hasBones = meshes.some((m) => m.bones && m.bones.length > 0); if (hasBones) { const skeleton = new Skeleton(data.name, Tools.RandomId(), runtime.scene);