@needle-tools/gltf-build-pipeline 2.13.0 → 2.13.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +520 -517
  2. package/README.md +38 -38
  3. package/dist/cache/cache.d.ts +55 -55
  4. package/dist/cache/cache.js +326 -326
  5. package/dist/cache/index.d.ts +1 -1
  6. package/dist/cache/index.js +1 -1
  7. package/dist/cli/index.d.ts +2 -2
  8. package/dist/cli/index.js +198 -198
  9. package/dist/config/index.d.ts +53 -53
  10. package/dist/config/index.js +152 -152
  11. package/dist/constants.d.ts +7 -7
  12. package/dist/constants.js +7 -7
  13. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
  14. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
  15. package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
  16. package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
  17. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +27 -27
  18. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +88 -88
  19. package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
  20. package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
  21. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
  22. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +980 -980
  23. package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
  24. package/dist/extensions/NEEDLE_opaque/index.js +30 -30
  25. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
  26. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
  27. package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
  28. package/dist/extensions/NEEDLE_progressive/index.js +1 -1
  29. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
  30. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
  31. package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
  32. package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +38 -38
  33. package/dist/extensions/index.d.ts +7 -7
  34. package/dist/extensions/index.js +17 -17
  35. package/dist/extensions/utils.d.ts +6 -6
  36. package/dist/extensions/utils.js +72 -72
  37. package/dist/functions/weld.3.d.ts +76 -76
  38. package/dist/functions/weld.3.js +414 -414
  39. package/dist/index.d.ts +8 -8
  40. package/dist/index.js +8 -8
  41. package/dist/scripts/index.d.ts +2 -2
  42. package/dist/scripts/index.js +2 -2
  43. package/dist/scripts/pack-gltf.d.ts +15 -15
  44. package/dist/scripts/pack-gltf.js +135 -133
  45. package/dist/scripts/stats.d.ts +2 -2
  46. package/dist/scripts/stats.js +19 -19
  47. package/dist/transforms/index.d.ts +9 -9
  48. package/dist/transforms/index.js +9 -9
  49. package/dist/transforms/needle_animation_transform.d.ts +2 -2
  50. package/dist/transforms/needle_animation_transform.js +5 -5
  51. package/dist/transforms/needle_asset.d.ts +3 -3
  52. package/dist/transforms/needle_asset.js +50 -50
  53. package/dist/transforms/needle_common.d.ts +17 -17
  54. package/dist/transforms/needle_common.js +1 -1
  55. package/dist/transforms/needle_mesh_transform.d.ts +15 -15
  56. package/dist/transforms/needle_mesh_transform.js +223 -223
  57. package/dist/transforms/needle_progressive.d.ts +45 -45
  58. package/dist/transforms/needle_progressive.js +1043 -1043
  59. package/dist/transforms/needle_texture_transform.d.ts +13 -13
  60. package/dist/transforms/needle_texture_transform.js +257 -257
  61. package/dist/transforms/needle_toktx.d.ts +26 -26
  62. package/dist/transforms/needle_toktx.js +243 -243
  63. package/dist/transforms/needle_webp.d.ts +15 -15
  64. package/dist/transforms/needle_webp.js +53 -53
  65. package/dist/transforms/toktx.d.ts +52 -52
  66. package/dist/transforms/toktx.js +221 -221
  67. package/dist/transforms/toktx_types.d.ts +78 -78
  68. package/dist/transforms/toktx_types.js +62 -62
  69. package/dist/transforms/util.d.ts +21 -21
  70. package/dist/transforms/util.js +90 -90
  71. package/dist/utils/compression_utils.d.ts +2 -2
  72. package/dist/utils/compression_utils.js +6 -6
  73. package/dist/utils/fileutils.d.ts +19 -19
  74. package/dist/utils/fileutils.js +177 -177
  75. package/dist/utils/guid.d.ts +1 -1
  76. package/dist/utils/guid.js +5 -5
  77. package/dist/utils/index.d.ts +10 -10
  78. package/dist/utils/index.js +10 -10
  79. package/dist/utils/merge.d.ts +12 -12
  80. package/dist/utils/merge.js +31 -31
  81. package/dist/utils/mesh.d.ts +13 -13
  82. package/dist/utils/mesh.js +124 -124
  83. package/dist/utils/nodeio.d.ts +6 -6
  84. package/dist/utils/nodeio.js +86 -86
  85. package/dist/utils/stats.d.ts +70 -70
  86. package/dist/utils/stats.js +258 -258
  87. package/dist/utils/texture.d.ts +5 -5
  88. package/dist/utils/texture.js +14 -14
  89. package/dist/utils/validate.d.ts +5 -5
  90. package/dist/utils/validate.js +17 -17
  91. package/dist/utils/version.d.ts +1 -1
  92. package/dist/utils/version.gen.d.ts +1 -1
  93. package/dist/utils/version.gen.js +1 -1
  94. package/dist/utils/version.js +4 -4
  95. package/package.json +79 -79
  96. package/scripts/clear-caches.mjs +3 -3
  97. package/scripts/defaults.mjs +11 -11
  98. package/scripts/fileutils.mjs +5 -5
  99. package/scripts/index.mjs +41 -41
  100. package/scripts/limit-caches.mjs +3 -3
  101. package/scripts/make-progressive.mjs +16 -16
  102. package/scripts/pack-gltf.mjs +106 -106
  103. package/tsconfig.json +19 -19
@@ -1,258 +1,258 @@
1
- import { getVersion } from "./version.js";
2
- import { Document, ImageUtils } from "@gltf-transform/core";
3
- import { getFileName } from "./fileutils.js";
4
- import { statSync, writeFileSync } from "fs";
5
- import { isLOD } from "../transforms/needle_progressive.js";
6
- import { inspect } from "@gltf-transform/functions";
7
- export function printStats(stats, logger, config) {
8
- const duration = Date.now() - stats.startTime;
9
- const durationInMinutes = duration / 1000 / 60;
10
- const msg = `[Needle Build Pipeline] v${getVersion()} — Finished compression \"${config?.usecase}\" of ${stats.totalFilesProcessed} files in ${durationInMinutes.toFixed(1)} minutes; total size ${stats.totalFileSizeInMBBefore.toFixed(1)} MB → ${stats.totalFileSizeInMB.toFixed(1)} MB, total GPU memory: ${stats.totalGPUMemoryInMB.toFixed(1)} MB`;
11
- if (logger)
12
- logger.info(msg);
13
- else
14
- console.log(msg);
15
- }
16
- class Stats {
17
- /** Size in bytes */
18
- size;
19
- asset;
20
- json;
21
- nodes;
22
- materials;
23
- meshes;
24
- textures;
25
- animations;
26
- constructor(document, json, size) {
27
- const root = document.getRoot();
28
- const asset = root.getAsset();
29
- this.asset = {
30
- generator: asset.generator,
31
- version: asset.version,
32
- copyright: asset.copyright,
33
- extras: asset.extras,
34
- };
35
- const report = inspect(document);
36
- this.size = size;
37
- this.json = calculateJSONDocumentInfo(json);
38
- this.nodes = root.listNodes().length;
39
- this.materials = root.listMaterials().length;
40
- this.meshes = calculateMeshInfo(document, report);
41
- this.textures = calculateTextureInfo(document, report);
42
- this.animations = calculateAnimationInfo(document);
43
- }
44
- static combine(others, type) {
45
- const res = new Stats(new Document(), null, 0);
46
- let foundAny = false;
47
- for (const other of others) {
48
- if (type != undefined) {
49
- const filename = other.filename;
50
- if (filename) {
51
- // skip main files if we only want LODs
52
- if (isLOD(filename)) {
53
- if (type === "main")
54
- continue;
55
- }
56
- // skip LODs if we only want main files
57
- else {
58
- if (type === "lods")
59
- continue;
60
- }
61
- }
62
- }
63
- foundAny = true;
64
- res.size += other.size;
65
- res.json.addFrom(other.json);
66
- res.nodes += other.nodes;
67
- res.materials += other.materials;
68
- res.meshes.addFrom(other.meshes);
69
- res.textures.addFrom(other.textures);
70
- res.animations.addFrom(other.animations);
71
- }
72
- if (!foundAny) {
73
- return null;
74
- }
75
- return res;
76
- }
77
- }
78
- export class FileStats extends Stats {
79
- filename;
80
- isLOD;
81
- constructor(file, document, json) {
82
- super(document, json, statSync(file).size);
83
- this.filename = getFileName(file);
84
- this.isLOD = isLOD(this.filename);
85
- }
86
- }
87
- export class MeshInfo {
88
- count = 0;
89
- primitives = 0;
90
- vertices = 0;
91
- triangles = 0;
92
- memory = 0;
93
- formats = [];
94
- errors;
95
- warnings;
96
- addFrom(other) {
97
- this.count += other.count;
98
- this.primitives += other.primitives;
99
- this.vertices += other.vertices;
100
- this.triangles += other.triangles;
101
- this.memory += other.memory;
102
- this.formats = Array.from(new Set(this.formats.concat(other.formats)));
103
- this.errors = Array.from(new Set(this.errors?.concat(other.errors)));
104
- this.warnings = Array.from(new Set(this.warnings?.concat(other.warnings)));
105
- }
106
- }
107
- export class TextureInfo {
108
- count = 0;
109
- memory = 0;
110
- gpu_memory = 0;
111
- formats = [];
112
- errors;
113
- warnings;
114
- addFrom(other) {
115
- this.count += other.count;
116
- this.memory += other.memory;
117
- this.gpu_memory += other.gpu_memory;
118
- this.formats = Array.from(new Set(this.formats.concat(other.formats)));
119
- this.errors = Array.from(new Set(this.errors?.concat(other.errors)));
120
- this.warnings = Array.from(new Set(this.warnings?.concat(other.warnings)));
121
- }
122
- }
123
- export class AnimationInfo {
124
- count = 0;
125
- size = 0;
126
- channels = 0;
127
- addFrom(other) {
128
- this.count += other.count;
129
- this.size += other.size;
130
- this.channels += other.channels;
131
- }
132
- }
133
- export class JSONDocumentInfo {
134
- size = 0;
135
- addFrom(other) {
136
- this.size += other.size;
137
- }
138
- }
139
- /**
140
- * Create a new filestats object from a file and a document
141
- */
142
- export function createNewFilestats(file, document, jsonDocument) {
143
- const filestats = new FileStats(file, document, jsonDocument);
144
- return filestats;
145
- }
146
- export function writeFileStatsToFile(filestats, output_path) {
147
- if (output_path == undefined) {
148
- console.error("No stats output path provided");
149
- return null;
150
- }
151
- const res = {
152
- sum: Stats.combine(filestats),
153
- // main: Stats.combine(filestats, "main"),
154
- // lods: Stats.combine(filestats, "lods"),
155
- files: filestats,
156
- };
157
- const json = JSON.stringify(res);
158
- writeFileSync(output_path, json);
159
- return json;
160
- }
161
- function calculateMeshInfo(document, report) {
162
- const root = document.getRoot();
163
- const meshes = root.listMeshes();
164
- const res = new MeshInfo();
165
- res.count = meshes.length;
166
- res.errors = report.meshes.errors;
167
- res.warnings = report.meshes.warnings;
168
- for (const mesh of root.listMeshes()) {
169
- const primitives = mesh.listPrimitives();
170
- res.primitives += primitives.length;
171
- for (const prim of primitives) {
172
- const positions = prim.getAttribute('POSITION');
173
- const indices = prim.getIndices();
174
- if (positions) {
175
- res.vertices += positions.getCount();
176
- }
177
- if (indices) {
178
- res.triangles += indices.getCount() / 3;
179
- }
180
- else {
181
- res.triangles += positions.getCount() / 3;
182
- }
183
- const semantics = prim.listSemantics();
184
- for (const semantic of semantics) {
185
- const accessor = prim.getAttribute(semantic);
186
- if (accessor) {
187
- const buffer = accessor.getByteLength();
188
- res.memory += buffer;
189
- }
190
- }
191
- }
192
- }
193
- const extensions = root.listExtensionsUsed();
194
- for (const ext of extensions) {
195
- if (ext.extensionName.startsWith("EXT_meshopt_compression")) {
196
- res.formats.push("meshopt");
197
- }
198
- else if (ext.extensionName.startsWith("KHR_draco_mesh_compression")) {
199
- res.formats.push("draco");
200
- }
201
- }
202
- // filter formats so we only have unique values
203
- res.formats = Array.from(new Set(res.formats));
204
- return res;
205
- }
206
- function calculateTextureInfo(document, report) {
207
- const root = document.getRoot();
208
- const textures = root.listTextures();
209
- const res = new TextureInfo();
210
- res.count = textures.length;
211
- res.formats = textures.map(t => t.getMimeType());
212
- res.errors = report.textures.errors;
213
- res.warnings = report.textures.warnings;
214
- res.gpu_memory = 0;
215
- res.memory = 0;
216
- for (const texture of textures) {
217
- const image = texture.getImage();
218
- const mimetype = texture.getMimeType();
219
- if (image && mimetype) {
220
- res.gpu_memory += ImageUtils.getVRAMByteLength(image, mimetype);
221
- res.memory += image.byteLength;
222
- }
223
- }
224
- // filter formats so we only have unique values
225
- res.formats = Array.from(new Set(res.formats));
226
- return res;
227
- }
228
- function calculateAnimationInfo(document) {
229
- const animations = document.getRoot().listAnimations();
230
- const info = new AnimationInfo();
231
- info.count = animations.length;
232
- info.channels = 0;
233
- info.size = 0;
234
- for (const anim of animations) {
235
- // calculate animation size
236
- const channels = anim.listChannels();
237
- info.channels += channels.length;
238
- for (const channel of channels) {
239
- const sampler = channel.getSampler();
240
- const times = sampler.getInput();
241
- const values = sampler.getOutput();
242
- if (times) {
243
- info.size += times.getArray()?.byteLength ?? 0;
244
- }
245
- if (values) {
246
- info.size += values.getArray()?.byteLength ?? 0;
247
- }
248
- }
249
- }
250
- return info;
251
- }
252
- function calculateJSONDocumentInfo(json) {
253
- const info = new JSONDocumentInfo();
254
- if (json) {
255
- info.size = JSON.stringify(json.json).length;
256
- }
257
- return info;
258
- }
1
+ import { getVersion } from "./version.js";
2
+ import { Document, ImageUtils } from "@gltf-transform/core";
3
+ import { getFileName } from "./fileutils.js";
4
+ import { statSync, writeFileSync } from "fs";
5
+ import { isLOD } from "../transforms/needle_progressive.js";
6
+ import { inspect } from "@gltf-transform/functions";
7
+ export function printStats(stats, logger, config) {
8
+ const duration = Date.now() - stats.startTime;
9
+ const durationInMinutes = duration / 1000 / 60;
10
+ const msg = `[Needle Build Pipeline] v${getVersion()} — Finished compression \"${config?.usecase}\" of ${stats.totalFilesProcessed} files in ${durationInMinutes.toFixed(1)} minutes; total size ${stats.totalFileSizeInMBBefore.toFixed(1)} MB → ${stats.totalFileSizeInMB.toFixed(1)} MB, total GPU memory: ${stats.totalGPUMemoryInMB.toFixed(1)} MB`;
11
+ if (logger)
12
+ logger.info(msg);
13
+ else
14
+ console.log(msg);
15
+ }
16
+ class Stats {
17
+ /** Size in bytes */
18
+ size;
19
+ asset;
20
+ json;
21
+ nodes;
22
+ materials;
23
+ meshes;
24
+ textures;
25
+ animations;
26
+ constructor(document, json, size) {
27
+ const root = document.getRoot();
28
+ const asset = root.getAsset();
29
+ this.asset = {
30
+ generator: asset.generator,
31
+ version: asset.version,
32
+ copyright: asset.copyright,
33
+ extras: asset.extras,
34
+ };
35
+ const report = inspect(document);
36
+ this.size = size;
37
+ this.json = calculateJSONDocumentInfo(json);
38
+ this.nodes = root.listNodes().length;
39
+ this.materials = root.listMaterials().length;
40
+ this.meshes = calculateMeshInfo(document, report);
41
+ this.textures = calculateTextureInfo(document, report);
42
+ this.animations = calculateAnimationInfo(document);
43
+ }
44
+ static combine(others, type) {
45
+ const res = new Stats(new Document(), null, 0);
46
+ let foundAny = false;
47
+ for (const other of others) {
48
+ if (type != undefined) {
49
+ const filename = other.filename;
50
+ if (filename) {
51
+ // skip main files if we only want LODs
52
+ if (isLOD(filename)) {
53
+ if (type === "main")
54
+ continue;
55
+ }
56
+ // skip LODs if we only want main files
57
+ else {
58
+ if (type === "lods")
59
+ continue;
60
+ }
61
+ }
62
+ }
63
+ foundAny = true;
64
+ res.size += other.size;
65
+ res.json.addFrom(other.json);
66
+ res.nodes += other.nodes;
67
+ res.materials += other.materials;
68
+ res.meshes.addFrom(other.meshes);
69
+ res.textures.addFrom(other.textures);
70
+ res.animations.addFrom(other.animations);
71
+ }
72
+ if (!foundAny) {
73
+ return null;
74
+ }
75
+ return res;
76
+ }
77
+ }
78
+ export class FileStats extends Stats {
79
+ filename;
80
+ isLOD;
81
+ constructor(file, document, json) {
82
+ super(document, json, statSync(file).size);
83
+ this.filename = getFileName(file);
84
+ this.isLOD = isLOD(this.filename);
85
+ }
86
+ }
87
+ export class MeshInfo {
88
+ count = 0;
89
+ primitives = 0;
90
+ vertices = 0;
91
+ triangles = 0;
92
+ memory = 0;
93
+ formats = [];
94
+ errors;
95
+ warnings;
96
+ addFrom(other) {
97
+ this.count += other.count;
98
+ this.primitives += other.primitives;
99
+ this.vertices += other.vertices;
100
+ this.triangles += other.triangles;
101
+ this.memory += other.memory;
102
+ this.formats = Array.from(new Set(this.formats.concat(other.formats)));
103
+ this.errors = Array.from(new Set(this.errors?.concat(other.errors)));
104
+ this.warnings = Array.from(new Set(this.warnings?.concat(other.warnings)));
105
+ }
106
+ }
107
+ export class TextureInfo {
108
+ count = 0;
109
+ memory = 0;
110
+ gpu_memory = 0;
111
+ formats = [];
112
+ errors;
113
+ warnings;
114
+ addFrom(other) {
115
+ this.count += other.count;
116
+ this.memory += other.memory;
117
+ this.gpu_memory += other.gpu_memory;
118
+ this.formats = Array.from(new Set(this.formats.concat(other.formats)));
119
+ this.errors = Array.from(new Set(this.errors?.concat(other.errors)));
120
+ this.warnings = Array.from(new Set(this.warnings?.concat(other.warnings)));
121
+ }
122
+ }
123
+ export class AnimationInfo {
124
+ count = 0;
125
+ size = 0;
126
+ channels = 0;
127
+ addFrom(other) {
128
+ this.count += other.count;
129
+ this.size += other.size;
130
+ this.channels += other.channels;
131
+ }
132
+ }
133
+ export class JSONDocumentInfo {
134
+ size = 0;
135
+ addFrom(other) {
136
+ this.size += other.size;
137
+ }
138
+ }
139
+ /**
140
+ * Create a new filestats object from a file and a document
141
+ */
142
+ export function createNewFilestats(file, document, jsonDocument) {
143
+ const filestats = new FileStats(file, document, jsonDocument);
144
+ return filestats;
145
+ }
146
+ export function writeFileStatsToFile(filestats, output_path) {
147
+ if (output_path == undefined) {
148
+ console.error("No stats output path provided");
149
+ return null;
150
+ }
151
+ const res = {
152
+ sum: Stats.combine(filestats),
153
+ // main: Stats.combine(filestats, "main"),
154
+ // lods: Stats.combine(filestats, "lods"),
155
+ files: filestats,
156
+ };
157
+ const json = JSON.stringify(res);
158
+ writeFileSync(output_path, json);
159
+ return json;
160
+ }
161
+ function calculateMeshInfo(document, report) {
162
+ const root = document.getRoot();
163
+ const meshes = root.listMeshes();
164
+ const res = new MeshInfo();
165
+ res.count = meshes.length;
166
+ res.errors = report.meshes.errors;
167
+ res.warnings = report.meshes.warnings;
168
+ for (const mesh of root.listMeshes()) {
169
+ const primitives = mesh.listPrimitives();
170
+ res.primitives += primitives.length;
171
+ for (const prim of primitives) {
172
+ const positions = prim.getAttribute('POSITION');
173
+ const indices = prim.getIndices();
174
+ if (positions) {
175
+ res.vertices += positions.getCount();
176
+ }
177
+ if (indices) {
178
+ res.triangles += indices.getCount() / 3;
179
+ }
180
+ else {
181
+ res.triangles += positions.getCount() / 3;
182
+ }
183
+ const semantics = prim.listSemantics();
184
+ for (const semantic of semantics) {
185
+ const accessor = prim.getAttribute(semantic);
186
+ if (accessor) {
187
+ const buffer = accessor.getByteLength();
188
+ res.memory += buffer;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ const extensions = root.listExtensionsUsed();
194
+ for (const ext of extensions) {
195
+ if (ext.extensionName.startsWith("EXT_meshopt_compression")) {
196
+ res.formats.push("meshopt");
197
+ }
198
+ else if (ext.extensionName.startsWith("KHR_draco_mesh_compression")) {
199
+ res.formats.push("draco");
200
+ }
201
+ }
202
+ // filter formats so we only have unique values
203
+ res.formats = Array.from(new Set(res.formats));
204
+ return res;
205
+ }
206
+ function calculateTextureInfo(document, report) {
207
+ const root = document.getRoot();
208
+ const textures = root.listTextures();
209
+ const res = new TextureInfo();
210
+ res.count = textures.length;
211
+ res.formats = textures.map(t => t.getMimeType());
212
+ res.errors = report.textures.errors;
213
+ res.warnings = report.textures.warnings;
214
+ res.gpu_memory = 0;
215
+ res.memory = 0;
216
+ for (const texture of textures) {
217
+ const image = texture.getImage();
218
+ const mimetype = texture.getMimeType();
219
+ if (image && mimetype) {
220
+ res.gpu_memory += ImageUtils.getVRAMByteLength(image, mimetype);
221
+ res.memory += image.byteLength;
222
+ }
223
+ }
224
+ // filter formats so we only have unique values
225
+ res.formats = Array.from(new Set(res.formats));
226
+ return res;
227
+ }
228
+ function calculateAnimationInfo(document) {
229
+ const animations = document.getRoot().listAnimations();
230
+ const info = new AnimationInfo();
231
+ info.count = animations.length;
232
+ info.channels = 0;
233
+ info.size = 0;
234
+ for (const anim of animations) {
235
+ // calculate animation size
236
+ const channels = anim.listChannels();
237
+ info.channels += channels.length;
238
+ for (const channel of channels) {
239
+ const sampler = channel.getSampler();
240
+ const times = sampler.getInput();
241
+ const values = sampler.getOutput();
242
+ if (times) {
243
+ info.size += times.getArray()?.byteLength ?? 0;
244
+ }
245
+ if (values) {
246
+ info.size += values.getArray()?.byteLength ?? 0;
247
+ }
248
+ }
249
+ }
250
+ return info;
251
+ }
252
+ function calculateJSONDocumentInfo(json) {
253
+ const info = new JSONDocumentInfo();
254
+ if (json) {
255
+ info.size = JSON.stringify(json.json).length;
256
+ }
257
+ return info;
258
+ }
@@ -1,5 +1,5 @@
1
- import { Texture } from "@gltf-transform/core";
2
- export declare function isMultipleOfFour(value: number): boolean;
3
- export declare function ceilMultipleOfFour(value: number): number;
4
- export declare function isLightmap(texture: Texture): boolean;
5
- export declare function setLightmapName(texture: Texture): void;
1
+ import { Texture } from "@gltf-transform/core";
2
+ export declare function isMultipleOfFour(value: number): boolean;
3
+ export declare function ceilMultipleOfFour(value: number): number;
4
+ export declare function isLightmap(texture: Texture): boolean;
5
+ export declare function setLightmapName(texture: Texture): void;
@@ -1,14 +1,14 @@
1
- export function isMultipleOfFour(value) {
2
- return value % 4 === 0;
3
- }
4
- export function ceilMultipleOfFour(value) {
5
- if (value <= 4)
6
- return 4;
7
- return value % 4 ? value + 4 - (value % 4) : value;
8
- }
9
- export function isLightmap(texture) {
10
- return texture.getName()?.startsWith("Lightmap");
11
- }
12
- export function setLightmapName(texture) {
13
- texture.setName("Lightmap");
14
- }
1
+ export function isMultipleOfFour(value) {
2
+ return value % 4 === 0;
3
+ }
4
+ export function ceilMultipleOfFour(value) {
5
+ if (value <= 4)
6
+ return 4;
7
+ return value % 4 ? value + 4 - (value % 4) : value;
8
+ }
9
+ export function isLightmap(texture) {
10
+ return texture.getName()?.startsWith("Lightmap");
11
+ }
12
+ export function setLightmapName(texture) {
13
+ texture.setName("Lightmap");
14
+ }
@@ -1,5 +1,5 @@
1
- export declare function validateImageMimeType(mimetype: string, image: Uint8Array): {
2
- error: boolean;
3
- message: string;
4
- mimeType: string;
5
- };
1
+ export declare function validateImageMimeType(mimetype: string, image: Uint8Array): {
2
+ error: boolean;
3
+ message: string;
4
+ mimeType: string;
5
+ };
@@ -1,17 +1,17 @@
1
- import { ImageUtils } from "@gltf-transform/core";
2
- export function validateImageMimeType(mimetype, image) {
3
- const actualMimeType = ImageUtils.getMimeType(image);
4
- if (actualMimeType != null && actualMimeType != mimetype) {
5
- const msg = `Image reported wrong mime type \"${mimetype}\" but is actually \"${actualMimeType}\"`;
6
- console.error(`WARN: ${msg}`);
7
- return {
8
- error: true,
9
- message: msg,
10
- mimeType: actualMimeType
11
- };
12
- }
13
- else if (actualMimeType === null) {
14
- console.warn(`WARN: Could not validate image type for \"${mimetype}\"`);
15
- }
16
- return null;
17
- }
1
+ import { ImageUtils } from "@gltf-transform/core";
2
+ export function validateImageMimeType(mimetype, image) {
3
+ const actualMimeType = ImageUtils.getMimeType(image);
4
+ if (actualMimeType != null && actualMimeType != mimetype) {
5
+ const msg = `Image reported wrong mime type \"${mimetype}\" but is actually \"${actualMimeType}\"`;
6
+ console.error(`WARN: ${msg}`);
7
+ return {
8
+ error: true,
9
+ message: msg,
10
+ mimeType: actualMimeType
11
+ };
12
+ }
13
+ else if (actualMimeType === null) {
14
+ console.warn(`WARN: Could not validate image type for \"${mimetype}\"`);
15
+ }
16
+ return null;
17
+ }
@@ -1 +1 @@
1
- export declare function getVersion(_marklocal?: boolean): string;
1
+ export declare function getVersion(_marklocal?: boolean): string;
@@ -1 +1 @@
1
- export declare const version = "2.13.0";
1
+ export declare const version = "2.13.1";
@@ -1 +1 @@
1
- export const version = "2.13.0";
1
+ export const version = "2.13.1";
@@ -1,4 +1,4 @@
1
- import { version } from './version.gen.js';
2
- export function getVersion(_marklocal = true) {
3
- return version;
4
- }
1
+ import { version } from './version.gen.js';
2
+ export function getVersion(_marklocal = true) {
3
+ return version;
4
+ }