@needle-tools/gltf-build-pipeline 2.2.1-alpha.2 → 2.2.1-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/.temp/Go2.bin +0 -0
- package/.temp/textures/0_1.exr +0 -0
- package/.temp/textures/1_1.jpg +0 -0
- package/CHANGELOG.md +395 -394
- package/README.md +35 -35
- package/dist/cache/cache.d.ts +54 -54
- package/dist/cache/cache.js +257 -257
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +154 -154
- package/dist/config/index.d.ts +53 -53
- package/dist/config/index.js +152 -152
- package/dist/constants.d.ts +5 -5
- package/dist/constants.js +5 -5
- package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
- package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
- package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
- package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
- package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +26 -26
- package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +85 -85
- package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
- package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
- package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +897 -897
- package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
- package/dist/extensions/NEEDLE_opaque/index.js +28 -28
- package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
- package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
- package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
- package/dist/extensions/NEEDLE_progressive/index.js +1 -1
- package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
- package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
- package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
- package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +67 -67
- package/dist/extensions/index.d.ts +7 -7
- package/dist/extensions/index.js +17 -17
- package/dist/extensions/utils.d.ts +6 -6
- package/dist/extensions/utils.js +72 -72
- package/dist/functions/weld.3.d.ts +76 -76
- package/dist/functions/weld.3.js +414 -414
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/scripts/index.d.ts +2 -2
- package/dist/scripts/index.js +2 -2
- package/dist/scripts/pack-gltf.d.ts +16 -16
- package/dist/scripts/pack-gltf.js +120 -120
- package/dist/scripts/stats.d.ts +2 -2
- package/dist/scripts/stats.js +18 -18
- package/dist/transforms/index.d.ts +9 -9
- package/dist/transforms/index.js +9 -9
- package/dist/transforms/needle_animation_transform.d.ts +2 -2
- package/dist/transforms/needle_animation_transform.js +5 -5
- package/dist/transforms/needle_asset.d.ts +3 -3
- package/dist/transforms/needle_asset.js +35 -35
- package/dist/transforms/needle_common.d.ts +16 -16
- package/dist/transforms/needle_common.js +1 -1
- package/dist/transforms/needle_mesh_transform.d.ts +10 -10
- package/dist/transforms/needle_mesh_transform.js +140 -140
- package/dist/transforms/needle_progressive.d.ts +42 -42
- package/dist/transforms/needle_progressive.js +921 -921
- package/dist/transforms/needle_texture_transform.d.ts +13 -13
- package/dist/transforms/needle_texture_transform.js +202 -196
- package/dist/transforms/needle_toktx.d.ts +25 -25
- package/dist/transforms/needle_toktx.js +230 -230
- package/dist/transforms/needle_webp.d.ts +13 -13
- package/dist/transforms/needle_webp.js +37 -37
- package/dist/transforms/toktx.d.ts +52 -52
- package/dist/transforms/toktx.js +221 -221
- package/dist/transforms/toktx_types.d.ts +78 -78
- package/dist/transforms/toktx_types.js +62 -62
- package/dist/transforms/util.d.ts +21 -21
- package/dist/transforms/util.js +90 -90
- package/dist/utils/compression_utils.d.ts +2 -2
- package/dist/utils/compression_utils.js +6 -6
- package/dist/utils/fileutils.d.ts +6 -6
- package/dist/utils/fileutils.js +141 -141
- package/dist/utils/guid.d.ts +1 -1
- package/dist/utils/guid.js +5 -5
- package/dist/utils/index.d.ts +10 -9
- package/dist/utils/index.js +10 -9
- package/dist/utils/merge.d.ts +12 -12
- package/dist/utils/merge.js +31 -31
- package/dist/utils/mesh.d.ts +13 -13
- package/dist/utils/mesh.js +107 -107
- package/dist/utils/nodeio.d.ts +5 -5
- package/dist/utils/nodeio.js +14 -14
- package/dist/utils/stats.d.ts +54 -53
- package/dist/utils/stats.js +191 -166
- package/dist/utils/texture.d.ts +2 -2
- package/dist/utils/texture.js +8 -8
- package/dist/utils/validate.d.ts +5 -0
- package/dist/utils/validate.js +16 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +5 -5
- package/package.json +77 -76
- package/scripts/clear-caches.mjs +3 -3
- package/scripts/defaults.mjs +11 -11
- package/scripts/fileutils.mjs +5 -5
- package/scripts/index.mjs +41 -41
- package/scripts/limit-caches.mjs +3 -3
- package/scripts/make-progressive.mjs +16 -16
- package/scripts/pack-gltf.mjs +107 -107
- package/tsconfig.json +19 -19
package/dist/utils/fileutils.js
CHANGED
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
import { existsSync, statSync, readdirSync, readFileSync } from 'fs';
|
|
2
|
-
import { isAbsolute } from 'path';
|
|
3
|
-
export function getFileName(filepath) {
|
|
4
|
-
const parts = filepath.replaceAll("\\", "/").split("/");
|
|
5
|
-
return parts[parts.length - 1];
|
|
6
|
-
}
|
|
7
|
-
export function getDirName(filepath) {
|
|
8
|
-
// should work for paths that end with "/" or not
|
|
9
|
-
const parts = filepath.replaceAll("\\", "/").split("/");
|
|
10
|
-
let res = parts.pop();
|
|
11
|
-
if (res === "") {
|
|
12
|
-
res = parts.pop();
|
|
13
|
-
}
|
|
14
|
-
return res;
|
|
15
|
-
}
|
|
16
|
-
export async function foreachGLTF(args, callback) {
|
|
17
|
-
// get original directory this run was invoked from
|
|
18
|
-
const initDir = process.env.INIT_CWD;
|
|
19
|
-
const context = {
|
|
20
|
-
baseDirectory: initDir,
|
|
21
|
-
files: [],
|
|
22
|
-
};
|
|
23
|
-
// traverse recursively through all files and directories
|
|
24
|
-
if (Array.isArray(args)) {
|
|
25
|
-
for (const arg of args) {
|
|
26
|
-
await testEntry(arg, context);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else if (typeof args === "string") {
|
|
30
|
-
await testEntry(args, context);
|
|
31
|
-
}
|
|
32
|
-
// try to run with needle config
|
|
33
|
-
if (context.files?.length <= 0 && context.baseDirectory) {
|
|
34
|
-
const needleConfigPath = context.baseDirectory + "/needle.config.json";
|
|
35
|
-
if (existsSync(needleConfigPath)) {
|
|
36
|
-
const config = JSON.parse(readFileSync(needleConfigPath, "utf8"));
|
|
37
|
-
const buildDirectory = config.buildDirectory;
|
|
38
|
-
if (buildDirectory?.length) {
|
|
39
|
-
// If it's an absolute path
|
|
40
|
-
if (existsSync(buildDirectory)) {
|
|
41
|
-
console.log("INFO: Using build directory from needle.config.json: " + buildDirectory);
|
|
42
|
-
await testEntry(buildDirectory, context);
|
|
43
|
-
}
|
|
44
|
-
else { // if its a relative path
|
|
45
|
-
const newPath = context.baseDirectory + "/" + buildDirectory;
|
|
46
|
-
if (existsSync(newPath)) {
|
|
47
|
-
console.log("INFO: Using build directory from needle.config.json: " + newPath);
|
|
48
|
-
await testEntry(newPath, context);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// if no file was found, we don't have a needle.config in the directory
|
|
55
|
-
// and we don't have any arguments, try to find it in the default dist directory
|
|
56
|
-
// await testEntry(context.baseDirectory + "/dist", callback, context);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (context.files.length <= 0) {
|
|
60
|
-
console.log("WARN: No glTF files found. Make sure to invoke with a valid path to a glTF file or directory. This path may be relative to \"" + initDir + "\"");
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
for (const file of context.files) {
|
|
64
|
-
await callback(file);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async function testEntry(entry, context) {
|
|
69
|
-
// ignore argument names (e.g. --debug)
|
|
70
|
-
if (entry.startsWith("--")) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
if (entry === "." || entry === "./") {
|
|
74
|
-
if (context.baseDirectory) {
|
|
75
|
-
entry = context.baseDirectory;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (existsSync(entry) === false) {
|
|
79
|
-
// If no base directory is defined we cannot try to resolve the path
|
|
80
|
-
if (context.baseDirectory === undefined) {
|
|
81
|
-
console.log("WARN: Path does not exist: " + entry);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
// Try resolve potential relative path
|
|
85
|
-
const newPath = context.baseDirectory + "/" + entry;
|
|
86
|
-
if (existsSync(newPath) === false) {
|
|
87
|
-
console.log(`INFO: Resolved path failed: \"${entry}\" -> ${newPath} (doesnt exist or is locked by another process)`);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`);
|
|
92
|
-
entry = newPath;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// When passing in a relative path (e.g. `dist`) we dont want to accidentally traverse this package's directory
|
|
97
|
-
// So in that case make sure we resolve to an absolute path relative to the calling directory
|
|
98
|
-
const isAbs = isAbsolute(entry);
|
|
99
|
-
if (!isAbs) {
|
|
100
|
-
if (context.baseDirectory) {
|
|
101
|
-
const newPath = context.baseDirectory + "/" + entry;
|
|
102
|
-
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`);
|
|
103
|
-
entry = newPath;
|
|
104
|
-
if (!existsSync(entry)) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (entry.endsWith(".glb") || entry.endsWith(".gltf") || entry.endsWith(".vrm")) {
|
|
111
|
-
context.files.push(entry);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
const stat = statSync(entry);
|
|
115
|
-
if (stat.isDirectory()) {
|
|
116
|
-
// Don't traverse node_modules
|
|
117
|
-
if (entry.endsWith("node_modules")) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const files = readdirSync(entry);
|
|
121
|
-
for (const file of files) {
|
|
122
|
-
await testEntry(entry + "/" + file, context);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
// console.log("WARN: Ignoring file: " + entry);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export function replaceExtension(filepath, newExtension) {
|
|
131
|
-
const parts = filepath.split(".");
|
|
132
|
-
parts.pop();
|
|
133
|
-
return parts.join(".") + "." + newExtension;
|
|
134
|
-
}
|
|
135
|
-
export function isDirectory(path) {
|
|
136
|
-
if (existsSync(path)) {
|
|
137
|
-
return statSync(path).isDirectory();
|
|
138
|
-
}
|
|
139
|
-
const hasExt = path.replaceAll("\\", "/").split("/").pop()?.includes(".");
|
|
140
|
-
return !hasExt;
|
|
141
|
-
}
|
|
1
|
+
import { existsSync, statSync, readdirSync, readFileSync } from 'fs';
|
|
2
|
+
import { isAbsolute } from 'path';
|
|
3
|
+
export function getFileName(filepath) {
|
|
4
|
+
const parts = filepath.replaceAll("\\", "/").split("/");
|
|
5
|
+
return parts[parts.length - 1];
|
|
6
|
+
}
|
|
7
|
+
export function getDirName(filepath) {
|
|
8
|
+
// should work for paths that end with "/" or not
|
|
9
|
+
const parts = filepath.replaceAll("\\", "/").split("/");
|
|
10
|
+
let res = parts.pop();
|
|
11
|
+
if (res === "") {
|
|
12
|
+
res = parts.pop();
|
|
13
|
+
}
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
export async function foreachGLTF(args, callback) {
|
|
17
|
+
// get original directory this run was invoked from
|
|
18
|
+
const initDir = process.env.INIT_CWD;
|
|
19
|
+
const context = {
|
|
20
|
+
baseDirectory: initDir,
|
|
21
|
+
files: [],
|
|
22
|
+
};
|
|
23
|
+
// traverse recursively through all files and directories
|
|
24
|
+
if (Array.isArray(args)) {
|
|
25
|
+
for (const arg of args) {
|
|
26
|
+
await testEntry(arg, context);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (typeof args === "string") {
|
|
30
|
+
await testEntry(args, context);
|
|
31
|
+
}
|
|
32
|
+
// try to run with needle config
|
|
33
|
+
if (context.files?.length <= 0 && context.baseDirectory) {
|
|
34
|
+
const needleConfigPath = context.baseDirectory + "/needle.config.json";
|
|
35
|
+
if (existsSync(needleConfigPath)) {
|
|
36
|
+
const config = JSON.parse(readFileSync(needleConfigPath, "utf8"));
|
|
37
|
+
const buildDirectory = config.buildDirectory;
|
|
38
|
+
if (buildDirectory?.length) {
|
|
39
|
+
// If it's an absolute path
|
|
40
|
+
if (existsSync(buildDirectory)) {
|
|
41
|
+
console.log("INFO: Using build directory from needle.config.json: " + buildDirectory);
|
|
42
|
+
await testEntry(buildDirectory, context);
|
|
43
|
+
}
|
|
44
|
+
else { // if its a relative path
|
|
45
|
+
const newPath = context.baseDirectory + "/" + buildDirectory;
|
|
46
|
+
if (existsSync(newPath)) {
|
|
47
|
+
console.log("INFO: Using build directory from needle.config.json: " + newPath);
|
|
48
|
+
await testEntry(newPath, context);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// if no file was found, we don't have a needle.config in the directory
|
|
55
|
+
// and we don't have any arguments, try to find it in the default dist directory
|
|
56
|
+
// await testEntry(context.baseDirectory + "/dist", callback, context);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (context.files.length <= 0) {
|
|
60
|
+
console.log("WARN: No glTF files found. Make sure to invoke with a valid path to a glTF file or directory. This path may be relative to \"" + initDir + "\"");
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
for (const file of context.files) {
|
|
64
|
+
await callback(file);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function testEntry(entry, context) {
|
|
69
|
+
// ignore argument names (e.g. --debug)
|
|
70
|
+
if (entry.startsWith("--")) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (entry === "." || entry === "./") {
|
|
74
|
+
if (context.baseDirectory) {
|
|
75
|
+
entry = context.baseDirectory;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (existsSync(entry) === false) {
|
|
79
|
+
// If no base directory is defined we cannot try to resolve the path
|
|
80
|
+
if (context.baseDirectory === undefined) {
|
|
81
|
+
console.log("WARN: Path does not exist: " + entry);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Try resolve potential relative path
|
|
85
|
+
const newPath = context.baseDirectory + "/" + entry;
|
|
86
|
+
if (existsSync(newPath) === false) {
|
|
87
|
+
console.log(`INFO: Resolved path failed: \"${entry}\" -> ${newPath} (doesnt exist or is locked by another process)`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`);
|
|
92
|
+
entry = newPath;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// When passing in a relative path (e.g. `dist`) we dont want to accidentally traverse this package's directory
|
|
97
|
+
// So in that case make sure we resolve to an absolute path relative to the calling directory
|
|
98
|
+
const isAbs = isAbsolute(entry);
|
|
99
|
+
if (!isAbs) {
|
|
100
|
+
if (context.baseDirectory) {
|
|
101
|
+
const newPath = context.baseDirectory + "/" + entry;
|
|
102
|
+
console.log(`INFO: Resolved path: ${entry} -> ${newPath}`);
|
|
103
|
+
entry = newPath;
|
|
104
|
+
if (!existsSync(entry)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (entry.endsWith(".glb") || entry.endsWith(".gltf") || entry.endsWith(".vrm")) {
|
|
111
|
+
context.files.push(entry);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const stat = statSync(entry);
|
|
115
|
+
if (stat.isDirectory()) {
|
|
116
|
+
// Don't traverse node_modules
|
|
117
|
+
if (entry.endsWith("node_modules")) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const files = readdirSync(entry);
|
|
121
|
+
for (const file of files) {
|
|
122
|
+
await testEntry(entry + "/" + file, context);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// console.log("WARN: Ignoring file: " + entry);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function replaceExtension(filepath, newExtension) {
|
|
131
|
+
const parts = filepath.split(".");
|
|
132
|
+
parts.pop();
|
|
133
|
+
return parts.join(".") + "." + newExtension;
|
|
134
|
+
}
|
|
135
|
+
export function isDirectory(path) {
|
|
136
|
+
if (existsSync(path)) {
|
|
137
|
+
return statSync(path).isDirectory();
|
|
138
|
+
}
|
|
139
|
+
const hasExt = path.replaceAll("\\", "/").split("/").pop()?.includes(".");
|
|
140
|
+
return !hasExt;
|
|
141
|
+
}
|
package/dist/utils/guid.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function generateGuid(key: string): any;
|
|
1
|
+
export declare function generateGuid(key: string): any;
|
package/dist/utils/guid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { v5 as uuidv5 } from 'uuid';
|
|
2
|
-
const NEEDLE_BUILD_PIPELINE_NAMESPACE = '208dcaa6-1398-4d42-a625-8f5fc1cc1ccf';
|
|
3
|
-
export function generateGuid(key) {
|
|
4
|
-
return uuidv5(key, NEEDLE_BUILD_PIPELINE_NAMESPACE);
|
|
5
|
-
}
|
|
1
|
+
import { v5 as uuidv5 } from 'uuid';
|
|
2
|
+
const NEEDLE_BUILD_PIPELINE_NAMESPACE = '208dcaa6-1398-4d42-a625-8f5fc1cc1ccf';
|
|
3
|
+
export function generateGuid(key) {
|
|
4
|
+
return uuidv5(key, NEEDLE_BUILD_PIPELINE_NAMESPACE);
|
|
5
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from "./compression_utils.js";
|
|
2
|
-
export * from "./fileutils.js";
|
|
3
|
-
export * from "./version.js";
|
|
4
|
-
export * from "./mesh.js";
|
|
5
|
-
export * from "./texture.js";
|
|
6
|
-
export * from "./guid.js";
|
|
7
|
-
export * from "./nodeio.js";
|
|
8
|
-
export * from "./stats.js";
|
|
9
|
-
export * from "./merge.js";
|
|
1
|
+
export * from "./compression_utils.js";
|
|
2
|
+
export * from "./fileutils.js";
|
|
3
|
+
export * from "./version.js";
|
|
4
|
+
export * from "./mesh.js";
|
|
5
|
+
export * from "./texture.js";
|
|
6
|
+
export * from "./guid.js";
|
|
7
|
+
export * from "./nodeio.js";
|
|
8
|
+
export * from "./stats.js";
|
|
9
|
+
export * from "./merge.js";
|
|
10
|
+
export * from "./validate.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from "./compression_utils.js";
|
|
2
|
-
export * from "./fileutils.js";
|
|
3
|
-
export * from "./version.js";
|
|
4
|
-
export * from "./mesh.js";
|
|
5
|
-
export * from "./texture.js";
|
|
6
|
-
export * from "./guid.js";
|
|
7
|
-
export * from "./nodeio.js";
|
|
8
|
-
export * from "./stats.js";
|
|
9
|
-
export * from "./merge.js";
|
|
1
|
+
export * from "./compression_utils.js";
|
|
2
|
+
export * from "./fileutils.js";
|
|
3
|
+
export * from "./version.js";
|
|
4
|
+
export * from "./mesh.js";
|
|
5
|
+
export * from "./texture.js";
|
|
6
|
+
export * from "./guid.js";
|
|
7
|
+
export * from "./nodeio.js";
|
|
8
|
+
export * from "./stats.js";
|
|
9
|
+
export * from "./merge.js";
|
|
10
|
+
export * from "./validate.js";
|
package/dist/utils/merge.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple object check.
|
|
3
|
-
* @param item
|
|
4
|
-
* @returns {boolean}
|
|
5
|
-
*/
|
|
6
|
-
export declare function isObject(item: object): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Deep merge two objects.
|
|
9
|
-
* @param target
|
|
10
|
-
* @param ...sources
|
|
11
|
-
*/
|
|
12
|
-
export declare function mergeDeep(target: any, ...sources: any[]): any;
|
|
1
|
+
/**
|
|
2
|
+
* Simple object check.
|
|
3
|
+
* @param item
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export declare function isObject(item: object): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Deep merge two objects.
|
|
9
|
+
* @param target
|
|
10
|
+
* @param ...sources
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeDeep(target: any, ...sources: any[]): any;
|
package/dist/utils/merge.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple object check.
|
|
3
|
-
* @param item
|
|
4
|
-
* @returns {boolean}
|
|
5
|
-
*/
|
|
6
|
-
export function isObject(item) {
|
|
7
|
-
return (item && typeof item === 'object' && !Array.isArray(item));
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Deep merge two objects.
|
|
11
|
-
* @param target
|
|
12
|
-
* @param ...sources
|
|
13
|
-
*/
|
|
14
|
-
export function mergeDeep(target, ...sources) {
|
|
15
|
-
if (!sources.length)
|
|
16
|
-
return target;
|
|
17
|
-
const source = sources.shift();
|
|
18
|
-
if (isObject(target) && isObject(source)) {
|
|
19
|
-
for (const key in source) {
|
|
20
|
-
if (isObject(source[key])) {
|
|
21
|
-
if (!target[key])
|
|
22
|
-
Object.assign(target, { [key]: {} });
|
|
23
|
-
mergeDeep(target[key], source[key]);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
Object.assign(target, { [key]: source[key] });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return mergeDeep(target, ...sources);
|
|
31
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Simple object check.
|
|
3
|
+
* @param item
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export function isObject(item) {
|
|
7
|
+
return (item && typeof item === 'object' && !Array.isArray(item));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Deep merge two objects.
|
|
11
|
+
* @param target
|
|
12
|
+
* @param ...sources
|
|
13
|
+
*/
|
|
14
|
+
export function mergeDeep(target, ...sources) {
|
|
15
|
+
if (!sources.length)
|
|
16
|
+
return target;
|
|
17
|
+
const source = sources.shift();
|
|
18
|
+
if (isObject(target) && isObject(source)) {
|
|
19
|
+
for (const key in source) {
|
|
20
|
+
if (isObject(source[key])) {
|
|
21
|
+
if (!target[key])
|
|
22
|
+
Object.assign(target, { [key]: {} });
|
|
23
|
+
mergeDeep(target[key], source[key]);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
Object.assign(target, { [key]: source[key] });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return mergeDeep(target, ...sources);
|
|
31
|
+
}
|
package/dist/utils/mesh.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Mesh, Primitive } from "@gltf-transform/core";
|
|
2
|
-
export declare type MeshInformation = {
|
|
3
|
-
readonly maxVertexCount: number;
|
|
4
|
-
readonly totalVertexCount: number;
|
|
5
|
-
readonly totalIndexCount: number;
|
|
6
|
-
};
|
|
7
|
-
export declare function getMeshInformation(mesh: Mesh): MeshInformation;
|
|
8
|
-
/**
|
|
9
|
-
* Calculate the density of a mesh.
|
|
10
|
-
* @param prim - The primitive to calculate the density for.
|
|
11
|
-
* @returns The density of the mesh or -1 if the mesh is not indexed.
|
|
12
|
-
*/
|
|
13
|
-
export declare function calculateMeshDensity(prim: Primitive): number | -1;
|
|
1
|
+
import { Mesh, Primitive } from "@gltf-transform/core";
|
|
2
|
+
export declare type MeshInformation = {
|
|
3
|
+
readonly maxVertexCount: number;
|
|
4
|
+
readonly totalVertexCount: number;
|
|
5
|
+
readonly totalIndexCount: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function getMeshInformation(mesh: Mesh): MeshInformation;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate the density of a mesh.
|
|
10
|
+
* @param prim - The primitive to calculate the density for.
|
|
11
|
+
* @returns The density of the mesh or -1 if the mesh is not indexed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function calculateMeshDensity(prim: Primitive): number | -1;
|