@needle-tools/gltf-build-pipeline 2.7.0 → 2.8.0-alpha.0

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,12 @@ 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.8.0-alpha.0] - 2024-02-27
8
+ - change: `product` usecase now uses webp compression for 'normalTexture' and 'metallicRoughnessTexture' textures
9
+
10
+ ## [2.7.1] - 2024-02-14
11
+ - fix: bug in caching path due to change in 2.7.0-alpha.2
12
+
7
13
  ## [2.7.0] - 2024-02-13
8
14
  - bump version
9
15
 
@@ -181,7 +181,8 @@ export function getKeyWithHash(property) {
181
181
  * @returns The hash as a number.
182
182
  */
183
183
  export function getHash(property, level = 0) {
184
- let hash = "";
184
+ let hashStr = "";
185
+ let hash = 0;
185
186
  if (property instanceof ExtensibleProperty) {
186
187
  const extensions = property.listExtensions();
187
188
  const extras = property.getExtras();
@@ -202,7 +203,7 @@ export function getHash(property, level = 0) {
202
203
  hash += hashObject(weights);
203
204
  const primitives = property.listPrimitives();
204
205
  for (const prim of primitives)
205
- hash += getHash(prim, level + 1);
206
+ hashStr += getHash(prim, level + 1);
206
207
  }
207
208
  else if (property instanceof Primitive) {
208
209
  const indices = property.getIndices();
@@ -232,7 +233,7 @@ export function getHash(property, level = 0) {
232
233
  else {
233
234
  hash += hashObject(property);
234
235
  }
235
- return hash;
236
+ return hashStr + hash;
236
237
  }
237
238
  const cleanBuildPipelineVersion = getVersion(false).replace(/[^a-zA-Z0-9]/g, "_");
238
239
  function getCacheDirectory(root) {
@@ -813,8 +813,8 @@ async function createMeshLod(inputFileName, doc, basePath, level, mesh, meshInfo
813
813
  hash = getHash(mesh);
814
814
  mesh["needle:mesh-hash"] = hash;
815
815
  }
816
- hash += getHash(lodLevel);
817
816
  hash += getHash({
817
+ lodLevel,
818
818
  guid,
819
819
  config: opts.config,
820
820
  });
@@ -964,6 +964,7 @@ async function createMeshLod(inputFileName, doc, basePath, level, mesh, meshInfo
964
964
  // add to cache
965
965
  if (cacheKey != undefined) {
966
966
  const bytes = readFileSync(outPath);
967
+ logger.info(`[${NAME}] Add LOD ${level} to cache for \"${mesh.getName()}\" as ${cacheKey}`);
967
968
  addToCache(cacheKey, bytes);
968
969
  addMetaToCache(cacheKey, { meshInfo: newMeshInformation, density: density });
969
970
  }
@@ -161,6 +161,14 @@ async function processTexture(texture, index, document, logger, context) {
161
161
  // mimetype = "image/webp";
162
162
  // }
163
163
  // }
164
+ // For product compression we automatically select webP if the texture is used in a PBR material
165
+ // https://linear.app/needle/issue/NE-6458
166
+ if (context.config.usecase === "product") {
167
+ const shouldUseWebp = slots.includes("normalTexture") || slots.includes("metallicRoughnessTexture");
168
+ if (shouldUseWebp) {
169
+ mimeType = "image/webp";
170
+ }
171
+ }
164
172
  // If we have a texture cached we can use it
165
173
  // the default compression is toktx so we can safely use that for now
166
174
  if (cached) {
@@ -1 +1 @@
1
- export declare const version = "2.7.0";
1
+ export declare const version = "2.8.0-alpha.0";
@@ -1 +1 @@
1
- export const version = "2.7.0";
1
+ export const version = "2.8.0-alpha.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.7.0",
3
+ "version": "2.8.0-alpha.0",
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",