@needle-tools/gltf-build-pipeline 2.9.2 → 2.9.4
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.1] - 2024-05-23
|
|
8
|
+
- change: `product` usecase uses `UASTC` compression for 'normalTexture'
|
|
9
|
+
|
|
7
10
|
## [2.9.0] - 2024-05-22
|
|
8
11
|
- add: initial texture compression mode support for `world` and `product`
|
|
9
12
|
|
|
@@ -97,7 +97,7 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
97
97
|
const compressionSettings = ext?.model;
|
|
98
98
|
// is a user has configured a texture explictly to NOT be compressed
|
|
99
99
|
// we should respect that
|
|
100
|
-
if (
|
|
100
|
+
if (compressionSettings?.mode === "none") {
|
|
101
101
|
logger.info(`→ Skipping texture compression for ${texture.getName()} [${index}] as configured in the texture extension`);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
@@ -113,7 +113,8 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
113
113
|
logger.info(`→ Using cached texture ${texture.getName()} [${index}] – ${(cached.length / 1024).toFixed(0)} KB`);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
let
|
|
116
|
+
let successfullyProcessed = false;
|
|
117
|
+
let useDefaultCompression = true;
|
|
117
118
|
const canRunToktx = context.noToktx !== true;
|
|
118
119
|
const originalUri = texture.getURI();
|
|
119
120
|
if (compressionSettings && compressionSettings.mode !== "auto") {
|
|
@@ -124,12 +125,17 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
124
125
|
break;
|
|
125
126
|
case "product":
|
|
126
127
|
switch (compressionSettings.slot) {
|
|
127
|
-
|
|
128
|
+
default:
|
|
129
|
+
compressionSettings.mode = "ETC1S";
|
|
130
|
+
break;
|
|
128
131
|
case "normalTexture":
|
|
132
|
+
compressionSettings.mode = "UASTC";
|
|
133
|
+
break;
|
|
134
|
+
case "baseColorTexture":
|
|
129
135
|
case "metallicRoughnessTexture":
|
|
130
136
|
case "lightmapTexture":
|
|
131
137
|
compressionSettings.mode = "webp";
|
|
132
|
-
compressionSettings.quality = 0.
|
|
138
|
+
compressionSettings.quality = 0.8;
|
|
133
139
|
break;
|
|
134
140
|
}
|
|
135
141
|
break;
|
|
@@ -141,7 +147,8 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
141
147
|
return;
|
|
142
148
|
}
|
|
143
149
|
await resizeTextureIfNecessary(texture);
|
|
144
|
-
|
|
150
|
+
useDefaultCompression = false;
|
|
151
|
+
successfullyProcessed = await context.webPContext.process(index, texture, compressionSettings, context);
|
|
145
152
|
break;
|
|
146
153
|
case "ETC1S":
|
|
147
154
|
if (cached) {
|
|
@@ -149,7 +156,8 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
149
156
|
return;
|
|
150
157
|
}
|
|
151
158
|
await resizeTextureIfNecessary(texture);
|
|
152
|
-
|
|
159
|
+
useDefaultCompression = false;
|
|
160
|
+
successfullyProcessed = await context.toktxContext.process(index, texture, compressionSettings, context);
|
|
153
161
|
break;
|
|
154
162
|
case "UASTC":
|
|
155
163
|
if (cached) {
|
|
@@ -157,11 +165,12 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
157
165
|
return;
|
|
158
166
|
}
|
|
159
167
|
await resizeTextureIfNecessary(texture);
|
|
160
|
-
|
|
168
|
+
useDefaultCompression = false;
|
|
169
|
+
successfullyProcessed = await context.toktxContext.process(index, texture, compressionSettings, context);
|
|
161
170
|
break;
|
|
162
171
|
}
|
|
163
172
|
}
|
|
164
|
-
|
|
173
|
+
if (useDefaultCompression) {
|
|
165
174
|
let mimeType = "image/ktx2";
|
|
166
175
|
let ktx2Format = undefined;
|
|
167
176
|
const slots = listTextureSlots(texture);
|
|
@@ -204,9 +213,10 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
204
213
|
}
|
|
205
214
|
await resizeTextureIfNecessary(texture);
|
|
206
215
|
if (mimeType === "image/webp") {
|
|
207
|
-
|
|
216
|
+
successfullyProcessed = await context.webPContext.process(index, texture, {
|
|
208
217
|
...webpOptions,
|
|
209
218
|
quality: .95,
|
|
219
|
+
slot: slots.join(","),
|
|
210
220
|
}, context);
|
|
211
221
|
}
|
|
212
222
|
else if (canRunToktx) {
|
|
@@ -217,18 +227,18 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
217
227
|
if (ktx2Format || isVRM) {
|
|
218
228
|
options = { mode: ktx2Format || "ETC1S" };
|
|
219
229
|
}
|
|
220
|
-
|
|
230
|
+
successfullyProcessed = await context.toktxContext.process(index, texture, options, context);
|
|
221
231
|
}
|
|
222
232
|
else {
|
|
223
233
|
console.log("Toktx not found: Skipping texture compression: " + originalMimeType);
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
|
-
if (context.useCache &&
|
|
236
|
+
if (context.useCache && successfullyProcessed && key) {
|
|
227
237
|
const data = texture.getImage();
|
|
228
238
|
if (data)
|
|
229
239
|
addToCache(key, data);
|
|
230
240
|
}
|
|
231
|
-
if (
|
|
241
|
+
if (successfullyProcessed) {
|
|
232
242
|
const newUri = texture.getURI();
|
|
233
243
|
if (originalUri && originalUri != newUri) {
|
|
234
244
|
const inDirectory = dirname(context.file);
|
|
@@ -10,6 +10,6 @@ export declare class NeedleWebPContext implements INeedleTextureTransformContext
|
|
|
10
10
|
private compressed;
|
|
11
11
|
constructor(options: NeedleWebPOptions);
|
|
12
12
|
prepare(document: Document): Promise<void>;
|
|
13
|
-
process(index: number, texture: Texture, settings: Pick<NEEDLE_compression_texture_schema, "quality"> & Partial<sharp.WebpOptions>, context: NeedleTransformContext): Promise<boolean>;
|
|
13
|
+
process(index: number, texture: Texture, settings: Pick<NEEDLE_compression_texture_schema, "quality" | "slot"> & Partial<sharp.WebpOptions>, context: NeedleTransformContext): Promise<boolean>;
|
|
14
14
|
finalize(document: Document): Promise<void>;
|
|
15
15
|
}
|
|
@@ -35,7 +35,7 @@ export class NeedleWebPContext {
|
|
|
35
35
|
options.quality = undefined; // If quality is 0 we use the default value
|
|
36
36
|
}
|
|
37
37
|
// console.log(options);
|
|
38
|
-
this.logger.info(
|
|
38
|
+
this.logger.info(`webp:texture[${index}] ${texture.getName()}: Slots → [${settings.slot}] with quality '${options.quality === undefined ? 'default' : options.quality}'`);
|
|
39
39
|
const buffer = await sharp(texture.getImage()).toFormat('webp', options).toBuffer();
|
|
40
40
|
texture
|
|
41
41
|
.setMimeType('image/webp')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.9.
|
|
1
|
+
export declare const version = "2.9.4";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.9.
|
|
1
|
+
export const version = "2.9.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
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",
|