@needle-tools/gltf-build-pipeline 1.1.4 → 1.1.6
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,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.5] - 2023-06-26
|
|
8
|
+
- change: bump gltf-transform dependency to latest 3.4.3
|
|
9
|
+
|
|
7
10
|
## [1.1.4] - 2023-06-09
|
|
8
11
|
- fix: progressive texture transform didnt pass mesh compression setting through
|
|
9
12
|
|
|
@@ -10,6 +10,10 @@ export interface IOpaqueExtension {
|
|
|
10
10
|
export interface IOpaqueProperty {
|
|
11
11
|
/** used by progressive texture extension to pass an extension between documents */
|
|
12
12
|
getExtensionDefinition(): object;
|
|
13
|
+
/** register a reference so gltf-transform will not remove it in e.g. dedup
|
|
14
|
+
* https://github.com/donmccurdy/glTF-Transform/issues/980#issuecomment-1585748202
|
|
15
|
+
*/
|
|
16
|
+
setReference(name: string, value: any): any;
|
|
13
17
|
}
|
|
14
18
|
export interface IExtensionWriter {
|
|
15
19
|
/** used by progressive texture extension to pass an extension between documents */
|
|
@@ -199,7 +199,7 @@ export function createOpaqueExtension(name, types, opts) {
|
|
|
199
199
|
// attach the property
|
|
200
200
|
target[index].setExtension(EXTENSION_NAME, prop);
|
|
201
201
|
// capture all the json pointers in the extension
|
|
202
|
-
this.jsonPointerHandler.read(context, target[index], ext);
|
|
202
|
+
this.jsonPointerHandler.read(context, target[index], ext, prop);
|
|
203
203
|
// make sure we write our extension back to the gltf
|
|
204
204
|
prop.add(new OpaqueWriter(map, gltfField, ext));
|
|
205
205
|
});
|
|
@@ -293,7 +293,11 @@ export function createOpaqueExtension(name, types, opts) {
|
|
|
293
293
|
extensionName = typeof EXTENSION_NAME;
|
|
294
294
|
parentTypes = ExtensionPropertyTypes;
|
|
295
295
|
propertyType = "NEEDLE_opaque_property";
|
|
296
|
-
|
|
296
|
+
setReference(name, value) {
|
|
297
|
+
this.setRef(name, value, { modifyChild: true });
|
|
298
|
+
}
|
|
299
|
+
init() {
|
|
300
|
+
}
|
|
297
301
|
writers = [];
|
|
298
302
|
add(writer) {
|
|
299
303
|
if (typeof writer === "function") {
|
|
@@ -495,7 +499,7 @@ class JsonPointerHandler {
|
|
|
495
499
|
this.document = document;
|
|
496
500
|
this.id = id;
|
|
497
501
|
}
|
|
498
|
-
read(context, prop, obj, key, fullPath) {
|
|
502
|
+
read(context, prop, obj, ext, key, fullPath) {
|
|
499
503
|
const value = key !== undefined ? obj[key] : obj;
|
|
500
504
|
// the pointer path contains the full path from the root object to the json pointer
|
|
501
505
|
if (key !== undefined) {
|
|
@@ -506,7 +510,7 @@ class JsonPointerHandler {
|
|
|
506
510
|
case 'object':
|
|
507
511
|
if (value !== null && value !== undefined) {
|
|
508
512
|
for (const key of Object.keys(value)) {
|
|
509
|
-
this.read(context, prop, value, key, fullPath);
|
|
513
|
+
this.read(context, prop, value, ext, key, fullPath);
|
|
510
514
|
}
|
|
511
515
|
}
|
|
512
516
|
break;
|
|
@@ -551,6 +555,19 @@ class JsonPointerHandler {
|
|
|
551
555
|
else
|
|
552
556
|
console.warn("WARN: failed registering pointer", fullPath, value);
|
|
553
557
|
}
|
|
558
|
+
if (value.startsWith("/materials/")) {
|
|
559
|
+
// set a reference to the material to avoid dedup
|
|
560
|
+
// see https://github.com/donmccurdy/glTF-Transform/issues/980#issuecomment-1585748202
|
|
561
|
+
if (this.debug)
|
|
562
|
+
console.log("Read pointer", value);
|
|
563
|
+
const index = parseInt(value.substring("/materials/".length));
|
|
564
|
+
const mat = context.materials[index];
|
|
565
|
+
if (mat) {
|
|
566
|
+
if (ext) {
|
|
567
|
+
ext.setReference(key, mat);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
554
571
|
}
|
|
555
572
|
break;
|
|
556
573
|
}
|
package/dist/utils/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getVersion(): string;
|
|
1
|
+
export declare function getVersion(marklocal?: boolean): string;
|
package/dist/utils/version.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
let version = undefined;
|
|
3
|
-
|
|
3
|
+
let isLocal = false;
|
|
4
|
+
export function getVersion(marklocal = true) {
|
|
4
5
|
if (version === undefined) {
|
|
5
6
|
version = null;
|
|
6
7
|
const path = process.cwd() + "/package.json";
|
|
8
|
+
isLocal = !path.includes("node_modules");
|
|
7
9
|
if (existsSync(path)) {
|
|
8
10
|
const packageJson = readFileSync(path, "utf8");
|
|
9
11
|
const packageVersion = JSON.parse(packageJson).version;
|
|
@@ -12,5 +14,8 @@ export function getVersion() {
|
|
|
12
14
|
else
|
|
13
15
|
console.log("Could not find package.json at " + path);
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
let res = version;
|
|
18
|
+
if (marklocal && isLocal)
|
|
19
|
+
res += " (local)";
|
|
20
|
+
return res;
|
|
16
21
|
}
|
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.6",
|
|
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",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"compile": "tsc || exit 1"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@gltf-transform/core": "^3.
|
|
20
|
-
"@gltf-transform/extensions": "^3.
|
|
21
|
-
"@gltf-transform/functions": "^3.
|
|
19
|
+
"@gltf-transform/core": "^3.4.6",
|
|
20
|
+
"@gltf-transform/extensions": "^3.4.6",
|
|
21
|
+
"@gltf-transform/functions": "^3.4.6",
|
|
22
22
|
"@squoosh/lib": "^0.4.0",
|
|
23
23
|
"command-exists": "^1.2.9",
|
|
24
24
|
"command-line-args": "^5.2.1",
|