@needle-tools/gltf-build-pipeline 2.15.0 → 2.15.2

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/dist/cli/index.js CHANGED
@@ -40,7 +40,7 @@ Caches are limited to ${cacheSizeLimit} MB disc space by default.
40
40
  const stats = await calculateStats(file);
41
41
  filestats.push(stats);
42
42
  });
43
- let output = args.ourput?.toString();
43
+ let output = args.output?.toString();
44
44
  if (!output) {
45
45
  if (isDirectory(input)) {
46
46
  output = path.join(input, "stats.needle.json");
@@ -172,6 +172,9 @@ Each version will be compressed and written to the output directory.
172
172
  verbose,
173
173
  useCache,
174
174
  logger: logger,
175
+ // When progressive ran first, inputFile points to the progressive output copy.
176
+ // Pass the original source path so extensions can resolve sibling assets (e.g. .exr files).
177
+ sourceFile: progressive_results.length > 0 ? file : undefined,
175
178
  };
176
179
  // If we have produced progressive assets then the array already contains the input
177
180
  if (progressive_results.length > 0) {
@@ -9,6 +9,8 @@ export type PackGLTFOptions = {
9
9
  logger?: ILogger;
10
10
  debug: boolean;
11
11
  verbose?: boolean;
12
+ /** Original source file path, used to resolve external assets (e.g. .exr files) when inputFile differs from the source (e.g. after progressive transform) */
13
+ sourceFile?: string;
12
14
  };
13
15
  /** Compress a glTF file
14
16
  */
@@ -67,8 +67,10 @@ export async function packGLTF(inputFile, outputFile, options) {
67
67
  'meshopt.encoder': MeshoptEncoder,
68
68
  });
69
69
  // Set input file path so extensions can resolve external EXR files
70
- NEEDLE_lightmaps_ext.inputFile = inputFile;
71
- setOpaqueInputFile(inputFile);
70
+ // Use sourceFile when available (e.g. when inputFile is a progressive output copy)
71
+ const assetSourceFile = options.sourceFile ?? inputFile;
72
+ NEEDLE_lightmaps_ext.inputFile = assetSourceFile;
73
+ setOpaqueInputFile(assetSourceFile);
72
74
  const document = await ioTryReadWithMissingResources(io, inputFile);
73
75
  if (options.logger) {
74
76
  document.setLogger(options.logger);
@@ -32,7 +32,11 @@ class Stats {
32
32
  copyright: asset.copyright,
33
33
  extras: asset.extras,
34
34
  };
35
- const report = inspect(document);
35
+ let report = null;
36
+ try {
37
+ report = inspect(document);
38
+ }
39
+ catch { /* e.g. unsupported KTX2 colorModel */ }
36
40
  this.size = size;
37
41
  this.json = calculateJSONDocumentInfo(json);
38
42
  this.nodes = root.listNodes().length;
@@ -163,8 +167,8 @@ function calculateMeshInfo(document, report) {
163
167
  const meshes = root.listMeshes();
164
168
  const res = new MeshInfo();
165
169
  res.count = meshes.length;
166
- res.errors = report.meshes.errors;
167
- res.warnings = report.meshes.warnings;
170
+ res.errors = report?.meshes.errors;
171
+ res.warnings = report?.meshes.warnings;
168
172
  for (const mesh of root.listMeshes()) {
169
173
  const primitives = mesh.listPrimitives();
170
174
  res.primitives += primitives.length;
@@ -209,15 +213,18 @@ function calculateTextureInfo(document, report) {
209
213
  const res = new TextureInfo();
210
214
  res.count = textures.length;
211
215
  res.formats = textures.map(t => t.getMimeType());
212
- res.errors = report.textures.errors;
213
- res.warnings = report.textures.warnings;
216
+ res.errors = report?.textures.errors;
217
+ res.warnings = report?.textures.warnings;
214
218
  res.gpu_memory = 0;
215
219
  res.memory = 0;
216
220
  for (const texture of textures) {
217
221
  const image = texture.getImage();
218
222
  const mimetype = texture.getMimeType();
219
223
  if (image && mimetype) {
220
- res.gpu_memory += ImageUtils.getVRAMByteLength(image, mimetype);
224
+ try {
225
+ res.gpu_memory += ImageUtils.getVRAMByteLength(image, mimetype);
226
+ }
227
+ catch { /* unsupported KTX2 colorModel (e.g. ASTC HDR) */ }
221
228
  res.memory += image.byteLength;
222
229
  }
223
230
  }
@@ -1 +1 @@
1
- export declare const version = "2.15.0";
1
+ export declare const version = "2.15.2";
@@ -1 +1 @@
1
- export const version = "2.15.0";
1
+ export const version = "2.15.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.15.0",
3
+ "version": "2.15.2",
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",