Skip to content

Commit

Permalink
fix: transform output
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Jan 5, 2025
1 parent aadc788 commit f3c2b44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-three-gltf",
"version": "1.1.2",
"version": "1.1.3",
"description": "GLTF to Angular Three converter",
"scripts": {
"cleanup": "rimraf node_modules"
Expand Down
21 changes: 16 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ export default function (file, output, options) {
return relativePath;
}

function getTransformOutput(output, file) {
const { name, dir } = path.parse(path.resolve(file));

// default angular's assets directory
if (file.includes("public")) {
return path.join(dir, name + "-transformed.glb");
}

const outputDir = path.parse(path.resolve(output ?? file)).dir;
return path.join(outputDir, name + "-transformed.glb");
}

// function getFilePath(file) {
// // remove public from path. assuming that public is the assets root
// if (file.includes("public/")) {
Expand All @@ -62,11 +74,10 @@ export default function (file, output, options) {
let size = "";

if (options.transform || options.instance || options.instanceall) {
const { name } = path.parse(file);
const outputDir = path.parse(path.resolve(output ?? file)).dir;
const transformOut = path.join(outputDir, name + "-transformed.glb");

console.log({ file, name, outputDir, transformOut });
const transformOut = getTransformOutput(output, file);
console.warn(
`Transform output ${transformOut} might not work for you. Move the file manually if needed.`,
);

await transform(file, transformOut, options);
const { size: sizeOriginal, sizeKB: sizeKBOriginal } =
Expand Down

0 comments on commit f3c2b44

Please sign in to comment.