@needle-tools/gltf-build-pipeline 1.4.10 → 1.5.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 +8 -0
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +1 -0
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +48 -6
- package/dist/extensions/NEEDLE_opaque/index.js +1 -0
- package/dist/transforms/needle_progressive.js +3 -2
- package/dist/utils/fileutils.js +5 -1
- package/make-progressive.mjs +2 -2
- package/pack-gltf.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ 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
|
+
## [1.5.0-alpha] - 2023-05-01
|
|
8
|
+
- add: NEEDLE_opaque `node: <index>` retargeting
|
|
9
|
+
- add: passthrough VRM extension
|
|
10
|
+
|
|
11
|
+
## [1.4.11] - 2023-04-29
|
|
12
|
+
- add: NEEDLE_progressive mesh now run sparse transform
|
|
13
|
+
- change: cli params for debug and caching are now `--debug` and `--no-caching`
|
|
14
|
+
|
|
7
15
|
## [1.4.10] - 2023-04-23
|
|
8
16
|
- add: NEEDLE_progressive can now load and process already draco compressed meshes
|
|
9
17
|
|
|
@@ -19,6 +19,8 @@ export function createOpaqueExtension(name, types, opts) {
|
|
|
19
19
|
// private roots: Array<OpaqueProperty> = [];
|
|
20
20
|
jsonPointerHandler;
|
|
21
21
|
read(context) {
|
|
22
|
+
if (opts.breakpoint === true)
|
|
23
|
+
debugger;
|
|
22
24
|
currentGenerator = context.jsonDoc.json.asset?.generator;
|
|
23
25
|
if (debugLog)
|
|
24
26
|
console.log("READ " + EXTENSION_NAME);
|
|
@@ -222,6 +224,8 @@ export function createOpaqueExtension(name, types, opts) {
|
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
226
|
write(context) {
|
|
227
|
+
if (opts.breakpoint === true)
|
|
228
|
+
debugger;
|
|
225
229
|
if (opts?.write === false) {
|
|
226
230
|
return this;
|
|
227
231
|
}
|
|
@@ -276,6 +280,8 @@ export function createOpaqueExtension(name, types, opts) {
|
|
|
276
280
|
if (prop instanceof OpaqueProperty) {
|
|
277
281
|
prop.onWrite(context, root);
|
|
278
282
|
}
|
|
283
|
+
else if (debugLog)
|
|
284
|
+
console.warn("WARN: no extension found on root", EXTENSION_NAME);
|
|
279
285
|
break;
|
|
280
286
|
}
|
|
281
287
|
}
|
|
@@ -552,7 +558,7 @@ class JsonPointerHandler {
|
|
|
552
558
|
if (object) {
|
|
553
559
|
const res = new TexturePointerResolver(this.document, object, definition);
|
|
554
560
|
res.init(context); // < init here otherwise the fields defined in the TexturePointer will be undefined (this caused e.g. finding the previous texture filter to fail)
|
|
555
|
-
pointer = new JsonPointer(path, res);
|
|
561
|
+
pointer = new JsonPointer(path, res, value);
|
|
556
562
|
pointer.debug = this.debug;
|
|
557
563
|
this.map.set(value, pointer);
|
|
558
564
|
}
|
|
@@ -585,7 +591,7 @@ class JsonPointerHandler {
|
|
|
585
591
|
const definition = context.jsonDoc.json.materials[index];
|
|
586
592
|
const res = new MaterialPointerResolver(this.document, mat, definition);
|
|
587
593
|
res.init(context); // < init here otherwise the fields defined in the TexturePointer will be undefined (this caused e.g. finding the previous texture filter to fail)
|
|
588
|
-
pointer = new JsonPointer("/materials/", res);
|
|
594
|
+
pointer = new JsonPointer("/materials/", res, value);
|
|
589
595
|
pointer.debug = this.debug;
|
|
590
596
|
this.map.set(value, pointer);
|
|
591
597
|
}
|
|
@@ -594,6 +600,23 @@ class JsonPointerHandler {
|
|
|
594
600
|
}
|
|
595
601
|
}
|
|
596
602
|
break;
|
|
603
|
+
case 'number':
|
|
604
|
+
if (key === "node") {
|
|
605
|
+
const object = context.nodes[value];
|
|
606
|
+
if (object) {
|
|
607
|
+
const res = new NodeIndexResolver(this.document, object, context.jsonDoc.json.nodes[value]);
|
|
608
|
+
res.init(context);
|
|
609
|
+
const dictKey = "/nodes/" + value;
|
|
610
|
+
let pointer = this.map.get(dictKey);
|
|
611
|
+
if (!pointer) {
|
|
612
|
+
pointer = new JsonPointer(null, res, value);
|
|
613
|
+
}
|
|
614
|
+
pointer.debug = this.debug;
|
|
615
|
+
pointer.register(obj, key);
|
|
616
|
+
this.map.set(dictKey, pointer);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
break;
|
|
597
620
|
}
|
|
598
621
|
}
|
|
599
622
|
resolveAndWrite(context) {
|
|
@@ -607,9 +630,11 @@ class JsonPointer {
|
|
|
607
630
|
debug = false;
|
|
608
631
|
resolver;
|
|
609
632
|
pointerBase;
|
|
610
|
-
|
|
633
|
+
oldPointer;
|
|
634
|
+
constructor(pointerBase, resolver, oldPointer) {
|
|
611
635
|
this.pointerBase = pointerBase;
|
|
612
636
|
this.resolver = resolver;
|
|
637
|
+
this.oldPointer = oldPointer;
|
|
613
638
|
}
|
|
614
639
|
_objects = [];
|
|
615
640
|
_props = [];
|
|
@@ -622,9 +647,19 @@ class JsonPointer {
|
|
|
622
647
|
//@ts-ignore
|
|
623
648
|
this.resolver.debug = this.debug;
|
|
624
649
|
const index = this.resolver.resolve(context);
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
650
|
+
if (index != undefined) {
|
|
651
|
+
if (this.pointerBase != null) {
|
|
652
|
+
this.newPointer = this.pointerBase + index;
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
this.newPointer = index;
|
|
656
|
+
}
|
|
657
|
+
if (this.debug)
|
|
658
|
+
console.log(`RESOLVED ${this.oldPointer} to → ${this.newPointer}`);
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
console.log("ERR: failed to resolve pointer", this.pointerBase);
|
|
662
|
+
}
|
|
628
663
|
}
|
|
629
664
|
write() {
|
|
630
665
|
for (let i = 0; i < this._objects.length; i++) {
|
|
@@ -746,3 +781,10 @@ class MaterialPointerResolver extends PointerResolver {
|
|
|
746
781
|
return context.materialIndexMap.get(this.inputObject);
|
|
747
782
|
}
|
|
748
783
|
}
|
|
784
|
+
class NodeIndexResolver extends PointerResolver {
|
|
785
|
+
init(context) {
|
|
786
|
+
}
|
|
787
|
+
resolve(context) {
|
|
788
|
+
return context.nodeIndexMap.get(this.inputObject);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
@@ -17,4 +17,5 @@ export const ALL_EXTENSIONS = [
|
|
|
17
17
|
createOpaqueExtension("EXT_texture_exr", [PropertyType.TEXTURE], { ...opaqueOptions }),
|
|
18
18
|
createOpaqueExtension("NEEDLE_editor", [PropertyType.NODE, PropertyType.MATERIAL], { ...opaqueOptions }),
|
|
19
19
|
createOpaqueExtension("NEEDLE_gltf_dependencies", [PropertyType.ROOT], { ...opaqueOptions }),
|
|
20
|
+
createOpaqueExtension("VRM", [PropertyType.ROOT], { ...opaqueOptions }),
|
|
20
21
|
];
|
|
@@ -21,7 +21,7 @@ export async function make_progressive(opts) {
|
|
|
21
21
|
console.log(`Progressive Transform: Ignore existing LOD file at ${f}`);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
await
|
|
24
|
+
await onProcess(f, opts);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
function registerExtensions(io) {
|
|
@@ -37,7 +37,7 @@ function registerExtensions(io) {
|
|
|
37
37
|
// createOpaqueExtension(NEEDLE_mesh_compression.EXTENSION_NAME, [PropertyType.ROOT, PropertyType.MESH, PropertyType.PRIMITIVE]),
|
|
38
38
|
]);
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
40
|
+
async function onProcess(file, opts) {
|
|
41
41
|
if (!file.endsWith(".glb") && !file.endsWith(".gltf")) {
|
|
42
42
|
console.log("ERR: file is not gltf/glb");
|
|
43
43
|
return;
|
|
@@ -722,6 +722,7 @@ async function createMeshLod(doc, basePath, level, mesh, meshInfo, guid, lodLeve
|
|
|
722
722
|
console.log(`[${NAME}] Pass compression format to mesh LOD ${level} → ${JSON.stringify(compressionExt.model)}`);
|
|
723
723
|
newDoc.getRoot().setExtension(NEEDLE_mesh_compression.EXTENSION_NAME, newProp);
|
|
724
724
|
}
|
|
725
|
+
await newDoc.transform(sparse());
|
|
725
726
|
const newIo = new NodeIO();
|
|
726
727
|
registerExtensions(newIo);
|
|
727
728
|
console.log(`[${NAME}] Write mesh LOD ${level} with to \"${fileName}\"`);
|
package/dist/utils/fileutils.js
CHANGED
|
@@ -48,6 +48,10 @@ export async function foreachGLTF(args, callback) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async function testEntry(entry, callback, context) {
|
|
51
|
+
// ignore argument names (e.g. --debug)
|
|
52
|
+
if (entry.startsWith("--")) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
51
55
|
if (entry === "." || entry === "./") {
|
|
52
56
|
if (context.baseDirectory) {
|
|
53
57
|
entry = context.baseDirectory;
|
|
@@ -62,7 +66,7 @@ async function testEntry(entry, callback, context) {
|
|
|
62
66
|
// Try resolve potential relative path
|
|
63
67
|
const newPath = context.baseDirectory + "/" + entry;
|
|
64
68
|
if (existsSync(newPath) === false) {
|
|
65
|
-
console.log(`INFO: Resolved path failed: ${entry} -> ${newPath} (doesnt exist or is locked by another process)`);
|
|
69
|
+
console.log(`INFO: Resolved path failed: \"${entry}\" -> ${newPath} (doesnt exist or is locked by another process)`);
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
else {
|
package/make-progressive.mjs
CHANGED
|
@@ -7,8 +7,8 @@ console.log(`[Needle Build Pipeline] transform to progressive — version ${getV
|
|
|
7
7
|
|
|
8
8
|
make_progressive({
|
|
9
9
|
path: args,
|
|
10
|
-
debug: args.includes("debug"),
|
|
11
|
-
useCache: args.includes("no-caching") === false,
|
|
10
|
+
debug: args.includes("--debug"),
|
|
11
|
+
useCache: args.includes("--no-caching") === false,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
|
package/pack-gltf.mjs
CHANGED
|
@@ -58,12 +58,12 @@ if (debug) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
let allowCaching = true;
|
|
61
|
-
if (args.includes("no-caching")) {
|
|
61
|
+
if (args.includes("--no-caching")) {
|
|
62
62
|
console.log("Caching is disabled")
|
|
63
63
|
allowCaching = false;
|
|
64
64
|
}
|
|
65
65
|
else if (showHelp)
|
|
66
|
-
console.log("Caching is enabled, use \"no-caching\" to disable it");
|
|
66
|
+
console.log("Caching is enabled, use \"--no-caching\" to disable it");
|
|
67
67
|
|
|
68
68
|
const noToktx = args.includes("no-toktx");
|
|
69
69
|
if (noToktx)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-alpha",
|
|
4
4
|
"description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"type": "module",
|