@needle-tools/gltf-build-pipeline 2.2.1-alpha.2 → 2.2.1-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/.temp/Go2.bin +0 -0
- package/.temp/textures/0_1.exr +0 -0
- package/.temp/textures/1_1.jpg +0 -0
- package/CHANGELOG.md +395 -394
- package/README.md +35 -35
- package/dist/cache/cache.d.ts +54 -54
- package/dist/cache/cache.js +257 -257
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +154 -154
- package/dist/config/index.d.ts +53 -53
- package/dist/config/index.js +152 -152
- package/dist/constants.d.ts +5 -5
- package/dist/constants.js +5 -5
- package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
- package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
- package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
- package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
- package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +26 -26
- package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +85 -85
- package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
- package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +897 -897
- package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
- package/dist/extensions/NEEDLE_opaque/index.js +28 -28
- package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
- package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
- package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
- package/dist/extensions/NEEDLE_progressive/index.js +1 -1
- package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
- package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
- package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
- package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +67 -67
- package/dist/extensions/index.d.ts +7 -7
- package/dist/extensions/index.js +17 -17
- package/dist/extensions/utils.d.ts +6 -6
- package/dist/extensions/utils.js +72 -72
- package/dist/functions/weld.3.d.ts +76 -76
- package/dist/functions/weld.3.js +414 -414
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/scripts/index.d.ts +2 -2
- package/dist/scripts/index.js +2 -2
- package/dist/scripts/pack-gltf.d.ts +16 -16
- package/dist/scripts/pack-gltf.js +120 -120
- package/dist/scripts/stats.d.ts +2 -2
- package/dist/scripts/stats.js +18 -18
- package/dist/transforms/index.d.ts +9 -9
- package/dist/transforms/index.js +9 -9
- package/dist/transforms/needle_animation_transform.d.ts +2 -2
- package/dist/transforms/needle_animation_transform.js +5 -5
- package/dist/transforms/needle_asset.d.ts +3 -3
- package/dist/transforms/needle_asset.js +35 -35
- package/dist/transforms/needle_common.d.ts +16 -16
- package/dist/transforms/needle_common.js +1 -1
- package/dist/transforms/needle_mesh_transform.d.ts +10 -10
- package/dist/transforms/needle_mesh_transform.js +140 -140
- package/dist/transforms/needle_progressive.d.ts +42 -42
- package/dist/transforms/needle_progressive.js +933 -921
- package/dist/transforms/needle_texture_transform.d.ts +13 -13
- package/dist/transforms/needle_texture_transform.js +202 -196
- package/dist/transforms/needle_toktx.d.ts +25 -25
- package/dist/transforms/needle_toktx.js +230 -230
- package/dist/transforms/needle_webp.d.ts +13 -13
- package/dist/transforms/needle_webp.js +37 -37
- package/dist/transforms/toktx.d.ts +52 -52
- package/dist/transforms/toktx.js +221 -221
- package/dist/transforms/toktx_types.d.ts +78 -78
- package/dist/transforms/toktx_types.js +62 -62
- package/dist/transforms/util.d.ts +21 -21
- package/dist/transforms/util.js +90 -90
- package/dist/utils/compression_utils.d.ts +2 -2
- package/dist/utils/compression_utils.js +6 -6
- package/dist/utils/fileutils.d.ts +6 -6
- package/dist/utils/fileutils.js +141 -141
- package/dist/utils/guid.d.ts +1 -1
- package/dist/utils/guid.js +5 -5
- package/dist/utils/index.d.ts +10 -9
- package/dist/utils/index.js +10 -9
- package/dist/utils/merge.d.ts +12 -12
- package/dist/utils/merge.js +31 -31
- package/dist/utils/mesh.d.ts +13 -13
- package/dist/utils/mesh.js +107 -107
- package/dist/utils/nodeio.d.ts +5 -5
- package/dist/utils/nodeio.js +14 -14
- package/dist/utils/stats.d.ts +54 -53
- package/dist/utils/stats.js +191 -166
- package/dist/utils/texture.d.ts +2 -2
- package/dist/utils/texture.js +8 -8
- package/dist/utils/validate.d.ts +5 -0
- package/dist/utils/validate.js +16 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +5 -5
- package/package.json +77 -76
- package/scripts/clear-caches.mjs +3 -3
- package/scripts/defaults.mjs +11 -11
- package/scripts/fileutils.mjs +5 -5
- package/scripts/index.mjs +41 -41
- package/scripts/limit-caches.mjs +3 -3
- package/scripts/make-progressive.mjs +16 -16
- package/scripts/pack-gltf.mjs +107 -107
- package/tsconfig.json +19 -19
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import { Primitive } from "@gltf-transform/core";
|
|
2
|
-
import { meshopt, simplifyPrimitive, SIMPLIFY_DEFAULTS, WELD_DEFAULTS, draco } from "@gltf-transform/functions";
|
|
3
|
-
import { MeshoptEncoder, MeshoptSimplifier } from "meshoptimizer";
|
|
4
|
-
import { NEEDLE_mesh_compression } from "../extensions/index.js";
|
|
5
|
-
import { weldPrimitive } from "../functions/weld.3.js";
|
|
6
|
-
const NAME = 'needle_mesh_transform';
|
|
7
|
-
export const needle_mesh_transform = function (context, simplify) {
|
|
8
|
-
return async (document, _context) => {
|
|
9
|
-
// TODO: needs to be moved into NEEDLE_progressive
|
|
10
|
-
await simplifierTransform(document, _context, simplify);
|
|
11
|
-
await applyMeshCompression(document, _context, context);
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
async function applyMeshCompression(document, transform_context, context) {
|
|
15
|
-
const rootExtension = document.getRoot().getExtension(NEEDLE_mesh_compression.EXTENSION_NAME);
|
|
16
|
-
if (rootExtension) {
|
|
17
|
-
const rootModel = rootExtension.model;
|
|
18
|
-
if (rootModel.compression) {
|
|
19
|
-
if (rootModel.compression === "none") {
|
|
20
|
-
document.getLogger().info(`[${NAME}]: NONE → will not apply mesh compression`);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
document.getLogger().info(`[${NAME}]: ${rootModel.compression.toUpperCase()} → will apply ${rootModel.compression} mesh compression`);
|
|
24
|
-
if (rootModel.compression === "draco") {
|
|
25
|
-
const transform = draco();
|
|
26
|
-
return transform(document, transform_context);
|
|
27
|
-
}
|
|
28
|
-
else if (rootModel.compression === "meshopt") {
|
|
29
|
-
const transform = meshopt({ encoder: MeshoptEncoder });
|
|
30
|
-
return transform(document, transform_context);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// If nothing is configured apply meshopt compression as long as we're running gltf-transform 3.x
|
|
35
|
-
// if (context.file.endsWith(".vrm")) {
|
|
36
|
-
// document.getLogger().info(`[${NAME}]: VRM → will apply meshopt mesh compression`);
|
|
37
|
-
// const transform = meshopt({ encoder: MeshoptEncoder });
|
|
38
|
-
// return transform(document, transform_context);
|
|
39
|
-
// }
|
|
40
|
-
// by default we still want to run draco if the root doesnt have a compression model configured
|
|
41
|
-
document.getLogger().info(`[${NAME}]: → will apply draco mesh compression (default)`);
|
|
42
|
-
return draco()(document, transform_context);
|
|
43
|
-
}
|
|
44
|
-
async function simplifierTransform(document, _context, _options) {
|
|
45
|
-
const simplifier = MeshoptSimplifier;
|
|
46
|
-
if (!simplifier) {
|
|
47
|
-
console.log(`WARN: [${NAME}] simplifier dependency required — install "meshoptimizer".`);
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const logger = document.getLogger();
|
|
51
|
-
const options = { ...SIMPLIFY_DEFAULTS, ..._options };
|
|
52
|
-
if (!options.simplifier)
|
|
53
|
-
options.simplifier = simplifier;
|
|
54
|
-
const weldOptions = {
|
|
55
|
-
...WELD_DEFAULTS,
|
|
56
|
-
tolerance: 0.00000000001,
|
|
57
|
-
overwrite: true,
|
|
58
|
-
};
|
|
59
|
-
for (const mesh of document.getRoot().listMeshes()) {
|
|
60
|
-
let i = 0;
|
|
61
|
-
for (const prim of mesh.listPrimitives()) {
|
|
62
|
-
const index = i++;
|
|
63
|
-
// TODO: mesh compression caching
|
|
64
|
-
// const key = getKey(prim);
|
|
65
|
-
// const cached = tryGetFromCache(key);
|
|
66
|
-
// if (cached) {
|
|
67
|
-
// logger.debug(`[${NAME}]: Skipping primitive of mesh "${mesh.getName()}": Already cached.`);
|
|
68
|
-
// continue;
|
|
69
|
-
// }
|
|
70
|
-
// updatePrimitive(prim, simplifier, null, prim.getIndices());
|
|
71
|
-
// continue;
|
|
72
|
-
const ext = prim.getExtension(NEEDLE_mesh_compression.EXTENSION_NAME);
|
|
73
|
-
const mesh_compression = ext?.model;
|
|
74
|
-
const simplifyOpts = { ...options };
|
|
75
|
-
if (!ext) {
|
|
76
|
-
// If no extension exists on the primitive dont apply any simplification
|
|
77
|
-
// console.log(`[${NAME}]: Skipping primitive simplification of mesh "${mesh.getName()}": No mesh compression extension found.`);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (mesh_compression) {
|
|
81
|
-
// Dont run if useSimplifier is turned off explictly
|
|
82
|
-
if (mesh_compression.useSimplifier === false) {
|
|
83
|
-
logger.debug(`[${NAME}]: Skipping primitive of mesh "${mesh.getName()}": useSimplifier is false.`);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (mesh_compression.error >= 0)
|
|
87
|
-
simplifyOpts.error = mesh_compression.error;
|
|
88
|
-
if (mesh_compression.ratio >= 0)
|
|
89
|
-
simplifyOpts.ratio = mesh_compression.ratio;
|
|
90
|
-
simplifyOpts.lockBorder = mesh_compression.lockBorder;
|
|
91
|
-
}
|
|
92
|
-
if (prim.getMode() !== Primitive.Mode.TRIANGLES) {
|
|
93
|
-
logger.warn(`[${NAME}]: Skipping primitive of mesh "${mesh.getName()}": Requires TRIANGLES draw mode.`);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
compressPrimitive(document, mesh, prim, index, weldOptions, simplifyOpts);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
export async function compressPrimitive(document, mesh, prim, index, weldOptions, meshOptions) {
|
|
102
|
-
const logger = document.getLogger();
|
|
103
|
-
logger.debug(`weld: primitive[${index}] of mesh "${mesh.getName()}"`);
|
|
104
|
-
weldPrimitive(prim, weldOptions);
|
|
105
|
-
// make sure we wait for the mesh simplifier to be ready
|
|
106
|
-
if (meshOptions.simplifier && meshOptions.simplifier?.ready instanceof Promise) {
|
|
107
|
-
const res = await meshOptions.simplifier?.ready
|
|
108
|
-
.then(() => {
|
|
109
|
-
// ready!
|
|
110
|
-
return true;
|
|
111
|
-
})
|
|
112
|
-
.catch((err) => {
|
|
113
|
-
console.error(`[${NAME}]: Simplifier failed to load...\n${err}`);
|
|
114
|
-
return false;
|
|
115
|
-
});
|
|
116
|
-
if (!res)
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
logger.debug(`simplify: primitive[${index}] of mesh "${mesh.getName()}" → ratio: ${meshOptions.ratio}, error: ${meshOptions.error}, lockBorder: ${meshOptions.lockBorder}`);
|
|
120
|
-
return simplifyPrimitive(prim, meshOptions);
|
|
121
|
-
}
|
|
122
|
-
// function updatePrimitive(prim: Primitive, simplifier: any, positionArray, dstIndicesArray) {
|
|
123
|
-
// const position = prim.getAttribute('POSITION')!;
|
|
124
|
-
// const srcIndices = prim.getIndices()!;
|
|
125
|
-
// const srcVertexCount = position.getCount();
|
|
126
|
-
// const [remap, unique] = simplifier.compactMesh(dstIndicesArray);
|
|
127
|
-
// // logger.debug(`${NAME}: ${formatDeltaOp(position.getCount(), unique)} vertices, error: ${error.toFixed(4)}.`);
|
|
128
|
-
// // (3) Write vertex attributes.
|
|
129
|
-
// for (const srcAttribute of deepListAttributes(prim)) {
|
|
130
|
-
// const dstAttribute = srcAttribute.clone();
|
|
131
|
-
// remapAttribute(dstAttribute, remap, unique);
|
|
132
|
-
// deepSwapAttribute(prim, srcAttribute, dstAttribute);
|
|
133
|
-
// if (srcAttribute.listParents().length === 1) srcAttribute.dispose();
|
|
134
|
-
// }
|
|
135
|
-
// // (4) Write indices.
|
|
136
|
-
// const dstIndices = srcIndices.clone();
|
|
137
|
-
// dstIndices.setArray(srcVertexCount <= 65534 ? new Uint16Array(dstIndicesArray) : dstIndicesArray);
|
|
138
|
-
// prim.setIndices(dstIndices);
|
|
139
|
-
// if (srcIndices.listParents().length === 1) srcIndices.dispose();
|
|
140
|
-
// }
|
|
1
|
+
import { Primitive } from "@gltf-transform/core";
|
|
2
|
+
import { meshopt, simplifyPrimitive, SIMPLIFY_DEFAULTS, WELD_DEFAULTS, draco } from "@gltf-transform/functions";
|
|
3
|
+
import { MeshoptEncoder, MeshoptSimplifier } from "meshoptimizer";
|
|
4
|
+
import { NEEDLE_mesh_compression } from "../extensions/index.js";
|
|
5
|
+
import { weldPrimitive } from "../functions/weld.3.js";
|
|
6
|
+
const NAME = 'needle_mesh_transform';
|
|
7
|
+
export const needle_mesh_transform = function (context, simplify) {
|
|
8
|
+
return async (document, _context) => {
|
|
9
|
+
// TODO: needs to be moved into NEEDLE_progressive
|
|
10
|
+
await simplifierTransform(document, _context, simplify);
|
|
11
|
+
await applyMeshCompression(document, _context, context);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
async function applyMeshCompression(document, transform_context, context) {
|
|
15
|
+
const rootExtension = document.getRoot().getExtension(NEEDLE_mesh_compression.EXTENSION_NAME);
|
|
16
|
+
if (rootExtension) {
|
|
17
|
+
const rootModel = rootExtension.model;
|
|
18
|
+
if (rootModel.compression) {
|
|
19
|
+
if (rootModel.compression === "none") {
|
|
20
|
+
document.getLogger().info(`[${NAME}]: NONE → will not apply mesh compression`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
document.getLogger().info(`[${NAME}]: ${rootModel.compression.toUpperCase()} → will apply ${rootModel.compression} mesh compression`);
|
|
24
|
+
if (rootModel.compression === "draco") {
|
|
25
|
+
const transform = draco();
|
|
26
|
+
return transform(document, transform_context);
|
|
27
|
+
}
|
|
28
|
+
else if (rootModel.compression === "meshopt") {
|
|
29
|
+
const transform = meshopt({ encoder: MeshoptEncoder });
|
|
30
|
+
return transform(document, transform_context);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// If nothing is configured apply meshopt compression as long as we're running gltf-transform 3.x
|
|
35
|
+
// if (context.file.endsWith(".vrm")) {
|
|
36
|
+
// document.getLogger().info(`[${NAME}]: VRM → will apply meshopt mesh compression`);
|
|
37
|
+
// const transform = meshopt({ encoder: MeshoptEncoder });
|
|
38
|
+
// return transform(document, transform_context);
|
|
39
|
+
// }
|
|
40
|
+
// by default we still want to run draco if the root doesnt have a compression model configured
|
|
41
|
+
document.getLogger().info(`[${NAME}]: → will apply draco mesh compression (default)`);
|
|
42
|
+
return draco()(document, transform_context);
|
|
43
|
+
}
|
|
44
|
+
async function simplifierTransform(document, _context, _options) {
|
|
45
|
+
const simplifier = MeshoptSimplifier;
|
|
46
|
+
if (!simplifier) {
|
|
47
|
+
console.log(`WARN: [${NAME}] simplifier dependency required — install "meshoptimizer".`);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const logger = document.getLogger();
|
|
51
|
+
const options = { ...SIMPLIFY_DEFAULTS, ..._options };
|
|
52
|
+
if (!options.simplifier)
|
|
53
|
+
options.simplifier = simplifier;
|
|
54
|
+
const weldOptions = {
|
|
55
|
+
...WELD_DEFAULTS,
|
|
56
|
+
tolerance: 0.00000000001,
|
|
57
|
+
overwrite: true,
|
|
58
|
+
};
|
|
59
|
+
for (const mesh of document.getRoot().listMeshes()) {
|
|
60
|
+
let i = 0;
|
|
61
|
+
for (const prim of mesh.listPrimitives()) {
|
|
62
|
+
const index = i++;
|
|
63
|
+
// TODO: mesh compression caching
|
|
64
|
+
// const key = getKey(prim);
|
|
65
|
+
// const cached = tryGetFromCache(key);
|
|
66
|
+
// if (cached) {
|
|
67
|
+
// logger.debug(`[${NAME}]: Skipping primitive of mesh "${mesh.getName()}": Already cached.`);
|
|
68
|
+
// continue;
|
|
69
|
+
// }
|
|
70
|
+
// updatePrimitive(prim, simplifier, null, prim.getIndices());
|
|
71
|
+
// continue;
|
|
72
|
+
const ext = prim.getExtension(NEEDLE_mesh_compression.EXTENSION_NAME);
|
|
73
|
+
const mesh_compression = ext?.model;
|
|
74
|
+
const simplifyOpts = { ...options };
|
|
75
|
+
if (!ext) {
|
|
76
|
+
// If no extension exists on the primitive dont apply any simplification
|
|
77
|
+
// console.log(`[${NAME}]: Skipping primitive simplification of mesh "${mesh.getName()}": No mesh compression extension found.`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (mesh_compression) {
|
|
81
|
+
// Dont run if useSimplifier is turned off explictly
|
|
82
|
+
if (mesh_compression.useSimplifier === false) {
|
|
83
|
+
logger.debug(`[${NAME}]: Skipping primitive of mesh "${mesh.getName()}": useSimplifier is false.`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (mesh_compression.error >= 0)
|
|
87
|
+
simplifyOpts.error = mesh_compression.error;
|
|
88
|
+
if (mesh_compression.ratio >= 0)
|
|
89
|
+
simplifyOpts.ratio = mesh_compression.ratio;
|
|
90
|
+
simplifyOpts.lockBorder = mesh_compression.lockBorder;
|
|
91
|
+
}
|
|
92
|
+
if (prim.getMode() !== Primitive.Mode.TRIANGLES) {
|
|
93
|
+
logger.warn(`[${NAME}]: Skipping primitive of mesh "${mesh.getName()}": Requires TRIANGLES draw mode.`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
compressPrimitive(document, mesh, prim, index, weldOptions, simplifyOpts);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
export async function compressPrimitive(document, mesh, prim, index, weldOptions, meshOptions) {
|
|
102
|
+
const logger = document.getLogger();
|
|
103
|
+
logger.debug(`weld: primitive[${index}] of mesh "${mesh.getName()}"`);
|
|
104
|
+
weldPrimitive(prim, weldOptions);
|
|
105
|
+
// make sure we wait for the mesh simplifier to be ready
|
|
106
|
+
if (meshOptions.simplifier && meshOptions.simplifier?.ready instanceof Promise) {
|
|
107
|
+
const res = await meshOptions.simplifier?.ready
|
|
108
|
+
.then(() => {
|
|
109
|
+
// ready!
|
|
110
|
+
return true;
|
|
111
|
+
})
|
|
112
|
+
.catch((err) => {
|
|
113
|
+
console.error(`[${NAME}]: Simplifier failed to load...\n${err}`);
|
|
114
|
+
return false;
|
|
115
|
+
});
|
|
116
|
+
if (!res)
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
logger.debug(`simplify: primitive[${index}] of mesh "${mesh.getName()}" → ratio: ${meshOptions.ratio}, error: ${meshOptions.error}, lockBorder: ${meshOptions.lockBorder}`);
|
|
120
|
+
return simplifyPrimitive(prim, meshOptions);
|
|
121
|
+
}
|
|
122
|
+
// function updatePrimitive(prim: Primitive, simplifier: any, positionArray, dstIndicesArray) {
|
|
123
|
+
// const position = prim.getAttribute('POSITION')!;
|
|
124
|
+
// const srcIndices = prim.getIndices()!;
|
|
125
|
+
// const srcVertexCount = position.getCount();
|
|
126
|
+
// const [remap, unique] = simplifier.compactMesh(dstIndicesArray);
|
|
127
|
+
// // logger.debug(`${NAME}: ${formatDeltaOp(position.getCount(), unique)} vertices, error: ${error.toFixed(4)}.`);
|
|
128
|
+
// // (3) Write vertex attributes.
|
|
129
|
+
// for (const srcAttribute of deepListAttributes(prim)) {
|
|
130
|
+
// const dstAttribute = srcAttribute.clone();
|
|
131
|
+
// remapAttribute(dstAttribute, remap, unique);
|
|
132
|
+
// deepSwapAttribute(prim, srcAttribute, dstAttribute);
|
|
133
|
+
// if (srcAttribute.listParents().length === 1) srcAttribute.dispose();
|
|
134
|
+
// }
|
|
135
|
+
// // (4) Write indices.
|
|
136
|
+
// const dstIndices = srcIndices.clone();
|
|
137
|
+
// dstIndices.setArray(srcVertexCount <= 65534 ? new Uint16Array(dstIndicesArray) : dstIndicesArray);
|
|
138
|
+
// prim.setIndices(dstIndices);
|
|
139
|
+
// if (srcIndices.listParents().length === 1) srcIndices.dispose();
|
|
140
|
+
// }
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { ILogger, Texture, Transform, vec2 } from '@gltf-transform/core';
|
|
2
|
-
import { Config } from '../config/index.js';
|
|
3
|
-
declare interface ProgressiveOptions {
|
|
4
|
-
path: string | Array<string>;
|
|
5
|
-
results: Array<string>;
|
|
6
|
-
config: Config;
|
|
7
|
-
debug?: boolean;
|
|
8
|
-
verbose?: boolean;
|
|
9
|
-
useCache?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function make_progressive(opts: ProgressiveOptions): Promise<boolean>;
|
|
12
|
-
export declare function createTransform(name: string, fn: Transform): Transform;
|
|
13
|
-
export declare function make_progressive_textures(filePath: string, _options: TextureResizeOptions, opts: ProgressiveOptions): Transform;
|
|
14
|
-
/** Options for the {@link textureResize} function. */
|
|
15
|
-
export interface TextureResizeOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Maximum width/height to enforce, preserving aspect ratio. For example,
|
|
18
|
-
* a 4096x8192 texture, resized with limit [2048, 2048] will be reduced
|
|
19
|
-
* to 1024x2048.
|
|
20
|
-
*/
|
|
21
|
-
size: vec2;
|
|
22
|
-
/** Resampling filter method. LANCZOS3 is sharper, LANCZOS2 is smoother. */
|
|
23
|
-
filter?: TextureResizeFilter;
|
|
24
|
-
/** Pattern identifying textures to resize, matched to name or URI. */
|
|
25
|
-
pattern?: RegExp | null;
|
|
26
|
-
/** Pattern to match slots usage for resizing. */
|
|
27
|
-
slots?: RegExp | null;
|
|
28
|
-
}
|
|
29
|
-
/** Resampling filter methods. LANCZOS3 is sharper, LANCZOS2 is smoother. */
|
|
30
|
-
export declare enum TextureResizeFilter {
|
|
31
|
-
/** Lanczos3 (sharp) */
|
|
32
|
-
LANCZOS3 = "lanczos3",
|
|
33
|
-
/** Lanczos2 (smooth) */
|
|
34
|
-
LANCZOS2 = "lanczos2"
|
|
35
|
-
}
|
|
36
|
-
export declare const TEXTURE_RESIZE_DEFAULTS: TextureResizeOptions;
|
|
37
|
-
export declare function resizeTextureToMax(texture: Texture, maxSize: number, logger: ILogger): Promise<void>;
|
|
38
|
-
export declare function make_progressive_meshes(filePath: string, _options: any, opts?: ProgressiveOptions): Transform;
|
|
39
|
-
export declare function isMeshLOD(filepath: string): boolean;
|
|
40
|
-
export declare function isImageLOD(filepath: string): boolean;
|
|
41
|
-
export declare function isLOD(filepath: string): boolean;
|
|
42
|
-
export {};
|
|
1
|
+
import { ILogger, Texture, Transform, vec2 } from '@gltf-transform/core';
|
|
2
|
+
import { Config } from '../config/index.js';
|
|
3
|
+
declare interface ProgressiveOptions {
|
|
4
|
+
path: string | Array<string>;
|
|
5
|
+
results: Array<string>;
|
|
6
|
+
config: Config;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
verbose?: boolean;
|
|
9
|
+
useCache?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function make_progressive(opts: ProgressiveOptions): Promise<boolean>;
|
|
12
|
+
export declare function createTransform(name: string, fn: Transform): Transform;
|
|
13
|
+
export declare function make_progressive_textures(filePath: string, _options: TextureResizeOptions, opts: ProgressiveOptions): Transform;
|
|
14
|
+
/** Options for the {@link textureResize} function. */
|
|
15
|
+
export interface TextureResizeOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Maximum width/height to enforce, preserving aspect ratio. For example,
|
|
18
|
+
* a 4096x8192 texture, resized with limit [2048, 2048] will be reduced
|
|
19
|
+
* to 1024x2048.
|
|
20
|
+
*/
|
|
21
|
+
size: vec2;
|
|
22
|
+
/** Resampling filter method. LANCZOS3 is sharper, LANCZOS2 is smoother. */
|
|
23
|
+
filter?: TextureResizeFilter;
|
|
24
|
+
/** Pattern identifying textures to resize, matched to name or URI. */
|
|
25
|
+
pattern?: RegExp | null;
|
|
26
|
+
/** Pattern to match slots usage for resizing. */
|
|
27
|
+
slots?: RegExp | null;
|
|
28
|
+
}
|
|
29
|
+
/** Resampling filter methods. LANCZOS3 is sharper, LANCZOS2 is smoother. */
|
|
30
|
+
export declare enum TextureResizeFilter {
|
|
31
|
+
/** Lanczos3 (sharp) */
|
|
32
|
+
LANCZOS3 = "lanczos3",
|
|
33
|
+
/** Lanczos2 (smooth) */
|
|
34
|
+
LANCZOS2 = "lanczos2"
|
|
35
|
+
}
|
|
36
|
+
export declare const TEXTURE_RESIZE_DEFAULTS: TextureResizeOptions;
|
|
37
|
+
export declare function resizeTextureToMax(texture: Texture, maxSize: number, logger: ILogger): Promise<void>;
|
|
38
|
+
export declare function make_progressive_meshes(filePath: string, _options: any, opts?: ProgressiveOptions): Transform;
|
|
39
|
+
export declare function isMeshLOD(filepath: string): boolean;
|
|
40
|
+
export declare function isImageLOD(filepath: string): boolean;
|
|
41
|
+
export declare function isLOD(filepath: string): boolean;
|
|
42
|
+
export {};
|