@needle-tools/gltf-build-pipeline 1.2.2 → 1.2.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,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
+ ## [1.2.3] - 2023-09-29
8
+ - fix: bug in progressive texture transform where texture wasnt found
9
+
7
10
  ## [1.2.2] - 2023-08-14
8
11
  - remove: legacy squoosh dependency
9
12
 
@@ -11,10 +11,10 @@ export class NEEDLE_compression_texture extends Extension {
11
11
  return ext;
12
12
  }
13
13
  read(context) {
14
- if (!context.jsonDoc.json.textures)
15
- return this;
16
14
  if (debugLog)
17
15
  console.log("READ " + EXTENSION_NAME);
16
+ if (!context.jsonDoc.json.textures)
17
+ return this;
18
18
  context.textures?.forEach((tex, _) => {
19
19
  const textureDefinition = getTextureDefinition(context, tex);
20
20
  if (textureDefinition?.extensions && textureDefinition.extensions[EXTENSION_NAME]) {
@@ -16,7 +16,12 @@ export class NEEDLE_progressive_texture_settings extends Extension {
16
16
  const ext = texDef.extensions[EXTENSION_NAME];
17
17
  const prop = new NEEDLE_progressive_texture_settings_property(this.document.getGraph(), "");
18
18
  Object.assign(prop, ext);
19
- textures[i].setExtension(EXTENSION_NAME, prop);
19
+ const tex = textures[i];
20
+ if (tex)
21
+ tex.setExtension(EXTENSION_NAME, prop);
22
+ else {
23
+ console.warn("Texture not found for texture index " + i);
24
+ }
20
25
  }
21
26
  }
22
27
  return this;
@@ -81,6 +81,10 @@ async function processTexture(texture, index, document, logger, context) {
81
81
  return;
82
82
  const ext = texture.getExtension(NEEDLE_compression_texture.EXTENSION_NAME);
83
83
  const compressionSettings = ext?.model;
84
+ // is a user has configured a texture explictly to NOT be compressed
85
+ // we should respect that
86
+ if (ext?.model?.mode === "none")
87
+ return;
84
88
  const key = context.useCache ? getKey(texture) : undefined;
85
89
  let cached = context.useCache && key ? tryGetFromCache(key) : undefined;
86
90
  if (cached) {
@@ -37,6 +37,11 @@ export async function foreachGLTF(args, callback) {
37
37
  }
38
38
  }
39
39
  }
40
+ else {
41
+ // if no file was found, we don't have a needle.config in the directory
42
+ // and we don't have any arguments, try to find it in the default dist directory
43
+ // await testEntry(context.baseDirectory + "/dist", callback, context);
44
+ }
40
45
  }
41
46
  if (context.filesFound <= 0) {
42
47
  console.log("WARN: No glTF files found. Make sure to invoke with a valid path to a glTF file or directory. This path may be relative to " + initDir);
package/pack-gltf.mjs CHANGED
@@ -145,7 +145,8 @@ async function packFile(file) {
145
145
 
146
146
 
147
147
  let startTime = Date.now();
148
- foreachGLTF(process.argv, async (file) => {
148
+ const inputArgs = args.slice(2);
149
+ foreachGLTF(inputArgs, async (file) => {
149
150
  await packFile(file);
150
151
  }).then(() => {
151
152
  const duration = Date.now() - startTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
5
  "main": "index.mjs",
6
6
  "type": "module",