@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/package.json CHANGED
@@ -1,79 +1,79 @@
1
- {
2
- "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.13.0",
4
- "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
- "main": "dist/index.js",
6
- "type": "module",
7
- "readme": "README.md",
8
- "author": {
9
- "name": "Needle",
10
- "email": "help@needle.tools",
11
- "url": "https://needle.tools/"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/needle-tools/needle-gltf-extensions.git"
16
- },
17
- "bin": {
18
- "gltf-build-pipeline": "dist/cli/index.js",
19
- "needle-gltf": "dist/cli/index.js"
20
- },
21
- "imports": {
22
- "#package.json": "./package.json"
23
- },
24
- "scripts": {
25
- "start": "node scripts/index.mjs",
26
- "dev": "npm-watch compile",
27
- "publish-package": "npm run compile && npm publish",
28
- "prepublishOnly": "npm run compile",
29
- "compile": "node tools/prebuild.mjs && (tsc || exit 1) && node tools/postbuild.mjs",
30
- "clear-caches": "node scripts/clear-caches.mjs",
31
- "limit-caches": "node scripts/limit-caches.mjs",
32
- "transform": "node scripts/index.mjs",
33
- "transform:make-progressive": "node scripts/make-progressive.mjs",
34
- "transform:pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
35
- "pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
36
- "dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs"
37
- },
38
- "devDependencies": {
39
- "@types/node": "^18.7.23",
40
- "npm-watch": "^0.13.0",
41
- "typescript": "^4.9.5"
42
- },
43
- "optionalDependencies": {
44
- "@img/sharp-darwin-arm64": "^0.33.4",
45
- "@img/sharp-darwin-x64": "^0.33.4",
46
- "@img/sharp-linux-arm": "^0.33.4",
47
- "@img/sharp-win32-x64": "^0.33.4"
48
- },
49
- "dependencies": {
50
- "@donmccurdy/caporal": "~0.0.10",
51
- "@gltf-transform/core": "4.2.1",
52
- "@gltf-transform/extensions": "4.2.1",
53
- "@gltf-transform/functions": "npm:@needle-tools/gltf-transform-functions@4.3.0-alpha.1",
54
- "command-exists": "^1.2.9",
55
- "command-line-args": "^5.2.1",
56
- "draco3dgltf": "^1.5.3",
57
- "glob": "^7.2.0",
58
- "meshoptimizer": "0.25.0",
59
- "micromatch": "^4.0.5",
60
- "ndarray": "^1.0.19",
61
- "ndarray-lanczos": "^0.3.0",
62
- "ndarray-pixels": "^2.0.1",
63
- "p-limit": "3.1.0",
64
- "semver": "^7.3.7",
65
- "sharp": "^0.33.4",
66
- "tmp": "^0.2.1",
67
- "uuid": "^9.0.1",
68
- "xxhash-wasm": "^1.1.0"
69
- },
70
- "watch": {
71
- "compile": {
72
- "patterns": [
73
- "src"
74
- ],
75
- "extensions": "ts",
76
- "quiet": false
77
- }
78
- }
79
- }
1
+ {
2
+ "name": "@needle-tools/gltf-build-pipeline",
3
+ "version": "2.13.1",
4
+ "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "readme": "README.md",
8
+ "author": {
9
+ "name": "Needle",
10
+ "email": "help@needle.tools",
11
+ "url": "https://needle.tools/"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/needle-tools/needle-gltf-extensions.git"
16
+ },
17
+ "bin": {
18
+ "gltf-build-pipeline": "dist/cli/index.js",
19
+ "needle-gltf": "dist/cli/index.js"
20
+ },
21
+ "imports": {
22
+ "#package.json": "./package.json"
23
+ },
24
+ "scripts": {
25
+ "start": "node scripts/index.mjs",
26
+ "dev": "npm-watch compile",
27
+ "publish-package": "npm run compile && npm publish",
28
+ "prepublishOnly": "npm run compile",
29
+ "compile": "node tools/prebuild.mjs && (tsc || exit 1) && node tools/postbuild.mjs",
30
+ "clear-caches": "node scripts/clear-caches.mjs",
31
+ "limit-caches": "node scripts/limit-caches.mjs",
32
+ "transform": "node scripts/index.mjs",
33
+ "transform:make-progressive": "node scripts/make-progressive.mjs",
34
+ "transform:pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
35
+ "pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
36
+ "dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^18.7.23",
40
+ "npm-watch": "^0.13.0",
41
+ "typescript": "^4.9.5"
42
+ },
43
+ "optionalDependencies": {
44
+ "@img/sharp-darwin-arm64": "^0.33.4",
45
+ "@img/sharp-darwin-x64": "^0.33.4",
46
+ "@img/sharp-linux-arm": "^0.33.4",
47
+ "@img/sharp-win32-x64": "^0.33.4"
48
+ },
49
+ "dependencies": {
50
+ "@donmccurdy/caporal": "~0.0.10",
51
+ "@gltf-transform/core": "4.2.1",
52
+ "@gltf-transform/extensions": "4.2.1",
53
+ "@gltf-transform/functions": "npm:@needle-tools/gltf-transform-functions@4.3.0-alpha.1",
54
+ "command-exists": "^1.2.9",
55
+ "command-line-args": "^5.2.1",
56
+ "draco3dgltf": "^1.5.3",
57
+ "glob": "^7.2.0",
58
+ "meshoptimizer": "0.25.0",
59
+ "micromatch": "^4.0.5",
60
+ "ndarray": "^1.0.19",
61
+ "ndarray-lanczos": "^0.3.0",
62
+ "ndarray-pixels": "^2.0.1",
63
+ "p-limit": "3.1.0",
64
+ "semver": "^7.3.7",
65
+ "sharp": "^0.33.4",
66
+ "tmp": "^0.2.1",
67
+ "uuid": "^9.0.1",
68
+ "xxhash-wasm": "^1.1.0"
69
+ },
70
+ "watch": {
71
+ "compile": {
72
+ "patterns": [
73
+ "src"
74
+ ],
75
+ "extensions": "ts",
76
+ "quiet": false
77
+ }
78
+ }
79
+ }
@@ -1,4 +1,4 @@
1
-
2
- import { clearCache } from '../dist/cache/index.js';
3
-
1
+
2
+ import { clearCache } from '../dist/cache/index.js';
3
+
4
4
  clearCache();
@@ -1,12 +1,12 @@
1
- import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
2
- import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS } from "../dist/extensions/NEEDLE_opaque/index.js";
3
- import { NEEDLE_progressive } from '../dist/index.js';
4
-
5
-
6
- export function registerExtensions(node) {
7
- node.registerExtensions(ALL_EXTENSIONS);
8
- node.registerExtensions(NEEDLE_EXTENSIONS);
9
- node.registerExtensions([
10
- NEEDLE_progressive
11
- ])
1
+ import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
2
+ import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS } from "../dist/extensions/NEEDLE_opaque/index.js";
3
+ import { NEEDLE_progressive } from '../dist/index.js';
4
+
5
+
6
+ export function registerExtensions(node) {
7
+ node.registerExtensions(ALL_EXTENSIONS);
8
+ node.registerExtensions(NEEDLE_EXTENSIONS);
9
+ node.registerExtensions([
10
+ NEEDLE_progressive
11
+ ])
12
12
  }
@@ -1,6 +1,6 @@
1
- import { foreachGLTF as foreach } from '../dist/index.js';
2
-
3
-
4
- export function foreachGLTF(args, callback) {
5
- return foreach(args, callback);
1
+ import { foreachGLTF as foreach } from '../dist/index.js';
2
+
3
+
4
+ export function foreachGLTF(args, callback) {
5
+ return foreach(args, callback);
6
6
  }
package/scripts/index.mjs CHANGED
@@ -1,41 +1,41 @@
1
-
2
- import { spawnSync } from "child_process";
3
- import { getVersion } from "../dist/index.js";
4
-
5
- const workingDir = process.cwd();
6
-
7
- // Original invoked dir set by npm
8
- // const dir = process.env.INIT_CWD;
9
-
10
-
11
- const defaultArgs = { shell: true, cwd: workingDir, stdio: 'inherit' }
12
-
13
- function getCommandLineArgs(_cmd) {
14
- // Wrap paths with parentheses if they contain spaces
15
- const args = process.argv.slice(2);
16
- for (let i = 0; i < args.length; i++) {
17
- const arg = args[i];
18
- if (arg.includes("\\") || arg.includes("/")) {
19
- if (arg.includes(" "))
20
- args[i] = "\"" + arg + "\"";
21
- }
22
- }
23
- return args;
24
- }
25
-
26
-
27
- function runWithArgs(cmd) {
28
- const commandline_args = getCommandLineArgs(cmd).join(" ");
29
- spawnSync(cmd + " " + commandline_args, defaultArgs);
30
- }
31
-
32
- try {
33
- const startTime = Date.now();
34
- runWithArgs("node scripts/make-progressive.mjs");
35
- runWithArgs("node scripts/pack-gltf.mjs");
36
- const durationInMinutes = ((Date.now() - startTime) / 1000 / 60).toFixed(1);
37
- console.log(`[Needle Build Pipeline] v${getVersion()} — Finished progressive transform and optimization in ${durationInMinutes} minutes.`);
38
- }
39
- catch (err) {
40
- console.error("Failed running commandline args:", err.message);
41
- }
1
+
2
+ import { spawnSync } from "child_process";
3
+ import { getVersion } from "../dist/index.js";
4
+
5
+ const workingDir = process.cwd();
6
+
7
+ // Original invoked dir set by npm
8
+ // const dir = process.env.INIT_CWD;
9
+
10
+
11
+ const defaultArgs = { shell: true, cwd: workingDir, stdio: 'inherit' }
12
+
13
+ function getCommandLineArgs(_cmd) {
14
+ // Wrap paths with parentheses if they contain spaces
15
+ const args = process.argv.slice(2);
16
+ for (let i = 0; i < args.length; i++) {
17
+ const arg = args[i];
18
+ if (arg.includes("\\") || arg.includes("/")) {
19
+ if (arg.includes(" "))
20
+ args[i] = "\"" + arg + "\"";
21
+ }
22
+ }
23
+ return args;
24
+ }
25
+
26
+
27
+ function runWithArgs(cmd) {
28
+ const commandline_args = getCommandLineArgs(cmd).join(" ");
29
+ spawnSync(cmd + " " + commandline_args, defaultArgs);
30
+ }
31
+
32
+ try {
33
+ const startTime = Date.now();
34
+ runWithArgs("node scripts/make-progressive.mjs");
35
+ runWithArgs("node scripts/pack-gltf.mjs");
36
+ const durationInMinutes = ((Date.now() - startTime) / 1000 / 60).toFixed(1);
37
+ console.log(`[Needle Build Pipeline] v${getVersion()} — Finished progressive transform and optimization in ${durationInMinutes} minutes.`);
38
+ }
39
+ catch (err) {
40
+ console.error("Failed running commandline args:", err.message);
41
+ }
@@ -1,4 +1,4 @@
1
-
2
- import { limitCacheSize } from '../dist/cache/index.js';
3
-
1
+
2
+ import { limitCacheSize } from '../dist/cache/index.js';
3
+
4
4
  limitCacheSize(512);
@@ -1,16 +1,16 @@
1
- import { getConfig, getVersion } from '../dist/index.js';
2
- import { make_progressive } from '../dist/transforms/needle_progressive.js';
3
-
4
- const args = process.argv;
5
-
6
- console.log(`[Needle Build Pipeline] transform to progressive — version ${getVersion()}`)
7
-
8
- make_progressive({
9
- path: args,
10
- results: [],
11
- config: getConfig(),
12
- debug: args.includes("--debug"),
13
- useCache: args.includes("--no-caching") === false,
14
- });
15
-
16
-
1
+ import { getConfig, getVersion } from '../dist/index.js';
2
+ import { make_progressive } from '../dist/transforms/needle_progressive.js';
3
+
4
+ const args = process.argv;
5
+
6
+ console.log(`[Needle Build Pipeline] transform to progressive — version ${getVersion()}`)
7
+
8
+ make_progressive({
9
+ path: args,
10
+ results: [],
11
+ config: getConfig(),
12
+ debug: args.includes("--debug"),
13
+ useCache: args.includes("--no-caching") === false,
14
+ });
15
+
16
+
@@ -1,107 +1,107 @@
1
- import commandLineArgs from "command-line-args";
2
- import { foreachGLTF } from './fileutils.mjs';
3
- import { getVersion, limitCacheSize, getConfig, packGLTF, printStats } from '../dist/index.js';
4
- import { Logger, Verbosity } from "@gltf-transform/core";
5
-
6
- console.log(`[Needle Build Pipeline] pack glTF — version ${getVersion()}`)
7
-
8
- const args = process.argv;
9
- const showHelp = args.includes("help");
10
-
11
- const optionDefinitions = [
12
- { name: 'debug', type: Boolean },
13
- { name: 'toktxPath', type: String, multiple: true },
14
- { name: 'file', type: String, multiple: true },
15
- ];
16
- let options = undefined;
17
- try {
18
- options = commandLineArgs(optionDefinitions);
19
- }
20
- catch (err) {
21
- if (args?.includes("debug"))
22
- console.log("Failed parsing commandline args:", err.message);
23
- options = {
24
- file: [...process.argv],
25
- debug: args?.includes("debug"),
26
- toktxPath: new Array(),
27
- };
28
- for (const arg of args) {
29
- if (arg.includes("KTX-Software")) {
30
- options.toktxPath = [arg];
31
- break;
32
- }
33
- }
34
- }
35
-
36
- const toktxPaths = options?.toktxPath?.join(";");
37
- if (showHelp) {
38
- if (!toktxPaths) {
39
- console.log("You can define a toktx search path by adding --toktxPath <path> to the command line. The command may appear multiple times");
40
- }
41
- else console.log("Toktx path at " + toktxPaths);
42
- }
43
-
44
- // console.log(args);
45
- const debug = options?.debug ?? false;
46
- if (debug) {
47
- console.log(options);
48
- }
49
-
50
- let allowCaching = true;
51
- if (args.includes("--no-caching")) {
52
- allowCaching = false;
53
- }
54
- else console.log("Use --no-caching to disable caching");
55
-
56
- const noToktx = args.includes("no-toktx");
57
- if (noToktx)
58
- console.log("Using toktx is disabled");
59
-
60
- const packedFiles = new Set();
61
-
62
- /**
63
- * @type {import("../dist/index.js").ProcessStats}
64
- */
65
- const stats = {
66
- startTime: Date.now(),
67
- totalGPUMemoryInMB: 0,
68
- totalFilesProcessed: 0,
69
- totalFileSizeInMB: 0,
70
- totalFileSizeInMBBefore: 0,
71
- };
72
-
73
- const config = getConfig();
74
-
75
-
76
- /** Compress a glTF file
77
- * @param {string} file
78
- */
79
- async function packFile(file) {
80
- return packGLTF(file, file, {
81
- config,
82
- debug,
83
- packedFiles,
84
- useCache: allowCaching,
85
- stats,
86
- })
87
- }
88
-
89
- const inputArgs = args.slice(2);
90
- let failed = false;
91
- const logger = new Logger(Verbosity.INFO);
92
-
93
- foreachGLTF(inputArgs, async (file) => {
94
- const res = await packFile(file);
95
- if (!res) failed = true;
96
- }).then(async () => {
97
- if (allowCaching) {
98
- limitCacheSize();
99
- }
100
- printStats(stats, logger, config);
101
- if (failed) {
102
- process.exit(1);
103
- }
104
- }).catch(err => {
105
- console.error("ERR: packing failed: " + err.message);
106
- if (debug) throw err;
1
+ import commandLineArgs from "command-line-args";
2
+ import { foreachGLTF } from './fileutils.mjs';
3
+ import { getVersion, limitCacheSize, getConfig, packGLTF, printStats } from '../dist/index.js';
4
+ import { Logger, Verbosity } from "@gltf-transform/core";
5
+
6
+ console.log(`[Needle Build Pipeline] pack glTF — version ${getVersion()}`)
7
+
8
+ const args = process.argv;
9
+ const showHelp = args.includes("help");
10
+
11
+ const optionDefinitions = [
12
+ { name: 'debug', type: Boolean },
13
+ { name: 'toktxPath', type: String, multiple: true },
14
+ { name: 'file', type: String, multiple: true },
15
+ ];
16
+ let options = undefined;
17
+ try {
18
+ options = commandLineArgs(optionDefinitions);
19
+ }
20
+ catch (err) {
21
+ if (args?.includes("debug"))
22
+ console.log("Failed parsing commandline args:", err.message);
23
+ options = {
24
+ file: [...process.argv],
25
+ debug: args?.includes("debug"),
26
+ toktxPath: new Array(),
27
+ };
28
+ for (const arg of args) {
29
+ if (arg.includes("KTX-Software")) {
30
+ options.toktxPath = [arg];
31
+ break;
32
+ }
33
+ }
34
+ }
35
+
36
+ const toktxPaths = options?.toktxPath?.join(";");
37
+ if (showHelp) {
38
+ if (!toktxPaths) {
39
+ console.log("You can define a toktx search path by adding --toktxPath <path> to the command line. The command may appear multiple times");
40
+ }
41
+ else console.log("Toktx path at " + toktxPaths);
42
+ }
43
+
44
+ // console.log(args);
45
+ const debug = options?.debug ?? false;
46
+ if (debug) {
47
+ console.log(options);
48
+ }
49
+
50
+ let allowCaching = true;
51
+ if (args.includes("--no-caching")) {
52
+ allowCaching = false;
53
+ }
54
+ else console.log("Use --no-caching to disable caching");
55
+
56
+ const noToktx = args.includes("no-toktx");
57
+ if (noToktx)
58
+ console.log("Using toktx is disabled");
59
+
60
+ const packedFiles = new Set();
61
+
62
+ /**
63
+ * @type {import("../dist/index.js").ProcessStats}
64
+ */
65
+ const stats = {
66
+ startTime: Date.now(),
67
+ totalGPUMemoryInMB: 0,
68
+ totalFilesProcessed: 0,
69
+ totalFileSizeInMB: 0,
70
+ totalFileSizeInMBBefore: 0,
71
+ };
72
+
73
+ const config = getConfig();
74
+
75
+
76
+ /** Compress a glTF file
77
+ * @param {string} file
78
+ */
79
+ async function packFile(file) {
80
+ return packGLTF(file, file, {
81
+ config,
82
+ debug,
83
+ packedFiles,
84
+ useCache: allowCaching,
85
+ stats,
86
+ })
87
+ }
88
+
89
+ const inputArgs = args.slice(2);
90
+ let failed = false;
91
+ const logger = new Logger(Verbosity.INFO);
92
+
93
+ foreachGLTF(inputArgs, async (file) => {
94
+ const res = await packFile(file);
95
+ if (!res) failed = true;
96
+ }).then(async () => {
97
+ if (allowCaching) {
98
+ limitCacheSize();
99
+ }
100
+ printStats(stats, logger, config);
101
+ if (failed) {
102
+ process.exit(1);
103
+ }
104
+ }).catch(err => {
105
+ console.error("ERR: packing failed: " + err.message);
106
+ if (debug) throw err;
107
107
  });
package/tsconfig.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "declaration": true,
7
- "moduleResolution": "NodeNext",
8
- "module": "NodeNext",
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "resolveJsonModule": true,
12
- "lib": [
13
- "ESNext",
14
- "DOM"
15
- ],
16
- },
17
- "include": [
18
- "src/index.ts",
19
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "declaration": true,
7
+ "moduleResolution": "NodeNext",
8
+ "module": "NodeNext",
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "resolveJsonModule": true,
12
+ "lib": [
13
+ "ESNext",
14
+ "DOM"
15
+ ],
16
+ },
17
+ "include": [
18
+ "src/index.ts",
19
+ ]
20
20
  }