@needle-tools/gltf-build-pipeline 2.2.1-alpha.5 → 2.2.1-alpha.6
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
CHANGED
|
@@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [2.2.1-alpha.6] - 2023-06-19
|
|
8
|
+
- fix: WARN if image validation can not run
|
|
9
|
+
|
|
7
10
|
## [2.2.1-alpha.5] - 2023-06-18
|
|
8
11
|
- add: `stats` now includes json and animation size info
|
|
9
12
|
- change: VRM's are compressed with meshopt again
|
package/dist/cache/cache.js
CHANGED
|
@@ -41,8 +41,9 @@ export function limitCacheSize(maxSizeMB = cacheSizeLimit) {
|
|
|
41
41
|
const dir = getCacheDirectory(true);
|
|
42
42
|
console.log(`Limit cache size to ${maxSizeMB.toFixed(2)} MB at ${dir}...`);
|
|
43
43
|
let totalSize = 0;
|
|
44
|
+
const files = new Array();
|
|
44
45
|
function recurseDirectories(dir) {
|
|
45
|
-
|
|
46
|
+
fs.readdirSync(dir).forEach(file => {
|
|
46
47
|
const path = `${dir}/${file}`;
|
|
47
48
|
const stats = statSync(path);
|
|
48
49
|
if (stats.isDirectory()) {
|
|
@@ -50,12 +51,11 @@ export function limitCacheSize(maxSizeMB = cacheSizeLimit) {
|
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
52
53
|
totalSize += stats.size;
|
|
54
|
+
files.push({ path, size: stats.size });
|
|
53
55
|
}
|
|
54
|
-
return { path, size: stats.size };
|
|
55
56
|
});
|
|
56
|
-
return files;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
recurseDirectories(dir);
|
|
59
59
|
const maxSizeInBytes = maxSizeMB * 1024 * 1024;
|
|
60
60
|
console.log(`Current cache size is ${(totalSize / (1024 * 1024)).toFixed(1)} MB`);
|
|
61
61
|
if (totalSize < maxSizeInBytes)
|
|
@@ -67,17 +67,19 @@ export function limitCacheSize(maxSizeMB = cacheSizeLimit) {
|
|
|
67
67
|
});
|
|
68
68
|
const targetSize = maxSizeInBytes * 0.9;
|
|
69
69
|
// remove oldest files first
|
|
70
|
+
let filesRemoved = 0;
|
|
70
71
|
while (totalSize > targetSize) {
|
|
71
72
|
const file = files.shift();
|
|
72
73
|
if (!file)
|
|
73
74
|
break;
|
|
74
|
-
if (fs.statSync(file.path).isDirectory())
|
|
75
|
+
if (fs.statSync(file.path).isDirectory()) {
|
|
75
76
|
continue;
|
|
76
|
-
|
|
77
|
+
}
|
|
78
|
+
filesRemoved++;
|
|
77
79
|
fs.rmSync(file.path);
|
|
78
80
|
totalSize -= file.size;
|
|
79
81
|
}
|
|
80
|
-
console.log(`Cache size reduced to ${(totalSize / (1024 * 1024)).toFixed(1)} MB`);
|
|
82
|
+
console.log(`Cache size reduced to ${(totalSize / (1024 * 1024)).toFixed(1)} MB (${filesRemoved} files removed)`);
|
|
81
83
|
}
|
|
82
84
|
/**
|
|
83
85
|
* Add data to the cache.
|
package/dist/cli/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { printStats, writeFileStatsToFile } from '../utils/stats.js';
|
|
|
5
5
|
import { getVersion } from '../utils/version.js';
|
|
6
6
|
import { UsecaseOptions, createConfig, getConfig } from '../config/index.js';
|
|
7
7
|
import { make_progressive } from '../transforms/needle_progressive.js';
|
|
8
|
-
import { cacheSizeLimit, clearCache } from '../cache/cache.js';
|
|
8
|
+
import { cacheSizeLimit, clearCache, limitCacheSize } from '../cache/cache.js';
|
|
9
9
|
import { statSync } from 'fs';
|
|
10
10
|
import { foreachGLTF, isDirectory } from '../utils/fileutils.js';
|
|
11
11
|
import path, { dirname } from 'path';
|
|
@@ -135,6 +135,7 @@ Each version will be compressed and written to the output directory.
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
printStats(stats, logger, config);
|
|
138
|
+
limitCacheSize();
|
|
138
139
|
});
|
|
139
140
|
program.run().catch(err => {
|
|
140
141
|
// Since we still invoke this package with paths when running npm scripts we need to ignore this error
|
|
@@ -2,7 +2,7 @@ import { BufferUtils, FileUtils, ImageUtils, uuid } from "@gltf-transform/core";
|
|
|
2
2
|
import { listTextureSlots, getTextureChannelMask, fitPowerOfTwo, TextureResizeFilter } from "@gltf-transform/functions";
|
|
3
3
|
import { KHRTextureBasisu } from "@gltf-transform/extensions";
|
|
4
4
|
import { checkKTXSoftware, createParams, KTX_SOFTWARE_VERSION_MIN, Mode } from "./toktx.js";
|
|
5
|
-
import { existsSync, mkdirSync } from "fs";
|
|
5
|
+
import { existsSync, mkdirSync, rmdirSync } from "fs";
|
|
6
6
|
import { formatBytes, spawn, waitExit } from './util.js';
|
|
7
7
|
import { ETC1S_DEFAULTS, UASTC_DEFAULTS } from "./toktx_types.js";
|
|
8
8
|
import fs from 'fs/promises';
|
|
@@ -18,6 +18,7 @@ export class NeedleToktxContext {
|
|
|
18
18
|
limit;
|
|
19
19
|
basisuExtension;
|
|
20
20
|
version;
|
|
21
|
+
cacheDirectory;
|
|
21
22
|
tmpPathBase;
|
|
22
23
|
document;
|
|
23
24
|
env;
|
|
@@ -76,6 +77,7 @@ export class NeedleToktxContext {
|
|
|
76
77
|
}
|
|
77
78
|
this.basisuExtension = document.createExtension(KHRTextureBasisu).setRequired(true);
|
|
78
79
|
const tmpDir = `${tmp.tmpdir}/gltf-transform`;
|
|
80
|
+
this.cacheDirectory = tmpDir;
|
|
79
81
|
if (!(existsSync(tmpDir)))
|
|
80
82
|
mkdirSync(tmpDir);
|
|
81
83
|
this.tmpPathBase = tmpDir + "/" + uuid();
|
|
@@ -226,5 +228,8 @@ export class NeedleToktxContext {
|
|
|
226
228
|
if (!usesKTX2) {
|
|
227
229
|
this.basisuExtension?.dispose();
|
|
228
230
|
}
|
|
231
|
+
if (this.cacheDirectory && existsSync(this.cacheDirectory)) {
|
|
232
|
+
rmdirSync(this.cacheDirectory, { recursive: true });
|
|
233
|
+
}
|
|
229
234
|
}
|
|
230
235
|
}
|
package/dist/utils/validate.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.2.1-alpha.
|
|
3
|
+
"version": "2.2.1-alpha.6",
|
|
4
4
|
"description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|