@needle-tools/gltf-build-pipeline 1.4.1-beta → 1.4.1-beta.3
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,10 +4,15 @@ 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
|
-
## [1.4.1-beta] - 2023-03-
|
|
7
|
+
## [1.4.1-beta.3] - 2023-03-14
|
|
8
|
+
- fix: wait for mesh simplifier to be ready
|
|
9
|
+
|
|
10
|
+
## [1.4.1-beta.2] - 2023-03-13
|
|
8
11
|
- change: update gltf-transform to `^3.10.0`
|
|
9
12
|
- change: progressive mesh transform does now set ratio for LODs (see [simplifier issue 661 on github](https://github.com/zeux/meshoptimizer/issues/661))
|
|
10
13
|
- fix: issue where progressive meshes were not generated if a mesh was multiple times in the glTF
|
|
14
|
+
- change: simplify to use ratio, fix issue where not all meshes were processed
|
|
15
|
+
- change: auto LOD max error set to 0.1
|
|
11
16
|
|
|
12
17
|
## [1.4.0-beta] - 2023-03-12
|
|
13
18
|
- add: progressive mesh transform to automatically generate mesh LOD levels (currently we only generate one low poly version)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Transform, Document, Primitive, Mesh } from "@gltf-transform/core";
|
|
2
2
|
import { SimplifyOptions, WeldOptions } from "@gltf-transform/functions";
|
|
3
3
|
export declare const needle_mesh_transform: (_options: SimplifyOptions) => Transform;
|
|
4
|
-
export declare function compressPrimitive(document: Document, mesh: Mesh, prim: Primitive, weldOptions: Required<WeldOptions>, meshOptions: Required<SimplifyOptions>): void
|
|
4
|
+
export declare function compressPrimitive(document: Document, mesh: Mesh, prim: Primitive, weldOptions: Required<WeldOptions>, meshOptions: Required<SimplifyOptions>): Promise<void>;
|
|
@@ -88,10 +88,24 @@ async function simplifierTransform(document, _context, _options) {
|
|
|
88
88
|
}
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
|
-
export function compressPrimitive(document, mesh, prim, weldOptions, meshOptions) {
|
|
91
|
+
export async function compressPrimitive(document, mesh, prim, weldOptions, meshOptions) {
|
|
92
92
|
const logger = document.getLogger();
|
|
93
93
|
logger.debug(`[${NAME}]: Welding primitive of mesh "${mesh.getName()}" → tolerance: ${weldOptions.tolerance}`);
|
|
94
94
|
weldPrimitive(document, prim, weldOptions);
|
|
95
|
+
// make sure we wait for the mesh simplifier to be ready
|
|
96
|
+
if (meshOptions.simplifier && meshOptions.simplifier?.ready instanceof Promise) {
|
|
97
|
+
const res = await meshOptions.simplifier?.ready
|
|
98
|
+
.then(() => {
|
|
99
|
+
// ready!
|
|
100
|
+
return true;
|
|
101
|
+
})
|
|
102
|
+
.catch((err) => {
|
|
103
|
+
console.error(`[${NAME}]: Simplifier failed to load...\n${err}`);
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
106
|
+
if (!res)
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
95
109
|
logger.debug(`[${NAME}]: Simplifying primitive of mesh "${mesh.getName()}" → ratio: ${meshOptions.ratio}, error: ${meshOptions.error}, lockBorder: ${meshOptions.lockBorder}`);
|
|
96
110
|
simplifyPrimitive(document, prim, meshOptions);
|
|
97
111
|
}
|
|
@@ -305,8 +305,8 @@ export function make_progressive_meshes(filePath, _options, opts) {
|
|
|
305
305
|
// the lowest LOD (last entry) will be saved in the original file
|
|
306
306
|
const LODS = [
|
|
307
307
|
{ error: 0 },
|
|
308
|
-
{ ratio: 0.5, error: 1 },
|
|
309
|
-
{ ratio: 0.25, error: 1 },
|
|
308
|
+
{ ratio: 0.5, error: .1 },
|
|
309
|
+
{ ratio: 0.25, error: .1 },
|
|
310
310
|
];
|
|
311
311
|
/** Map of visited GUID -> extension */
|
|
312
312
|
const visited = new Map();
|
|
@@ -448,7 +448,7 @@ function createMeshLod(doc, basePath, level, mesh, guid, lodLevel) {
|
|
|
448
448
|
newIo.write(outName, newDoc);
|
|
449
449
|
return filename;
|
|
450
450
|
}
|
|
451
|
-
function simplifyMesh(doc, mesh, prim, lodinfo) {
|
|
451
|
+
async function simplifyMesh(doc, mesh, prim, lodinfo) {
|
|
452
452
|
const weldOptions = {
|
|
453
453
|
...WELD_DEFAULTS,
|
|
454
454
|
overwrite: true,
|
|
@@ -460,7 +460,7 @@ function simplifyMesh(doc, mesh, prim, lodinfo) {
|
|
|
460
460
|
simplifyOptions.error = lodinfo.error;
|
|
461
461
|
if (lodinfo.ratio != undefined)
|
|
462
462
|
simplifyOptions.ratio = lodinfo.ratio;
|
|
463
|
-
compressPrimitive(doc, mesh, prim, weldOptions, simplifyOptions);
|
|
463
|
+
return compressPrimitive(doc, mesh, prim, weldOptions, simplifyOptions);
|
|
464
464
|
}
|
|
465
465
|
function isMeshLOD(filepath) {
|
|
466
466
|
return filepath.includes("mesh_lod_");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "1.4.1-beta",
|
|
3
|
+
"version": "1.4.1-beta.3",
|
|
4
4
|
"description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"type": "module",
|