@needle-tools/gltf-build-pipeline 2.7.1 → 2.8.0-alpha.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.8.0-alpha.0] - 2024-02-27
|
|
8
|
+
- change: `product` usecase now uses webp compression for 'normalTexture' and 'metallicRoughnessTexture' textures
|
|
9
|
+
|
|
7
10
|
## [2.7.1] - 2024-02-14
|
|
8
11
|
- fix: bug in caching path due to change in 2.7.0-alpha.2
|
|
9
12
|
|
|
@@ -97,8 +97,11 @@ 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 (ext?.model?.mode === "none")
|
|
100
|
+
if (ext?.model?.mode === "none") {
|
|
101
|
+
logger.info(`→ Skipping texture compression for ${texture.getName()} [${index}] as configured in the texture extension`);
|
|
101
102
|
return;
|
|
103
|
+
}
|
|
104
|
+
// generate the cache key from the file data and settings
|
|
102
105
|
const key = context.useCache ? (getKey(texture) + getHash(context.config)) : undefined;
|
|
103
106
|
let cached = context.useCache && key ? tryGetFromCache(key) : undefined;
|
|
104
107
|
if (cached) {
|
|
@@ -143,13 +146,10 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
143
146
|
}
|
|
144
147
|
else {
|
|
145
148
|
let mimeType = "image/ktx2";
|
|
149
|
+
let ktx2Format = undefined;
|
|
146
150
|
const slots = listTextureSlots(texture);
|
|
147
|
-
|
|
148
|
-
// mimeType = "image/webp";
|
|
151
|
+
const size = texture.getSize();
|
|
149
152
|
const isVRM = context.file?.toLowerCase().endsWith(".vrm");
|
|
150
|
-
if (slots.includes("lightmapTexture") || isLightmap(texture)) {
|
|
151
|
-
mimeType = "image/webp";
|
|
152
|
-
}
|
|
153
153
|
// TODO: need to make this into a function
|
|
154
154
|
// const webpThreshold = 256; // this is the default threshold in progressive textures (needle_progressive.ts)
|
|
155
155
|
// console.log(context.file, isVRM);
|
|
@@ -161,6 +161,27 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
161
161
|
// mimetype = "image/webp";
|
|
162
162
|
// }
|
|
163
163
|
// }
|
|
164
|
+
if (slots.includes("lightmapTexture") || isLightmap(texture)) {
|
|
165
|
+
mimeType = "image/webp";
|
|
166
|
+
}
|
|
167
|
+
// for https://linear.app/needle/issue/NE-6464
|
|
168
|
+
else if (size[0] <= 32 || size[1] <= 32) {
|
|
169
|
+
if (canRunToktx) {
|
|
170
|
+
mimeType = "image/ktx2";
|
|
171
|
+
ktx2Format = "UASTC";
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
mimeType = "image/webp";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// For product compression we automatically select webP if the texture is used in a PBR material
|
|
178
|
+
// https://linear.app/needle/issue/NE-6458
|
|
179
|
+
else if (context.config.usecase === "product") {
|
|
180
|
+
const shouldUseWebp = slots.includes("normalTexture") || slots.includes("metallicRoughnessTexture");
|
|
181
|
+
if (shouldUseWebp) {
|
|
182
|
+
mimeType = "image/webp";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
164
185
|
// If we have a texture cached we can use it
|
|
165
186
|
// the default compression is toktx so we can safely use that for now
|
|
166
187
|
if (cached) {
|
|
@@ -178,8 +199,8 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
178
199
|
// if we ever change what is used for default compression we need to teach the cache to save the mime type
|
|
179
200
|
// For VRMs we use ETC1S always
|
|
180
201
|
let options = null;
|
|
181
|
-
if (isVRM) {
|
|
182
|
-
options = { mode: "ETC1S" };
|
|
202
|
+
if (ktx2Format || isVRM) {
|
|
203
|
+
options = { mode: ktx2Format || "ETC1S" };
|
|
183
204
|
}
|
|
184
205
|
successFullyProcessed = await context.toktxContext.process(index, texture, options, context);
|
|
185
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.8.0-alpha.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.
|
|
1
|
+
export const version = "2.8.0-alpha.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0-alpha.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",
|