@needle-tools/gltf-build-pipeline 2.11.0-next.340ffdd → 2.11.0-next.dc26d01

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,10 @@ 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.0] - 2025-08-01
8
+ - add: store densities per primitive
9
+ - fix: exception during cache key calculation
10
+
7
11
  ## [2.10.2] - 2025-07-17
8
12
  - fix: issue where draco compression fails with `[KHR_draco_mesh_compression] Accessor cannot be shared by compressed and uncompressed primitives`
9
13
 
@@ -252,7 +252,7 @@ function getCacheDirectory(root) {
252
252
  }
253
253
  return tmpDir;
254
254
  }
255
- function hashObject(obj) {
255
+ function hashObject(obj, depth = 0) {
256
256
  if (obj instanceof Accessor) {
257
257
  const buffer = obj.getArray();
258
258
  return hashBuffer(buffer.buffer);
@@ -260,14 +260,42 @@ function hashObject(obj) {
260
260
  else if (obj == null) {
261
261
  return 0;
262
262
  }
263
+ if (typeof obj !== 'object') {
264
+ return hashString(String(obj));
265
+ }
263
266
  try {
264
267
  const str = JSON.stringify(obj);
265
268
  return hashString(str);
266
269
  }
267
270
  catch (err) {
268
- console.error(err);
269
- debugger;
270
- throw err;
271
+ console.warn("WARN: [Cache] error during hashing of object:\n" + err);
272
+ if (debugLogs)
273
+ debugger;
274
+ // Fallback to a simple hash of the keys and values
275
+ // TODO: maybe we want to exclude this object now from the cache if it fails to serialize?
276
+ let fallbackHashj = 0;
277
+ if (typeof obj === 'object') {
278
+ if (obj === null)
279
+ return 0;
280
+ for (const key in obj) {
281
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
282
+ const value = obj[key];
283
+ fallbackHashj += hashString(key);
284
+ if (typeof value === 'object') {
285
+ if (depth > 10) {
286
+ fallbackHashj += hashString("[object]");
287
+ }
288
+ else {
289
+ fallbackHashj += hashObject(value, depth + 1);
290
+ }
291
+ }
292
+ else {
293
+ fallbackHashj += hashString(String(value));
294
+ }
295
+ }
296
+ }
297
+ }
298
+ return fallbackHashj;
271
299
  }
272
300
  }
273
301
  function hashBuffer(buffer, offset, length) {
package/dist/cli/index.js CHANGED
@@ -67,10 +67,10 @@ Each version will be compressed and written to the output directory.
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
69
  if (options.compress === false && options.progressive === false) {
70
- logger.error("You need to enable at least one of the options: --compress or --progressive");
70
+ logger.error(`[Needle Build Pipeline] v${getVersion()} You need to enable at least one of the options: --compress or --progressive`);
71
71
  return;
72
72
  }
73
- logger.info("Transforming glTF file: " + args.input);
73
+ logger.info(`[Needle Build Pipeline] v${getVersion()} — Transform '${args.input}'`);
74
74
  const stats = {
75
75
  startTime: Date.now(),
76
76
  totalGPUMemoryInMB: 0,
@@ -138,6 +138,7 @@ Each version will be compressed and written to the output directory.
138
138
  debug,
139
139
  verbose,
140
140
  useCache,
141
+ logger,
141
142
  }).catch(err => {
142
143
  logger.error(err);
143
144
  process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
@@ -9,6 +9,7 @@ declare interface ProgressiveOptions {
9
9
  debug?: boolean;
10
10
  verbose?: boolean;
11
11
  useCache?: boolean;
12
+ logger: ILogger;
12
13
  }
13
14
  export declare function make_progressive(opts: ProgressiveOptions): Promise<boolean>;
14
15
  export declare function createTransform(name: string, fn: Transform): Transform;
@@ -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
- console.log(`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);
@@ -1 +1 @@
1
- export declare const version = "2.11.0-next.340ffdd";
1
+ export declare const version = "2.11.0-next.dc26d01";
@@ -1 +1 @@
1
- export const version = "2.11.0-next.340ffdd";
1
+ export const version = "2.11.0-next.dc26d01";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.11.0-next.340ffdd",
3
+ "version": "2.11.0-next.dc26d01",
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",