@needle-tools/gltf-build-pipeline 2.11.2 → 2.11.3-next.2bc6b5b
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 +5 -0
- package/dist/cache/cache.d.ts +1 -1
- package/dist/cache/cache.js +1 -1
- package/dist/cli/index.js +8 -1
- package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +2 -31
- package/dist/transforms/needle_mesh_transform.js +3 -2
- package/dist/transforms/needle_progressive.js +8 -8
- package/dist/utils/version.gen.d.ts +1 -1
- package/dist/utils/version.gen.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ 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
|
+
- Fix: texture compression settings not being applied correctly
|
|
9
|
+
- Change: CLI `transform` with `--progressive` does now ignore LOD files
|
|
10
|
+
- Change: Increase local cache size to 5 GB
|
|
11
|
+
|
|
7
12
|
## [2.11.2] - 2025-08-07
|
|
8
13
|
- Change: `product` usecase should not flatten/join objects
|
|
9
14
|
|
package/dist/cache/cache.d.ts
CHANGED
|
@@ -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
|
|
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.
|
package/dist/cache/cache.js
CHANGED
|
@@ -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
|
-
|
|
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({
|
|
@@ -8,43 +8,14 @@ export class NEEDLE_progressive_texture_settings extends Extension {
|
|
|
8
8
|
const textureDefinitions = context.jsonDoc.json.textures;
|
|
9
9
|
if (!textureDefinitions)
|
|
10
10
|
return this;
|
|
11
|
-
const root = this.document.getRoot();
|
|
12
|
-
const textures = root.listTextures();
|
|
13
|
-
/**
|
|
14
|
-
* If a texture is used in multiple slots it only appears once in the gltf-transform list
|
|
15
|
-
* So we have to store the key and the index of the texture in the list
|
|
16
|
-
*/
|
|
17
|
-
const textureMap = new Map();
|
|
18
|
-
let offset = 0;
|
|
19
11
|
for (let i = 0; i < textureDefinitions.length; i++) {
|
|
20
12
|
const texDef = textureDefinitions[i];
|
|
21
13
|
if (texDef.extensions && texDef.extensions[EXTENSION_NAME]) {
|
|
22
14
|
const ext = texDef.extensions[EXTENSION_NAME];
|
|
23
15
|
const prop = new NEEDLE_progressive_texture_settings_property(this.document.getGraph(), "");
|
|
24
16
|
Object.assign(prop, ext);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (textureMap.has(key)) {
|
|
28
|
-
// we keep a track of the index offset assuming gltf-transform textures order is the same as the texture definition order. This is by no means *not* bullet-proof but I'm not sure how to do it properly right now
|
|
29
|
-
// Perhaps we could try to find the texture with the same image source binary array as defined in the texture definition but this would also not be perfect I think...
|
|
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
|
-
offset += 1;
|
|
32
|
-
// textureIndex = textureMap.get(key);
|
|
33
|
-
console.log(`INFO: Progressive texture extension was ${i} already found...`);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
textureMap.set(key, textureIndex);
|
|
38
|
-
}
|
|
39
|
-
const tex = textures[textureIndex];
|
|
40
|
-
if (tex)
|
|
41
|
-
tex.setExtension(EXTENSION_NAME, prop);
|
|
42
|
-
else {
|
|
43
|
-
// console.log(textureDefinitions)
|
|
44
|
-
console.warn(`WARN: Progressive texture at index ${i} was not found in the glTF file. This might result in falsely loaded textures for ${ext.guid} / name \"${texDef.name}\"`);
|
|
45
|
-
// if(debug)
|
|
46
|
-
// throw new Error(`Progressive texture at index ${i} was not found in the glTF file.`)
|
|
47
|
-
}
|
|
17
|
+
const texture = context.textures[texDef.source];
|
|
18
|
+
texture.setExtension(EXTENSION_NAME, prop);
|
|
48
19
|
}
|
|
49
20
|
}
|
|
50
21
|
return this;
|
|
@@ -68,6 +68,7 @@ export const needle_mesh_transform = function (context) {
|
|
|
68
68
|
};
|
|
69
69
|
async function applyMeshCompression(document, transform_context, context) {
|
|
70
70
|
const isLOD = isMeshLOD(context.file);
|
|
71
|
+
const isProduct = context.config?.usecase === "product";
|
|
71
72
|
const compressionModel = determineMeshCompression(document, context.file); // document.getRoot().getExtension(NEEDLE_mesh_compression.EXTENSION_NAME) as NEEDLE_mesh_compression_property;
|
|
72
73
|
if (compressionModel) {
|
|
73
74
|
// const rootModel = rootExtension.model as NEEDLE_mesh_compression_model_root;
|
|
@@ -79,7 +80,7 @@ async function applyMeshCompression(document, transform_context, context) {
|
|
|
79
80
|
document.getLogger().info(`[${NAME}]: ${compressionModel.compression.toUpperCase()} → will apply ${compressionModel.compression} mesh compression`);
|
|
80
81
|
if (compressionModel.compression === "draco") {
|
|
81
82
|
const transform = draco({
|
|
82
|
-
quantizationVolume: isLOD ? "scene" : undefined
|
|
83
|
+
quantizationVolume: isLOD || isProduct ? "scene" : undefined
|
|
83
84
|
});
|
|
84
85
|
return transform(document, transform_context);
|
|
85
86
|
}
|
|
@@ -92,7 +93,7 @@ async function applyMeshCompression(document, transform_context, context) {
|
|
|
92
93
|
// by default we still want to run draco if the root doesnt have a compression model configured
|
|
93
94
|
document.getLogger().info(`[${NAME}]: → will apply draco mesh compression (default)`);
|
|
94
95
|
const transform = draco({
|
|
95
|
-
quantizationVolume: isLOD ? "scene" : undefined
|
|
96
|
+
quantizationVolume: isLOD || isProduct ? "scene" : undefined
|
|
96
97
|
});
|
|
97
98
|
return transform(document, transform_context);
|
|
98
99
|
}
|
|
@@ -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
|
|
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(
|
|
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(
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
1
|
+
export declare const version = "2.11.3-next.2bc6b5b";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.11.
|
|
1
|
+
export const version = "2.11.3-next.2bc6b5b";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.3-next.2bc6b5b",
|
|
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",
|