@needle-tools/gltf-build-pipeline 2.4.0-alpha.2 → 2.4.0-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.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ 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.4.0-beta] - 2023-08-13
|
|
8
|
+
- fix: issue where a mesh lod is removed during second processing of a directory that contains existing mesh lods
|
|
9
|
+
|
|
10
|
+
## [2.4.0-alpha.3] - 2023-08-11
|
|
11
|
+
- fix: issue where files would not correctly be overriden in subdirectories when no output directory was specified
|
|
12
|
+
|
|
7
13
|
## [2.4.0-alpha.2] - 2023-06-29
|
|
8
14
|
- fix: prevent joining/flattening of progressive assets
|
|
9
15
|
|
package/dist/cli/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import { calculateStats, packGLTF } from "../scripts/index.js";
|
|
|
4
4
|
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
|
-
import { make_progressive } from '../transforms/needle_progressive.js';
|
|
7
|
+
import { isLOD, make_progressive } from '../transforms/needle_progressive.js';
|
|
8
8
|
import { cacheSizeLimit, clearCache, limitCacheSize } from '../cache/cache.js';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
9
10
|
import { ensureIsDirectory, foreachGLTF, isDirectory } from '../utils/fileutils.js';
|
|
10
11
|
import path, { resolve } from 'path';
|
|
11
12
|
import { ERROR_CODES } from '../constants.js';
|
|
@@ -91,15 +92,19 @@ Each version will be compressed and written to the output directory.
|
|
|
91
92
|
config.usecase = options.usecase.toString();
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
let output = args.output?.toString() || input;
|
|
95
95
|
const inputIsDirectory = isDirectory(input);
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
let output = args.output?.toString();
|
|
97
|
+
// If the input path is a filepath and no specific output is defined we set output to the input file
|
|
98
|
+
if (!inputIsDirectory && !output) {
|
|
99
|
+
output = input;
|
|
100
|
+
}
|
|
101
|
+
const outputIsDirectory = output && isDirectory(output);
|
|
102
|
+
if (inputIsDirectory && output && !outputIsDirectory) {
|
|
98
103
|
logger.error("When <input> is a directory then <output> must also be a directory");
|
|
99
104
|
process.exit(ERROR_CODES.INVALID_ARGS);
|
|
100
105
|
}
|
|
101
106
|
// Handle the output bath being relative to the input path
|
|
102
|
-
if (path.isAbsolute(output) === false) {
|
|
107
|
+
if (output && path.isAbsolute(output) === false) {
|
|
103
108
|
const base = ensureIsDirectory(input);
|
|
104
109
|
output = resolve(base, output);
|
|
105
110
|
}
|
|
@@ -108,6 +113,20 @@ Each version will be compressed and written to the output directory.
|
|
|
108
113
|
const debug = options.debug === true;
|
|
109
114
|
const verbose = options.verbose === true;
|
|
110
115
|
await foreachGLTF(input, async (file) => {
|
|
116
|
+
if (!existsSync(file)) {
|
|
117
|
+
// Safeguard if we run compression in a souce directory that already has progressive assets
|
|
118
|
+
// Here it can happen that a LOD file is generated with the same GUID at the moment
|
|
119
|
+
// And then later removed because simplification is too small.
|
|
120
|
+
// See https://linear.app/needle/issue/NE-5518
|
|
121
|
+
if (isLOD(file)) {
|
|
122
|
+
logger.warn(`WARN: Ignore previously found file that does not exist anymore: \"${file}\"`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
logger.error(`ERR: Previously found file is now missing: \"${file}\"`);
|
|
127
|
+
process.exit(ERROR_CODES.LOST_FILE);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
111
130
|
logger.info("→ Transform " + file);
|
|
112
131
|
const progressive_results = new Array();
|
|
113
132
|
if (options.progressive === true) {
|
|
@@ -117,6 +136,7 @@ Each version will be compressed and written to the output directory.
|
|
|
117
136
|
results: progressive_results,
|
|
118
137
|
config,
|
|
119
138
|
debug,
|
|
139
|
+
verbose,
|
|
120
140
|
useCache,
|
|
121
141
|
}).catch(err => {
|
|
122
142
|
logger.error(err);
|
|
@@ -124,6 +144,9 @@ Each version will be compressed and written to the output directory.
|
|
|
124
144
|
}) === false) {
|
|
125
145
|
process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
|
|
126
146
|
}
|
|
147
|
+
if (verbose) {
|
|
148
|
+
console.log("Progressive results:\n", progressive_results);
|
|
149
|
+
}
|
|
127
150
|
}
|
|
128
151
|
if (options.compress === true) {
|
|
129
152
|
const opts = {
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function packGLTF(inputFile, outputFile, options) {
|
|
|
17
17
|
}
|
|
18
18
|
const { debug, stats, packedFiles, useCache, logger } = options;
|
|
19
19
|
if (!existsSync(inputFile)) {
|
|
20
|
-
logger.error(
|
|
20
|
+
logger.error(`WARN: can not pack, file does not exist: \"${inputFile}\"`);
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
// check if it's in the cache.
|
|
@@ -65,7 +65,7 @@ async function onProcess(file, opts) {
|
|
|
65
65
|
if (document) {
|
|
66
66
|
const logger = document.getLogger();
|
|
67
67
|
//@ts-ignore
|
|
68
|
-
logger.verbosity = opts.debug || opts.verbose ? Verbosity.DEBUG : Verbosity.WARN;
|
|
68
|
+
logger.verbosity = (opts.debug || opts.verbose) ? Verbosity.DEBUG : Verbosity.WARN;
|
|
69
69
|
let smallesTextureSize = 128;
|
|
70
70
|
if (opts.config.usecase === "product") {
|
|
71
71
|
smallesTextureSize = 512;
|
|
@@ -652,6 +652,7 @@ export function make_progressive_meshes(filePath, _options, opts) {
|
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
if (shouldOmitLevel) {
|
|
655
|
+
logger.debug(`[${NAME}] Omitting LOD ${level} for \"${mesh.getName()}\" at \"${lodInfo.path}\"`);
|
|
655
656
|
generatedLODInfos.splice(i, 1);
|
|
656
657
|
rmSync(fullPath);
|
|
657
658
|
i--;
|
package/dist/utils/fileutils.js
CHANGED
|
@@ -77,7 +77,7 @@ export async function foreachGLTF(args, callback) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
if (context.files.length <= 0) {
|
|
80
|
-
console.log(
|
|
80
|
+
console.log(`WARN: No glTF files found. Make sure to invoke with a valid path to a glTF file or directory.\nBase Directory: ${context.baseDirectory}\nPaths can be relative to \"${initDir}\"`);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
for (const file of context.files) {
|
|
@@ -99,13 +99,13 @@ async function testEntry(entry, context) {
|
|
|
99
99
|
// If no base directory is defined we cannot try to resolve the path
|
|
100
100
|
if (context.baseDirectory === undefined) {
|
|
101
101
|
console.log("WARN: Path does not exist: " + entry);
|
|
102
|
-
return;
|
|
102
|
+
return false;
|
|
103
103
|
}
|
|
104
104
|
// Try resolve potential relative path
|
|
105
105
|
const newPath = context.baseDirectory + "/" + entry;
|
|
106
106
|
if (existsSync(newPath) === false) {
|
|
107
107
|
console.log(`INFO: Resolved path failed: \"${entry}\" -> ${newPath} (doesnt exist or is locked by another process)`);
|
|
108
|
-
return;
|
|
108
|
+
return false;
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`);
|
|
@@ -122,7 +122,7 @@ async function testEntry(entry, context) {
|
|
|
122
122
|
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`);
|
|
123
123
|
entry = newPath;
|
|
124
124
|
if (!existsSync(entry)) {
|
|
125
|
-
return;
|
|
125
|
+
return false;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -135,7 +135,7 @@ async function testEntry(entry, context) {
|
|
|
135
135
|
if (stat.isDirectory()) {
|
|
136
136
|
// Don't traverse node_modules
|
|
137
137
|
if (entry.endsWith("node_modules")) {
|
|
138
|
-
return;
|
|
138
|
+
return false;
|
|
139
139
|
}
|
|
140
140
|
const files = readdirSync(entry);
|
|
141
141
|
for (const file of files) {
|
|
@@ -153,6 +153,9 @@ export function replaceExtension(filepath, newExtension) {
|
|
|
153
153
|
return parts.join(".") + "." + newExtension;
|
|
154
154
|
}
|
|
155
155
|
export function isDirectory(path) {
|
|
156
|
+
if (!path) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
156
159
|
if (existsSync(path)) {
|
|
157
160
|
return statSync(path).isDirectory();
|
|
158
161
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.4.0-alpha.
|
|
3
|
+
"version": "2.4.0-alpha.4",
|
|
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",
|