Skip to content
Merged
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
28 changes: 16 additions & 12 deletions src/converters/assimp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,24 @@ export async function convert(
execFile: ExecFileFn = execFileOriginal, // to make it mockable
): Promise<string> {
return new Promise((resolve, reject) => {
execFile("assimp", ["export", filePath, targetPath], (error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}
execFile(
"assimp",
["export", filePath, targetPath, `-f${convertTo}`],
(error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}

if (stdout) {
console.log(`stdout: ${stdout}`);
}
if (stdout) {
console.log(`stdout: ${stdout}`);
}

if (stderr) {
console.error(`stderr: ${stderr}`);
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}

resolve("Done");
});
resolve("Done");
},
);
});
}
18 changes: 18 additions & 0 deletions src/helpers/normalizeFiletype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ export const normalizeOutputFiletype = (filetype: string): string => {
case "markdown_mmd":
case "markdown":
return "md";
// assimp format ids that aren't real file extensions — map to the
// canonical extension for the underlying format so the output file
// opens in third-party viewers. The format id is still passed to
// `assimp export -f<id>` so the right encoding/variant is produced.
case "glb2":
return "glb";
case "gltf2":
return "gltf";
case "objnomtl":
return "obj";
case "stlb":
return "stl";
case "plyb":
return "ply";
case "fbxa":
return "fbx";
case "assjson":
return "json";
default:
return lowercaseFiletype;
}
Expand Down
Loading