@needle-tools/gltf-build-pipeline 2.14.0 → 2.15.0-next.18cdb52
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/dist/cache/cache.d.ts +1 -0
- package/dist/cache/cache.js +4 -4
- package/dist/cli/index.js +0 -0
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +56 -30
- package/dist/extensions/NEEDLE_pmrem/index.d.ts +19 -0
- package/dist/extensions/NEEDLE_pmrem/index.js +44 -0
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +1 -0
- package/dist/scripts/pack-gltf.js +14 -4
- package/dist/transforms/needle_pmrem.d.ts +16 -0
- package/dist/transforms/needle_pmrem.js +172 -0
- package/dist/transforms/needle_progressive.js +26 -9
- package/dist/transforms/needle_texture_transform.d.ts +2 -0
- package/dist/transforms/needle_texture_transform.js +12 -2
- package/dist/utils/test-assert.d.ts +8 -0
- package/dist/utils/test-assert.js +18 -0
- package/dist/utils/version.gen.d.ts +1 -1
- package/dist/utils/version.gen.js +1 -1
- package/package.json +18 -4
- package/tools/pmrem/basis/linux/basisu +0 -0
- package/tools/pmrem/basis/osx/basisu +0 -0
- package/tools/pmrem/basis/package.json +3 -0
- package/tools/pmrem/basis/wasm/basis_encoder_threads.js +6693 -0
- package/tools/pmrem/basis/wasm/basis_encoder_threads.wasm +0 -0
- package/tools/pmrem/basis/win/basisu.exe +0 -0
- package/tools/pmrem/basis/win/basisu_help.txt +0 -0
- package/tools/pmrem/basis/win/ocl_kernels.cl +1290 -0
- package/tools/pmrem/pkg/pmrem_wasm.d.ts +68 -0
- package/tools/pmrem/pkg/pmrem_wasm.js +401 -0
- package/tools/pmrem/pkg/pmrem_wasm_bg.wasm +0 -0
- package/tsconfig.json +0 -20
|
@@ -4,6 +4,7 @@ import { NEEDLE_compression_texture } from '../extensions/index.js';
|
|
|
4
4
|
import { addToCache, getHash, getKey, tryGetFromCache } from "../cache/index.js";
|
|
5
5
|
import { NeedleWebPContext } from "./needle_webp.js";
|
|
6
6
|
import { NeedleToktxContext } from "./needle_toktx.js";
|
|
7
|
+
import { NeedlePmremContext } from "./needle_pmrem.js";
|
|
7
8
|
import { createTransform, listTextureSlots } from "@gltf-transform/functions";
|
|
8
9
|
import { dirname } from "path";
|
|
9
10
|
import { existsSync, rmSync } from "fs";
|
|
@@ -33,11 +34,13 @@ export const needle_texture_transform = function (options) {
|
|
|
33
34
|
jobs: undefined,
|
|
34
35
|
debug: options.debug,
|
|
35
36
|
});
|
|
37
|
+
const pmremContext = new NeedlePmremContext();
|
|
36
38
|
const context = {
|
|
37
39
|
config: options.config,
|
|
38
40
|
...options,
|
|
39
41
|
webPContext,
|
|
40
|
-
toktxContext
|
|
42
|
+
toktxContext,
|
|
43
|
+
pmremContext
|
|
41
44
|
};
|
|
42
45
|
return createTransform("needle_texture_transform", async (document) => {
|
|
43
46
|
await webPContext.prepare(document);
|
|
@@ -47,6 +50,7 @@ export const needle_texture_transform = function (options) {
|
|
|
47
50
|
context.noToktx = true;
|
|
48
51
|
}
|
|
49
52
|
}
|
|
53
|
+
await pmremContext.prepare(document);
|
|
50
54
|
try {
|
|
51
55
|
const logger = document.getLogger();
|
|
52
56
|
const textures = document.getRoot().listTextures();
|
|
@@ -79,6 +83,7 @@ export const needle_texture_transform = function (options) {
|
|
|
79
83
|
await webPContext.finalize(document);
|
|
80
84
|
if (context.noToktx !== true)
|
|
81
85
|
await toktxContext.finalize(document);
|
|
86
|
+
await pmremContext.finalize(document);
|
|
82
87
|
}
|
|
83
88
|
});
|
|
84
89
|
};
|
|
@@ -89,8 +94,13 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
89
94
|
texture.setMimeType(validationResult.mimeType);
|
|
90
95
|
}
|
|
91
96
|
const originalMimeType = texture.getMimeType();
|
|
97
|
+
// Handle EXR textures via PMREM → KTX2 HDR
|
|
98
|
+
if (originalMimeType === "image/exr") {
|
|
99
|
+
await context.pmremContext.process(index, texture, null, context);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
92
102
|
const isSupported = originalMimeType === "image/jpeg" || originalMimeType === "image/png" || originalMimeType === "image/webp";
|
|
93
|
-
// dont try to transform
|
|
103
|
+
// dont try to transform already processed textures
|
|
94
104
|
if (!isSupported)
|
|
95
105
|
return;
|
|
96
106
|
const ext = texture.getExtension(NEEDLE_compression_texture.EXTENSION_NAME);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class TestAssertionError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight assertion that throws under vitest and is a no-op in production.
|
|
6
|
+
* Use as a one-liner in pipeline code to catch regressions during tests.
|
|
7
|
+
*/
|
|
8
|
+
export declare function testAssert(condition: boolean, message: string): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const IS_TEST = process.env.VITEST === 'true';
|
|
2
|
+
export class TestAssertionError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'TestAssertionError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Lightweight assertion that throws under vitest and is a no-op in production.
|
|
10
|
+
* Use as a one-liner in pipeline code to catch regressions during tests.
|
|
11
|
+
*/
|
|
12
|
+
export function testAssert(condition, message) {
|
|
13
|
+
if (condition)
|
|
14
|
+
return;
|
|
15
|
+
if (IS_TEST) {
|
|
16
|
+
throw new TestAssertionError(`Assertion failed: ${message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.15.0-next.18cdb52";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.
|
|
1
|
+
export const version = "2.15.0-next.18cdb52";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0-next.18cdb52",
|
|
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",
|
|
@@ -18,6 +18,13 @@
|
|
|
18
18
|
"gltf-build-pipeline": "dist/cli/index.js",
|
|
19
19
|
"needle-gltf": "dist/cli/index.js"
|
|
20
20
|
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"scripts",
|
|
24
|
+
"tools/pmrem",
|
|
25
|
+
"README.md",
|
|
26
|
+
"CHANGELOG.md"
|
|
27
|
+
],
|
|
21
28
|
"imports": {
|
|
22
29
|
"#package.json": "./package.json"
|
|
23
30
|
},
|
|
@@ -33,12 +40,19 @@
|
|
|
33
40
|
"transform:make-progressive": "node scripts/make-progressive.mjs",
|
|
34
41
|
"transform:pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
|
|
35
42
|
"pack-gltf": "node --no-experimental-fetch scripts/pack-gltf.mjs",
|
|
36
|
-
"dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs"
|
|
43
|
+
"dev:pack-gltf": "npm run compile && node scripts/pack-gltf.mjs",
|
|
44
|
+
"test": "tsx tests/utils/download-fixtures.ts && vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"test:setup": "tsx tests/utils/download-fixtures.ts",
|
|
47
|
+
"update-pmrem": "node update-pmrem.mjs"
|
|
37
48
|
},
|
|
38
49
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^
|
|
50
|
+
"@types/node": "^22.19.15",
|
|
51
|
+
"gltf-validator": "^2.0.0-dev.3.9",
|
|
40
52
|
"npm-watch": "^0.13.0",
|
|
41
|
-
"
|
|
53
|
+
"tsx": "^4.19.0",
|
|
54
|
+
"typescript": "^4.9.5",
|
|
55
|
+
"vitest": "^3.1.1"
|
|
42
56
|
},
|
|
43
57
|
"optionalDependencies": {
|
|
44
58
|
"@img/sharp-darwin-arm64": "^0.33.4",
|
|
Binary file
|
|
Binary file
|