@needle-tools/gltf-build-pipeline 2.9.5 → 2.10.0-next.8757b68

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.
@@ -519,15 +519,15 @@ class TextureHandler {
519
519
  // return new TexturePointerPointerProperty(doc.getGraph());
520
520
  // }
521
521
  class JsonPointerHandler {
522
- id;
522
+ extension_name;
523
523
  document;
524
524
  map = new Map();
525
525
  debug = false;
526
526
  breakPoint = false;
527
527
  VRM_0_MaterialIndexRegex = new RegExp(/materialProperties\/(?<material_index>\d+)\//g);
528
- constructor(document, id) {
528
+ constructor(document, extension_name) {
529
529
  this.document = document;
530
- this.id = id;
530
+ this.extension_name = extension_name;
531
531
  }
532
532
  read(context, extProp, obj, prop, key, fullPath) {
533
533
  const value = key !== undefined ? obj[key] : obj;
@@ -543,8 +543,15 @@ class JsonPointerHandler {
543
543
  switch (typeof value) {
544
544
  case 'object':
545
545
  if (value !== null && value !== undefined) {
546
- for (const key of Object.keys(value)) {
547
- this.read(context, extProp, value, prop, key, fullPath);
546
+ if (Array.isArray(value)) {
547
+ for (let i = 0; i < value.length; i++) {
548
+ this.read(context, extProp, value, prop, i.toString(), fullPath);
549
+ }
550
+ }
551
+ else {
552
+ for (const key of Object.keys(value)) {
553
+ this.read(context, extProp, value, prop, key, fullPath);
554
+ }
548
555
  }
549
556
  }
550
557
  break;
@@ -593,7 +600,7 @@ class JsonPointerHandler {
593
600
  }
594
601
  if (pointer) {
595
602
  if (this.debug)
596
- console.log("> Register pointer", this.id + "/" + fullPath + " : " + value);
603
+ console.log("> Register pointer", this.extension_name + "/" + fullPath + " : " + value);
597
604
  pointer?.register(obj, key, fullPath);
598
605
  }
599
606
  else
@@ -694,7 +701,9 @@ class JsonPointerHandler {
694
701
  // VRM 0.0 material properties
695
702
  || fullPath.match(/materialProperties\/(?<material_index>\d+)\/textureProperties/g)
696
703
  // VRM 1.0 meta
697
- || fullPath.match(/meta\/thumbnailImage/g)) {
704
+ || fullPath.match(/meta\/thumbnailImage/g)
705
+ // NEEDLE_materials_mtlx where the root extension has { textures: [0, 1, 2, ...] }
706
+ || fullPath.match(/^\/textures\/\d{1,}/)) {
698
707
  const index = value;
699
708
  // e.g. in meta.texture for VRM avatars it seems like we can have negative values
700
709
  if (index < 0) {
@@ -17,6 +17,8 @@ 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
+ // MaterialX
21
+ createOpaqueExtension("NEEDLE_materials_mtlx", [PropertyType.ROOT, PropertyType.MATERIAL], { ...opaqueOptions }),
20
22
  // VRM 0.0
21
23
  createOpaqueExtension("VRM", [PropertyType.ROOT], { ...opaqueOptions }),
22
24
  // VRM 1.0 https://vrm.dev/en/vrm1/changed/
@@ -87,14 +87,22 @@ export async function packGLTF(inputFile, outputFile, options) {
87
87
  // Can not dedup "materials" because progressive textures will then assigned to the wrong material instance
88
88
  // HACK: keepUniqueNames is enabled to fix https://linear.app/needle/issue/NE-6288
89
89
  dedup({ propertyTypes: [PropertyType.MESH, PropertyType.MATERIAL] }),
90
- // prune(),
91
90
  ];
92
91
  const isProgressiveAsset = isLOD(inputFile);
93
92
  // TODO: progressive mesh LODs should not be pruned right now because it will remove e.g. UVs from meshes (and probably blend shapes too) (so we just not do it for any progressive asset)
94
93
  if (!isProgressiveAsset) {
95
94
  transforms.push(prune({
96
95
  // Pruning animations is not supported yet (e.g. if the animation is only referenced by a component)
97
- propertyTypes: ['MESH', 'MATERIAL', 'TEXTURE']
96
+ propertyTypes: [
97
+ PropertyType.MESH,
98
+ PropertyType.MATERIAL,
99
+ PropertyType.TEXTURE,
100
+ PropertyType.ACCESSOR,
101
+ PropertyType.BUFFER,
102
+ ],
103
+ keepAttributes: true,
104
+ keepExtras: true,
105
+ keepSolidTextures: true,
98
106
  }));
99
107
  }
100
108
  const isVRM = inputFile.toLowerCase().endsWith(".vrm");
@@ -1 +1 @@
1
- export declare const version = "2.9.5";
1
+ export declare const version = "2.10.0-next.8757b68";
@@ -1 +1 @@
1
- export const version = "2.9.5";
1
+ export const version = "2.10.0-next.8757b68";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.9.5",
3
+ "version": "2.10.0-next.8757b68",
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",
@@ -24,8 +24,8 @@
24
24
  "scripts": {
25
25
  "start": "node scripts/index.mjs",
26
26
  "dev": "npm-watch compile",
27
- "publish-package": "npm run compile && npm publish --access public --tag latest",
28
- "publish-package-tag": "npm dist-tag add @needle-tools/gltf-build-pipeline@2.7.0 latest",
27
+ "publish-package": "npm run compile && npm publish",
28
+ "prepublishOnly": "npm run compile",
29
29
  "compile": "node tools/prebuild.mjs && (tsc || exit 1) && node tools/postbuild.mjs",
30
30
  "clear-caches": "node scripts/clear-caches.mjs",
31
31
  "limit-caches": "node scripts/limit-caches.mjs",