@needle-tools/gltf-build-pipeline 3.0.0-next.47d9f08 → 3.0.0-next.7e6c33d
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 +25 -0
- package/README.md +13 -1
- package/dist/cli/index.js +136 -58
- package/package.json +1 -1
- package/tools/pmrem/pkg/pmrem_wasm.d.ts +25 -0
- package/tools/pmrem/pkg/pmrem_wasm.js +110 -0
- package/tools/pmrem/pkg/pmrem_wasm_bg.wasm +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,31 @@ 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.0-alpha] - 2026-05-26
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
- CLI now requires JWT authentication via `--auth-token`
|
|
11
|
+
- The package ships as a CLI-only right now
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- **Job cache**: file-level cache that skips an entire transform when the same input + config was already processed
|
|
15
|
+
- **Audio compression**: external audio references are re-encoded to Opus/OGG; supported input formats are WAV, FLAC, and AIFF (lossy formats pass through unchanged)
|
|
16
|
+
- **PMREM standalone CLI command**: `needle-gltf pmrem <input>` converts EXR and Radiance HDR files to PMREM KTX2
|
|
17
|
+
- **Multiple file inputs**: `transform` now accepts comma-separated paths (e.g. `needle-gltf transform a.glb,b.glb out/`)
|
|
18
|
+
- Auth surfaces clean "token expired" message when the JWT `exp` claim is past
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Cache restore now also restores external files (KTX2, PMREM) alongside the main GLB
|
|
22
|
+
- PMREM NaN generation that caused artifacts in certain EXR files
|
|
23
|
+
- xxHash WASM init race condition, now resolved with `ensureHashReady` gate
|
|
24
|
+
- LOD file detection no longer matches against directory names
|
|
25
|
+
- toktx: probes `ktx` binary to match what the compression step actually runs
|
|
26
|
+
- `getConfig` now returns a fresh copy instead of a shared mutable reference
|
|
27
|
+
- `stats` tolerates undefined errors/warnings in `addFrom`
|
|
28
|
+
- Material-only GLBs are no longer incorrectly pruned
|
|
29
|
+
- `createOpaqueExtension` return type fixed, downstream casts removed
|
|
30
|
+
- `stats` command exits with code 0
|
|
31
|
+
|
|
7
32
|
## [2.15.0] - 2026-03-20
|
|
8
33
|
- add: EXR environment map compression (PMREM / FASTHDR) for Needle Engine, supporting both Unity and Blender exports
|
|
9
34
|
- fix: cache hashing stability (circular reference handling)
|
package/README.md
CHANGED
|
@@ -26,6 +26,18 @@ To load progressively enhanced glTF files in Needle Engine or another three.js b
|
|
|
26
26
|
### Commands
|
|
27
27
|
- `help` - use help to view options
|
|
28
28
|
|
|
29
|
+
### Platform support
|
|
30
|
+
|
|
31
|
+
The bundled `basisu` encoder (used for HDR / EXR → KTX2 HDR) supports:
|
|
32
|
+
|
|
33
|
+
| OS | Arch | Status |
|
|
34
|
+
|---------|-----------------------|--------|
|
|
35
|
+
| Linux | x64 | Supported |
|
|
36
|
+
| Linux | arm64 | Not supported |
|
|
37
|
+
| macOS | arm64 (Apple Silicon) | Supported |
|
|
38
|
+
| macOS | x64 (Intel) | Not supported |
|
|
39
|
+
| Windows | x64 | Supported |
|
|
40
|
+
|
|
29
41
|
### Configuration
|
|
30
42
|
|
|
31
43
|
The pipeline reads an optional `needle.config.json` from the working directory (or any parent directory). Configure pipeline behaviour under the `gltf` key:
|
|
@@ -49,7 +61,7 @@ The `gltf` value may also be a string shorthand for `usecase` — `"gltf": "prod
|
|
|
49
61
|
| `usecase` | `"default" \| "product" \| "world"` | `"default"` | High-level optimisation profile. |
|
|
50
62
|
| `textures.lods` | `boolean` | `true` | Generate progressive texture LODs. |
|
|
51
63
|
| `meshes.lods` | `boolean` | `true` | Generate progressive mesh LODs. |
|
|
52
|
-
| `audio.enabled` | `boolean` | `true` | Compress externally referenced
|
|
64
|
+
| `audio.enabled` | `boolean` | `true` | Compress externally referenced lossless audio files (`.wav`, `.flac`, `.aiff`/`.aif`) to Opus in an `.ogg` container, rewriting the URIs in the glTF. Lossy formats (`.mp3`, `.ogg`, `.m4a`, `.aac`) pass through unchanged to avoid compounding compression artifacts. Requires `ffmpeg` with `libopus` on `PATH`; when missing the build logs a warning and leaves the audio files untouched. |
|
|
53
65
|
| `audio.bitrate` | `number` (kbps) | `128` | Opus encoding bitrate. 96 is near-transparent for most music; 128 matches YouTube's music tier and is the safe "won't sound bad" default. Drop to 48–64 for known mono/UI-only assets. |
|
|
54
66
|
| `exr.enabled` | `boolean` | `true` | Convert EXR textures to KTX2 HDR via PMREM. When `false`, EXR textures (bundled and externally referenced) are left as-is so a downstream step can handle them. |
|
|
55
67
|
|
package/dist/cli/index.js
CHANGED
|
@@ -138,7 +138,7 @@ function listAudioRefs() {
|
|
|
138
138
|
function clearAudioRegistry() {
|
|
139
139
|
_refs = [];
|
|
140
140
|
}
|
|
141
|
-
var AUDIO_EXTENSIONS = [".wav"], _audioRegex = new RegExp(`(${AUDIO_EXTENSIONS.map((e) => "\\" + e).join("|")})$`, "i");
|
|
141
|
+
var AUDIO_EXTENSIONS = [".wav", ".flac", ".aiff", ".aif"], _audioRegex = new RegExp(`(${AUDIO_EXTENSIONS.map((e) => "\\" + e).join("|")})$`, "i");
|
|
142
142
|
function isAudioUri(value) {
|
|
143
143
|
return _audioRegex.test(value);
|
|
144
144
|
}
|
|
@@ -1190,7 +1190,7 @@ function registerExtensions(node) {
|
|
|
1190
1190
|
import { createTransform } from "@gltf-transform/functions";
|
|
1191
1191
|
|
|
1192
1192
|
// src/utils/version.gen.ts
|
|
1193
|
-
var version = "3.0.0-next.
|
|
1193
|
+
var version = "3.0.0-next.7e6c33d";
|
|
1194
1194
|
|
|
1195
1195
|
// src/utils/version.ts
|
|
1196
1196
|
function getVersion(_marklocal = !0) {
|
|
@@ -1406,6 +1406,11 @@ function getFileName(filepath) {
|
|
|
1406
1406
|
let parts = filepath.replaceAll("\\", "/").split("/");
|
|
1407
1407
|
return parts[parts.length - 1];
|
|
1408
1408
|
}
|
|
1409
|
+
function parseInputPaths(raw) {
|
|
1410
|
+
if (!raw.includes(",")) return [raw];
|
|
1411
|
+
let segments = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
1412
|
+
return segments.length < 2 ? [raw] : !segments.some((s) => existsSync3(s)) && existsSync3(raw) ? [raw] : segments;
|
|
1413
|
+
}
|
|
1409
1414
|
async function foreachGLTF(args, callback) {
|
|
1410
1415
|
let initDir = process.env.INIT_CWD, context = {
|
|
1411
1416
|
baseDirectory: initDir,
|
|
@@ -3231,16 +3236,22 @@ async function createPmremRuntime(logger) {
|
|
|
3231
3236
|
async function disposePmremRuntime(runtime) {
|
|
3232
3237
|
runtime?.tmpDir && await safeRmDir(runtime.tmpDir);
|
|
3233
3238
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3239
|
+
function convertExrBytesToPmremKtx2(runtime, exrBytes, opts = {}) {
|
|
3240
|
+
return convertBytesToPmremKtx2(runtime, exrBytes, "exr", opts);
|
|
3241
|
+
}
|
|
3242
|
+
function convertHdrBytesToPmremKtx2(runtime, hdrBytes, opts = {}) {
|
|
3243
|
+
return convertBytesToPmremKtx2(runtime, hdrBytes, "hdr", opts);
|
|
3244
|
+
}
|
|
3245
|
+
async function convertBytesToPmremKtx2(runtime, inputBytes, kind, opts = {}) {
|
|
3246
|
+
let useCache = opts.useCache !== !1, label = opts.logLabel ?? "pmrem", logger = runtime.logger, contentHash = createHash("md5").update(inputBytes).digest("hex"), cacheKey = kind === "hdr" ? `pmrem-hdr-${contentHash}` : `pmrem-${contentHash}`;
|
|
3236
3247
|
if (useCache) {
|
|
3237
3248
|
let cached = tryGetFromCache(cacheKey);
|
|
3238
3249
|
if (cached && cached.length > 0)
|
|
3239
3250
|
return logger.debug(`${label}: loaded from cache`), cached;
|
|
3240
3251
|
}
|
|
3241
|
-
let inputSize =
|
|
3242
|
-
logger.debug(`${label}: Running PMREM WASM (${inputSize}
|
|
3243
|
-
let t0 = Date.now(), pmremExrBytes = runtime.wasmModule.pmrem_exr(
|
|
3252
|
+
let inputSize = inputBytes.byteLength < 100 * 1024 ? `${(inputBytes.byteLength / 1024).toFixed(0)} KB` : `${(inputBytes.byteLength / (1024 * 1024)).toFixed(2)} MB`, sourceLabel = kind === "hdr" ? "HDR" : "EXR";
|
|
3253
|
+
logger.debug(`${label}: Running PMREM WASM (${inputSize} ${sourceLabel}) \u2014 this may take a while...`), await new Promise((r) => setTimeout(r, 0));
|
|
3254
|
+
let t0 = Date.now(), pmremExrBytes = (kind === "hdr" ? runtime.wasmModule.pmrem_hdr : runtime.wasmModule.pmrem_exr)(inputBytes), elapsed = ((Date.now() - t0) / 1e3).toFixed(1);
|
|
3244
3255
|
logger.debug(`${label}: PMREM done in ${elapsed}s (${(pmremExrBytes.byteLength / 1024 / 1024).toFixed(1)} MB)`);
|
|
3245
3256
|
let id = uuid3(), tempExr = join5(runtime.tmpDir, `${id}.pmrem.exr`), tempKtx2 = join5(runtime.tmpDir, `${id}.ktx2`);
|
|
3246
3257
|
if (writeFileSync4(tempExr, Buffer.from(pmremExrBytes)), logger.debug(`${label}: Encoding KTX2 HDR...`), await encodeKTX2WithBasisu(runtime.basisuExe, tempExr, tempKtx2, "hdr4x4", !0), !existsSync8(tempKtx2))
|
|
@@ -3794,7 +3805,7 @@ function resolveConfig(filename, content, logger) {
|
|
|
3794
3805
|
}
|
|
3795
3806
|
|
|
3796
3807
|
// src/cli/index.ts
|
|
3797
|
-
import { existsSync as
|
|
3808
|
+
import { existsSync as existsSync14, readFileSync as readFileSync11, readdirSync as readdirSync3, statSync as statSync7, writeFileSync as writeFileSync7 } from "fs";
|
|
3798
3809
|
import path7, { basename as basename4, dirname as dirname8, resolve as resolve3 } from "path";
|
|
3799
3810
|
|
|
3800
3811
|
// src/constants.ts
|
|
@@ -3890,7 +3901,7 @@ function trackPipelineEnd(info) {
|
|
|
3890
3901
|
}
|
|
3891
3902
|
|
|
3892
3903
|
// src/auth/verify.ts
|
|
3893
|
-
import { jwtVerify, importJWK } from "jose";
|
|
3904
|
+
import { jwtVerify, importJWK, decodeProtectedHeader } from "jose";
|
|
3894
3905
|
|
|
3895
3906
|
// src/auth/keys.ts
|
|
3896
3907
|
var PROD_KEYS = [
|
|
@@ -3911,48 +3922,108 @@ var PROD_KEYS = [
|
|
|
3911
3922
|
var trusted = [...PROD_KEYS], TRUSTED_KEYS = trusted;
|
|
3912
3923
|
|
|
3913
3924
|
// src/auth/verify.ts
|
|
3925
|
+
import { readFileSync as readFileSync10, existsSync as existsSync13 } from "fs";
|
|
3926
|
+
import { join as join8 } from "path";
|
|
3927
|
+
import { homedir } from "os";
|
|
3914
3928
|
var AuthError = class extends Error {
|
|
3915
3929
|
constructor(message) {
|
|
3916
3930
|
super(message), this.name = "AuthError";
|
|
3917
3931
|
}
|
|
3918
|
-
};
|
|
3932
|
+
}, LOCAL_FETCH_TIMEOUT_MS = 2e3;
|
|
3933
|
+
function getLocalServerToken() {
|
|
3934
|
+
try {
|
|
3935
|
+
let file = join8(homedir(), ".needle", "local-server-token");
|
|
3936
|
+
if (!existsSync13(file)) return null;
|
|
3937
|
+
let data = JSON.parse(readFileSync10(file, "utf-8"));
|
|
3938
|
+
return typeof data.token == "string" ? data.token : null;
|
|
3939
|
+
} catch {
|
|
3940
|
+
return null;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
async function tryFetchLocalToken(org) {
|
|
3944
|
+
try {
|
|
3945
|
+
let baseUrl = process.env.NEEDLE_LICENSE_SERVER_URL || "http://localhost:8424/api/license", url = new URL(baseUrl);
|
|
3946
|
+
org && url.searchParams.set("org", org);
|
|
3947
|
+
let headers = {}, serverToken = getLocalServerToken();
|
|
3948
|
+
serverToken && (headers.Authorization = `Bearer ${serverToken}`);
|
|
3949
|
+
let res = await fetch(url, {
|
|
3950
|
+
signal: AbortSignal.timeout(LOCAL_FETCH_TIMEOUT_MS),
|
|
3951
|
+
headers
|
|
3952
|
+
});
|
|
3953
|
+
if (!res.ok) return null;
|
|
3954
|
+
let jwt = (await res.json()).needle_license_jwt;
|
|
3955
|
+
return typeof jwt == "string" && jwt.length > 0 ? jwt : null;
|
|
3956
|
+
} catch {
|
|
3957
|
+
return null;
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
async function verifyWithKey(token, key) {
|
|
3961
|
+
if (!key.alg) throw new AuthError(`trusted key '${key.kid ?? "?"}' is missing 'alg'`);
|
|
3962
|
+
let keyObj = await importJWK(key, key.alg);
|
|
3963
|
+
await jwtVerify(token, keyObj);
|
|
3964
|
+
}
|
|
3919
3965
|
async function verifyAuthToken(token) {
|
|
3920
3966
|
if (!token)
|
|
3921
3967
|
throw new AuthError("no token provided");
|
|
3968
|
+
if (token.startsWith("nc_"))
|
|
3969
|
+
throw new AuthError("NEEDLE_CLOUD_TOKEN is a needle-cloud access token (nc_*), not a JWT.");
|
|
3922
3970
|
try {
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
throw new AuthError("token header missing 'kid'");
|
|
3971
|
+
let header = decodeProtectedHeader(token);
|
|
3972
|
+
if (header.kid) {
|
|
3926
3973
|
let match = TRUSTED_KEYS.find((k) => k.kid === header.kid);
|
|
3927
3974
|
if (!match)
|
|
3928
3975
|
throw new AuthError(`token signed by unknown key '${header.kid}'`);
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3976
|
+
await verifyWithKey(token, match);
|
|
3977
|
+
} else {
|
|
3978
|
+
let lastError = null;
|
|
3979
|
+
for (let key of TRUSTED_KEYS)
|
|
3980
|
+
try {
|
|
3981
|
+
await verifyWithKey(token, key);
|
|
3982
|
+
return;
|
|
3983
|
+
} catch (err) {
|
|
3984
|
+
lastError = err;
|
|
3985
|
+
}
|
|
3986
|
+
if (lastError instanceof AuthError) throw lastError;
|
|
3987
|
+
let message = lastError instanceof Error ? lastError.message : String(lastError);
|
|
3988
|
+
throw new AuthError(message || "no trusted key could verify this token");
|
|
3989
|
+
}
|
|
3933
3990
|
} catch (err) {
|
|
3934
3991
|
if (err instanceof AuthError) throw err;
|
|
3992
|
+
if (err && typeof err == "object" && "code" in err && err.code === "ERR_JWT_EXPIRED")
|
|
3993
|
+
throw new AuthError("token expired");
|
|
3935
3994
|
let message = err instanceof Error ? err.message : String(err);
|
|
3936
3995
|
throw new AuthError(message);
|
|
3937
3996
|
}
|
|
3938
3997
|
}
|
|
3939
|
-
async function requireAuth(cliToken) {
|
|
3998
|
+
async function requireAuth(cliToken, org) {
|
|
3940
3999
|
let token = typeof cliToken == "string" && cliToken.length > 0 ? cliToken : process.env.NEEDLE_CLOUD_TOKEN;
|
|
3941
|
-
if (!token)
|
|
3942
|
-
throw new AuthError(
|
|
4000
|
+
if ((!token || typeof token == "string" && token.length === 0) && (token = await tryFetchLocalToken(org ?? process.env.NEEDLE_CLOUD_ORG)), !token)
|
|
4001
|
+
throw new AuthError(
|
|
4002
|
+
"No valid auth token found. Provide one via --auth-token, NEEDLE_CLOUD_TOKEN env, or log in to the needle-cloud CLI (npx needle-cloud@version-2 start --restart). If you are logged in but still see this error, try updating: npx needle-cloud@version-2 start --restart"
|
|
4003
|
+
);
|
|
3943
4004
|
await verifyAuthToken(token);
|
|
3944
4005
|
}
|
|
3945
4006
|
|
|
3946
4007
|
// src/cli/index.ts
|
|
3947
|
-
|
|
4008
|
+
function warnUnknownOptions(options, logger) {
|
|
4009
|
+
if (!process.env.NEEDLE_WORKER) return;
|
|
4010
|
+
let knownKeys = new Set(Object.keys(options));
|
|
4011
|
+
for (let arg of process.argv) {
|
|
4012
|
+
if (!arg.startsWith("--")) continue;
|
|
4013
|
+
let raw = arg.split("=")[0].replace(/^--/, ""), key = raw.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
4014
|
+
knownKeys.has(key) || logger.warn(`[Needle Build Pipeline] v${getVersion()} Unknown option --${raw}, ignoring.`);
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
async function gateAuth(authToken, org, logger) {
|
|
3948
4018
|
try {
|
|
3949
|
-
await requireAuth(authToken);
|
|
4019
|
+
await requireAuth(authToken, typeof org == "string" ? org : void 0);
|
|
3950
4020
|
} catch (err) {
|
|
3951
4021
|
let message = err instanceof AuthError || err instanceof Error ? err.message : String(err);
|
|
3952
4022
|
logger.error(`[Needle Build Pipeline] Auth failed: ${message}`), process.exit(ERROR_CODES.AUTH_FAILED);
|
|
3953
4023
|
}
|
|
3954
4024
|
}
|
|
3955
4025
|
program.cast(!1);
|
|
4026
|
+
process.env.NEEDLE_WORKER && program.strict(!1);
|
|
3956
4027
|
program.command("version", "Print current version").action(async ({ logger }) => {
|
|
3957
4028
|
logger.info(getVersion());
|
|
3958
4029
|
}).command("clear-caches", "Clear all caches").help(`Clears all cached files
|
|
@@ -3960,8 +4031,8 @@ Caches are limited to ${cacheSizeLimit} MB disc space by default.
|
|
|
3960
4031
|
`).action(async ({ logger }) => {
|
|
3961
4032
|
logger.info("Clearing caches"), clearCache(logger);
|
|
3962
4033
|
}).command("stats", "Calculate glTF stats").help(`
|
|
3963
|
-
`).argument("<input>", "Path to a glTF, GLB or VRM file OR a directory").argument("<output>", "Output path for the stats", { default:
|
|
3964
|
-
await gateAuth(options.authToken, logger), logger.level = options.verbose ? "debug" : "info", await ensureHashReady(), logger.info('Calculating stats for "' + args.input + '"');
|
|
4034
|
+
`).argument("<input>", "Path to a glTF, GLB or VRM file OR a directory").argument("<output>", "Output path for the stats", { default: "", validator: program.STRING }).option("--verbose", "Enable verbose output", { validator: program.BOOLEAN, default: !1 }).option("--auth-token <jwt>", "Required. A JWT minted by needle-cloud (alternatively set NEEDLE_CLOUD_TOKEN). Note: an `nc_*` needle-cloud access token is NOT a JWT and will be rejected.", { validator: program.STRING }).option("--org <org>", "Organization ID for local license-server fallback (or set NEEDLE_CLOUD_ORG).", { validator: program.STRING }).action(async ({ logger, args, options }) => {
|
|
4035
|
+
warnUnknownOptions(options, logger), await gateAuth(options.authToken, options.org, logger), logger.level = options.verbose ? "debug" : "info", await ensureHashReady(), logger.info('Calculating stats for "' + args.input + '"');
|
|
3965
4036
|
let input = args.input.toString(), filestats = new Array();
|
|
3966
4037
|
await foreachGLTF(input, async (file) => {
|
|
3967
4038
|
let stats = await calculateStats(file, { verbose: !!options.verbose });
|
|
@@ -3972,13 +4043,15 @@ Caches are limited to ${cacheSizeLimit} MB disc space by default.
|
|
|
3972
4043
|
}).command("transform", "Transform (progressive loading) and compress glTF, GLB or VRM files").help(`
|
|
3973
4044
|
This will produce multiple versions of the input file, each with a different level of optimization.
|
|
3974
4045
|
Each version will be compressed and written to the output directory.
|
|
3975
|
-
`).argument("<input>", "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed", { validator: program.STRING }).argument("<output>", "The output file or directory. It can be an absolute path or a relative path to the input file. If not provided, the input file will be overwritten.", { default:
|
|
3976
|
-
When 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: !0 }).option("--debug", 'Enable for more verbose outout with "--debug True"', { validator: program.BOOLEAN, default: !1 }).option("--verbose", 'Enable for more verbose outout with "--verbose True"', { validator: program.BOOLEAN, default: !1 }).option("--auth-token <
|
|
3977
|
-
if (await gateAuth(options.authToken, logger), logger.level = options.debug || options.verbose ? "debug" : "info", options.compress === !1 && options.progressive === !1) {
|
|
4046
|
+
`).argument("<input>", "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed. Multiple files can be separated by commas.", { validator: program.STRING }).argument("<output>", "The output file or directory. It can be an absolute path or a relative path to the input file. If not provided, the input file will be overwritten.", { default: "", validator: program.STRING }).option("--compress", "When enabled files will be compressed", { validator: program.BOOLEAN, default: !0 }).option("--progressive", "When enabled files will processed to be progressively loaded", { validator: program.BOOLEAN, default: !0 }).option("--usecase <usecase>", `The usecase for the compression. This will set the compression settings. Possible options: [${UsecaseOptions.join(", ")}]`, { validator: program.STRING }).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 }).option("--cache", `Use "--cache False" to disable caching.
|
|
4047
|
+
When 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: !0 }).option("--debug", 'Enable for more verbose outout with "--debug True"', { validator: program.BOOLEAN, default: !1 }).option("--verbose", 'Enable for more verbose outout with "--verbose True"', { validator: program.BOOLEAN, default: !1 }).option("--auth-token <jwt>", "Required. A JWT minted by needle-cloud (alternatively set NEEDLE_CLOUD_TOKEN). Note: an `nc_*` needle-cloud access token is NOT a JWT and will be rejected.", { validator: program.STRING }).option("--org <org>", "Organization ID for local license-server fallback (or set NEEDLE_CLOUD_ORG).", { validator: program.STRING }).action(async ({ logger, args, options }) => {
|
|
4048
|
+
if (warnUnknownOptions(options, logger), await gateAuth(options.authToken, options.org, logger), logger.level = options.debug || options.verbose ? "debug" : "info", options.compress === !1 && options.progressive === !1) {
|
|
3978
4049
|
logger.error(`[Needle Build Pipeline] v${getVersion()} You need to enable at least one of the options: --compress or --progressive`);
|
|
3979
4050
|
return;
|
|
3980
4051
|
}
|
|
3981
|
-
await ensureHashReady()
|
|
4052
|
+
await ensureHashReady();
|
|
4053
|
+
let inputPaths = parseInputPaths(args.input.toString()), input = inputPaths[0], isMultiInput = inputPaths.length > 1;
|
|
4054
|
+
logger.info(`[Needle Build Pipeline] v${getVersion()} \u2014 Transform ${isMultiInput ? `${inputPaths.length} files` : `'${input}'`}`);
|
|
3982
4055
|
let pipelineMode = [options.progressive && "progressive", options.compress && "compress"].filter(Boolean).join("+");
|
|
3983
4056
|
trackPipelineStart({ mode: pipelineMode, usecase: options.usecase?.toString() });
|
|
3984
4057
|
let stats = {
|
|
@@ -3987,20 +4060,20 @@ When caching is enabled then previously processed files will be detected and loa
|
|
|
3987
4060
|
totalFilesProcessed: 0,
|
|
3988
4061
|
totalFileSizeInMB: 0,
|
|
3989
4062
|
totalFileSizeInMBBefore: 0
|
|
3990
|
-
},
|
|
4063
|
+
}, config = getConfig(options.config?.toString(), input, {
|
|
3991
4064
|
logger
|
|
3992
4065
|
});
|
|
3993
4066
|
options.usecase && (logger.info("Using usecase: " + options.usecase), config = { ...createConfig(options.usecase.toString()), ...config }, config.usecase != "default" && config.usecase != options.usecase.toString() ? 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.`) : config.usecase = options.usecase.toString());
|
|
3994
|
-
let inputIsDirectory = isDirectory(input), output = args.output?.toString();
|
|
3995
|
-
!inputIsDirectory && !output && (output = input);
|
|
4067
|
+
let inputIsDirectory = !isMultiInput && isDirectory(input), output = args.output?.toString();
|
|
4068
|
+
isMultiInput && output && !isDirectory(output) && (logger.error("When <input> contains multiple files then <output> must be a directory"), trackError(new Error("Invalid args: multi-input but output is not a directory"), { mode: pipelineMode }), process.exit(ERROR_CODES.INVALID_ARGS)), !inputIsDirectory && !isMultiInput && !output && (output = input);
|
|
3996
4069
|
let outputIsDirectory = output && isDirectory(output);
|
|
3997
4070
|
if (inputIsDirectory && output && !outputIsDirectory && (logger.error("When <input> is a directory then <output> must also be a directory"), trackError(new Error("Invalid args: input is directory but output is not"), { mode: pipelineMode }), process.exit(ERROR_CODES.INVALID_ARGS)), output && path7.isAbsolute(output) === !1) {
|
|
3998
4071
|
let base = ensureIsDirectory(input);
|
|
3999
4072
|
output = resolve3(base, output);
|
|
4000
4073
|
}
|
|
4001
4074
|
let set = /* @__PURE__ */ new Set(), useCache = options.cache !== !1, debug = options.debug === !0, verbose = options.verbose === !0;
|
|
4002
|
-
await foreachGLTF(
|
|
4003
|
-
if (
|
|
4075
|
+
await foreachGLTF(inputPaths, async (file) => {
|
|
4076
|
+
if (existsSync14(file)) {
|
|
4004
4077
|
if (file != input && options.progressive === !0 && isLOD(file)) {
|
|
4005
4078
|
logger.debug(`\u2192 Ignore existing LOD file at ${file}`);
|
|
4006
4079
|
return;
|
|
@@ -4016,7 +4089,7 @@ When caching is enabled then previously processed files will be detected and loa
|
|
|
4016
4089
|
config
|
|
4017
4090
|
}, file) : void 0;
|
|
4018
4091
|
if (jobKey) {
|
|
4019
|
-
let outputDir = output ?
|
|
4092
|
+
let outputDir = output ? existsSync14(output) && isDirectory(output) ? output : dirname8(output) : dirname8(file), restored = tryRestoreJobResult(jobKey, outputDir, logger);
|
|
4020
4093
|
if (restored) {
|
|
4021
4094
|
let inputFileSize = statSync7(file).size / 1024 / 1024;
|
|
4022
4095
|
for (let f of restored)
|
|
@@ -4085,35 +4158,36 @@ When caching is enabled then previously processed files will be detected and loa
|
|
|
4085
4158
|
gpuMemory_MB: stats.totalGPUMemoryInMB,
|
|
4086
4159
|
duration_ms: Date.now() - stats.startTime
|
|
4087
4160
|
}), useCache && limitCacheSize();
|
|
4088
|
-
}).command("pmrem", "Convert EXR files to PMREM-processed KTX2 HDR (Needle PMREM)").help(`Runs the PMREM WASM + basisu encoder on .exr files,
|
|
4089
|
-
This is the same processing the Needle build pipeline
|
|
4090
|
-
GLB/GLTF files, exposed as a standalone command for
|
|
4091
|
-
|
|
4092
|
-
|
|
4161
|
+
}).command("pmrem", "Convert EXR / HDR files to PMREM-processed KTX2 HDR (Needle PMREM)").help(`Runs the PMREM WASM + basisu encoder on .exr or .hdr (Radiance RGBE) files,
|
|
4162
|
+
producing <name>.pmrem.ktx2. This is the same processing the Needle build pipeline
|
|
4163
|
+
applies to EXR textures inside GLB/GLTF files, exposed as a standalone command for
|
|
4164
|
+
raw .exr / .hdr inputs.
|
|
4165
|
+
`).argument("<input>", "Path to a .exr/.hdr file OR a directory containing .exr/.hdr files (recursive)", { validator: program.STRING }).argument("<output>", "Output file (when input is a single .exr/.hdr) or output directory. Defaults to writing next to the input file.", { default: "", validator: program.STRING }).option("--cache", 'Use "--cache False" to disable caching.', { validator: program.BOOLEAN, default: !0 }).option("--debug", 'Enable verbose output with "--debug True"', { validator: program.BOOLEAN, default: !1 }).option("--verbose", 'Enable verbose output with "--verbose True"', { validator: program.BOOLEAN, default: !1 }).option("--auth-token <jwt>", "Required. A JWT minted by needle-cloud (alternatively set NEEDLE_CLOUD_TOKEN). Note: an `nc_*` needle-cloud access token is NOT a JWT and will be rejected.", { validator: program.STRING }).option("--org <org>", "Organization ID for local license-server fallback (or set NEEDLE_CLOUD_ORG).", { validator: program.STRING }).hide().action(async ({ logger, args, options }) => {
|
|
4166
|
+
warnUnknownOptions(options, logger), await gateAuth(options.authToken, options.org, logger), logger.level = options.debug || options.verbose ? "debug" : "info", await ensureHashReady();
|
|
4093
4167
|
let input = args.input.toString();
|
|
4094
|
-
|
|
4095
|
-
let
|
|
4096
|
-
if (inputIsDirectory ?
|
|
4097
|
-
logger.warn(`No .exr files found in ${input}`);
|
|
4168
|
+
existsSync14(input) || (logger.error(`Input does not exist: ${input}`), process.exit(ERROR_CODES.INVALID_ARGS));
|
|
4169
|
+
let inputFiles = [], inputIsDirectory = isDirectory(input);
|
|
4170
|
+
if (inputIsDirectory ? collectPmremInputFiles(input, inputFiles) : isPmremInputFile(input) ? inputFiles.push(input) : (logger.error(`Input is not an .exr/.hdr file or directory: ${input}`), process.exit(ERROR_CODES.INVALID_ARGS)), inputFiles.length === 0) {
|
|
4171
|
+
logger.warn(`No .exr/.hdr files found in ${input}`);
|
|
4098
4172
|
return;
|
|
4099
4173
|
}
|
|
4100
|
-
let
|
|
4174
|
+
let outputArg = args.output?.toString() || null;
|
|
4101
4175
|
if (outputArg && !path7.isAbsolute(outputArg)) {
|
|
4102
4176
|
let base = inputIsDirectory ? input : dirname8(input);
|
|
4103
4177
|
outputArg = resolve3(base, outputArg);
|
|
4104
4178
|
}
|
|
4105
4179
|
let useCache = options.cache !== !1;
|
|
4106
|
-
logger.info(`[Needle Build Pipeline] v${getVersion()} \u2014 pmrem: ${
|
|
4180
|
+
logger.info(`[Needle Build Pipeline] v${getVersion()} \u2014 pmrem: ${inputFiles.length} file(s)`);
|
|
4107
4181
|
let runtime = await createPmremRuntime(logger);
|
|
4108
4182
|
runtime || (logger.error("pmrem runtime is not available (WASM or basisu binary missing). Run `npm run build:pmrem` in the package directory."), process.exit(ERROR_CODES.PACKING_FAILED));
|
|
4109
4183
|
try {
|
|
4110
|
-
for (let
|
|
4111
|
-
let outPath = resolvePmremOutputPath(
|
|
4112
|
-
logger.info(`\u2192 pmrem ${
|
|
4113
|
-
let
|
|
4184
|
+
for (let inPath of inputFiles) {
|
|
4185
|
+
let outPath = resolvePmremOutputPath(inPath, input, inputIsDirectory, outputArg);
|
|
4186
|
+
logger.info(`\u2192 pmrem ${inPath} \u2192 ${outPath}`);
|
|
4187
|
+
let srcBytes = readFileSync11(inPath), bytes = new Uint8Array(srcBytes.buffer, srcBytes.byteOffset, srcBytes.byteLength), ktx2Bytes = await (inPath.toLowerCase().endsWith(".hdr") ? convertHdrBytesToPmremKtx2 : convertExrBytesToPmremKtx2)(
|
|
4114
4188
|
runtime,
|
|
4115
|
-
|
|
4116
|
-
{ useCache, logLabel: `pmrem ${basename4(
|
|
4189
|
+
bytes,
|
|
4190
|
+
{ useCache, logLabel: `pmrem ${basename4(inPath)}` }
|
|
4117
4191
|
);
|
|
4118
4192
|
writeFileSync7(outPath, ktx2Bytes);
|
|
4119
4193
|
}
|
|
@@ -4122,22 +4196,26 @@ GLB/GLTF files, exposed as a standalone command for raw .exr inputs.
|
|
|
4122
4196
|
}
|
|
4123
4197
|
useCache && limitCacheSize();
|
|
4124
4198
|
});
|
|
4125
|
-
function
|
|
4199
|
+
function isPmremInputFile(name) {
|
|
4200
|
+
let lower = name.toLowerCase();
|
|
4201
|
+
return lower.endsWith(".exr") || lower.endsWith(".hdr");
|
|
4202
|
+
}
|
|
4203
|
+
function collectPmremInputFiles(dir, out) {
|
|
4126
4204
|
for (let entry of readdirSync3(dir)) {
|
|
4127
4205
|
if (entry === "node_modules" || entry.startsWith(".")) continue;
|
|
4128
4206
|
let full = path7.join(dir, entry);
|
|
4129
|
-
statSync7(full).isDirectory() ?
|
|
4207
|
+
statSync7(full).isDirectory() ? collectPmremInputFiles(full, out) : isPmremInputFile(entry) && out.push(full);
|
|
4130
4208
|
}
|
|
4131
4209
|
}
|
|
4132
|
-
function resolvePmremOutputPath(
|
|
4133
|
-
let outName = basename4(
|
|
4210
|
+
function resolvePmremOutputPath(srcPath, input, inputIsDirectory, outputArg) {
|
|
4211
|
+
let outName = basename4(srcPath).replace(/\.(exr|hdr)$/i, ".pmrem.ktx2");
|
|
4134
4212
|
if (!outputArg)
|
|
4135
|
-
return path7.join(dirname8(
|
|
4213
|
+
return path7.join(dirname8(srcPath), outName);
|
|
4136
4214
|
if (inputIsDirectory) {
|
|
4137
|
-
let rel = path7.relative(input,
|
|
4215
|
+
let rel = path7.relative(input, srcPath), relDir = dirname8(rel), outDir = relDir === "." ? outputArg : path7.join(outputArg, relDir);
|
|
4138
4216
|
return ensureIsDirectory(outDir), path7.join(outDir, outName);
|
|
4139
4217
|
}
|
|
4140
|
-
return
|
|
4218
|
+
return existsSync14(outputArg) && isDirectory(outputArg) ? path7.join(outputArg, outName) : outputArg.toLowerCase().endsWith(".ktx2") ? (ensureIsDirectory(dirname8(outputArg)), outputArg) : (ensureIsDirectory(outputArg), path7.join(outputArg, outName));
|
|
4141
4219
|
}
|
|
4142
4220
|
program.run().catch((err) => {
|
|
4143
4221
|
if (!(err.message.includes("Unknown command") && !err.message.includes("Did you mean")))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.7e6c33d",
|
|
4
4
|
"description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Decode a Radiance `.hdr` file and re-encode it as an EXR (`SMALL_LOSSLESS`).
|
|
6
|
+
*/
|
|
7
|
+
export function hdr_to_exr(input: Uint8Array): Uint8Array;
|
|
8
|
+
|
|
4
9
|
export function pmrem_exr(input: Uint8Array): Uint8Array;
|
|
5
10
|
|
|
6
11
|
/**
|
|
@@ -14,6 +19,22 @@ export function pmrem_exr_resized(input: Uint8Array, target_width: number): Uint
|
|
|
14
19
|
*/
|
|
15
20
|
export function pmrem_exr_resized_with_filter(input: Uint8Array, target_width: number, filter: string): Uint8Array;
|
|
16
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Decode a Radiance `.hdr` file, run PMREM, and return PMREM EXR bytes.
|
|
24
|
+
* Output is structurally identical to `pmrem_exr`.
|
|
25
|
+
*/
|
|
26
|
+
export function pmrem_hdr(input: Uint8Array): Uint8Array;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* PMREM from HDR with optional downscale to `target_width` (Lanczos3).
|
|
30
|
+
*/
|
|
31
|
+
export function pmrem_hdr_resized(input: Uint8Array, target_width: number): Uint8Array;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* PMREM from HDR with optional downscale and selectable filter.
|
|
35
|
+
*/
|
|
36
|
+
export function pmrem_hdr_resized_with_filter(input: Uint8Array, target_width: number, filter: string): Uint8Array;
|
|
37
|
+
|
|
17
38
|
/**
|
|
18
39
|
* Resize equirectangular EXR to target width (maintain aspect), returning EXR bytes.
|
|
19
40
|
*/
|
|
@@ -33,9 +54,13 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
33
54
|
|
|
34
55
|
export interface InitOutput {
|
|
35
56
|
readonly memory: WebAssembly.Memory;
|
|
57
|
+
readonly hdr_to_exr: (a: number, b: number, c: number) => void;
|
|
36
58
|
readonly pmrem_exr: (a: number, b: number, c: number) => void;
|
|
37
59
|
readonly pmrem_exr_resized: (a: number, b: number, c: number, d: number) => void;
|
|
38
60
|
readonly pmrem_exr_resized_with_filter: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
61
|
+
readonly pmrem_hdr: (a: number, b: number, c: number) => void;
|
|
62
|
+
readonly pmrem_hdr_resized: (a: number, b: number, c: number, d: number) => void;
|
|
63
|
+
readonly pmrem_hdr_resized_with_filter: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
39
64
|
readonly resize_equirect_exr: (a: number, b: number, c: number, d: number) => void;
|
|
40
65
|
readonly resize_equirect_exr_with_filter: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
41
66
|
readonly split_pmrem_exr_to_zip: (a: number, b: number, c: number) => void;
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
/* @ts-self-types="./pmrem_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Decode a Radiance `.hdr` file and re-encode it as an EXR (`SMALL_LOSSLESS`).
|
|
5
|
+
* @param {Uint8Array} input
|
|
6
|
+
* @returns {Uint8Array}
|
|
7
|
+
*/
|
|
8
|
+
export function hdr_to_exr(input) {
|
|
9
|
+
try {
|
|
10
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
11
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
wasm.hdr_to_exr(retptr, ptr0, len0);
|
|
14
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
15
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
16
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
17
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
18
|
+
if (r3) {
|
|
19
|
+
throw takeObject(r2);
|
|
20
|
+
}
|
|
21
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
22
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
23
|
+
return v2;
|
|
24
|
+
} finally {
|
|
25
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
3
29
|
/**
|
|
4
30
|
* @param {Uint8Array} input
|
|
5
31
|
* @returns {Uint8Array}
|
|
@@ -83,6 +109,90 @@ export function pmrem_exr_resized_with_filter(input, target_width, filter) {
|
|
|
83
109
|
}
|
|
84
110
|
}
|
|
85
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Decode a Radiance `.hdr` file, run PMREM, and return PMREM EXR bytes.
|
|
114
|
+
* Output is structurally identical to `pmrem_exr`.
|
|
115
|
+
* @param {Uint8Array} input
|
|
116
|
+
* @returns {Uint8Array}
|
|
117
|
+
*/
|
|
118
|
+
export function pmrem_hdr(input) {
|
|
119
|
+
try {
|
|
120
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
121
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
122
|
+
const len0 = WASM_VECTOR_LEN;
|
|
123
|
+
wasm.pmrem_hdr(retptr, ptr0, len0);
|
|
124
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
125
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
126
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
127
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
128
|
+
if (r3) {
|
|
129
|
+
throw takeObject(r2);
|
|
130
|
+
}
|
|
131
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
132
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
133
|
+
return v2;
|
|
134
|
+
} finally {
|
|
135
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* PMREM from HDR with optional downscale to `target_width` (Lanczos3).
|
|
141
|
+
* @param {Uint8Array} input
|
|
142
|
+
* @param {number} target_width
|
|
143
|
+
* @returns {Uint8Array}
|
|
144
|
+
*/
|
|
145
|
+
export function pmrem_hdr_resized(input, target_width) {
|
|
146
|
+
try {
|
|
147
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
148
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
149
|
+
const len0 = WASM_VECTOR_LEN;
|
|
150
|
+
wasm.pmrem_hdr_resized(retptr, ptr0, len0, target_width);
|
|
151
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
152
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
153
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
154
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
155
|
+
if (r3) {
|
|
156
|
+
throw takeObject(r2);
|
|
157
|
+
}
|
|
158
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
159
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
160
|
+
return v2;
|
|
161
|
+
} finally {
|
|
162
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* PMREM from HDR with optional downscale and selectable filter.
|
|
168
|
+
* @param {Uint8Array} input
|
|
169
|
+
* @param {number} target_width
|
|
170
|
+
* @param {string} filter
|
|
171
|
+
* @returns {Uint8Array}
|
|
172
|
+
*/
|
|
173
|
+
export function pmrem_hdr_resized_with_filter(input, target_width, filter) {
|
|
174
|
+
try {
|
|
175
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
176
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
const ptr1 = passStringToWasm0(filter, wasm.__wbindgen_export, wasm.__wbindgen_export3);
|
|
179
|
+
const len1 = WASM_VECTOR_LEN;
|
|
180
|
+
wasm.pmrem_hdr_resized_with_filter(retptr, ptr0, len0, target_width, ptr1, len1);
|
|
181
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
182
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
183
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
184
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
185
|
+
if (r3) {
|
|
186
|
+
throw takeObject(r2);
|
|
187
|
+
}
|
|
188
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
189
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
190
|
+
return v3;
|
|
191
|
+
} finally {
|
|
192
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
86
196
|
/**
|
|
87
197
|
* Resize equirectangular EXR to target width (maintain aspect), returning EXR bytes.
|
|
88
198
|
* @param {Uint8Array} input
|
|
Binary file
|