@needle-tools/gltf-build-pipeline 2.2.0-alpha.1 → 2.2.0-alpha.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,12 +4,13 @@ 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.2.0-alpha] - 2023-06-06
8
- - Add: CLI `--progressive` option to `transform` command (default is enabled)
9
- - Add: config `meshes: { lods: boolean }` option
10
- - Remove: CLI "compress" command
11
- - Change: enable texture LODs by default
12
- - Fix: `--config` path can now point to a directory or a `needle.config.json` file as well
7
+ ## [2.2.0-alpha.2] - 2023-06-06
8
+ - add: CLI `--progressive` option to `transform` command (default is true)
9
+ - add: CLI `--compress` option to `transform` command (default is true)
10
+ - add: config `meshes: { lods: boolean }` option
11
+ - remove: CLI "compress" command
12
+ - change: enable texture LODs by default
13
+ - fix: `--config` path can now point to a directory or a `needle.config.json` file as well
13
14
 
14
15
  ## [2.1.0-alpha.6] - 2023-06-04
15
16
  - fix: errors when invoking npm scripts caused by the cli program
package/dist/cli/index.js CHANGED
@@ -32,6 +32,7 @@ Each version will be compressed and written to the output directory.
32
32
  `)
33
33
  .argument('<input>', "The input glTF, GLB or VRM file that should be compressed OR a directory that contains files to be compressed")
34
34
  // .argument('<output>', "The output file. If not provided, the input file will be overwritten.", { default: "" })
35
+ .option("--compress", `When enabled files will be compressed`, { validator: program.BOOLEAN, default: true })
35
36
  .option("--progressive", `When enabled files will processed to be progressively loaded`, { validator: program.BOOLEAN, default: true })
36
37
  .option("--usecase <usecase>", `The usecase for the compression. This will set the compression settings. Possible options: [${UsecaseOptions.join(", ")}]`, { validator: program.STRING })
37
38
  .option("--config <config>", "The path to a JSON file containing the compression settings. This can also be a needle.config.json file with a \"compression\" object or usecase string.", { validator: program.STRING })
@@ -39,6 +40,10 @@ Each version will be compressed and written to the output directory.
39
40
  .option("--cache", "Use \"--cache False\" to disable caching.\nWhen caching is enabled then previously processed files will be detected and loaded from disc cache instead of being processed again if settings or the file contents have not changed.", { validator: program.BOOLEAN, default: true })
40
41
  .option("--debug", "Enable for more verbose outout with \"--debug True\"", { validator: program.BOOLEAN, default: false })
41
42
  .action(async ({ logger, args, options }) => {
43
+ if (options.compress === false && options.progressive === false) {
44
+ logger.error("You need to enable at least one of the options: --compress or --progressive");
45
+ return;
46
+ }
42
47
  logger.info("Transforming glTF file: " + args.input);
43
48
  const stats = {
44
49
  startTime: Date.now(),
@@ -83,23 +88,25 @@ Each version will be compressed and written to the output directory.
83
88
  process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
84
89
  });
85
90
  }
86
- const opts = {
87
- config,
88
- stats,
89
- packedFiles: set,
90
- debug,
91
- useCache,
92
- logger: logger,
93
- file_stats,
94
- };
95
- for (const res of progressive_results) {
96
- if (await packGLTF(res, res, opts) === false) {
91
+ if (options.compress === true) {
92
+ const opts = {
93
+ config,
94
+ stats,
95
+ packedFiles: set,
96
+ debug,
97
+ useCache,
98
+ logger: logger,
99
+ file_stats,
100
+ };
101
+ for (const res of progressive_results) {
102
+ if (await packGLTF(res, res, opts) === false) {
103
+ process.exit(ERROR_CODES.PACKING_FAILED);
104
+ }
105
+ }
106
+ if (await packGLTF(file, file, opts) === false) {
97
107
  process.exit(ERROR_CODES.PACKING_FAILED);
98
108
  }
99
109
  }
100
- if (await packGLTF(file, file, opts) === false) {
101
- process.exit(ERROR_CODES.PACKING_FAILED);
102
- }
103
110
  });
104
111
  printStats(stats, logger, config);
105
112
  if (options.stats) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "2.2.0-alpha.1",
3
+ "version": "2.2.0-alpha.3",
4
4
  "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
- "main": "src/index.js",
5
+ "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "readme": "README.md",
8
8
  "author": {
@@ -1,4 +1,4 @@
1
1
 
2
- import { clearCache } from '../dist/src/cache/index.js';
2
+ import { clearCache } from '../dist/cache/index.js';
3
3
 
4
4
  clearCache();
@@ -1,6 +1,6 @@
1
1
  import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
2
- import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS } from "../dist/src/extensions/NEEDLE_opaque/index.js";
3
- import { NEEDLE_progressive } from '../dist/src/index.js';
2
+ import { ALL_EXTENSIONS as NEEDLE_EXTENSIONS } from "../dist/extensions/NEEDLE_opaque/index.js";
3
+ import { NEEDLE_progressive } from '../dist/index.js';
4
4
 
5
5
 
6
6
  export function registerExtensions(node) {
@@ -1,4 +1,4 @@
1
- import { foreachGLTF as foreach } from '../dist/src/index.js';
1
+ import { foreachGLTF as foreach } from '../dist/index.js';
2
2
 
3
3
 
4
4
  export function foreachGLTF(args, callback) {
package/scripts/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { spawnSync } from "child_process";
3
- import { getVersion } from "../dist/src/index.js";
3
+ import { getVersion } from "../dist/index.js";
4
4
 
5
5
  const workingDir = process.cwd();
6
6
 
@@ -1,4 +1,4 @@
1
1
 
2
- import { limitCacheSize } from '../dist/src/cache/index.js';
2
+ import { limitCacheSize } from '../dist/cache/index.js';
3
3
 
4
4
  limitCacheSize(512);
@@ -1,5 +1,5 @@
1
- import { getConfig, getVersion } from '../dist/src/index.js';
2
- import { make_progressive } from '../dist/src/transforms/needle_progressive.js';
1
+ import { getConfig, getVersion } from '../dist/index.js';
2
+ import { make_progressive } from '../dist/transforms/needle_progressive.js';
3
3
 
4
4
  const args = process.argv;
5
5
 
@@ -1,6 +1,6 @@
1
1
  import commandLineArgs from "command-line-args";
2
2
  import { foreachGLTF } from './fileutils.mjs';
3
- import { getVersion, limitCacheSize, getConfig, packGLTF, printStats } from '../dist/src/index.js';
3
+ import { getVersion, limitCacheSize, getConfig, packGLTF, printStats } from '../dist/index.js';
4
4
  import { Logger, Verbosity } from "@gltf-transform/core";
5
5
 
6
6
  console.log(`[Needle Build Pipeline] pack glTF — version ${getVersion()}`)
@@ -60,7 +60,7 @@ if (noToktx)
60
60
  const packedFiles = new Set();
61
61
 
62
62
  /**
63
- * @type {import("../dist/src/index.js").Stats}
63
+ * @type {import("../dist/index.js").Stats}
64
64
  */
65
65
  const stats = {
66
66
  startTime: Date.now(),