@needle-tools/gltf-build-pipeline 2.3.0-alpha.1 → 2.4.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [2.4.0-alpha] - 2023-06-26
|
|
8
|
+
- add: heuristic for choosing mesh compression if not explictly configured
|
|
9
|
+
|
|
10
|
+
## [2.3.0-alpha.2] - 2023-06-26
|
|
11
|
+
- change: usecase `product` does compress with UASTC again (for certain slots)
|
|
12
|
+
|
|
7
13
|
## [2.3.0-alpha.1] - 2023-06-23
|
|
8
14
|
- change: bump gltf-transform to 4.0.2 to fix meshopt skinning regression [1439](https://github.com/donmccurdy/glTF-Transform/pull/1439)
|
|
9
15
|
|
|
@@ -40,6 +40,32 @@ async function applyMeshCompression(document, transform_context, context) {
|
|
|
40
40
|
return transform(document, transform_context);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
// heuristic to detect if we should choose meshopt over draco
|
|
44
|
+
// because meshopt can compress blendshapes while draco can not
|
|
45
|
+
// we currently only consider the vertex count of the blendshapes
|
|
46
|
+
let sizeOfBlendshapes = 0;
|
|
47
|
+
let sizeOfMeshes = 0;
|
|
48
|
+
for (const mesh of document.getRoot().listMeshes()) {
|
|
49
|
+
for (const prim of mesh.listPrimitives()) {
|
|
50
|
+
for (const target of prim.listTargets()) {
|
|
51
|
+
sizeOfBlendshapes += target.getAttribute('POSITION').getArray().length;
|
|
52
|
+
}
|
|
53
|
+
sizeOfMeshes += prim.getAttribute('POSITION').getArray().length;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// consider meshopt if blendshape size is > 256 KB
|
|
57
|
+
const sizeThreshold = 256 * 1024;
|
|
58
|
+
if (sizeOfBlendshapes > sizeThreshold) {
|
|
59
|
+
/** How big are the blendshapes compared to the overall mesh size */
|
|
60
|
+
const blendshapeRatio = sizeOfBlendshapes / sizeOfMeshes;
|
|
61
|
+
/** 25% of the size are blendshapres */
|
|
62
|
+
const ratioThreshold = 0.25;
|
|
63
|
+
if (blendshapeRatio >= ratioThreshold) {
|
|
64
|
+
document.getLogger().info(`[${NAME}]: will apply meshopt mesh compression because blendshapes are ${(blendshapeRatio * 100).toFixed(2)}% of the mesh size`);
|
|
65
|
+
const transform = meshopt({ encoder: MeshoptEncoder });
|
|
66
|
+
return transform(document, transform_context);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
43
69
|
// by default we still want to run draco if the root doesnt have a compression model configured
|
|
44
70
|
document.getLogger().info(`[${NAME}]: → will apply draco mesh compression (default)`);
|
|
45
71
|
return draco()(document, transform_context);
|
|
@@ -147,10 +147,7 @@ async function processTexture(texture, index, document, logger, context) {
|
|
|
147
147
|
// if (slots.includes("metallicRoughnessTexture"))
|
|
148
148
|
// mimeType = "image/webp";
|
|
149
149
|
const isVRM = context.file?.toLowerCase().endsWith(".vrm");
|
|
150
|
-
if (
|
|
151
|
-
mimeType = "image/webp";
|
|
152
|
-
}
|
|
153
|
-
else if (slots.includes("lightmapTexture") || isLightmap(texture)) {
|
|
150
|
+
if (slots.includes("lightmapTexture") || isLightmap(texture)) {
|
|
154
151
|
mimeType = "image/webp";
|
|
155
152
|
}
|
|
156
153
|
// TODO: need to make this into a function
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-alpha",
|
|
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",
|