@needle-tools/gltf-build-pipeline 3.0.1 → 3.0.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 +13 -0
- package/dist/cli/index.js +116 -115
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ 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
|
+
## [3.0.2] - 2026-10-15
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Remote `.exr` references in opaque extensions (e.g. a `RemoteSkybox` https URL) are no longer joined onto the input directory and reported as `External EXR not found`. Only relative paths are resolved and injected for PMREM; absolute and remote URLs are left untouched.
|
|
11
|
+
|
|
12
|
+
## [3.0.1] - 2026-08-10
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Fresh installs failing at the first texture operation with `colourspace: parameter space not set`. `ndarray-pixels@5.2.0` moved its `sharp` requirement to `^0.35.0` in a minor release, so npm installed a second `sharp`/libvips alongside ours and both native addons loaded into the same process with incompatible `VipsInterpretation` enums.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- All runtime and optional dependencies are now pinned to exact versions to prevent upstream minor releases from changing the installed dependency tree.
|
|
19
|
+
|
|
7
20
|
## [3.0.0] - 2026-06-23
|
|
8
21
|
|
|
9
22
|
First stable 3.0 release. Summary of the headline changes across the 3.0 alpha/beta cycle.
|
package/dist/cli/index.js
CHANGED
|
@@ -123,9 +123,109 @@ function testAssert(condition, message) {
|
|
|
123
123
|
throw new TestAssertionError(`Assertion failed: ${message}`);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// src/utils/fileutils.ts
|
|
127
|
+
import { existsSync, statSync, readdirSync, readFileSync, mkdirSync, rmSync } from "fs";
|
|
128
|
+
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
129
|
+
import { dirname, isAbsolute, join } from "path";
|
|
130
|
+
function getOutputPath(filepath, outDirOrFile, opts) {
|
|
131
|
+
if (!outDirOrFile)
|
|
132
|
+
return filepath;
|
|
133
|
+
if (!isDirectory(outDirOrFile))
|
|
134
|
+
return outDirOrFile;
|
|
135
|
+
let filename = getFileName(filepath);
|
|
136
|
+
return opts?.create != !1 && !existsSync(outDirOrFile) && mkdirSync(outDirOrFile, { recursive: !0 }), join(outDirOrFile, filename);
|
|
137
|
+
}
|
|
138
|
+
function getFileName(filepath) {
|
|
139
|
+
let parts = filepath.replaceAll("\\", "/").split("/");
|
|
140
|
+
return parts[parts.length - 1];
|
|
141
|
+
}
|
|
142
|
+
function parseInputPaths(raw) {
|
|
143
|
+
if (!raw.includes(",")) return [raw];
|
|
144
|
+
let segments = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
145
|
+
return segments.length < 2 ? [raw] : !segments.some((s) => existsSync(s)) && existsSync(raw) ? [raw] : segments;
|
|
146
|
+
}
|
|
147
|
+
async function foreachGLTF(args, callback) {
|
|
148
|
+
let initDir = process.env.INIT_CWD, context = {
|
|
149
|
+
baseDirectory: initDir,
|
|
150
|
+
files: []
|
|
151
|
+
};
|
|
152
|
+
if (Array.isArray(args))
|
|
153
|
+
for (let arg of args)
|
|
154
|
+
await testEntry(arg, context);
|
|
155
|
+
else typeof args == "string" && await testEntry(args, context);
|
|
156
|
+
if (context.files?.length <= 0 && context.baseDirectory) {
|
|
157
|
+
let needleConfigPath = context.baseDirectory + "/needle.config.json";
|
|
158
|
+
if (existsSync(needleConfigPath)) {
|
|
159
|
+
let buildDirectory = JSON.parse(readFileSync(needleConfigPath, "utf8")).buildDirectory;
|
|
160
|
+
if (buildDirectory?.length)
|
|
161
|
+
if (existsSync(buildDirectory))
|
|
162
|
+
console.log("INFO: Using build directory from needle.config.json: " + buildDirectory), await testEntry(buildDirectory, context);
|
|
163
|
+
else {
|
|
164
|
+
let newPath = context.baseDirectory + "/" + buildDirectory;
|
|
165
|
+
existsSync(newPath) && (console.log("INFO: Using build directory from needle.config.json: " + newPath), await testEntry(newPath, context));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (context.files.length <= 0)
|
|
170
|
+
console.log(`WARN: No glTF files found. Make sure to invoke with a valid path to a glTF file or directory.
|
|
171
|
+
Base Directory: ${context.baseDirectory}
|
|
172
|
+
Paths can be relative to "${initDir}"`);
|
|
173
|
+
else
|
|
174
|
+
for (let file of context.files)
|
|
175
|
+
await callback(file);
|
|
176
|
+
}
|
|
177
|
+
async function testEntry(entry, context) {
|
|
178
|
+
if (entry.startsWith("--"))
|
|
179
|
+
return !1;
|
|
180
|
+
if ((entry === "." || entry === "./") && context.baseDirectory && (entry = context.baseDirectory), existsSync(entry) === !1) {
|
|
181
|
+
if (context.baseDirectory === void 0)
|
|
182
|
+
return console.log("WARN: Path does not exist: " + entry), !1;
|
|
183
|
+
let newPath = context.baseDirectory + "/" + entry;
|
|
184
|
+
if (existsSync(newPath) === !1)
|
|
185
|
+
return console.log(`INFO: Resolved path failed: "${entry}" -> ${newPath} (doesnt exist or is locked by another process)`), !1;
|
|
186
|
+
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`), entry = newPath;
|
|
187
|
+
} else if (!isAbsolute(entry) && context.baseDirectory) {
|
|
188
|
+
let newPath = context.baseDirectory + "/" + entry;
|
|
189
|
+
if (console.log(`INFO: Resolved path: ${entry} -> ${newPath}`), entry = newPath, !existsSync(entry))
|
|
190
|
+
return !1;
|
|
191
|
+
}
|
|
192
|
+
if (entry.endsWith(".glb") || entry.endsWith(".gltf") || entry.endsWith(".vrm"))
|
|
193
|
+
context.files.push(entry);
|
|
194
|
+
else if (statSync(entry).isDirectory()) {
|
|
195
|
+
if (entry.endsWith("node_modules"))
|
|
196
|
+
return !1;
|
|
197
|
+
let files = readdirSync(entry);
|
|
198
|
+
for (let file of files)
|
|
199
|
+
await testEntry(entry + "/" + file, context);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function replaceExtension(filepath, newExtension) {
|
|
203
|
+
let parts = filepath.split(".");
|
|
204
|
+
return parts.pop(), parts.join(".") + "." + newExtension;
|
|
205
|
+
}
|
|
206
|
+
function isDirectory(path8) {
|
|
207
|
+
return path8 ? existsSync(path8) ? statSync(path8).isDirectory() : !path8.replaceAll("\\", "/").split("/").pop()?.includes(".") : !1;
|
|
208
|
+
}
|
|
209
|
+
function ensureIsDirectory(path8) {
|
|
210
|
+
return isDirectory(path8) || (path8 = dirname(path8)), existsSync(path8) || mkdirSync(path8, { recursive: !0 }), path8;
|
|
211
|
+
}
|
|
212
|
+
async function safeRmDir(dirPath, retries = 3, delayMs = 150) {
|
|
213
|
+
for (let i = 0; i <= retries; i++)
|
|
214
|
+
try {
|
|
215
|
+
existsSync(dirPath) && rmSync(dirPath, { recursive: !0 });
|
|
216
|
+
return;
|
|
217
|
+
} catch (err) {
|
|
218
|
+
if (!(err?.code === "EBUSY" || err?.code === "EPERM") || i === retries) return;
|
|
219
|
+
await setTimeout2(delayMs);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function isRelativeUri(value) {
|
|
223
|
+
return !(!value || /^[a-z]+:/i.test(value) || value.startsWith("//") || value.startsWith("/") || /^[a-z]:[\\/]/i.test(value));
|
|
224
|
+
}
|
|
225
|
+
|
|
126
226
|
// src/extensions/NEEDLE_opaque/NEEDLE_opaque.ts
|
|
127
|
-
import { existsSync, readFileSync } from "fs";
|
|
128
|
-
import { dirname, join } from "path";
|
|
227
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
228
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
129
229
|
|
|
130
230
|
// src/transforms/needle_audio_registry.ts
|
|
131
231
|
var _refs = [];
|
|
@@ -143,7 +243,7 @@ function isAudioUri(value) {
|
|
|
143
243
|
return _audioRegex.test(value);
|
|
144
244
|
}
|
|
145
245
|
function isRelativeAudioUri(value) {
|
|
146
|
-
return
|
|
246
|
+
return isRelativeUri(value);
|
|
147
247
|
}
|
|
148
248
|
|
|
149
249
|
// src/extensions/NEEDLE_opaque/NEEDLE_opaque.ts
|
|
@@ -508,15 +608,15 @@ var GenericWriter = class {
|
|
|
508
608
|
pointer ? (this.debug && console.log("> Register pointer", this.extension_name + "/" + fullPath + " : " + value), pointer?.register(obj, key, fullPath)) : console.warn("WARN: failed registering pointer", fullPath, value);
|
|
509
609
|
}
|
|
510
610
|
if (!isTexturePointer && isAudioUri(value) && isRelativeAudioUri(value)) {
|
|
511
|
-
let inputDir = getExtensionInputFile() ?
|
|
512
|
-
audioPath &&
|
|
611
|
+
let inputDir = getExtensionInputFile() ? dirname2(getExtensionInputFile()) : "", audioPath = inputDir ? join2(inputDir, value) : "";
|
|
612
|
+
audioPath && existsSync2(audioPath) ? (registerAudioRef({ obj, key, sourcePath: audioPath, sourceUri: value }), this.debug && console.log(`Registered external audio "${value}" at ${fullPath}`)) : audioPath && this.document.getLogger().warn(`NEEDLE_opaque: external audio not found: ${audioPath}`);
|
|
513
613
|
}
|
|
514
|
-
if (!isTexturePointer && value.match(/\.exr$/i)) {
|
|
515
|
-
let inputDir = getExtensionInputFile() ?
|
|
516
|
-
if (exrPath &&
|
|
614
|
+
if (!isTexturePointer && value.match(/\.exr$/i) && isRelativeUri(value)) {
|
|
615
|
+
let inputDir = getExtensionInputFile() ? dirname2(getExtensionInputFile()) : "", exrPath = inputDir ? join2(inputDir, value) : "";
|
|
616
|
+
if (exrPath && existsSync2(exrPath)) {
|
|
517
617
|
let texture = this.externalExrTextures.get(value);
|
|
518
618
|
if (!texture) {
|
|
519
|
-
let exrBytes =
|
|
619
|
+
let exrBytes = readFileSync2(exrPath);
|
|
520
620
|
texture = this.document.createTexture(value).setImage(new Uint8Array(exrBytes)).setMimeType("image/exr").setURI(value), this.externalExrTextures.set(value, texture), this.debug && console.log(`Injected external EXR "${value}" as Texture`);
|
|
521
621
|
}
|
|
522
622
|
prop.setReference(`exr_${value}`, texture, { channels: TextureChannel.R | TextureChannel.G | TextureChannel.B | TextureChannel.A });
|
|
@@ -1026,8 +1126,8 @@ var EXTENSION_NAME5 = "NEEDLE_pmrem", NEEDLE_pmrem = class extends Extension7 {
|
|
|
1026
1126
|
|
|
1027
1127
|
// src/extensions/NEEDLE_lightmaps/index.ts
|
|
1028
1128
|
import { Extension as Extension8, ExtensionProperty as ExtensionProperty7, PropertyType as PropertyType9, TextureChannel as TextureChannel2 } from "@gltf-transform/core";
|
|
1029
|
-
import { existsSync as
|
|
1030
|
-
import { join as
|
|
1129
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
1130
|
+
import { join as join3, dirname as dirname3 } from "path";
|
|
1031
1131
|
var EXTENSION_NAME6 = "NEEDLE_lightmaps", LightmapProperty = class extends ExtensionProperty7 {
|
|
1032
1132
|
static EXTENSION_NAME = EXTENSION_NAME6;
|
|
1033
1133
|
propertyType = "LightmapProperty";
|
|
@@ -1059,15 +1159,15 @@ var EXTENSION_NAME6 = "NEEDLE_lightmaps", LightmapProperty = class extends Exten
|
|
|
1059
1159
|
preread(context, _propertyType) {
|
|
1060
1160
|
let json = context.jsonDoc.json, ext = json.extensions?.[EXTENSION_NAME6];
|
|
1061
1161
|
if (!ext?.textures) return this;
|
|
1062
|
-
let inputFile = getExtensionInputFile(), inputDir = inputFile ?
|
|
1162
|
+
let inputFile = getExtensionInputFile(), inputDir = inputFile ? dirname3(inputFile) : "";
|
|
1063
1163
|
for (let entry of ext.textures) {
|
|
1064
1164
|
if (entry.pointer.startsWith("/") || entry.pointer.startsWith("textures/") || !entry.pointer.match(/\.exr$/i)) continue;
|
|
1065
|
-
let exrPath = inputDir ?
|
|
1066
|
-
if (!exrPath || !
|
|
1165
|
+
let exrPath = inputDir ? join3(inputDir, entry.pointer) : "";
|
|
1166
|
+
if (!exrPath || !existsSync3(exrPath)) {
|
|
1067
1167
|
this.document.getLogger().error(`NEEDLE_lightmaps: External EXR not found: ${exrPath || entry.pointer}`), testAssert(!1, `NEEDLE_lightmaps: External EXR not found: ${exrPath || entry.pointer}`);
|
|
1068
1168
|
continue;
|
|
1069
1169
|
}
|
|
1070
|
-
let exrBytes =
|
|
1170
|
+
let exrBytes = readFileSync3(exrPath);
|
|
1071
1171
|
json.images = json.images || [], json.textures = json.textures || [];
|
|
1072
1172
|
let imageIndex = json.images.length;
|
|
1073
1173
|
json.images.push({
|
|
@@ -1194,7 +1294,7 @@ function registerExtensions(node) {
|
|
|
1194
1294
|
import { createTransform } from "@gltf-transform/functions";
|
|
1195
1295
|
|
|
1196
1296
|
// src/utils/version.gen.ts
|
|
1197
|
-
var version = "3.0.
|
|
1297
|
+
var version = "3.0.2";
|
|
1198
1298
|
|
|
1199
1299
|
// src/utils/version.ts
|
|
1200
1300
|
function getVersion(_marklocal = !0) {
|
|
@@ -1393,105 +1493,6 @@ import { BufferUtils as BufferUtils2, FileUtils, ImageUtils as ImageUtils3, uuid
|
|
|
1393
1493
|
import { listTextureSlots as listTextureSlots2, getTextureChannelMask, fitPowerOfTwo, TextureResizeFilter as TextureResizeFilter3 } from "@gltf-transform/functions";
|
|
1394
1494
|
import { KHRTextureBasisu } from "@gltf-transform/extensions";
|
|
1395
1495
|
import { existsSync as existsSync7, mkdirSync as mkdirSync5 } from "fs";
|
|
1396
|
-
|
|
1397
|
-
// src/utils/fileutils.ts
|
|
1398
|
-
import { existsSync as existsSync3, statSync, readdirSync, readFileSync as readFileSync3, mkdirSync, rmSync } from "fs";
|
|
1399
|
-
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
1400
|
-
import { dirname as dirname3, isAbsolute, join as join3 } from "path";
|
|
1401
|
-
function getOutputPath(filepath, outDirOrFile, opts) {
|
|
1402
|
-
if (!outDirOrFile)
|
|
1403
|
-
return filepath;
|
|
1404
|
-
if (!isDirectory(outDirOrFile))
|
|
1405
|
-
return outDirOrFile;
|
|
1406
|
-
let filename = getFileName(filepath);
|
|
1407
|
-
return opts?.create != !1 && !existsSync3(outDirOrFile) && mkdirSync(outDirOrFile, { recursive: !0 }), join3(outDirOrFile, filename);
|
|
1408
|
-
}
|
|
1409
|
-
function getFileName(filepath) {
|
|
1410
|
-
let parts = filepath.replaceAll("\\", "/").split("/");
|
|
1411
|
-
return parts[parts.length - 1];
|
|
1412
|
-
}
|
|
1413
|
-
function parseInputPaths(raw) {
|
|
1414
|
-
if (!raw.includes(",")) return [raw];
|
|
1415
|
-
let segments = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
1416
|
-
return segments.length < 2 ? [raw] : !segments.some((s) => existsSync3(s)) && existsSync3(raw) ? [raw] : segments;
|
|
1417
|
-
}
|
|
1418
|
-
async function foreachGLTF(args, callback) {
|
|
1419
|
-
let initDir = process.env.INIT_CWD, context = {
|
|
1420
|
-
baseDirectory: initDir,
|
|
1421
|
-
files: []
|
|
1422
|
-
};
|
|
1423
|
-
if (Array.isArray(args))
|
|
1424
|
-
for (let arg of args)
|
|
1425
|
-
await testEntry(arg, context);
|
|
1426
|
-
else typeof args == "string" && await testEntry(args, context);
|
|
1427
|
-
if (context.files?.length <= 0 && context.baseDirectory) {
|
|
1428
|
-
let needleConfigPath = context.baseDirectory + "/needle.config.json";
|
|
1429
|
-
if (existsSync3(needleConfigPath)) {
|
|
1430
|
-
let buildDirectory = JSON.parse(readFileSync3(needleConfigPath, "utf8")).buildDirectory;
|
|
1431
|
-
if (buildDirectory?.length)
|
|
1432
|
-
if (existsSync3(buildDirectory))
|
|
1433
|
-
console.log("INFO: Using build directory from needle.config.json: " + buildDirectory), await testEntry(buildDirectory, context);
|
|
1434
|
-
else {
|
|
1435
|
-
let newPath = context.baseDirectory + "/" + buildDirectory;
|
|
1436
|
-
existsSync3(newPath) && (console.log("INFO: Using build directory from needle.config.json: " + newPath), await testEntry(newPath, context));
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
if (context.files.length <= 0)
|
|
1441
|
-
console.log(`WARN: No glTF files found. Make sure to invoke with a valid path to a glTF file or directory.
|
|
1442
|
-
Base Directory: ${context.baseDirectory}
|
|
1443
|
-
Paths can be relative to "${initDir}"`);
|
|
1444
|
-
else
|
|
1445
|
-
for (let file of context.files)
|
|
1446
|
-
await callback(file);
|
|
1447
|
-
}
|
|
1448
|
-
async function testEntry(entry, context) {
|
|
1449
|
-
if (entry.startsWith("--"))
|
|
1450
|
-
return !1;
|
|
1451
|
-
if ((entry === "." || entry === "./") && context.baseDirectory && (entry = context.baseDirectory), existsSync3(entry) === !1) {
|
|
1452
|
-
if (context.baseDirectory === void 0)
|
|
1453
|
-
return console.log("WARN: Path does not exist: " + entry), !1;
|
|
1454
|
-
let newPath = context.baseDirectory + "/" + entry;
|
|
1455
|
-
if (existsSync3(newPath) === !1)
|
|
1456
|
-
return console.log(`INFO: Resolved path failed: "${entry}" -> ${newPath} (doesnt exist or is locked by another process)`), !1;
|
|
1457
|
-
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`), entry = newPath;
|
|
1458
|
-
} else if (!isAbsolute(entry) && context.baseDirectory) {
|
|
1459
|
-
let newPath = context.baseDirectory + "/" + entry;
|
|
1460
|
-
if (console.log(`INFO: Resolved path: ${entry} -> ${newPath}`), entry = newPath, !existsSync3(entry))
|
|
1461
|
-
return !1;
|
|
1462
|
-
}
|
|
1463
|
-
if (entry.endsWith(".glb") || entry.endsWith(".gltf") || entry.endsWith(".vrm"))
|
|
1464
|
-
context.files.push(entry);
|
|
1465
|
-
else if (statSync(entry).isDirectory()) {
|
|
1466
|
-
if (entry.endsWith("node_modules"))
|
|
1467
|
-
return !1;
|
|
1468
|
-
let files = readdirSync(entry);
|
|
1469
|
-
for (let file of files)
|
|
1470
|
-
await testEntry(entry + "/" + file, context);
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
function replaceExtension(filepath, newExtension) {
|
|
1474
|
-
let parts = filepath.split(".");
|
|
1475
|
-
return parts.pop(), parts.join(".") + "." + newExtension;
|
|
1476
|
-
}
|
|
1477
|
-
function isDirectory(path8) {
|
|
1478
|
-
return path8 ? existsSync3(path8) ? statSync(path8).isDirectory() : !path8.replaceAll("\\", "/").split("/").pop()?.includes(".") : !1;
|
|
1479
|
-
}
|
|
1480
|
-
function ensureIsDirectory(path8) {
|
|
1481
|
-
return isDirectory(path8) || (path8 = dirname3(path8)), existsSync3(path8) || mkdirSync(path8, { recursive: !0 }), path8;
|
|
1482
|
-
}
|
|
1483
|
-
async function safeRmDir(dirPath, retries = 3, delayMs = 150) {
|
|
1484
|
-
for (let i = 0; i <= retries; i++)
|
|
1485
|
-
try {
|
|
1486
|
-
existsSync3(dirPath) && rmSync(dirPath, { recursive: !0 });
|
|
1487
|
-
return;
|
|
1488
|
-
} catch (err) {
|
|
1489
|
-
if (!(err?.code === "EBUSY" || err?.code === "EPERM") || i === retries) return;
|
|
1490
|
-
await setTimeout2(delayMs);
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
// src/transforms/needle_toktx.ts
|
|
1495
1496
|
import fs2 from "fs/promises";
|
|
1496
1497
|
import os3 from "os";
|
|
1497
1498
|
import tmp3 from "tmp";
|
package/package.json
CHANGED