@needle-tools/gltf-build-pipeline 2.1.0-alpha.6 → 2.2.0-alpha.2
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 +7 -0
- package/dist/cli/index.js +118 -0
- package/dist/{src/config → config}/index.d.ts +8 -2
- package/dist/{src/config → config}/index.js +31 -15
- package/dist/{src/transforms → transforms}/needle_mesh_transform.js +1 -1
- package/dist/{src/transforms → transforms}/needle_progressive.js +20 -18
- package/dist/{src/transforms → transforms}/needle_toktx.js +1 -1
- package/dist/{src/transforms → transforms}/toktx.d.ts +1 -1
- package/dist/{src/transforms → transforms}/toktx.js +2 -6
- package/dist/transforms/toktx_types.d.ts +78 -0
- package/dist/transforms/toktx_types.js +62 -0
- package/dist/{src/utils → utils}/version.js +1 -1
- package/package.json +10 -9
- package/scripts/clear-caches.mjs +1 -1
- package/scripts/defaults.mjs +2 -2
- package/scripts/fileutils.mjs +1 -1
- package/scripts/index.mjs +1 -1
- package/scripts/limit-caches.mjs +1 -1
- package/scripts/make-progressive.mjs +2 -2
- package/scripts/pack-gltf.mjs +2 -2
- package/tsconfig.json +7 -3
- package/dist/___config.json +0 -3
- package/dist/package.json +0 -75
- package/dist/src/cli/index.js +0 -192
- /package/dist/{src/cache → cache}/cache.d.ts +0 -0
- /package/dist/{src/cache → cache}/cache.js +0 -0
- /package/dist/{src/cache → cache}/index.d.ts +0 -0
- /package/dist/{src/cache → cache}/index.js +0 -0
- /package/dist/{src/cli → cli}/index.d.ts +0 -0
- /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/{src/constants.js → constants.js} +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_compression_texture/NEEDLE_compression_texture.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_compression_texture/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_compression_texture/index.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_mesh_compression/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_mesh_compression/index.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_opaque/NEEDLE_opaque.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_opaque/NEEDLE_opaque.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_opaque/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_opaque/index.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive/NEEDLE_progressive.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive/NEEDLE_progressive.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive/index.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive_mesh_settings/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive_mesh_settings/index.js +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive_texture_settings/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/NEEDLE_progressive_texture_settings/index.js +0 -0
- /package/dist/{src/extensions → extensions}/index.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/index.js +0 -0
- /package/dist/{src/extensions → extensions}/utils.d.ts +0 -0
- /package/dist/{src/extensions → extensions}/utils.js +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/scripts → scripts}/index.d.ts +0 -0
- /package/dist/{src/scripts → scripts}/index.js +0 -0
- /package/dist/{src/scripts → scripts}/pack-gltf.d.ts +0 -0
- /package/dist/{src/scripts → scripts}/pack-gltf.js +0 -0
- /package/dist/{src/transforms → transforms}/index.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/index.js +0 -0
- /package/dist/{src/transforms → transforms}/needle_animation_transform.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_animation_transform.js +0 -0
- /package/dist/{src/transforms → transforms}/needle_asset.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_asset.js +0 -0
- /package/dist/{src/transforms → transforms}/needle_common.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_common.js +0 -0
- /package/dist/{src/transforms → transforms}/needle_mesh_transform.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_progressive.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_texture_transform.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_texture_transform.js +0 -0
- /package/dist/{src/transforms → transforms}/needle_toktx.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_webp.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/needle_webp.js +0 -0
- /package/dist/{src/transforms → transforms}/util.d.ts +0 -0
- /package/dist/{src/transforms → transforms}/util.js +0 -0
- /package/dist/{src/utils → utils}/compression_utils.d.ts +0 -0
- /package/dist/{src/utils → utils}/compression_utils.js +0 -0
- /package/dist/{src/utils → utils}/fileutils.d.ts +0 -0
- /package/dist/{src/utils → utils}/fileutils.js +0 -0
- /package/dist/{src/utils → utils}/guid.d.ts +0 -0
- /package/dist/{src/utils → utils}/guid.js +0 -0
- /package/dist/{src/utils → utils}/index.d.ts +0 -0
- /package/dist/{src/utils → utils}/index.js +0 -0
- /package/dist/{src/utils → utils}/mesh.d.ts +0 -0
- /package/dist/{src/utils → utils}/mesh.js +0 -0
- /package/dist/{src/utils → utils}/nodeio.d.ts +0 -0
- /package/dist/{src/utils → utils}/nodeio.js +0 -0
- /package/dist/{src/utils → utils}/stats.d.ts +0 -0
- /package/dist/{src/utils → utils}/stats.js +0 -0
- /package/dist/{src/utils → utils}/texture.d.ts +0 -0
- /package/dist/{src/utils → utils}/texture.js +0 -0
- /package/dist/{src/utils → utils}/version.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha.2",
|
|
4
4
|
"description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
|
|
5
|
-
"main": "index.
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"readme": "README.md",
|
|
8
8
|
"author": {
|
|
@@ -15,14 +15,17 @@
|
|
|
15
15
|
"url": "git+https://github.com/needle-tools/needle-gltf-extensions.git"
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
18
|
-
"gltf-build-pipeline": "
|
|
19
|
-
"needle-gltf": "
|
|
18
|
+
"gltf-build-pipeline": "dist/cli/index.js",
|
|
19
|
+
"needle-gltf": "dist/cli/index.js"
|
|
20
|
+
},
|
|
21
|
+
"imports": {
|
|
22
|
+
"#package.json": "./package.json"
|
|
20
23
|
},
|
|
21
24
|
"scripts": {
|
|
22
25
|
"start": "node scripts/index.mjs",
|
|
23
26
|
"dev": "npm-watch compile",
|
|
24
|
-
"compile": "tsc || exit 1",
|
|
25
|
-
"clear-caches":
|
|
27
|
+
"compile": "node tools/prebuild.mjs && (tsc || exit 1) && node tools/postbuild.mjs",
|
|
28
|
+
"clear-caches": "node scripts/clear-caches.mjs",
|
|
26
29
|
"limit-caches": "node scripts/limit-caches.mjs",
|
|
27
30
|
"transform": "node scripts/index.mjs",
|
|
28
31
|
"transform:make-progressive": "node scripts/make-progressive.mjs",
|
|
@@ -31,7 +34,6 @@
|
|
|
31
34
|
"dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
|
-
"@img/sharp-win32-x64": "^0.33.4",
|
|
35
37
|
"@types/node": "^18.7.23",
|
|
36
38
|
"npm-watch": "^0.13.0",
|
|
37
39
|
"typescript": "^4.9.5"
|
|
@@ -44,7 +46,6 @@
|
|
|
44
46
|
},
|
|
45
47
|
"dependencies": {
|
|
46
48
|
"@donmccurdy/caporal": "~0.0.10",
|
|
47
|
-
"@gltf-transform/cli": "^4.0.1",
|
|
48
49
|
"@gltf-transform/core": "^4.0.1",
|
|
49
50
|
"@gltf-transform/extensions": "^4.0.1",
|
|
50
51
|
"@gltf-transform/functions": "^4.0.1",
|
|
@@ -72,4 +73,4 @@
|
|
|
72
73
|
"quiet": false
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
}
|
|
76
|
+
}
|
package/scripts/clear-caches.mjs
CHANGED
package/scripts/defaults.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
|
|
2
|
-
import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS } from "../dist/
|
|
3
|
-
import { NEEDLE_progressive } from '../dist/
|
|
2
|
+
import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS } from "../dist/extensions/NEEDLE_opaque/index.js";
|
|
3
|
+
import { NEEDLE_progressive } from '../dist/index.js';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export function registerExtensions(node) {
|
package/scripts/fileutils.mjs
CHANGED
package/scripts/index.mjs
CHANGED
package/scripts/limit-caches.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getConfig, getVersion } from '../dist/
|
|
2
|
-
import { make_progressive } from '../dist/
|
|
1
|
+
import { getConfig, getVersion } from '../dist/index.js';
|
|
2
|
+
import { make_progressive } from '../dist/transforms/needle_progressive.js';
|
|
3
3
|
|
|
4
4
|
const args = process.argv;
|
|
5
5
|
|
package/scripts/pack-gltf.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import commandLineArgs from "command-line-args";
|
|
2
2
|
import { foreachGLTF } from './fileutils.mjs';
|
|
3
|
-
import { getVersion, limitCacheSize, getConfig, packGLTF, printStats } from '../dist/
|
|
3
|
+
import { getVersion, limitCacheSize, getConfig, packGLTF, printStats } from '../dist/index.js';
|
|
4
4
|
import { Logger, Verbosity } from "@gltf-transform/core";
|
|
5
5
|
|
|
6
6
|
console.log(`[Needle Build Pipeline] pack glTF — version ${getVersion()}`)
|
|
@@ -60,7 +60,7 @@ if (noToktx)
|
|
|
60
60
|
const packedFiles = new Set();
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* @type {import("../dist/
|
|
63
|
+
* @type {import("../dist/index.js").Stats}
|
|
64
64
|
*/
|
|
65
65
|
const stats = {
|
|
66
66
|
startTime: Date.now(),
|
package/tsconfig.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ESNext",
|
|
4
|
+
"rootDir": "src",
|
|
4
5
|
"outDir": "dist",
|
|
5
6
|
"declaration": true,
|
|
6
7
|
"moduleResolution": "NodeNext",
|
|
7
8
|
"module": "NodeNext",
|
|
8
9
|
"esModuleInterop": true,
|
|
9
10
|
"skipLibCheck": true,
|
|
10
|
-
"resolveJsonModule": true
|
|
11
|
-
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"lib": [
|
|
13
|
+
"ESNext",
|
|
14
|
+
"DOM"
|
|
15
|
+
],
|
|
12
16
|
},
|
|
13
17
|
"include": [
|
|
14
|
-
"src/index.ts"
|
|
18
|
+
"src/index.ts",
|
|
15
19
|
]
|
|
16
20
|
}
|
package/dist/___config.json
DELETED
package/dist/package.json
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.1.0-alpha.6",
|
|
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
|
-
"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/src/cli/index.js",
|
|
19
|
-
"needle-gltf": "./dist/src/cli/index.js"
|
|
20
|
-
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"start": "node scripts/index.mjs",
|
|
23
|
-
"dev": "npm-watch compile",
|
|
24
|
-
"compile": "tsc || exit 1",
|
|
25
|
-
"clear-caches": "node scripts/clear-caches.mjs",
|
|
26
|
-
"limit-caches": "node scripts/limit-caches.mjs",
|
|
27
|
-
"transform": "node scripts/index.mjs",
|
|
28
|
-
"transform:make-progressive": "node scripts/make-progressive.mjs",
|
|
29
|
-
"transform:pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
|
|
30
|
-
"pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
|
|
31
|
-
"dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@img/sharp-win32-x64": "^0.33.4",
|
|
35
|
-
"@types/node": "^18.7.23",
|
|
36
|
-
"npm-watch": "^0.13.0",
|
|
37
|
-
"typescript": "^4.9.5"
|
|
38
|
-
},
|
|
39
|
-
"optionalDependencies": {
|
|
40
|
-
"@img/sharp-linux-arm": "^0.33.4",
|
|
41
|
-
"@img/sharp-win32-x64": "^0.33.4",
|
|
42
|
-
"@img/sharp-darwin-arm64": "^0.33.4",
|
|
43
|
-
"@img/sharp-darwin-x64": "^0.33.4"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@donmccurdy/caporal": "~0.0.10",
|
|
47
|
-
"@gltf-transform/cli": "^4.0.1",
|
|
48
|
-
"@gltf-transform/core": "^4.0.1",
|
|
49
|
-
"@gltf-transform/extensions": "^4.0.1",
|
|
50
|
-
"@gltf-transform/functions": "^4.0.1",
|
|
51
|
-
"command-exists": "^1.2.9",
|
|
52
|
-
"command-line-args": "^5.2.1",
|
|
53
|
-
"draco3dgltf": "^1.5.3",
|
|
54
|
-
"glob": "^7.2.0",
|
|
55
|
-
"meshoptimizer": "^0.18.1",
|
|
56
|
-
"micromatch": "^4.0.5",
|
|
57
|
-
"ndarray": "^1.0.19",
|
|
58
|
-
"ndarray-lanczos": "^0.3.0",
|
|
59
|
-
"ndarray-pixels": "^2.0.1",
|
|
60
|
-
"p-limit": "3.1.0",
|
|
61
|
-
"semver": "^7.3.7",
|
|
62
|
-
"sharp": "^0.33.4",
|
|
63
|
-
"tmp": "^0.2.1",
|
|
64
|
-
"uuid": "^9.0.1"
|
|
65
|
-
},
|
|
66
|
-
"watch": {
|
|
67
|
-
"compile": {
|
|
68
|
-
"patterns": [
|
|
69
|
-
"src"
|
|
70
|
-
],
|
|
71
|
-
"extensions": "ts",
|
|
72
|
-
"quiet": false
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
package/dist/src/cli/index.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import { program } from '@donmccurdy/caporal';
|
|
3
|
-
import { 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 { make_progressive } from '../transforms/needle_progressive.js';
|
|
8
|
-
import { cacheSizeLimit, clearCache } from '../cache/cache.js';
|
|
9
|
-
import { existsSync, statSync } from 'fs';
|
|
10
|
-
import { foreachGLTF, getDirName } from '../utils/fileutils.js';
|
|
11
|
-
import path, { dirname } 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 verison")
|
|
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("compress", "Compress glTF, GLB or VRM files")
|
|
29
|
-
.help(`
|
|
30
|
-
Compress a single glTF file. The input file is compressed and written to the output file.
|
|
31
|
-
`)
|
|
32
|
-
.argument('<input>', "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed")
|
|
33
|
-
.argument('<output>', "The output file. If not provided, the input file will be overwritten.", { default: "" })
|
|
34
|
-
.option("--usecase <usecase>", `The usecase for the compression allows you to determine how your asset is supposed to be used:\nThis will set compression and transform settings on a high level if no other settings are found.\nPossible options: [${UsecaseOptions.join(", ")}] e.g. \"--usecase ${UsecaseOptions[0]}\"`, { validator: program.STRING })
|
|
35
|
-
.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 })
|
|
36
|
-
.option("--stats", "Output a stats file next to input file (or inside the input directory). It will be named as the input file/directory \"<input>.needle.stats.json\"", { validator: program.BOOLEAN, default: false })
|
|
37
|
-
.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 })
|
|
38
|
-
.option("--debug", "Enable for more verbose outout with \"--debug True\"", { validator: program.BOOLEAN, default: false })
|
|
39
|
-
.action(async ({ logger, args, options }) => {
|
|
40
|
-
logger.info("Transforming glTF file: " + args.input);
|
|
41
|
-
const stats = {
|
|
42
|
-
startTime: Date.now(),
|
|
43
|
-
totalGPUMemoryInMB: 0,
|
|
44
|
-
totalFilesProcessed: 0,
|
|
45
|
-
totalFileSizeInMB: 0,
|
|
46
|
-
totalFileSizeInMBBefore: 0,
|
|
47
|
-
};
|
|
48
|
-
const file = args.input.toString();
|
|
49
|
-
let config = getConfig(options.config?.toString(), file);
|
|
50
|
-
if (options.usecase) {
|
|
51
|
-
logger.info("Using usecase: " + options.usecase);
|
|
52
|
-
config = { ...createConfig(options.usecase.toString()), ...config, };
|
|
53
|
-
if (config.usecase != "default" && config.usecase != options.usecase.toString()) {
|
|
54
|
-
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.`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
config.usecase = options.usecase.toString();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const debug = options.debug === true;
|
|
61
|
-
const isDirectory = statSync(file).isDirectory();
|
|
62
|
-
const outDir = isDirectory ? file : dirname(file);
|
|
63
|
-
let outputIsDirectory = false;
|
|
64
|
-
if (statSync(file).isDirectory() && options.output) {
|
|
65
|
-
if (statSync(options.output.toString()).isDirectory()) {
|
|
66
|
-
outputIsDirectory = true;
|
|
67
|
-
if (!existsSync(options.output.toString())) {
|
|
68
|
-
logger.error("Output directory does not exist: " + options.output.toString());
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
logger.error("--output must be a directory if input is a directory");
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const file_stats = [];
|
|
78
|
-
const set = new Set();
|
|
79
|
-
await foreachGLTF(file, async (file) => {
|
|
80
|
-
let outputFile = args.output?.toString();
|
|
81
|
-
if (!outputFile?.length) {
|
|
82
|
-
outputFile = file;
|
|
83
|
-
}
|
|
84
|
-
if (outputIsDirectory) {
|
|
85
|
-
const filename = file.replaceAll("\\", "/").split("/").pop();
|
|
86
|
-
outputFile = args.output?.toString() + "/" + filename;
|
|
87
|
-
}
|
|
88
|
-
const res = await packGLTF(file, outputFile, {
|
|
89
|
-
config,
|
|
90
|
-
packedFiles: set,
|
|
91
|
-
stats,
|
|
92
|
-
debug,
|
|
93
|
-
useCache: options.cache !== false,
|
|
94
|
-
logger: logger,
|
|
95
|
-
file_stats: file_stats,
|
|
96
|
-
});
|
|
97
|
-
if (res === false) {
|
|
98
|
-
process.exit(ERROR_CODES.PACKING_FAILED);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
printStats(stats, logger, config);
|
|
102
|
-
console.log("Stats: ", options);
|
|
103
|
-
if (options.stats) {
|
|
104
|
-
const statsFile = (isDirectory ? (path.join(file, getDirName(file))) : file) + ".needle.stats.json";
|
|
105
|
-
writeFileStatsToFile(config, file_stats, statsFile);
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
.command("transform", "Transform (progressive loading) and compress glTF, GLB or VRM files")
|
|
109
|
-
.help(`
|
|
110
|
-
This will produce multiple versions of the input file, each with a different level of optimization.
|
|
111
|
-
Each version will be compressed and written to the output directory.
|
|
112
|
-
`)
|
|
113
|
-
.argument('<input>', "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed")
|
|
114
|
-
// .argument('<output>', "The output file. If not provided, the input file will be overwritten.", { default: "" })
|
|
115
|
-
.option("--usecase <usecase>", `The usecase for the compression. This will set the compression settings. Possible options: [${UsecaseOptions.join(", ")}]`, { validator: program.STRING })
|
|
116
|
-
.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 })
|
|
117
|
-
.option("--stats", "Output a stats file next to input file (or inside the input directory). It will be named as the input file/directory \"<input>.needle.stats.json\"", { validator: program.BOOLEAN, default: false })
|
|
118
|
-
.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 })
|
|
119
|
-
.option("--debug", "Enable for more verbose outout with \"--debug True\"", { validator: program.BOOLEAN, default: false })
|
|
120
|
-
.action(async ({ logger, args, options }) => {
|
|
121
|
-
logger.info("Transforming glTF file: " + args.input);
|
|
122
|
-
const stats = {
|
|
123
|
-
startTime: Date.now(),
|
|
124
|
-
totalGPUMemoryInMB: 0,
|
|
125
|
-
totalFilesProcessed: 0,
|
|
126
|
-
totalFileSizeInMB: 0,
|
|
127
|
-
totalFileSizeInMBBefore: 0,
|
|
128
|
-
};
|
|
129
|
-
const file = args.input.toString();
|
|
130
|
-
let config = getConfig(options.config?.toString(), file);
|
|
131
|
-
if (options.usecase) {
|
|
132
|
-
logger.info("Using usecase: " + options.usecase);
|
|
133
|
-
config = { ...createConfig(options.usecase.toString()), ...config, };
|
|
134
|
-
if (config.usecase != "default" && config.usecase != options.usecase.toString()) {
|
|
135
|
-
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.`);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
config.usecase = options.usecase.toString();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const isDirectory = statSync(file).isDirectory();
|
|
142
|
-
const outDir = isDirectory ? file : dirname(file);
|
|
143
|
-
const file_stats = [];
|
|
144
|
-
const set = new Set();
|
|
145
|
-
const useCache = options.cache !== false;
|
|
146
|
-
const debug = options.debug === true;
|
|
147
|
-
await foreachGLTF(file, async (file) => {
|
|
148
|
-
logger.info("→ Transform " + file);
|
|
149
|
-
const progressive_results = new Array();
|
|
150
|
-
await make_progressive({
|
|
151
|
-
path: file,
|
|
152
|
-
results: progressive_results,
|
|
153
|
-
config,
|
|
154
|
-
debug,
|
|
155
|
-
useCache,
|
|
156
|
-
}).catch(err => {
|
|
157
|
-
logger.error(err);
|
|
158
|
-
process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
|
|
159
|
-
});
|
|
160
|
-
const opts = {
|
|
161
|
-
config,
|
|
162
|
-
stats,
|
|
163
|
-
packedFiles: set,
|
|
164
|
-
debug,
|
|
165
|
-
useCache,
|
|
166
|
-
logger: logger,
|
|
167
|
-
file_stats,
|
|
168
|
-
};
|
|
169
|
-
for (const res of progressive_results) {
|
|
170
|
-
if (await packGLTF(res, res, opts) === false) {
|
|
171
|
-
process.exit(ERROR_CODES.PACKING_FAILED);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (await packGLTF(file, file, opts) === false) {
|
|
175
|
-
process.exit(ERROR_CODES.PACKING_FAILED);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
printStats(stats, logger, config);
|
|
179
|
-
if (options.stats) {
|
|
180
|
-
const statsFile = (isDirectory ? (path.join(file, getDirName(file))) : file) + ".needle.stats.json";
|
|
181
|
-
writeFileStatsToFile(config, file_stats, statsFile);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
program.run().catch(err => {
|
|
185
|
-
// Since we still invoke this package with paths when running npm scripts we need to ignore this error
|
|
186
|
-
// We might want to move this code here into an extra package.
|
|
187
|
-
if (err.message.includes("Unknown command") && !err.message.includes("Did you mean")) {
|
|
188
|
-
// ignore
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
throw err;
|
|
192
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{src/extensions → extensions}/NEEDLE_compression_texture/NEEDLE_compression_texture.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{src/extensions → extensions}/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts
RENAMED
|
File without changes
|
/package/dist/{src/extensions → extensions}/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js
RENAMED
|
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
|
|
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
|