@needle-tools/gltf-build-pipeline 2.12.0 → 2.12.1

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/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # glTF Build Pipeline
2
2
 
3
- Creating optimized glTF, GLB and VRM files for the web.
4
- Includes support for generating LOD quality level for textures and meshes that can be used with [@needle-tools/gltf-progressive](https://www.npmjs.com/package/@needle-tools/gltf-progressive)
3
+ Creating optimized glTF, GLB and VRM files for the web.
4
+
5
+ Includes support for generating LOD quality level for textures and meshes. Use with [@needle-tools/gltf-progressive](https://www.npmjs.com/package/@needle-tools/gltf-progressive)
5
6
 
6
7
  ## Examples
7
8
 
@@ -23,12 +24,14 @@ To load progressively enhanced glTF files in any three.js based engine see examp
23
24
  `npx @needle-tools/gltf-build-pipeline@latest`
24
25
 
25
26
  ### Commands
26
- - `gltf-build-pipeline help` - use help to see options for each command
27
- - `gltf-build-pipeline compress <input>`
28
- - `gltf-build-pipeline transform <input>`
27
+ - `help` - use help to view options
28
+
29
+ # Contact
30
+
31
+ For licensing questions please contact us.
29
32
 
30
- # Contact ✒️
31
- <b>[🌵 needle — tools for creators](https://needle.tools)</b> •
33
+ <b>[🌵 Needle](https://needle.tools)</b> •
34
+ [Email](mailto:hi@needle.tools) •
32
35
  [Twitter](https://twitter.com/NeedleTools) •
33
36
  [Discord](https://discord.needle.tools) •
34
37
  [Forum](https://forum.needle.tools)
@@ -199,7 +199,7 @@ export async function compressPrimitive(document, mesh, prim, index, weldOptions
199
199
  return;
200
200
  }
201
201
  // TODO: enable regularize once it's available: https://github.com/zeux/meshoptimizer/pull/914/files
202
- logger.debug(`simplify: primitive[${index}] of mesh "${mesh.getName()}" → ratio: ${meshOptions.ratio}, error: ${meshOptions.error}, lockBorder: ${meshOptions.lockBorder}`);
202
+ logger.debug(`simplify: primitive[${index}] of mesh "${mesh.getName()}" → ratio: ${meshOptions.ratio}, error: ${meshOptions.error}, lockBorder: ${meshOptions.lockBorder}, regularize: ${meshOptions.regularize}, normalWeight: ${meshOptions.normalWeight}, colorWeight: ${meshOptions.colorWeight}, textureWeight: ${meshOptions.textureWeight}`);
203
203
  return simplifyPrimitive(prim, meshOptions);
204
204
  }
205
205
  // function updatePrimitive(prim: Primitive, simplifier: any, positionArray, dstIndicesArray) {
@@ -530,31 +530,42 @@ export function make_progressive_meshes(filePath, _options, opts) {
530
530
  const filename = path.basename(filePath);
531
531
  logger.info(`[${NAME}]: Begin generating progressive meshes for \"${filename}\"`);
532
532
  let index = 0;
533
+ // Try settings here: https://meshoptimizer.org/demo/simplify.html
533
534
  // the lowest LOD (last entry) will be saved in the original file
534
535
  let MAX_LODS = 6;
535
536
  if (opts.config.usecase === "product") {
536
537
  MAX_LODS = 3;
537
538
  }
538
- const LODS = [
539
- {
540
- ratio: 1,
541
- error: 0,
542
- lockBorder: true
543
- },
544
- ];
539
+ const lod0_settings = {
540
+ ratio: 1,
541
+ error: 0,
542
+ lockBorder: true,
543
+ normalWeight: 2,
544
+ colorWeight: 1,
545
+ textureWeight: 1
546
+ };
547
+ const errorLevel = [0, .003, .005, .01, .02]; // 0.02 is roughly 10^-1.7 → disable scale error and set error https://meshoptimizer.org/demo/simplify.html
548
+ const LODS = [lod0_settings];
545
549
  for (let l = 0; l < MAX_LODS; l++) {
546
- const t = l / (MAX_LODS - 1);
547
- const latest = LODS[LODS.length - 1];
548
- const ratio = latest.ratio * .5;
549
- let error = 0.003 + t * .01; // using max 1%, example mesh: https://linear.app/needle/issue/NE-6653
550
+ const t01 = l / (MAX_LODS - 1);
551
+ const previous = LODS[LODS.length - 1];
552
+ const ratio = previous.ratio * .5;
553
+ let error = errorLevel[Math.min(errorLevel.length - 1, l)]; // example mesh: https://linear.app/needle/issue/NE-6653 or https://cloud-staging.needle.tools/edit/Z1S7sey8bb7061
550
554
  if (opts.config.usecase === "product") {
551
555
  error *= .5;
552
556
  }
557
+ const normalWeight = lod0_settings.normalWeight; // keep normalWeight constantly high since it's so important
558
+ const colorWeight = Math.max(.2, Math.min(1, lod0_settings.colorWeight * (1 - t01)));
559
+ const textureWeight = Math.max(.2, Math.min(10, lod0_settings.textureWeight * (1 - t01 * 2)));
560
+ const regularize = l > 1 && l < (MAX_LODS - 2); // only regularize the inner LODs
553
561
  LODS.push({
554
562
  ratio: ratio,
555
563
  error,
556
564
  lockBorder: true,
557
- // toleranceNormal: 0.1 + t * 0.1,
565
+ regularize: regularize,
566
+ normalWeight: normalWeight,
567
+ colorWeight: colorWeight,
568
+ textureWeight: textureWeight,
558
569
  });
559
570
  }
560
571
  logger.debug(`[${NAME}]: Generating mesh LODs:\n${JSON.stringify(LODS, undefined, 2)}`);
@@ -1 +1 @@
1
- export declare const version = "2.12.0";
1
+ export declare const version = "2.12.1";
@@ -1 +1 @@
1
- export const version = "2.12.0";
1
+ export const version = "2.12.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
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",