Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion editor/src/electron/assimp/assimpjs-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions editor/src/loader/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion editor/src/loader/mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down