@needle-tools/gltf-build-pipeline 2.4.0-alpha.1 → 2.4.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.4.0-alpha.3] - 2023-08-11
8
+ - fix: issue where files would not correctly be overriden in subdirectories when no output directory was specified
9
+
10
+ ## [2.4.0-alpha.2] - 2023-06-29
11
+ - fix: prevent joining/flattening of progressive assets
12
+
7
13
  ## [2.4.0-alpha.1] - 2023-06-26
8
14
  - add: heuristic for choosing mesh compression if not explictly configured
9
15
 
package/dist/cli/index.js CHANGED
@@ -91,15 +91,19 @@ Each version will be compressed and written to the output directory.
91
91
  config.usecase = options.usecase.toString();
92
92
  }
93
93
  }
94
- let output = args.output?.toString() || input;
95
94
  const inputIsDirectory = isDirectory(input);
96
- const outputIsDirectory = isDirectory(output);
97
- if (inputIsDirectory && !outputIsDirectory) {
95
+ let output = args.output?.toString();
96
+ // If the input path is a filepath and no specific output is defined we set output to the input file
97
+ if (!inputIsDirectory && !output) {
98
+ output = input;
99
+ }
100
+ const outputIsDirectory = output && isDirectory(output);
101
+ if (inputIsDirectory && output && !outputIsDirectory) {
98
102
  logger.error("When <input> is a directory then <output> must also be a directory");
99
103
  process.exit(ERROR_CODES.INVALID_ARGS);
100
104
  }
101
105
  // Handle the output bath being relative to the input path
102
- if (path.isAbsolute(output) === false) {
106
+ if (output && path.isAbsolute(output) === false) {
103
107
  const base = ensureIsDirectory(input);
104
108
  output = resolve(base, output);
105
109
  }
@@ -90,11 +90,12 @@ export async function packGLTF(inputFile, outputFile, options) {
90
90
  propertyTypes: ['MESH', 'MATERIAL', 'TEXTURE']
91
91
  }));
92
92
  }
93
- await document.transform(...transforms);
94
93
  const isVRM = inputFile.toLowerCase().endsWith(".vrm");
95
- if (!isVRM && config?.usecase === "product") {
96
- await document.transform(flatten(), join({ keepNamed: false }));
94
+ if (!isVRM && !isProgressiveAsset && config?.usecase === "product") {
95
+ transforms.push(flatten());
96
+ transforms.push(join({ keepNamed: false }));
97
97
  }
98
+ await document.transform(...transforms);
98
99
  if (!outputFile)
99
100
  outputFile = inputFile;
100
101
  else {
@@ -153,6 +153,9 @@ export function replaceExtension(filepath, newExtension) {
153
153
  return parts.join(".") + "." + newExtension;
154
154
  }
155
155
  export function isDirectory(path) {
156
+ if (!path) {
157
+ return false;
158
+ }
156
159
  if (existsSync(path)) {
157
160
  return statSync(path).isDirectory();
158
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.4.0-alpha.1",
3
+ "version": "2.4.0-alpha.3",
4
4
  "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",