@needle-tools/gltf-build-pipeline 2.8.0-alpha.0 → 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.
|
@@ -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,9 +161,22 @@ 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
|
+
}
|
|
164
177
|
// For product compression we automatically select webP if the texture is used in a PBR material
|
|
165
178
|
// https://linear.app/needle/issue/NE-6458
|
|
166
|
-
if (context.config.usecase === "product") {
|
|
179
|
+
else if (context.config.usecase === "product") {
|
|
167
180
|
const shouldUseWebp = slots.includes("normalTexture") || slots.includes("metallicRoughnessTexture");
|
|
168
181
|
if (shouldUseWebp) {
|
|
169
182
|
mimeType = "image/webp";
|
|
@@ -186,8 +199,8 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
186
199
|
// if we ever change what is used for default compression we need to teach the cache to save the mime type
|
|
187
200
|
// For VRMs we use ETC1S always
|
|
188
201
|
let options = null;
|
|
189
|
-
if (isVRM) {
|
|
190
|
-
options = { mode: "ETC1S" };
|
|
202
|
+
if (ktx2Format || isVRM) {
|
|
203
|
+
options = { mode: ktx2Format || "ETC1S" };
|
|
191
204
|
}
|
|
192
205
|
successFullyProcessed = await context.toktxContext.process(index, texture, options, context);
|
|
193
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.8.0-alpha.
|
|
1
|
+
export declare const version = "2.8.0-alpha.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.8.0-alpha.
|
|
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.8.0-alpha.
|
|
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",
|