@needle-tools/gltf-build-pipeline 2.11.2 → 2.11.3-next.9f96868

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,9 @@ 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.11.3] - 2025-08-08
8
+ - Change: CLI `transform` with `--progressive` does now ignore LOD files
9
+
7
10
  ## [2.11.2] - 2025-08-07
8
11
  - Change: `product` usecase should not flatten/join objects
9
12
 
@@ -6,7 +6,7 @@ import { Logger } from "@donmccurdy/caporal";
6
6
  * This will remove all files in the cache directory.
7
7
  */
8
8
  export declare function clearCache(logger?: Logger): void;
9
- export declare const cacheSizeLimit = 1024;
9
+ export declare const cacheSizeLimit: number;
10
10
  /**
11
11
  * Ensure that the cache size does not exceed the given maximum size in MB.
12
12
  * @param maxSizeMB The maximum size in MB.
@@ -32,7 +32,7 @@ export function clearCache(logger) {
32
32
  else
33
33
  logger.info(`Cleared cache at ${dir}`);
34
34
  }
35
- export const cacheSizeLimit = 1024;
35
+ export const cacheSizeLimit = 1024 * 5;
36
36
  /**
37
37
  * Ensure that the cache size does not exceed the given maximum size in MB.
38
38
  * @param maxSizeMB The maximum size in MB.
package/dist/cli/index.js CHANGED
@@ -66,6 +66,8 @@ Each version will be compressed and written to the output directory.
66
66
  .option("--debug", "Enable for more verbose outout with \"--debug True\"", { validator: program.BOOLEAN, default: false })
67
67
  .option("--verbose", "Enable for more verbose outout with \"--verbose True\"", { validator: program.BOOLEAN, default: false })
68
68
  .action(async ({ logger, args, options }) => {
69
+ logger.level = (options.debug || options.verbose) ? "debug" : "info";
70
+ // const logger = new Logger((options.debug || options.verbose) ? Verbosity.DEBUG : Verbosity.INFO);
69
71
  if (options.compress === false && options.progressive === false) {
70
72
  logger.error(`[Needle Build Pipeline] v${getVersion()} You need to enable at least one of the options: --compress or --progressive`);
71
73
  return;
@@ -127,7 +129,12 @@ Each version will be compressed and written to the output directory.
127
129
  process.exit(ERROR_CODES.LOST_FILE);
128
130
  }
129
131
  }
130
- logger.info("→ Transform " + file);
132
+ // If we run compression in a directory that has previously generated LOD files AND this command should also generate LOD files with this command we should ignore found LOD meshes or textures
133
+ else if (file != input && options.progressive === true && isLOD(file)) {
134
+ logger.debug(`→ Ignore existing LOD file at ${file}`);
135
+ return;
136
+ }
137
+ logger.info(`→ Transform ${file}`);
131
138
  const progressive_results = new Array();
132
139
  if (options.progressive === true) {
133
140
  if (await make_progressive({
@@ -30,7 +30,7 @@ export class NEEDLE_progressive_texture_settings extends Extension {
30
30
  // TODO: find a better way to handle texture definition count and texture count mismatch due to a texture being used in multiple slots (where gltf-transform optimizes the texture list and removes duplicates)
31
31
  offset += 1;
32
32
  // textureIndex = textureMap.get(key);
33
- console.log(`INFO: Progressive texture extension was ${i} already found...`);
33
+ console.log(`INFO: Progressive texture extension was already found at index ${i}...`);
34
34
  continue;
35
35
  }
36
36
  else {
@@ -22,7 +22,7 @@ export async function make_progressive(opts) {
22
22
  }
23
23
  // Don't re-process files that are already LODs
24
24
  if (isMeshLOD(f) || isImageLOD(f)) {
25
- opts.logger.info(`Progressive Transform: Ignore existing LOD file at ${f}`);
25
+ opts.logger.info(`[Progressive Transform]: Ignore existing LOD file at ${f}`);
26
26
  return;
27
27
  }
28
28
  const res = await onProcess(f, opts);
@@ -40,7 +40,7 @@ export async function make_progressive(opts) {
40
40
  }
41
41
  const resultsChanged = resultsCount !== opts.results.length;
42
42
  if (opts.debug)
43
- console.log(`Progressive Transform: ${opts.results.length} files processed. ${resultsChanged ? "Some results were removed" : ""}`);
43
+ console.log(`[Progressive Transform]: ${opts.results.length} files processed. ${resultsChanged ? "Some results were removed" : ""}`);
44
44
  }
45
45
  return success;
46
46
  }
@@ -253,7 +253,7 @@ export function make_progressive_textures(filePath, _options = TEXTURE_RESIZE_DE
253
253
  });
254
254
  opts.results.push(outpath);
255
255
  }
256
- const key = getKey(texture);
256
+ const cacheKey = getKey(texture);
257
257
  // TODO: this path should be added to the NEEDLE dependencies extension
258
258
  const model = {
259
259
  guid: textureGuid,
@@ -261,7 +261,7 @@ export function make_progressive_textures(filePath, _options = TEXTURE_RESIZE_DE
261
261
  };
262
262
  texture.setExtension(NEEDLE_PROGRESSIVE_EXTENSION_NAME, progressiveExt.createTexture(model));
263
263
  if (opts.useCache) {
264
- const cached = tryGetFromCache(key);
264
+ const cached = tryGetFromCache(cacheKey);
265
265
  if (cached) {
266
266
  logger.debug(`Progressive image ${index}: using cached preview version (size: ${options.size}))`);
267
267
  texture.setImage(cached);
@@ -275,7 +275,7 @@ export function make_progressive_textures(filePath, _options = TEXTURE_RESIZE_DE
275
275
  if (opts?.useCache === false) {
276
276
  }
277
277
  else
278
- addToCache(key, texture.getImage());
278
+ addToCache(cacheKey, texture.getImage());
279
279
  }
280
280
  logger.debug(`Progressive transform finished in ${((Date.now() - startTime) / 1000).toFixed(1)} sec.`);
281
281
  });
@@ -492,7 +492,7 @@ async function resizeTexture(options, texture, logger, uri, slots) {
492
492
  }
493
493
  dstWidth = Math.floor(dstWidth);
494
494
  dstHeight = Math.floor(dstHeight);
495
- logger.warn("> Resize texture to " + dstWidth + "x" + dstHeight + " (from " + srcWidth + "x" + srcHeight + ")");
495
+ logger.info(`→ Resize texture (${uri || texture.getName() || slots.join(", ")}) from ${srcWidth}x${srcHeight} to ${dstWidth}x${dstHeight}px`);
496
496
  // https://sharp.pixelplumbing.com/api-resize
497
497
  const buffer = await sharp(texture.getImage())
498
498
  .resize(dstWidth, dstHeight, {
@@ -657,11 +657,11 @@ export function make_progressive_meshes(filePath, _options, opts) {
657
657
  const vertexDifference = lastMeshInfo.totalVertexCount - meshInfo.totalVertexCount;
658
658
  const diff01 = vertexDifference / lastMeshInfo.totalVertexCount;
659
659
  if (vertexDifference < 0) {
660
- console.log(`WARN: [${NAME}] Flag mesh LOD ${level}: vertex count did increase (${-vertexDifference.toFixed(0)} vertices, ${(-diff01 * 100).toFixed(4)}%) → LOD ${level} will be omitted. \"${mesh.getName()}\" at \"${lodInfo.path}\" ${JSON.stringify(lastMeshInfo)} → ${JSON.stringify(meshInfo)}`);
660
+ logger.info(`[${NAME}] Flag mesh LOD ${level}: vertex count did increase (${-vertexDifference.toFixed(0)} vertices, ${(-diff01 * 100).toFixed(4)}%) → LOD ${level} will be omitted. \"${mesh.getName()}\" at \"${lodInfo.path}\" ${JSON.stringify(lastMeshInfo)} → ${JSON.stringify(meshInfo)}`);
661
661
  shouldOmitLevel = true;
662
662
  }
663
663
  else if (vertexDifference < 32 || diff01 < 0.05) {
664
- logger.warn(`[${NAME}] Flag mesh LOD ${level}: vertex count difference below threshold (removed ${vertexDifference.toFixed(0)} vertices, ${(-diff01 * 100).toFixed(4)}%) → LOD ${level} will be omitted. \"${mesh.getName()}\" at \"${lodInfo.path}\"`);
664
+ logger.info(`[${NAME}] Flag mesh LOD ${level}: vertex count difference below threshold (removed ${vertexDifference.toFixed(0)} vertices, ${(-diff01 * 100).toFixed(4)}%) → LOD ${level} will be omitted. \"${mesh.getName()}\" at \"${lodInfo.path}\"`);
665
665
  shouldOmitLevel = true;
666
666
  }
667
667
  }
@@ -1 +1 @@
1
- export declare const version = "2.11.2";
1
+ export declare const version = "2.11.3-next.9f96868";
@@ -1 +1 @@
1
- export const version = "2.11.2";
1
+ export const version = "2.11.3-next.9f96868";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.11.2",
3
+ "version": "2.11.3-next.9f96868",
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",