@needle-tools/gltf-build-pipeline 2.13.0 → 2.13.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +520 -517
  2. package/README.md +38 -38
  3. package/dist/cache/cache.d.ts +55 -55
  4. package/dist/cache/cache.js +326 -326
  5. package/dist/cache/index.d.ts +1 -1
  6. package/dist/cache/index.js +1 -1
  7. package/dist/cli/index.d.ts +2 -2
  8. package/dist/cli/index.js +198 -198
  9. package/dist/config/index.d.ts +53 -53
  10. package/dist/config/index.js +152 -152
  11. package/dist/constants.d.ts +7 -7
  12. package/dist/constants.js +7 -7
  13. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
  14. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
  15. package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
  16. package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
  17. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +27 -27
  18. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +88 -88
  19. package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
  20. package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
  21. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
  22. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +980 -980
  23. package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
  24. package/dist/extensions/NEEDLE_opaque/index.js +30 -30
  25. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
  26. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
  27. package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
  28. package/dist/extensions/NEEDLE_progressive/index.js +1 -1
  29. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
  30. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
  31. package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
  32. package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +38 -38
  33. package/dist/extensions/index.d.ts +7 -7
  34. package/dist/extensions/index.js +17 -17
  35. package/dist/extensions/utils.d.ts +6 -6
  36. package/dist/extensions/utils.js +72 -72
  37. package/dist/functions/weld.3.d.ts +76 -76
  38. package/dist/functions/weld.3.js +414 -414
  39. package/dist/index.d.ts +8 -8
  40. package/dist/index.js +8 -8
  41. package/dist/scripts/index.d.ts +2 -2
  42. package/dist/scripts/index.js +2 -2
  43. package/dist/scripts/pack-gltf.d.ts +15 -15
  44. package/dist/scripts/pack-gltf.js +135 -133
  45. package/dist/scripts/stats.d.ts +2 -2
  46. package/dist/scripts/stats.js +19 -19
  47. package/dist/transforms/index.d.ts +9 -9
  48. package/dist/transforms/index.js +9 -9
  49. package/dist/transforms/needle_animation_transform.d.ts +2 -2
  50. package/dist/transforms/needle_animation_transform.js +5 -5
  51. package/dist/transforms/needle_asset.d.ts +3 -3
  52. package/dist/transforms/needle_asset.js +50 -50
  53. package/dist/transforms/needle_common.d.ts +17 -17
  54. package/dist/transforms/needle_common.js +1 -1
  55. package/dist/transforms/needle_mesh_transform.d.ts +15 -15
  56. package/dist/transforms/needle_mesh_transform.js +223 -223
  57. package/dist/transforms/needle_progressive.d.ts +45 -45
  58. package/dist/transforms/needle_progressive.js +1043 -1043
  59. package/dist/transforms/needle_texture_transform.d.ts +13 -13
  60. package/dist/transforms/needle_texture_transform.js +257 -257
  61. package/dist/transforms/needle_toktx.d.ts +26 -26
  62. package/dist/transforms/needle_toktx.js +243 -243
  63. package/dist/transforms/needle_webp.d.ts +15 -15
  64. package/dist/transforms/needle_webp.js +53 -53
  65. package/dist/transforms/toktx.d.ts +52 -52
  66. package/dist/transforms/toktx.js +221 -221
  67. package/dist/transforms/toktx_types.d.ts +78 -78
  68. package/dist/transforms/toktx_types.js +62 -62
  69. package/dist/transforms/util.d.ts +21 -21
  70. package/dist/transforms/util.js +90 -90
  71. package/dist/utils/compression_utils.d.ts +2 -2
  72. package/dist/utils/compression_utils.js +6 -6
  73. package/dist/utils/fileutils.d.ts +19 -19
  74. package/dist/utils/fileutils.js +177 -177
  75. package/dist/utils/guid.d.ts +1 -1
  76. package/dist/utils/guid.js +5 -5
  77. package/dist/utils/index.d.ts +10 -10
  78. package/dist/utils/index.js +10 -10
  79. package/dist/utils/merge.d.ts +12 -12
  80. package/dist/utils/merge.js +31 -31
  81. package/dist/utils/mesh.d.ts +13 -13
  82. package/dist/utils/mesh.js +124 -124
  83. package/dist/utils/nodeio.d.ts +6 -6
  84. package/dist/utils/nodeio.js +86 -86
  85. package/dist/utils/stats.d.ts +70 -70
  86. package/dist/utils/stats.js +258 -258
  87. package/dist/utils/texture.d.ts +5 -5
  88. package/dist/utils/texture.js +14 -14
  89. package/dist/utils/validate.d.ts +5 -5
  90. package/dist/utils/validate.js +17 -17
  91. package/dist/utils/version.d.ts +1 -1
  92. package/dist/utils/version.gen.d.ts +1 -1
  93. package/dist/utils/version.gen.js +1 -1
  94. package/dist/utils/version.js +4 -4
  95. package/package.json +79 -79
  96. package/scripts/clear-caches.mjs +3 -3
  97. package/scripts/defaults.mjs +11 -11
  98. package/scripts/fileutils.mjs +5 -5
  99. package/scripts/index.mjs +41 -41
  100. package/scripts/limit-caches.mjs +3 -3
  101. package/scripts/make-progressive.mjs +16 -16
  102. package/scripts/pack-gltf.mjs +106 -106
  103. package/tsconfig.json +19 -19
package/dist/cli/index.js CHANGED
@@ -1,198 +1,198 @@
1
- #! /usr/bin/env node
2
- import { program } from '@donmccurdy/caporal';
3
- import { calculateStats, packGLTF } from "../scripts/index.js";
4
- import { printStats, writeFileStatsToFile } from '../utils/stats.js';
5
- import { getVersion } from '../utils/version.js';
6
- import { UsecaseOptions, createConfig, getConfig } from '../config/index.js';
7
- import { isLOD, make_progressive } from '../transforms/needle_progressive.js';
8
- import { cacheSizeLimit, clearCache, limitCacheSize } from '../cache/cache.js';
9
- import { existsSync } from 'fs';
10
- import { ensureIsDirectory, foreachGLTF, isDirectory } from '../utils/fileutils.js';
11
- import path, { resolve } from 'path';
12
- import { ERROR_CODES } from '../constants.js';
13
- // For testing / dev you can run `npm link` in the package directory
14
- // For removing the link run `npm rm --global @needle-tools/gltf-build-pipeline`
15
- program
16
- .command("version", "Print current version")
17
- .action(async ({ logger }) => {
18
- logger.info(getVersion());
19
- })
20
- .command("clear-caches", "Clear all caches")
21
- .help(`Clears all cached files
22
- Caches are limited to ${cacheSizeLimit} MB disc space by default.
23
- `)
24
- .action(async ({ logger }) => {
25
- logger.info("Clearing caches");
26
- clearCache(logger);
27
- })
28
- .command("stats", "Calculate glTF stats")
29
- .help(`
30
- `)
31
- .argument('<input>', "Path to a glTF, GLB or VRM file OR a directory")
32
- .argument('<output>', "Output path for the stats", { default: null, validator: program.STRING })
33
- .action(async ({ logger, args, options }) => {
34
- logger.level = "info";
35
- logger.info("Calculating stats for \"" + args.input + "\"");
36
- const input = args.input.toString();
37
- const filestats = new Array();
38
- await foreachGLTF(input, async (file) => {
39
- const stats = await calculateStats(file);
40
- filestats.push(stats);
41
- });
42
- let output = args.ourput?.toString();
43
- if (!output) {
44
- if (isDirectory(input)) {
45
- output = path.join(input, "stats.needle.json");
46
- }
47
- else {
48
- output = input + ".needle.stats.json";
49
- }
50
- }
51
- logger.info("Writing stats to: " + output);
52
- writeFileStatsToFile(filestats, output);
53
- })
54
- .command("transform", "Transform (progressive loading) and compress glTF, GLB or VRM files")
55
- .help(`
56
- This will produce multiple versions of the input file, each with a different level of optimization.
57
- Each version will be compressed and written to the output directory.
58
- `)
59
- .argument('<input>', "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed")
60
- .argument('<output>', "The output file or directory. It can be an absolute path or a relative path to the input file. If not provided, the input file will be overwritten.", { default: null })
61
- .option("--compress", `When enabled files will be compressed`, { validator: program.BOOLEAN, default: true })
62
- .option("--progressive", `When enabled files will processed to be progressively loaded`, { validator: program.BOOLEAN, default: true })
63
- .option("--usecase <usecase>", `The usecase for the compression. This will set the compression settings. Possible options: [${UsecaseOptions.join(", ")}]`, { validator: program.STRING })
64
- .option("--config <config>", "The path to a JSON file containing the compression settings. This can also be a needle.config.json file with a \"compression\" object or usecase string.", { validator: program.STRING })
65
- .option("--cache", "Use \"--cache False\" to disable caching.\nWhen caching is enabled then previously processed files will be detected and loaded from disc cache instead of being processed again if settings or the file contents have not changed.", { validator: program.BOOLEAN, default: true })
66
- .option("--debug", "Enable for more verbose outout with \"--debug True\"", { validator: program.BOOLEAN, default: false })
67
- .option("--verbose", "Enable for more verbose outout with \"--verbose True\"", { validator: program.BOOLEAN, default: false })
68
- .action(async ({ logger, args, options }) => {
69
- logger.level = (options.debug || options.verbose) ? "debug" : "info";
70
- // const logger = new Logger((options.debug || options.verbose) ? Verbosity.DEBUG : Verbosity.INFO);
71
- if (options.compress === false && options.progressive === false) {
72
- logger.error(`[Needle Build Pipeline] v${getVersion()} You need to enable at least one of the options: --compress or --progressive`);
73
- return;
74
- }
75
- logger.info(`[Needle Build Pipeline] v${getVersion()} — Transform '${args.input}'`);
76
- const stats = {
77
- startTime: Date.now(),
78
- totalGPUMemoryInMB: 0,
79
- totalFilesProcessed: 0,
80
- totalFileSizeInMB: 0,
81
- totalFileSizeInMBBefore: 0,
82
- };
83
- const input = args.input.toString();
84
- let config = getConfig(options.config?.toString(), input, {
85
- logger
86
- });
87
- if (options.usecase) {
88
- logger.info("Using usecase: " + options.usecase);
89
- config = { ...createConfig(options.usecase.toString()), ...config, };
90
- if (config.usecase != "default" && config.usecase != options.usecase.toString()) {
91
- logger.warn(`Conflicting usecase. Your specific config at \"${options.config}\" has a different usecase than the one provided by the CLI: \"${options.usecase}\". Using the usecase from the config file.`);
92
- }
93
- else {
94
- config.usecase = options.usecase.toString();
95
- }
96
- }
97
- const inputIsDirectory = isDirectory(input);
98
- let output = args.output?.toString();
99
- // If the input path is a filepath and no specific output is defined we set output to the input file
100
- if (!inputIsDirectory && !output) {
101
- output = input;
102
- }
103
- const outputIsDirectory = output && isDirectory(output);
104
- if (inputIsDirectory && output && !outputIsDirectory) {
105
- logger.error("When <input> is a directory then <output> must also be a directory");
106
- process.exit(ERROR_CODES.INVALID_ARGS);
107
- }
108
- // Handle the output bath being relative to the input path
109
- if (output && path.isAbsolute(output) === false) {
110
- const base = ensureIsDirectory(input);
111
- output = resolve(base, output);
112
- }
113
- const set = new Set();
114
- const useCache = options.cache !== false;
115
- const debug = options.debug === true;
116
- const verbose = options.verbose === true;
117
- await foreachGLTF(input, async (file) => {
118
- if (!existsSync(file)) {
119
- // Safeguard if we run compression in a souce directory that already has progressive assets
120
- // Here it can happen that a LOD file is generated with the same GUID at the moment
121
- // And then later removed because simplification is too small.
122
- // See https://linear.app/needle/issue/NE-5518
123
- if (isLOD(file)) {
124
- logger.warn(`WARN: Ignore previously found file that does not exist anymore: \"${file}\"`);
125
- return;
126
- }
127
- else {
128
- logger.error(`ERR: Previously found file is now missing: \"${file}\"`);
129
- process.exit(ERROR_CODES.LOST_FILE);
130
- }
131
- }
132
- // If we run compression in a directory that has previously generated LOD files AND this command should also generate LOD files with this command we should ignore found LOD meshes or textures
133
- else if (file != input && options.progressive === true && isLOD(file)) {
134
- logger.debug(`→ Ignore existing LOD file at ${file}`);
135
- return;
136
- }
137
- logger.info(`→ Transform ${file}`);
138
- const progressive_results = new Array();
139
- if (options.progressive === true) {
140
- if (await make_progressive({
141
- path: file,
142
- outpath: output,
143
- results: progressive_results,
144
- config,
145
- debug,
146
- verbose,
147
- useCache,
148
- logger,
149
- }).catch(err => {
150
- logger.error(err);
151
- process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
152
- }) === false) {
153
- process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
154
- }
155
- if (verbose) {
156
- console.log("Progressive results:\n", progressive_results);
157
- }
158
- }
159
- if (options.compress === true) {
160
- const opts = {
161
- config,
162
- stats,
163
- packedFiles: set,
164
- debug,
165
- verbose,
166
- useCache,
167
- logger: logger,
168
- };
169
- // If we have produced progressive assets then the array already contains the input
170
- if (progressive_results.length > 0) {
171
- for (const res of progressive_results) {
172
- if (await packGLTF(res, res, opts) === false) {
173
- process.exit(ERROR_CODES.PACKING_FAILED);
174
- }
175
- }
176
- }
177
- // If we have not produced progressive assets then we just need to compress the input
178
- // We can not just check if the file is in the list of results because the output path might have changed the name
179
- else {
180
- if (await packGLTF(file, output, opts) === false) {
181
- process.exit(ERROR_CODES.PACKING_FAILED);
182
- }
183
- }
184
- }
185
- });
186
- printStats(stats, logger, config);
187
- if (useCache)
188
- limitCacheSize();
189
- });
190
- program.run().catch(err => {
191
- // Since we still invoke this package with paths when running npm scripts we need to ignore this error
192
- // We might want to move this code here into an extra package.
193
- if (err.message.includes("Unknown command") && !err.message.includes("Did you mean")) {
194
- // ignore
195
- return;
196
- }
197
- throw err;
198
- });
1
+ #! /usr/bin/env node
2
+ import { program } from '@donmccurdy/caporal';
3
+ import { calculateStats, packGLTF } from "../scripts/index.js";
4
+ import { printStats, writeFileStatsToFile } from '../utils/stats.js';
5
+ import { getVersion } from '../utils/version.js';
6
+ import { UsecaseOptions, createConfig, getConfig } from '../config/index.js';
7
+ import { isLOD, make_progressive } from '../transforms/needle_progressive.js';
8
+ import { cacheSizeLimit, clearCache, limitCacheSize } from '../cache/cache.js';
9
+ import { existsSync } from 'fs';
10
+ import { ensureIsDirectory, foreachGLTF, isDirectory } from '../utils/fileutils.js';
11
+ import path, { resolve } from 'path';
12
+ import { ERROR_CODES } from '../constants.js';
13
+ // For testing / dev you can run `npm link` in the package directory
14
+ // For removing the link run `npm rm --global @needle-tools/gltf-build-pipeline`
15
+ program
16
+ .command("version", "Print current version")
17
+ .action(async ({ logger }) => {
18
+ logger.info(getVersion());
19
+ })
20
+ .command("clear-caches", "Clear all caches")
21
+ .help(`Clears all cached files
22
+ Caches are limited to ${cacheSizeLimit} MB disc space by default.
23
+ `)
24
+ .action(async ({ logger }) => {
25
+ logger.info("Clearing caches");
26
+ clearCache(logger);
27
+ })
28
+ .command("stats", "Calculate glTF stats")
29
+ .help(`
30
+ `)
31
+ .argument('<input>', "Path to a glTF, GLB or VRM file OR a directory")
32
+ .argument('<output>', "Output path for the stats", { default: null, validator: program.STRING })
33
+ .action(async ({ logger, args, options }) => {
34
+ logger.level = "info";
35
+ logger.info("Calculating stats for \"" + args.input + "\"");
36
+ const input = args.input.toString();
37
+ const filestats = new Array();
38
+ await foreachGLTF(input, async (file) => {
39
+ const stats = await calculateStats(file);
40
+ filestats.push(stats);
41
+ });
42
+ let output = args.ourput?.toString();
43
+ if (!output) {
44
+ if (isDirectory(input)) {
45
+ output = path.join(input, "stats.needle.json");
46
+ }
47
+ else {
48
+ output = input + ".needle.stats.json";
49
+ }
50
+ }
51
+ logger.info("Writing stats to: " + output);
52
+ writeFileStatsToFile(filestats, output);
53
+ })
54
+ .command("transform", "Transform (progressive loading) and compress glTF, GLB or VRM files")
55
+ .help(`
56
+ This will produce multiple versions of the input file, each with a different level of optimization.
57
+ Each version will be compressed and written to the output directory.
58
+ `)
59
+ .argument('<input>', "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed")
60
+ .argument('<output>', "The output file or directory. It can be an absolute path or a relative path to the input file. If not provided, the input file will be overwritten.", { default: null })
61
+ .option("--compress", `When enabled files will be compressed`, { validator: program.BOOLEAN, default: true })
62
+ .option("--progressive", `When enabled files will processed to be progressively loaded`, { validator: program.BOOLEAN, default: true })
63
+ .option("--usecase <usecase>", `The usecase for the compression. This will set the compression settings. Possible options: [${UsecaseOptions.join(", ")}]`, { validator: program.STRING })
64
+ .option("--config <config>", "The path to a JSON file containing the compression settings. This can also be a needle.config.json file with a \"compression\" object or usecase string.", { validator: program.STRING })
65
+ .option("--cache", "Use \"--cache False\" to disable caching.\nWhen caching is enabled then previously processed files will be detected and loaded from disc cache instead of being processed again if settings or the file contents have not changed.", { validator: program.BOOLEAN, default: true })
66
+ .option("--debug", "Enable for more verbose outout with \"--debug True\"", { validator: program.BOOLEAN, default: false })
67
+ .option("--verbose", "Enable for more verbose outout with \"--verbose True\"", { validator: program.BOOLEAN, default: false })
68
+ .action(async ({ logger, args, options }) => {
69
+ logger.level = (options.debug || options.verbose) ? "debug" : "info";
70
+ // const logger = new Logger((options.debug || options.verbose) ? Verbosity.DEBUG : Verbosity.INFO);
71
+ if (options.compress === false && options.progressive === false) {
72
+ logger.error(`[Needle Build Pipeline] v${getVersion()} You need to enable at least one of the options: --compress or --progressive`);
73
+ return;
74
+ }
75
+ logger.info(`[Needle Build Pipeline] v${getVersion()} — Transform '${args.input}'`);
76
+ const stats = {
77
+ startTime: Date.now(),
78
+ totalGPUMemoryInMB: 0,
79
+ totalFilesProcessed: 0,
80
+ totalFileSizeInMB: 0,
81
+ totalFileSizeInMBBefore: 0,
82
+ };
83
+ const input = args.input.toString();
84
+ let config = getConfig(options.config?.toString(), input, {
85
+ logger
86
+ });
87
+ if (options.usecase) {
88
+ logger.info("Using usecase: " + options.usecase);
89
+ config = { ...createConfig(options.usecase.toString()), ...config, };
90
+ if (config.usecase != "default" && config.usecase != options.usecase.toString()) {
91
+ logger.warn(`Conflicting usecase. Your specific config at \"${options.config}\" has a different usecase than the one provided by the CLI: \"${options.usecase}\". Using the usecase from the config file.`);
92
+ }
93
+ else {
94
+ config.usecase = options.usecase.toString();
95
+ }
96
+ }
97
+ const inputIsDirectory = isDirectory(input);
98
+ let output = args.output?.toString();
99
+ // If the input path is a filepath and no specific output is defined we set output to the input file
100
+ if (!inputIsDirectory && !output) {
101
+ output = input;
102
+ }
103
+ const outputIsDirectory = output && isDirectory(output);
104
+ if (inputIsDirectory && output && !outputIsDirectory) {
105
+ logger.error("When <input> is a directory then <output> must also be a directory");
106
+ process.exit(ERROR_CODES.INVALID_ARGS);
107
+ }
108
+ // Handle the output bath being relative to the input path
109
+ if (output && path.isAbsolute(output) === false) {
110
+ const base = ensureIsDirectory(input);
111
+ output = resolve(base, output);
112
+ }
113
+ const set = new Set();
114
+ const useCache = options.cache !== false;
115
+ const debug = options.debug === true;
116
+ const verbose = options.verbose === true;
117
+ await foreachGLTF(input, async (file) => {
118
+ if (!existsSync(file)) {
119
+ // Safeguard if we run compression in a souce directory that already has progressive assets
120
+ // Here it can happen that a LOD file is generated with the same GUID at the moment
121
+ // And then later removed because simplification is too small.
122
+ // See https://linear.app/needle/issue/NE-5518
123
+ if (isLOD(file)) {
124
+ logger.warn(`WARN: Ignore previously found file that does not exist anymore: \"${file}\"`);
125
+ return;
126
+ }
127
+ else {
128
+ logger.error(`ERR: Previously found file is now missing: \"${file}\"`);
129
+ process.exit(ERROR_CODES.LOST_FILE);
130
+ }
131
+ }
132
+ // If we run compression in a directory that has previously generated LOD files AND this command should also generate LOD files with this command we should ignore found LOD meshes or textures
133
+ else if (file != input && options.progressive === true && isLOD(file)) {
134
+ logger.debug(`→ Ignore existing LOD file at ${file}`);
135
+ return;
136
+ }
137
+ logger.info(`→ Transform ${file}`);
138
+ const progressive_results = new Array();
139
+ if (options.progressive === true) {
140
+ if (await make_progressive({
141
+ path: file,
142
+ outpath: output,
143
+ results: progressive_results,
144
+ config,
145
+ debug,
146
+ verbose,
147
+ useCache,
148
+ logger,
149
+ }).catch(err => {
150
+ logger.error(err);
151
+ process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
152
+ }) === false) {
153
+ process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
154
+ }
155
+ if (verbose) {
156
+ console.log("Progressive results:\n", progressive_results);
157
+ }
158
+ }
159
+ if (options.compress === true) {
160
+ const opts = {
161
+ config,
162
+ stats,
163
+ packedFiles: set,
164
+ debug,
165
+ verbose,
166
+ useCache,
167
+ logger: logger,
168
+ };
169
+ // If we have produced progressive assets then the array already contains the input
170
+ if (progressive_results.length > 0) {
171
+ for (const res of progressive_results) {
172
+ if (await packGLTF(res, res, opts) === false) {
173
+ process.exit(ERROR_CODES.PACKING_FAILED);
174
+ }
175
+ }
176
+ }
177
+ // If we have not produced progressive assets then we just need to compress the input
178
+ // We can not just check if the file is in the list of results because the output path might have changed the name
179
+ else {
180
+ if (await packGLTF(file, output, opts) === false) {
181
+ process.exit(ERROR_CODES.PACKING_FAILED);
182
+ }
183
+ }
184
+ }
185
+ });
186
+ printStats(stats, logger, config);
187
+ if (useCache)
188
+ limitCacheSize();
189
+ });
190
+ program.run().catch(err => {
191
+ // Since we still invoke this package with paths when running npm scripts we need to ignore this error
192
+ // We might want to move this code here into an extra package.
193
+ if (err.message.includes("Unknown command") && !err.message.includes("Did you mean")) {
194
+ // ignore
195
+ return;
196
+ }
197
+ throw err;
198
+ });
@@ -1,53 +1,53 @@
1
- import { ILogger } from "@gltf-transform/core";
2
- declare type Usecase = "default" | "product" | "world";
3
- export declare const UsecaseOptions: string[];
4
- /**
5
- * The config object contains information about how a file should be processed.
6
- */
7
- export type Config = {
8
- /** High-level configuration */
9
- usecase: Usecase;
10
- textures?: {
11
- lods: boolean;
12
- };
13
- meshes?: {
14
- lods: boolean;
15
- };
16
- };
17
- /**
18
- * Create a config object with the given usecase.
19
- */
20
- export declare function createConfig(usecase: string): {
21
- usecase: Usecase;
22
- };
23
- /**
24
- * Get the config object either provided by a CLI path or a needle.config.json file in the parent directory.
25
- *
26
- * @example CLI argument where the path points to a json file containing the config as `Config`
27
- * ```sh
28
- * node script.js --config path/to/my-optimization-config.json
29
- * ```
30
- *
31
- * @example needle.config.json - the usecase can be provided as a string
32
- * ```json
33
- * {
34
- * "optimization": "product"
35
- * }
36
- * ```
37
- *
38
- * @example needle.config.json - the whole config object can be provided
39
- * ```json
40
- * {
41
- * "optimization": {
42
- * "usecase": "product"
43
- * }
44
- * }
45
- * ```
46
- *
47
- *
48
- */
49
- export declare function getConfig(configPath?: string, fallbackSearchDirectory?: string, opts?: {
50
- logger: ILogger;
51
- }): Config;
52
- export declare function searchConfig(directory: string, logger: ILogger): Config | null;
53
- export {};
1
+ import { ILogger } from "@gltf-transform/core";
2
+ declare type Usecase = "default" | "product" | "world";
3
+ export declare const UsecaseOptions: string[];
4
+ /**
5
+ * The config object contains information about how a file should be processed.
6
+ */
7
+ export type Config = {
8
+ /** High-level configuration */
9
+ usecase: Usecase;
10
+ textures?: {
11
+ lods: boolean;
12
+ };
13
+ meshes?: {
14
+ lods: boolean;
15
+ };
16
+ };
17
+ /**
18
+ * Create a config object with the given usecase.
19
+ */
20
+ export declare function createConfig(usecase: string): {
21
+ usecase: Usecase;
22
+ };
23
+ /**
24
+ * Get the config object either provided by a CLI path or a needle.config.json file in the parent directory.
25
+ *
26
+ * @example CLI argument where the path points to a json file containing the config as `Config`
27
+ * ```sh
28
+ * node script.js --config path/to/my-optimization-config.json
29
+ * ```
30
+ *
31
+ * @example needle.config.json - the usecase can be provided as a string
32
+ * ```json
33
+ * {
34
+ * "optimization": "product"
35
+ * }
36
+ * ```
37
+ *
38
+ * @example needle.config.json - the whole config object can be provided
39
+ * ```json
40
+ * {
41
+ * "optimization": {
42
+ * "usecase": "product"
43
+ * }
44
+ * }
45
+ * ```
46
+ *
47
+ *
48
+ */
49
+ export declare function getConfig(configPath?: string, fallbackSearchDirectory?: string, opts?: {
50
+ logger: ILogger;
51
+ }): Config;
52
+ export declare function searchConfig(directory: string, logger: ILogger): Config | null;
53
+ export {};