Skip to content

Commit 5ce8d8a

Browse files
author
Yuri Pourre
committed
Fix loading bones
1 parent cdde35a commit 5ce8d8a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

editor/src/electron/assimp/assimpjs-worker.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ import { workerData, parentPort } from "worker_threads";
33

44
const assimpjs = require("assimpjs")();
55

6+
const AssimpPostProcessFlags = {
7+
aiProcess_LimitBoneWeights: 0x200000,
8+
} as const;
9+
610
assimpjs.then((ajs) => {
711
const fileList = new ajs.FileList();
812
fileList.AddFile(basename(workerData.absolutePath), new Uint8Array(workerData.content));
913

10-
const result = ajs.ConvertFileList(fileList, "assjson");
14+
const postProcessFlags =
15+
AssimpPostProcessFlags.aiProcess_LimitBoneWeights;
16+
const result = ajs.ConvertFileList(fileList, "assjson", postProcessFlags);
17+
1118
if (!result.IsSuccess() || result.FileCount() === 0) {
1219
console.log(result.GetErrorCode());
1320
return parentPort?.postMessage(null);

editor/src/loader/animation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,12 @@ function getNodeFromContainerByName(container: AssetContainer, name: string): Tr
9595
return mesh;
9696
}
9797

98+
for (const skeleton of container.skeletons) {
99+
const bone = skeleton.bones.find((b) => b.name === name);
100+
if (bone) {
101+
return bone;
102+
}
103+
}
104+
98105
return null;
99106
}

editor/src/loader/mesh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function parseMesh(runtime: AssimpJSRuntime, data: IAssimpJSNodeData): Me
6161
}
6262

6363
// Bones
64-
const hasBones = !meshes.find((m) => !m.bones);
64+
const hasBones = meshes.some((m) => m.bones && m.bones.length > 0);
6565

6666
if (hasBones) {
6767
const skeleton = new Skeleton(data.name, Tools.RandomId(), runtime.scene);

0 commit comments

Comments
 (0)