@needle-tools/gltf-build-pipeline 2.13.0-next.8c4b2db → 2.14.0-alpha
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,7 +4,10 @@ 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.
|
|
7
|
+
## [2.14.0-alpha] - 2025-12-08
|
|
8
|
+
- add: KHR_materials_pbrSpecularGlossiness extension support
|
|
9
|
+
|
|
10
|
+
## [2.13.0] - 2025-10-20
|
|
8
11
|
- Use xxhash-wasm for buffer hashing
|
|
9
12
|
|
|
10
13
|
## [2.12.0] - 2025-09-13
|
|
@@ -4,7 +4,7 @@ import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
|
|
|
4
4
|
import draco3d from 'draco3dgltf';
|
|
5
5
|
import { existsSync, readFileSync, statSync, writeFileSync } from 'fs';
|
|
6
6
|
import { MeshoptDecoder, MeshoptEncoder } from 'meshoptimizer';
|
|
7
|
-
import { dedup, prune, resample } from '@gltf-transform/functions';
|
|
7
|
+
import { dedup, metalRough, prune, resample } from '@gltf-transform/functions';
|
|
8
8
|
import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS, NEEDLE_compression_texture, NEEDLE_mesh_compression, } from '../extensions/index.js';
|
|
9
9
|
import { isLOD, isMeshLOD, needle_animation_transform, needle_asset, needle_mesh_transform, needle_texture_transform, } from '../transforms/index.js';
|
|
10
10
|
import { getOutputPath, getVersion, ioTryReadWithMissingResources, writeNodeIO } from "../utils/index.js";
|
|
@@ -70,6 +70,7 @@ export async function packGLTF(inputFile, outputFile, options) {
|
|
|
70
70
|
/** @type {Array<import('@gltf-transform/core').Transform>} */
|
|
71
71
|
const transforms = [
|
|
72
72
|
needle_asset(),
|
|
73
|
+
metalRough(),
|
|
73
74
|
needle_texture_transform({
|
|
74
75
|
file: inputFile,
|
|
75
76
|
outfile: outputFile,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BufferUtils, Document, NodeIO, PropertyType, TextureChannel, Verbosity } from '@gltf-transform/core';
|
|
2
|
-
import { SIMPLIFY_DEFAULTS, WELD_DEFAULTS, listTextureChannels, listTextureSlots, sparse } from '@gltf-transform/functions';
|
|
2
|
+
import { SIMPLIFY_DEFAULTS, WELD_DEFAULTS, listTextureChannels, listTextureSlots, metalRough, sparse } from '@gltf-transform/functions';
|
|
3
|
+
import { KHRMaterialsSpecular } from '@gltf-transform/extensions';
|
|
3
4
|
import draco3d from 'draco3dgltf';
|
|
4
5
|
import { NEEDLE_PROGRESSIVE_EXTENSION_NAME, NEEDLE_progressive } from "../extensions/NEEDLE_progressive/index.js";
|
|
5
6
|
import { createOpaqueExtension, currentGenerator, NEEDLE_compression_texture, NEEDLE_mesh_compression, NEEDLE_progressive_mesh_settings, NEEDLE_progressive_texture_settings, registerExtensions as registerDefaultExtensions } from '../extensions/index.js';
|
|
@@ -87,6 +88,16 @@ async function onProcess(file, opts) {
|
|
|
87
88
|
const transforms = [
|
|
88
89
|
needle_asset(),
|
|
89
90
|
];
|
|
91
|
+
const json = await io.readAsJSON(file);
|
|
92
|
+
if (json.json.extensionsUsed?.includes("KHR_materials_pbrSpecularGlossiness")) {
|
|
93
|
+
// TODO: transforming the document here but we still get specularRoughness textures in subsequent code
|
|
94
|
+
// Test asset: https://github.com/KhronosGroup/glTF-Sample-Models/blob/main/2.0/SpecGlossVsMetalRough/glTF-Binary/SpecGlossVsMetalRough.glb
|
|
95
|
+
logger.warn("Converting KHR_materials_pbrSpecularGlossiness to metal/rough workflow...");
|
|
96
|
+
await document.transform(metalRough());
|
|
97
|
+
// await new Promise(resolve => setTimeout(resolve, 1000));
|
|
98
|
+
// await io.write(file, document);
|
|
99
|
+
// return onProcess(file, opts);
|
|
100
|
+
}
|
|
90
101
|
if (opts.config?.textures?.lods !== false) {
|
|
91
102
|
transforms.push(make_progressive_textures(file, { size: [smallesTextureSize, smallesTextureSize] }, opts));
|
|
92
103
|
}
|
|
@@ -97,6 +108,7 @@ async function onProcess(file, opts) {
|
|
|
97
108
|
}
|
|
98
109
|
else if (isVRM)
|
|
99
110
|
logger.warn("WARN: Progressive meshes are not supported for VRM files yet");
|
|
111
|
+
transforms.push(metalRough());
|
|
100
112
|
transforms.push(sparse());
|
|
101
113
|
logger.info("→ Transforming: " + file);
|
|
102
114
|
await document.transform(...transforms);
|
|
@@ -268,14 +280,18 @@ export function make_progressive_textures(filePath, _options = TEXTURE_RESIZE_DE
|
|
|
268
280
|
continue;
|
|
269
281
|
}
|
|
270
282
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
283
|
+
// If any texture LOD was generated we can resize the texture here
|
|
284
|
+
// E.g. for specular/glossiness textures we might not generate any LODs and then we don't want to downsize the texture
|
|
285
|
+
if (results?.length) {
|
|
286
|
+
options.size[0] = settings.maxSize;
|
|
287
|
+
options.size[1] = settings.maxSize;
|
|
288
|
+
logger.debug(`[${NAME}] Resizing embedded texture[${index}] to ${options.size[0]}x${options.size[1]}`);
|
|
289
|
+
await resizeTexture(options, texture, logger, uri || name, slots);
|
|
290
|
+
if (opts?.useCache === false) {
|
|
291
|
+
}
|
|
292
|
+
else
|
|
293
|
+
addToCache(cacheKey, texture.getImage());
|
|
276
294
|
}
|
|
277
|
-
else
|
|
278
|
-
addToCache(cacheKey, texture.getImage());
|
|
279
295
|
}
|
|
280
296
|
logger.debug(`Progressive transform finished in ${((Date.now() - startTime) / 1000).toFixed(1)} sec.`);
|
|
281
297
|
});
|
|
@@ -346,7 +362,23 @@ async function createTextureLod(args, opts) {
|
|
|
346
362
|
newMaterial.setBaseColorTexture(newTexture);
|
|
347
363
|
continue;
|
|
348
364
|
}
|
|
349
|
-
|
|
365
|
+
if (slot === "specularColorTexture") {
|
|
366
|
+
logger.info("Pass-through KHR_materials_pbrSpecularGlossiness specularColorTexture");
|
|
367
|
+
const ext = newDoc.createExtension(KHRMaterialsSpecular);
|
|
368
|
+
const prob = ext.createSpecular();
|
|
369
|
+
prob.setSpecularColorTexture(newTexture);
|
|
370
|
+
newMaterial.setExtension(KHRMaterialsSpecular.EXTENSION_NAME, prob);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
else if (slot === "specularTexture") {
|
|
374
|
+
logger.info("Pass-through KHR_materials_specular specularTexture");
|
|
375
|
+
const ext = newDoc.createExtension(KHRMaterialsSpecular);
|
|
376
|
+
const prob = ext.createSpecular();
|
|
377
|
+
prob.setSpecularTexture(newTexture);
|
|
378
|
+
newMaterial.setExtension(KHRMaterialsSpecular.EXTENSION_NAME, prob);
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
logger.warn(`WARN: Unknown texture slot: ${slot} for texture ${textureIndex} → can not load progressively (all slots: ${slots.join(", ")})`);
|
|
350
382
|
return null;
|
|
351
383
|
}
|
|
352
384
|
// Make sure the material is used
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.14.0-alpha";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.
|
|
1
|
+
export const version = "2.14.0-alpha";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0-alpha",
|
|
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",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"start": "node scripts/index.mjs",
|
|
26
26
|
"dev": "npm-watch compile",
|
|
27
27
|
"publish-package": "npm run compile && npm publish",
|
|
28
|
-
"postinstall": "node tools/prebuild.mjs",
|
|
29
28
|
"prepublishOnly": "npm run compile",
|
|
30
29
|
"compile": "node tools/prebuild.mjs && (tsc || exit 1) && node tools/postbuild.mjs",
|
|
31
30
|
"clear-caches": "node scripts/clear-caches.mjs",
|