@needle-tools/gltf-build-pipeline 1.1.3 → 1.1.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/CHANGELOG.md +3 -0
- package/dist/transforms/needle_asset.js +2 -13
- package/dist/transforms/needle_mesh_transform.js +1 -0
- package/dist/transforms/needle_progressive.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/version.js +16 -0
- package/make-progressive.mjs +3 -0
- package/pack-gltf.mjs +6 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,9 @@ 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.1.4] - 2023-06-09
|
|
8
|
+
- fix: progressive texture transform didnt pass mesh compression setting through
|
|
9
|
+
|
|
7
10
|
## [1.1.3] - 2023-05-24
|
|
8
11
|
- minor change adding info about reduced size after processing gltf files
|
|
9
12
|
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { createTransform } from '@gltf-transform/functions';
|
|
2
|
-
import {
|
|
3
|
-
let version = undefined;
|
|
2
|
+
import { getVersion } from '../index.js';
|
|
4
3
|
export function needle_asset() {
|
|
5
4
|
return createTransform("needle_asset_transform", (document) => {
|
|
6
5
|
const root = document.getRoot();
|
|
7
6
|
const asset = root.getAsset();
|
|
8
7
|
if (asset) {
|
|
9
|
-
|
|
10
|
-
version = null;
|
|
11
|
-
const path = process.cwd() + "/package.json";
|
|
12
|
-
if (existsSync(path)) {
|
|
13
|
-
const packageJson = readFileSync(path, "utf8");
|
|
14
|
-
const packageVersion = JSON.parse(packageJson).version;
|
|
15
|
-
version = packageVersion ?? null;
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
console.log("Could not find package.json at " + path);
|
|
19
|
-
}
|
|
8
|
+
const version = getVersion();
|
|
20
9
|
if (!asset.generator.startsWith("Needle glTF Build Pipeline")) {
|
|
21
10
|
asset.generator = "Needle glTF Build Pipeline";
|
|
22
11
|
if (version?.length > 0) {
|
|
@@ -30,6 +30,7 @@ async function applyMeshCompression(document, _context) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
// by default we still want to run draco if the root doesnt have a compression model configured
|
|
33
|
+
console.log(`[${NAME}]: No compression model configured → will apply draco mesh compression`);
|
|
33
34
|
return draco()(document, _context);
|
|
34
35
|
}
|
|
35
36
|
async function simplifierTransform(document, _context, _options) {
|
|
@@ -17,7 +17,7 @@ function registerExtensions(io) {
|
|
|
17
17
|
//@ts-ignore
|
|
18
18
|
createOpaqueExtension(NEEDLE_compression_texture.EXTENSION_NAME, PropertyType.TEXTURE),
|
|
19
19
|
//@ts-ignore
|
|
20
|
-
createOpaqueExtension(NEEDLE_mesh_compression.EXTENSION_NAME, [PropertyType.MESH, PropertyType.PRIMITIVE])
|
|
20
|
+
createOpaqueExtension(NEEDLE_mesh_compression.EXTENSION_NAME, [PropertyType.ROOT, PropertyType.MESH, PropertyType.PRIMITIVE])
|
|
21
21
|
]);
|
|
22
22
|
}
|
|
23
23
|
export async function make_progressive(opts) {
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getVersion(): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
let version = undefined;
|
|
3
|
+
export function getVersion() {
|
|
4
|
+
if (version === undefined) {
|
|
5
|
+
version = null;
|
|
6
|
+
const path = process.cwd() + "/package.json";
|
|
7
|
+
if (existsSync(path)) {
|
|
8
|
+
const packageJson = readFileSync(path, "utf8");
|
|
9
|
+
const packageVersion = JSON.parse(packageJson).version;
|
|
10
|
+
version = packageVersion ?? null;
|
|
11
|
+
}
|
|
12
|
+
else
|
|
13
|
+
console.log("Could not find package.json at " + path);
|
|
14
|
+
}
|
|
15
|
+
return version;
|
|
16
|
+
}
|
package/make-progressive.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { getVersion } from './dist/index.js';
|
|
1
2
|
import { make_progressive } from './dist/transforms/needle_progressive.js';
|
|
2
3
|
|
|
3
4
|
const args = process.argv;
|
|
4
5
|
|
|
6
|
+
console.log(`[Needle Build Pipeline] transform to progressive — version ${getVersion()}`)
|
|
7
|
+
|
|
5
8
|
make_progressive({
|
|
6
9
|
path: args,
|
|
7
10
|
debug: args.includes("debug"),
|
package/pack-gltf.mjs
CHANGED
|
@@ -14,6 +14,9 @@ import { needle_animation_transform } from "./dist/transforms/needle_animation_t
|
|
|
14
14
|
import { foreachGLTF } from './fileutils.mjs';
|
|
15
15
|
import { needle_asset } from './dist/transforms/needle_asset.js';
|
|
16
16
|
import { MeshoptDecoder, MeshoptEncoder } from 'meshoptimizer';
|
|
17
|
+
import { getVersion } from './dist/index.js';
|
|
18
|
+
|
|
19
|
+
console.log(`[Needle Build Pipeline] pack glTF — version ${getVersion()}`)
|
|
17
20
|
|
|
18
21
|
const args = process.argv;
|
|
19
22
|
const showHelp = args.includes("help");
|
|
@@ -139,11 +142,13 @@ async function packFile(file) {
|
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
|
|
145
|
+
|
|
146
|
+
|
|
142
147
|
let startTime = Date.now();
|
|
143
148
|
foreachGLTF(process.argv, async (file) => {
|
|
144
149
|
await packFile(file);
|
|
145
150
|
}).then(() => {
|
|
146
151
|
const duration = Date.now() - startTime;
|
|
147
152
|
const durationInMinutes = duration / 1000 / 60;
|
|
148
|
-
console.log(`Finished packing ${totalFilesProcessed} files in ${durationInMinutes.toFixed(1)} minutes; total size ${totalFileSizeInMBBefore.toFixed(1)} MB → ${totalFileSizeInMB.toFixed(1)} MB, total GPU memory: ${totalGPUMemoryInMB.toFixed(1)} MB`);
|
|
153
|
+
console.log(`[Needle Build Pipeline] v${getVersion()} — Finished packing ${totalFilesProcessed} files in ${durationInMinutes.toFixed(1)} minutes; total size ${totalFileSizeInMBBefore.toFixed(1)} MB → ${totalFileSizeInMB.toFixed(1)} MB, total GPU memory: ${totalGPUMemoryInMB.toFixed(1)} MB`);
|
|
149
154
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/gltf-build-pipeline",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
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",
|