@needle-tools/gltf-build-pipeline 1.4.11 → 1.5.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,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
|
+
## [1.5.0-alpha] - 2023-05-01
|
|
8
|
+
- add: NEEDLE_opaque `node: <index>` retargeting
|
|
9
|
+
- add: passthrough VRM extension
|
|
10
|
+
|
|
7
11
|
## [1.4.11] - 2023-04-29
|
|
8
12
|
- add: NEEDLE_progressive mesh now run sparse transform
|
|
9
13
|
- change: cli params for debug and caching are now `--debug` and `--no-caching`
|
|
@@ -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
|
];
|
package/dist/utils/fileutils.js
CHANGED
|
@@ -89,7 +89,7 @@ async function testEntry(entry, callback, context) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
if (entry.endsWith(".glb") || entry.endsWith(".gltf")) {
|
|
92
|
+
if (entry.endsWith(".glb") || entry.endsWith(".gltf") || entry.endsWith(".vrm")) {
|
|
93
93
|
context.filesFound += 1;
|
|
94
94
|
const res = callback(entry);
|
|
95
95
|
if (res instanceof Promise) {
|
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.1",
|
|
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",
|