@needle-tools/gltf-build-pipeline 2.8.1 → 2.9.1

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
+ ## [2.9.0] - 2024-05-22
8
+ - add: initial texture compression mode support for `world` and `product`
9
+
7
10
  ## [2.8.1] - 2024-04-17
8
11
  - bump version
9
12
 
@@ -1,7 +1,7 @@
1
1
  import { Extension, ExtensionProperty, PropertyType, ReaderContext, WriterContext } from "@gltf-transform/core";
2
2
  export declare const EXTENSION_NAME = "NEEDLE_compression_texture";
3
3
  export declare interface NEEDLE_compression_texture_schema {
4
- mode: "none" | "auto" | "webp" | "UASTC" | "ETC1S";
4
+ mode: "none" | "auto" | "webp" | "UASTC" | "ETC1S" | "world" | "product";
5
5
  slot: string;
6
6
  /** quality in range of 0 - 1 */
7
7
  quality: number;
@@ -117,6 +117,23 @@ async function processTexture(texture, index, document, logger, context) {
117
117
  const canRunToktx = context.noToktx !== true;
118
118
  const originalUri = texture.getURI();
119
119
  if (compressionSettings && compressionSettings.mode !== "auto") {
120
+ // Handle highlevel modes
121
+ switch (compressionSettings.mode) {
122
+ case "world":
123
+ compressionSettings.mode = "ETC1S";
124
+ break;
125
+ case "product":
126
+ switch (compressionSettings.slot) {
127
+ case "baseColorTexture":
128
+ case "normalTexture":
129
+ case "metallicRoughnessTexture":
130
+ case "lightmapTexture":
131
+ compressionSettings.mode = "webp";
132
+ compressionSettings.quality = 0.95;
133
+ break;
134
+ }
135
+ break;
136
+ }
120
137
  switch (compressionSettings.mode) {
121
138
  case "webp":
122
139
  if (cached) {
@@ -147,7 +164,6 @@ async function processTexture(texture, index, document, logger, context) {
147
164
  else {
148
165
  let mimeType = "image/ktx2";
149
166
  let ktx2Format = undefined;
150
- let webpOptions = {};
151
167
  const slots = listTextureSlots(texture);
152
168
  const size = texture.getSize();
153
169
  const isVRM = context.file?.toLowerCase().endsWith(".vrm");
@@ -162,6 +178,7 @@ async function processTexture(texture, index, document, logger, context) {
162
178
  // mimetype = "image/webp";
163
179
  // }
164
180
  // }
181
+ const webpOptions = {};
165
182
  if (slots.includes("lightmapTexture") || isLightmap(texture)) {
166
183
  mimeType = "image/webp";
167
184
  }
@@ -172,6 +189,7 @@ async function processTexture(texture, index, document, logger, context) {
172
189
  }
173
190
  // For product compression we automatically select webP if the texture is used in a PBR material
174
191
  // https://linear.app/needle/issue/NE-6458
192
+ // TODO: this should probably moved to the top and we should create a compression settings object
175
193
  else if (context.config.usecase === "product") {
176
194
  const shouldUseWebp = slots.includes("normalTexture") || slots.includes("metallicRoughnessTexture");
177
195
  if (shouldUseWebp) {
@@ -1 +1 @@
1
- export declare const version = "2.8.1";
1
+ export declare const version = "2.9.1";
@@ -1 +1 @@
1
- export const version = "2.8.1";
1
+ export const version = "2.9.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.8.1",
3
+ "version": "2.9.1",
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",