@needle-tools/gltf-build-pipeline 2.7.0-alpha → 2.7.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,9 @@ 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.0-alpha.1] - 2024-01-13
8
+ - fix: handle LOD omitting and remove deleted files from progressive transform results list
9
+
7
10
  ## [2.7.0-alpha] - 2024-01-13
8
11
  - add: VRM mesh simplification support
9
12
  - fix: issue where the output directory was not created if it didn't exist yet
@@ -29,6 +29,19 @@ export async function make_progressive(opts) {
29
29
  if (!res)
30
30
  success = false;
31
31
  });
32
+ if (success) {
33
+ // Make sure all results exist
34
+ // It's possible that files were deleted while omitting LODs - we want to remove them from the results list
35
+ const resultsCount = opts.results.length;
36
+ for (let i = opts.results.length - 1; i >= 0; i--) {
37
+ if (!existsSync(opts.results[i])) {
38
+ opts.results.splice(i, 1);
39
+ }
40
+ }
41
+ const resultsChanged = resultsCount !== opts.results.length;
42
+ if (opts.debug)
43
+ console.log(`Progressive Transform: ${opts.results.length} files processed. ${resultsChanged ? "Some results were removed" : ""}`);
44
+ }
32
45
  return success;
33
46
  }
34
47
  function registerExtensions(io) {
@@ -661,7 +674,7 @@ export function make_progressive_meshes(filePath, _options, opts) {
661
674
  if (shouldOmitLevel) {
662
675
  logger.debug(`[${NAME}] Omitting LOD ${level} for \"${mesh.getName()}\" at \"${lodInfo.path}\"`);
663
676
  generatedLODInfos.splice(i, 1);
664
- rmSync(fullPath);
677
+ deleteFile(fullPath, opts);
665
678
  i--;
666
679
  }
667
680
  else {
@@ -699,7 +712,7 @@ export function make_progressive_meshes(filePath, _options, opts) {
699
712
  logger.info(`[${NAME}]: Flag mesh LOD ${generatedLODInfos.length} (embedded): vertex count difference below threshold (removed ${difference} vertices, ${(-diff01 * 100).toFixed(2)} %) → will remove all LODs. \"${mesh.getName()}\"`);
700
713
  try {
701
714
  for (const lodInfo of generatedLODInfos) {
702
- rmSync(outputDirectory + "/" + lodInfo.path);
715
+ deleteFile(outputDirectory + "/" + lodInfo.path, opts);
703
716
  }
704
717
  }
705
718
  catch (err) {
@@ -744,6 +757,9 @@ export function make_progressive_meshes(filePath, _options, opts) {
744
757
  }
745
758
  });
746
759
  }
760
+ function deleteFile(filePath, _context) {
761
+ rmSync(filePath);
762
+ }
747
763
  function clonePrimitiveData(prim, logger) {
748
764
  const semantics = prim.listSemantics();
749
765
  if (semantics.some(s => s.includes("JOINTS"))) {
@@ -1 +1 @@
1
- export declare const version = "2.7.0-alpha";
1
+ export declare const version = "2.7.0-alpha.1";
@@ -1 +1 @@
1
- export const version = "2.7.0-alpha";
1
+ export const version = "2.7.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.7.0-alpha",
3
+ "version": "2.7.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": "dist/index.js",
6
6
  "type": "module",