@needle-tools/gltf-build-pipeline 1.5.0-alpha.1 → 1.5.0-alpha.2
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 +4 -0
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +21 -6
- package/dist/transforms/needle_progressive.js +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/nodeio.d.ts +5 -0
- package/dist/utils/nodeio.js +17 -0
- package/pack-gltf.mjs +3 -1
- package/package.json +1 -1
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.2] - 2023-05-03
|
|
8
|
+
- fix: VRM format should be saved as GLB. See https://github.com/donmccurdy/glTF-Transform/issues/1390
|
|
9
|
+
- fix: VRM texture index handling
|
|
10
|
+
|
|
7
11
|
## [1.5.0-alpha] - 2023-05-01
|
|
8
12
|
- add: NEEDLE_opaque `node: <index>` retargeting
|
|
9
13
|
- add: passthrough VRM extension
|
|
@@ -556,7 +556,7 @@ class JsonPointerHandler {
|
|
|
556
556
|
console.log("Texture index", index, imageIndex, context.jsonDoc.json.textures.length, "Textures:" + context.textures.length);
|
|
557
557
|
const object = tryGetInArray(context.textures, imageIndex);
|
|
558
558
|
if (object) {
|
|
559
|
-
const res = new
|
|
559
|
+
const res = new TextureIndexResolver(this.document, object, definition);
|
|
560
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)
|
|
561
561
|
pointer = new JsonPointer(path, res, value);
|
|
562
562
|
pointer.debug = this.debug;
|
|
@@ -589,7 +589,7 @@ class JsonPointerHandler {
|
|
|
589
589
|
let pointer = this.map.get(value);
|
|
590
590
|
if (!pointer) {
|
|
591
591
|
const definition = context.jsonDoc.json.materials[index];
|
|
592
|
-
const res = new
|
|
592
|
+
const res = new MaterialIndexResolver(this.document, mat, definition);
|
|
593
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)
|
|
594
594
|
pointer = new JsonPointer("/materials/", res, value);
|
|
595
595
|
pointer.debug = this.debug;
|
|
@@ -601,12 +601,27 @@ class JsonPointerHandler {
|
|
|
601
601
|
}
|
|
602
602
|
break;
|
|
603
603
|
case 'number':
|
|
604
|
-
if (key === "node") {
|
|
604
|
+
if (key === "node" || key === "mesh") {
|
|
605
605
|
const object = context.nodes[value];
|
|
606
606
|
if (object) {
|
|
607
607
|
const res = new NodeIndexResolver(this.document, object, context.jsonDoc.json.nodes[value]);
|
|
608
608
|
res.init(context);
|
|
609
|
-
const dictKey =
|
|
609
|
+
const dictKey = `/${key}/${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
|
+
else if (fullPath.match(/materialProperties\/\d+?\/textureProperties/g)) {
|
|
620
|
+
const object = context.textures[value];
|
|
621
|
+
if (object) {
|
|
622
|
+
const res = new TextureIndexResolver(this.document, object, context.jsonDoc.json.textures[value]);
|
|
623
|
+
res.init(context);
|
|
624
|
+
const dictKey = `/textures/${value}`;
|
|
610
625
|
let pointer = this.map.get(dictKey);
|
|
611
626
|
if (!pointer) {
|
|
612
627
|
pointer = new JsonPointer(null, res, value);
|
|
@@ -684,7 +699,7 @@ class PointerResolver {
|
|
|
684
699
|
}
|
|
685
700
|
debug = false;
|
|
686
701
|
}
|
|
687
|
-
class
|
|
702
|
+
class TextureIndexResolver extends PointerResolver {
|
|
688
703
|
_debugName;
|
|
689
704
|
_samplerDef;
|
|
690
705
|
init(context) {
|
|
@@ -774,7 +789,7 @@ function findSource(texDef) {
|
|
|
774
789
|
}
|
|
775
790
|
return undefined;
|
|
776
791
|
}
|
|
777
|
-
class
|
|
792
|
+
class MaterialIndexResolver extends PointerResolver {
|
|
778
793
|
init(context) {
|
|
779
794
|
}
|
|
780
795
|
resolve(context) {
|
|
@@ -7,7 +7,7 @@ import path, { basename } from 'path';
|
|
|
7
7
|
import { existsSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
|
|
8
8
|
import { addMetaToCache, addToCache, getHash, getKeyWithHash, tryGetFromCache, tryGetMetaFromCache } from '../cache/index.js';
|
|
9
9
|
import sharp from "sharp";
|
|
10
|
-
import { foreachGLTF, generateGuid } from '../utils/index.js';
|
|
10
|
+
import { foreachGLTF, generateGuid, writeNodeIO } from '../utils/index.js';
|
|
11
11
|
import { needle_asset, writeNeedleAsset } from './needle_asset.js';
|
|
12
12
|
import { MeshoptDecoder, MeshoptSimplifier } from 'meshoptimizer';
|
|
13
13
|
import { compressPrimitive } from './needle_mesh_transform.js';
|
|
@@ -81,7 +81,7 @@ async function onProcess(file, opts) {
|
|
|
81
81
|
// add new extension
|
|
82
82
|
filename = filename + ".debug." + extension;
|
|
83
83
|
}
|
|
84
|
-
io
|
|
84
|
+
await writeNodeIO(io, filename, document);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
catch (err) {
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { renameSync } from "fs";
|
|
2
|
+
/**
|
|
3
|
+
* Handle writing glTf, GLB and VRM files
|
|
4
|
+
*/
|
|
5
|
+
export async function writeNodeIO(nodeio, filename, document) {
|
|
6
|
+
let filename_write = filename;
|
|
7
|
+
// see https://github.com/donmccurdy/glTF-Transform/issues/1390
|
|
8
|
+
if (filename.endsWith(".vrm")) {
|
|
9
|
+
filename_write = filename_write.replace(".vrm", ".glb");
|
|
10
|
+
}
|
|
11
|
+
await nodeio.write(filename_write, document);
|
|
12
|
+
if (filename.endsWith(".vrm")) {
|
|
13
|
+
// rename the file to .vrm
|
|
14
|
+
renameSync(filename_write, filename);
|
|
15
|
+
}
|
|
16
|
+
return filename;
|
|
17
|
+
}
|
package/pack-gltf.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { foreachGLTF } from './fileutils.mjs';
|
|
|
13
13
|
import { needle_asset } from './dist/transforms/needle_asset.js';
|
|
14
14
|
import { MeshoptDecoder, MeshoptEncoder } from 'meshoptimizer';
|
|
15
15
|
import { getVersion, getHash, addToCache, tryGetFromCache, isLOD, ensureCacheSize as ensureMaxCacheSize, isMeshLOD } from './dist/index.js';
|
|
16
|
+
import { writeNodeIO } from './dist/utils/nodeio.js';
|
|
16
17
|
|
|
17
18
|
console.log(`[Needle Build Pipeline] pack glTF — version ${getVersion()}`)
|
|
18
19
|
|
|
@@ -139,7 +140,8 @@ async function packFile(file) {
|
|
|
139
140
|
// draco(),
|
|
140
141
|
);
|
|
141
142
|
if (debug) file += ".debug.glb";
|
|
142
|
-
|
|
143
|
+
|
|
144
|
+
await writeNodeIO(io, file, document);
|
|
143
145
|
|
|
144
146
|
if (allowCaching && cacheKey != undefined && existsSync(file))
|
|
145
147
|
addToCache(cacheKey, readFileSync(file));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "1.5.0-alpha.
|
|
3
|
+
"version": "1.5.0-alpha.2",
|
|
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",
|