@needle-tools/gltf-build-pipeline 1.6.0-alpha.3 → 1.6.0-alpha.5

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/package.json +66 -0
  3. package/dist/{cli → src/cli}/index.js +14 -3
  4. package/dist/src/constants.d.ts +5 -0
  5. package/dist/src/constants.js +5 -0
  6. package/dist/{index.d.ts → src/index.d.ts} +1 -0
  7. package/dist/{index.js → src/index.js} +1 -0
  8. package/dist/{transforms → src/transforms}/needle_progressive.js +1 -9
  9. package/dist/src/utils/version.d.ts +1 -0
  10. package/dist/src/utils/version.js +5 -0
  11. package/package.json +3 -3
  12. package/tsconfig.json +2 -1
  13. package/dist/utils/version.d.ts +0 -1
  14. package/dist/utils/version.js +0 -40
  15. /package/dist/{cache → src/cache}/cache.d.ts +0 -0
  16. /package/dist/{cache → src/cache}/cache.js +0 -0
  17. /package/dist/{cache → src/cache}/index.d.ts +0 -0
  18. /package/dist/{cache → src/cache}/index.js +0 -0
  19. /package/dist/{cli → src/cli}/index.d.ts +0 -0
  20. /package/dist/{config → src/config}/index.d.ts +0 -0
  21. /package/dist/{config → src/config}/index.js +0 -0
  22. /package/dist/{extensions → src/extensions}/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +0 -0
  23. /package/dist/{extensions → src/extensions}/NEEDLE_compression_texture/NEEDLE_compression_texture.js +0 -0
  24. /package/dist/{extensions → src/extensions}/NEEDLE_compression_texture/index.d.ts +0 -0
  25. /package/dist/{extensions → src/extensions}/NEEDLE_compression_texture/index.js +0 -0
  26. /package/dist/{extensions → src/extensions}/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +0 -0
  27. /package/dist/{extensions → src/extensions}/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +0 -0
  28. /package/dist/{extensions → src/extensions}/NEEDLE_mesh_compression/index.d.ts +0 -0
  29. /package/dist/{extensions → src/extensions}/NEEDLE_mesh_compression/index.js +0 -0
  30. /package/dist/{extensions → src/extensions}/NEEDLE_opaque/NEEDLE_opaque.d.ts +0 -0
  31. /package/dist/{extensions → src/extensions}/NEEDLE_opaque/NEEDLE_opaque.js +0 -0
  32. /package/dist/{extensions → src/extensions}/NEEDLE_opaque/index.d.ts +0 -0
  33. /package/dist/{extensions → src/extensions}/NEEDLE_opaque/index.js +0 -0
  34. /package/dist/{extensions → src/extensions}/NEEDLE_progressive/NEEDLE_progressive.d.ts +0 -0
  35. /package/dist/{extensions → src/extensions}/NEEDLE_progressive/NEEDLE_progressive.js +0 -0
  36. /package/dist/{extensions → src/extensions}/NEEDLE_progressive/index.d.ts +0 -0
  37. /package/dist/{extensions → src/extensions}/NEEDLE_progressive/index.js +0 -0
  38. /package/dist/{extensions → src/extensions}/NEEDLE_progressive_mesh_settings/index.d.ts +0 -0
  39. /package/dist/{extensions → src/extensions}/NEEDLE_progressive_mesh_settings/index.js +0 -0
  40. /package/dist/{extensions → src/extensions}/NEEDLE_progressive_texture_settings/index.d.ts +0 -0
  41. /package/dist/{extensions → src/extensions}/NEEDLE_progressive_texture_settings/index.js +0 -0
  42. /package/dist/{extensions → src/extensions}/index.d.ts +0 -0
  43. /package/dist/{extensions → src/extensions}/index.js +0 -0
  44. /package/dist/{extensions → src/extensions}/utils.d.ts +0 -0
  45. /package/dist/{extensions → src/extensions}/utils.js +0 -0
  46. /package/dist/{scripts → src/scripts}/index.d.ts +0 -0
  47. /package/dist/{scripts → src/scripts}/index.js +0 -0
  48. /package/dist/{scripts → src/scripts}/pack-gltf.d.ts +0 -0
  49. /package/dist/{scripts → src/scripts}/pack-gltf.js +0 -0
  50. /package/dist/{transforms → src/transforms}/index.d.ts +0 -0
  51. /package/dist/{transforms → src/transforms}/index.js +0 -0
  52. /package/dist/{transforms → src/transforms}/needle_animation_transform.d.ts +0 -0
  53. /package/dist/{transforms → src/transforms}/needle_animation_transform.js +0 -0
  54. /package/dist/{transforms → src/transforms}/needle_asset.d.ts +0 -0
  55. /package/dist/{transforms → src/transforms}/needle_asset.js +0 -0
  56. /package/dist/{transforms → src/transforms}/needle_common.d.ts +0 -0
  57. /package/dist/{transforms → src/transforms}/needle_common.js +0 -0
  58. /package/dist/{transforms → src/transforms}/needle_mesh_transform.d.ts +0 -0
  59. /package/dist/{transforms → src/transforms}/needle_mesh_transform.js +0 -0
  60. /package/dist/{transforms → src/transforms}/needle_progressive.d.ts +0 -0
  61. /package/dist/{transforms → src/transforms}/needle_texture_transform.d.ts +0 -0
  62. /package/dist/{transforms → src/transforms}/needle_texture_transform.js +0 -0
  63. /package/dist/{transforms → src/transforms}/needle_toktx.d.ts +0 -0
  64. /package/dist/{transforms → src/transforms}/needle_toktx.js +0 -0
  65. /package/dist/{transforms → src/transforms}/needle_webp.d.ts +0 -0
  66. /package/dist/{transforms → src/transforms}/needle_webp.js +0 -0
  67. /package/dist/{transforms → src/transforms}/toktx.d.ts +0 -0
  68. /package/dist/{transforms → src/transforms}/toktx.js +0 -0
  69. /package/dist/{transforms → src/transforms}/util.d.ts +0 -0
  70. /package/dist/{transforms → src/transforms}/util.js +0 -0
  71. /package/dist/{utils → src/utils}/compression_utils.d.ts +0 -0
  72. /package/dist/{utils → src/utils}/compression_utils.js +0 -0
  73. /package/dist/{utils → src/utils}/fileutils.d.ts +0 -0
  74. /package/dist/{utils → src/utils}/fileutils.js +0 -0
  75. /package/dist/{utils → src/utils}/guid.d.ts +0 -0
  76. /package/dist/{utils → src/utils}/guid.js +0 -0
  77. /package/dist/{utils → src/utils}/index.d.ts +0 -0
  78. /package/dist/{utils → src/utils}/index.js +0 -0
  79. /package/dist/{utils → src/utils}/mesh.d.ts +0 -0
  80. /package/dist/{utils → src/utils}/mesh.js +0 -0
  81. /package/dist/{utils → src/utils}/nodeio.d.ts +0 -0
  82. /package/dist/{utils → src/utils}/nodeio.js +0 -0
  83. /package/dist/{utils → src/utils}/stats.d.ts +0 -0
  84. /package/dist/{utils → src/utils}/stats.js +0 -0
package/CHANGELOG.md CHANGED
@@ -4,8 +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
- ## [1.6.0-alpha.3] - 2023-05-28
7
+ ## [1.6.0-alpha.5] - 2023-05-28
8
8
  - fix: determine build pipeline version
9
+ - change: throw error and exit process if packing or transform fails
9
10
 
10
11
  ## [1.6.0-alpha.2] - 2023-05-27
11
12
  - add: `gltf-build-pipeline` commandline support with `transform` and `compress` (pack-gltf) options.
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@needle-tools/gltf-build-pipeline",
3
+ "version": "1.6.0-alpha.5",
4
+ "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
+ "main": "index.mjs",
6
+ "type": "module",
7
+ "readme": "README.md",
8
+ "bin": {
9
+ "gltf-build-pipeline": "./dist/src/cli/index.js"
10
+ },
11
+ "scripts": {
12
+ "start": "node scripts/index.mjs",
13
+ "dev": "npm-watch compile",
14
+ "transform": "node scripts/index.mjs",
15
+ "transform:make-progressive": "node scripts/make-progressive.mjs",
16
+ "transform:pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
17
+ "pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
18
+ "dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs",
19
+ "clear-caches": "node scripts/clear-caches.mjs",
20
+ "limit-caches": "node scripts/limit-caches.mjs",
21
+ "compile": "tsc || exit 1"
22
+ },
23
+ "dependencies": {
24
+ "@donmccurdy/caporal": "~0.0.10",
25
+ "@gltf-transform/core": "^3.10.1",
26
+ "@gltf-transform/extensions": "^3.10.1",
27
+ "@gltf-transform/functions": "^3.10.1",
28
+ "command-exists": "^1.2.9",
29
+ "command-line-args": "^5.2.1",
30
+ "draco3dgltf": "^1.5.3",
31
+ "glob": "^7.2.0",
32
+ "meshoptimizer": "^0.18.1",
33
+ "micromatch": "^4.0.5",
34
+ "ndarray": "^1.0.19",
35
+ "ndarray-lanczos": "^0.3.0",
36
+ "ndarray-pixels": "^2.0.1",
37
+ "p-limit": "3.1.0",
38
+ "semver": "^7.3.7",
39
+ "sharp": "^0.32.6",
40
+ "tmp": "^0.2.1",
41
+ "uuid": "^9.0.1"
42
+ },
43
+ "watch": {
44
+ "compile": {
45
+ "patterns": [
46
+ "src"
47
+ ],
48
+ "extensions": "ts",
49
+ "quiet": false
50
+ }
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^18.7.23",
54
+ "npm-watch": "^0.11.0",
55
+ "typescript": "^4.9.5"
56
+ },
57
+ "author": {
58
+ "name": "Needle",
59
+ "email": "help@needle.tools",
60
+ "url": "https://needle.tools/"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/needle-tools/needle-gltf-extensions.git"
65
+ }
66
+ }
@@ -9,6 +9,7 @@ import { cacheSizeLimit, clearCache } from '../cache/cache.js';
9
9
  import { existsSync, statSync } from 'fs';
10
10
  import { foreachGLTF } from '../utils/fileutils.js';
11
11
  import { dirname } from 'path';
12
+ import { ERROR_CODES } from '../constants.js';
12
13
  // For testing / dev you can run `npm link` in the package directory
13
14
  // For removing the link run `npm rm --global @needle-tools/gltf-build-pipeline`
14
15
  program
@@ -77,7 +78,7 @@ Compress a single glTF file. The input file is compressed and written to the out
77
78
  const filename = file.replaceAll("\\", "/").split("/").pop();
78
79
  outputFile = options.output?.toString() + "/" + filename;
79
80
  }
80
- await packGLTF(file, outputFile, {
81
+ const res = await packGLTF(file, outputFile, {
81
82
  config,
82
83
  packedFiles: set,
83
84
  stats,
@@ -86,6 +87,9 @@ Compress a single glTF file. The input file is compressed and written to the out
86
87
  logger: logger,
87
88
  file_stats: file_stats,
88
89
  });
90
+ if (!res) {
91
+ process.exit(ERROR_CODES.PACKING_FAILED);
92
+ }
89
93
  });
90
94
  printStats(stats);
91
95
  console.log("Stats: ", options);
@@ -136,6 +140,9 @@ Each version will be compressed and written to the output directory.
136
140
  config,
137
141
  debug: false,
138
142
  useCache: true,
143
+ }).catch(err => {
144
+ logger.error(err);
145
+ process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
139
146
  });
140
147
  const opts = {
141
148
  config,
@@ -148,10 +155,14 @@ Each version will be compressed and written to the output directory.
148
155
  };
149
156
  for (const res of progressive_results) {
150
157
  logger.info("> Compress " + res);
151
- await packGLTF(res, res, opts);
158
+ if (!await packGLTF(res, res, opts)) {
159
+ process.exit(ERROR_CODES.PACKING_FAILED);
160
+ }
152
161
  }
153
162
  logger.info("> Compress " + file);
154
- await packGLTF(file, file, opts);
163
+ if (!await packGLTF(file, file, opts)) {
164
+ process.exit(ERROR_CODES.PACKING_FAILED);
165
+ }
155
166
  });
156
167
  printStats(stats);
157
168
  if (options.outputStats) {
@@ -0,0 +1,5 @@
1
+ export declare const ERROR_CODES: {
2
+ UNKNOWN_ERROR: number;
3
+ PACKING_FAILED: number;
4
+ PROGRESSIVE_FAILED: number;
5
+ };
@@ -0,0 +1,5 @@
1
+ export const ERROR_CODES = {
2
+ UNKNOWN_ERROR: 1,
3
+ PACKING_FAILED: 2,
4
+ PROGRESSIVE_FAILED: 3,
5
+ };
@@ -5,3 +5,4 @@ export * from "./transforms/index.js";
5
5
  export * from "./extensions/index.js";
6
6
  export * from "./cache/index.js";
7
7
  export * from "./scripts/index.js";
8
+ export * from "./constants.js";
@@ -5,3 +5,4 @@ export * from "./transforms/index.js";
5
5
  export * from "./extensions/index.js";
6
6
  export * from "./cache/index.js";
7
7
  export * from "./scripts/index.js";
8
+ export * from "./constants.js";
@@ -53,15 +53,7 @@ async function onProcess(file, opts) {
53
53
  'draco3d.decoder': await draco3d.createDecoderModule(),
54
54
  'draco3d.encoder': await draco3d.createEncoderModule(),
55
55
  });
56
- const document = await io.read(file).catch((err) => {
57
- // Log this message as a warning, it happens when trying to run on a already compressed gltf file (e.g. pre-processed. When logging an error we fail the build which is not desired)
58
- if (err.message === "Cannot read properties of undefined (reading 'DT_FLOAT32')") {
59
- console.log("WARN: \"" + err.message + "\" at \"" + file + "\"");
60
- }
61
- else
62
- console.log("ERR: \"" + err.message + "\" at \"" + file + "\"\nStacktrace:\n" + err.stack);
63
- return;
64
- });
56
+ let document = await io.read(file);
65
57
  if (document) {
66
58
  if (opts.debug === true) {
67
59
  if (file.includes(".debug.")) {
@@ -0,0 +1 @@
1
+ export declare function getVersion(_marklocal?: boolean): string;
@@ -0,0 +1,5 @@
1
+ import packageJson from "../../package.json" assert { type: "json" };
2
+ export function getVersion(_marklocal = true) {
3
+ let res = packageJson.version;
4
+ return res;
5
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "1.6.0-alpha.3",
3
+ "version": "1.6.0-alpha.5",
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",
7
7
  "readme": "README.md",
8
8
  "bin": {
9
- "gltf-build-pipeline": "./dist/cli/index.js"
9
+ "gltf-build-pipeline": "./dist/src/cli/index.js"
10
10
  },
11
11
  "scripts": {
12
12
  "start": "node scripts/index.mjs",
@@ -63,4 +63,4 @@
63
63
  "type": "git",
64
64
  "url": "git+https://github.com/needle-tools/needle-gltf-extensions.git"
65
65
  }
66
- }
66
+ }
package/tsconfig.json CHANGED
@@ -6,7 +6,8 @@
6
6
  "moduleResolution": "NodeNext",
7
7
  "module": "ESNext",
8
8
  "esModuleInterop": true,
9
- "skipLibCheck": true
9
+ "skipLibCheck": true,
10
+ "resolveJsonModule": true
10
11
 
11
12
  },
12
13
  "include": [
@@ -1 +0,0 @@
1
- export declare function getVersion(marklocal?: boolean): string;
@@ -1,40 +0,0 @@
1
- import { existsSync, readFileSync, statSync } from 'fs';
2
- let version = undefined;
3
- let isLocal = false;
4
- export function getVersion(marklocal = true) {
5
- if (version === undefined) {
6
- console.log(process.argv);
7
- const scriptLocation = process.argv[1].replaceAll("\\", "/");
8
- console.log("Determining version from " + scriptLocation);
9
- const path = scriptLocation.split('/');
10
- let packageJsonPath = null;
11
- while (path.length) {
12
- const dirname = path.join('/');
13
- if (statSync(dirname).isDirectory()) {
14
- const filename = dirname + '/package.json';
15
- if (existsSync(filename)) {
16
- packageJsonPath = filename;
17
- break;
18
- }
19
- }
20
- path.pop();
21
- }
22
- if (packageJsonPath) {
23
- isLocal = !path.includes("node_modules");
24
- if (existsSync(packageJsonPath)) {
25
- const packageJson = readFileSync(packageJsonPath, "utf8");
26
- const packageVersion = JSON.parse(packageJson).version;
27
- version = packageVersion ?? null;
28
- }
29
- else
30
- console.log("Could not find package.json at " + packageJsonPath);
31
- }
32
- if (!version) {
33
- throw new Error("Could not determine version");
34
- }
35
- }
36
- let res = version;
37
- if (marklocal && isLocal)
38
- res += " (local)";
39
- return res;
40
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes