Skip to content

Commit f3c2b44

Browse files
committed
fix: transform output
1 parent aadc788 commit f3c2b44

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-three-gltf",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "GLTF to Angular Three converter",
55
"scripts": {
66
"cleanup": "rimraf node_modules"

src/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ export default function (file, output, options) {
4949
return relativePath;
5050
}
5151

52+
function getTransformOutput(output, file) {
53+
const { name, dir } = path.parse(path.resolve(file));
54+
55+
// default angular's assets directory
56+
if (file.includes("public")) {
57+
return path.join(dir, name + "-transformed.glb");
58+
}
59+
60+
const outputDir = path.parse(path.resolve(output ?? file)).dir;
61+
return path.join(outputDir, name + "-transformed.glb");
62+
}
63+
5264
// function getFilePath(file) {
5365
// // remove public from path. assuming that public is the assets root
5466
// if (file.includes("public/")) {
@@ -62,11 +74,10 @@ export default function (file, output, options) {
6274
let size = "";
6375

6476
if (options.transform || options.instance || options.instanceall) {
65-
const { name } = path.parse(file);
66-
const outputDir = path.parse(path.resolve(output ?? file)).dir;
67-
const transformOut = path.join(outputDir, name + "-transformed.glb");
68-
69-
console.log({ file, name, outputDir, transformOut });
77+
const transformOut = getTransformOutput(output, file);
78+
console.warn(
79+
`Transform output ${transformOut} might not work for you. Move the file manually if needed.`,
80+
);
7081

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

0 commit comments

Comments
 (0)