@needle-tools/gltf-build-pipeline 2.2.1-alpha.2 → 2.2.1-alpha.4

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 (104) hide show
  1. package/.temp/Go2.bin +0 -0
  2. package/.temp/textures/0_1.exr +0 -0
  3. package/.temp/textures/1_1.jpg +0 -0
  4. package/CHANGELOG.md +395 -394
  5. package/README.md +35 -35
  6. package/dist/cache/cache.d.ts +54 -54
  7. package/dist/cache/cache.js +257 -257
  8. package/dist/cache/index.d.ts +1 -1
  9. package/dist/cache/index.js +1 -1
  10. package/dist/cli/index.d.ts +2 -2
  11. package/dist/cli/index.js +154 -154
  12. package/dist/config/index.d.ts +53 -53
  13. package/dist/config/index.js +152 -152
  14. package/dist/constants.d.ts +5 -5
  15. package/dist/constants.js +5 -5
  16. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
  17. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
  18. package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
  19. package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
  20. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +26 -26
  21. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +85 -85
  22. package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
  23. package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
  24. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
  25. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +897 -897
  26. package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
  27. package/dist/extensions/NEEDLE_opaque/index.js +28 -28
  28. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
  29. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
  30. package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
  31. package/dist/extensions/NEEDLE_progressive/index.js +1 -1
  32. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
  33. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
  34. package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
  35. package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +67 -67
  36. package/dist/extensions/index.d.ts +7 -7
  37. package/dist/extensions/index.js +17 -17
  38. package/dist/extensions/utils.d.ts +6 -6
  39. package/dist/extensions/utils.js +72 -72
  40. package/dist/functions/weld.3.d.ts +76 -76
  41. package/dist/functions/weld.3.js +414 -414
  42. package/dist/index.d.ts +8 -8
  43. package/dist/index.js +8 -8
  44. package/dist/scripts/index.d.ts +2 -2
  45. package/dist/scripts/index.js +2 -2
  46. package/dist/scripts/pack-gltf.d.ts +16 -16
  47. package/dist/scripts/pack-gltf.js +120 -120
  48. package/dist/scripts/stats.d.ts +2 -2
  49. package/dist/scripts/stats.js +18 -18
  50. package/dist/transforms/index.d.ts +9 -9
  51. package/dist/transforms/index.js +9 -9
  52. package/dist/transforms/needle_animation_transform.d.ts +2 -2
  53. package/dist/transforms/needle_animation_transform.js +5 -5
  54. package/dist/transforms/needle_asset.d.ts +3 -3
  55. package/dist/transforms/needle_asset.js +35 -35
  56. package/dist/transforms/needle_common.d.ts +16 -16
  57. package/dist/transforms/needle_common.js +1 -1
  58. package/dist/transforms/needle_mesh_transform.d.ts +10 -10
  59. package/dist/transforms/needle_mesh_transform.js +140 -140
  60. package/dist/transforms/needle_progressive.d.ts +42 -42
  61. package/dist/transforms/needle_progressive.js +933 -921
  62. package/dist/transforms/needle_texture_transform.d.ts +13 -13
  63. package/dist/transforms/needle_texture_transform.js +202 -196
  64. package/dist/transforms/needle_toktx.d.ts +25 -25
  65. package/dist/transforms/needle_toktx.js +230 -230
  66. package/dist/transforms/needle_webp.d.ts +13 -13
  67. package/dist/transforms/needle_webp.js +37 -37
  68. package/dist/transforms/toktx.d.ts +52 -52
  69. package/dist/transforms/toktx.js +221 -221
  70. package/dist/transforms/toktx_types.d.ts +78 -78
  71. package/dist/transforms/toktx_types.js +62 -62
  72. package/dist/transforms/util.d.ts +21 -21
  73. package/dist/transforms/util.js +90 -90
  74. package/dist/utils/compression_utils.d.ts +2 -2
  75. package/dist/utils/compression_utils.js +6 -6
  76. package/dist/utils/fileutils.d.ts +6 -6
  77. package/dist/utils/fileutils.js +141 -141
  78. package/dist/utils/guid.d.ts +1 -1
  79. package/dist/utils/guid.js +5 -5
  80. package/dist/utils/index.d.ts +10 -9
  81. package/dist/utils/index.js +10 -9
  82. package/dist/utils/merge.d.ts +12 -12
  83. package/dist/utils/merge.js +31 -31
  84. package/dist/utils/mesh.d.ts +13 -13
  85. package/dist/utils/mesh.js +107 -107
  86. package/dist/utils/nodeio.d.ts +5 -5
  87. package/dist/utils/nodeio.js +14 -14
  88. package/dist/utils/stats.d.ts +54 -53
  89. package/dist/utils/stats.js +191 -166
  90. package/dist/utils/texture.d.ts +2 -2
  91. package/dist/utils/texture.js +8 -8
  92. package/dist/utils/validate.d.ts +5 -0
  93. package/dist/utils/validate.js +16 -0
  94. package/dist/utils/version.d.ts +1 -1
  95. package/dist/utils/version.js +5 -5
  96. package/package.json +77 -76
  97. package/scripts/clear-caches.mjs +3 -3
  98. package/scripts/defaults.mjs +11 -11
  99. package/scripts/fileutils.mjs +5 -5
  100. package/scripts/index.mjs +41 -41
  101. package/scripts/limit-caches.mjs +3 -3
  102. package/scripts/make-progressive.mjs +16 -16
  103. package/scripts/pack-gltf.mjs +107 -107
  104. package/tsconfig.json +19 -19
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,108 +1,108 @@
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").Stats}
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
- file_stats: null
87
- })
88
- }
89
-
90
- const inputArgs = args.slice(2);
91
- let failed = false;
92
- const logger = new Logger(Verbosity.INFO);
93
-
94
- foreachGLTF(inputArgs, async (file) => {
95
- const res = await packFile(file);
96
- if (!res) failed = true;
97
- }).then(async () => {
98
- if (allowCaching) {
99
- limitCacheSize();
100
- }
101
- printStats(stats, logger, config);
102
- if (failed) {
103
- process.exit(1);
104
- }
105
- }).catch(err => {
106
- console.error("ERR: packing failed: " + err.message);
107
- 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").Stats}
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
+ file_stats: null
87
+ })
88
+ }
89
+
90
+ const inputArgs = args.slice(2);
91
+ let failed = false;
92
+ const logger = new Logger(Verbosity.INFO);
93
+
94
+ foreachGLTF(inputArgs, async (file) => {
95
+ const res = await packFile(file);
96
+ if (!res) failed = true;
97
+ }).then(async () => {
98
+ if (allowCaching) {
99
+ limitCacheSize();
100
+ }
101
+ printStats(stats, logger, config);
102
+ if (failed) {
103
+ process.exit(1);
104
+ }
105
+ }).catch(err => {
106
+ console.error("ERR: packing failed: " + err.message);
107
+ if (debug) throw err;
108
108
  });
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
  }