@loaders.gl/gltf 4.2.0-alpha.5 → 4.2.0-beta.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.
- package/dist/dist.dev.js +135 -107
- package/dist/dist.min.js +1 -1
- package/dist/glb-loader.d.ts +22 -2
- package/dist/glb-loader.d.ts.map +1 -1
- package/dist/glb-loader.js +2 -0
- package/dist/glb-writer.d.ts +17 -2
- package/dist/glb-writer.d.ts.map +1 -1
- package/dist/gltf-loader.d.ts +24 -2
- package/dist/gltf-loader.d.ts.map +1 -1
- package/dist/gltf-loader.js +2 -0
- package/dist/gltf-writer.d.ts +2 -18
- package/dist/gltf-writer.d.ts.map +1 -1
- package/dist/gltf-writer.js +2 -2
- package/dist/index.cjs +50 -47
- package/dist/index.cjs.map +2 -2
- package/dist/lib/api/gltf-scenegraph.js +4 -0
- package/dist/lib/api/normalize-gltf-v1.js +15 -16
- package/dist/lib/api/post-process-gltf.js +7 -5
- package/dist/lib/extensions/KHR_texture_transform.js +16 -24
- package/dist/lib/utils/version.js +1 -1
- package/package.json +7 -6
- package/src/glb-loader.ts +4 -2
- package/src/glb-writer.ts +2 -2
- package/src/gltf-loader.ts +4 -2
- package/src/gltf-writer.ts +5 -5
- package/src/lib/extensions/KHR_texture_transform.ts +18 -24
package/dist/dist.dev.js
CHANGED
|
@@ -45,13 +45,6 @@ var __exports__ = (() => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
// (disabled):../worker-utils/src/lib/node/require-utils.node
|
|
49
|
-
var require_require_utils = __commonJS({
|
|
50
|
-
"(disabled):../worker-utils/src/lib/node/require-utils.node"() {
|
|
51
|
-
"use strict";
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
48
|
// bundle.ts
|
|
56
49
|
var bundle_exports = {};
|
|
57
50
|
__export(bundle_exports, {
|
|
@@ -108,6 +101,17 @@ var __exports__ = (() => {
|
|
|
108
101
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
109
102
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
110
103
|
|
|
104
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
105
|
+
function registerJSModules(modules) {
|
|
106
|
+
globalThis.loaders ||= {};
|
|
107
|
+
globalThis.loaders.modules ||= {};
|
|
108
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
109
|
+
}
|
|
110
|
+
function getJSModuleOrNull(name12) {
|
|
111
|
+
const module = globalThis.loaders?.modules?.[name12];
|
|
112
|
+
return module || null;
|
|
113
|
+
}
|
|
114
|
+
|
|
111
115
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
112
116
|
var NPM_TAG = "latest";
|
|
113
117
|
function getVersion() {
|
|
@@ -154,7 +158,6 @@ var __exports__ = (() => {
|
|
|
154
158
|
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
155
159
|
|
|
156
160
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
157
|
-
var node = __toESM(require_require_utils(), 1);
|
|
158
161
|
var loadLibraryPromises = {};
|
|
159
162
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
160
163
|
if (moduleName) {
|
|
@@ -191,7 +194,8 @@ var __exports__ = (() => {
|
|
|
191
194
|
}
|
|
192
195
|
if (!isBrowser2) {
|
|
193
196
|
try {
|
|
194
|
-
|
|
197
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
198
|
+
return await requireFromFile?.(libraryUrl);
|
|
195
199
|
} catch (error) {
|
|
196
200
|
console.error(error);
|
|
197
201
|
return null;
|
|
@@ -205,7 +209,8 @@ var __exports__ = (() => {
|
|
|
205
209
|
}
|
|
206
210
|
function loadLibraryFromString(scriptSource, id) {
|
|
207
211
|
if (!isBrowser2) {
|
|
208
|
-
|
|
212
|
+
const { requireFromString } = globalThis.loaders || {};
|
|
213
|
+
return requireFromString?.(scriptSource, id);
|
|
209
214
|
}
|
|
210
215
|
if (isWorker) {
|
|
211
216
|
eval.call(globalThis, scriptSource);
|
|
@@ -222,18 +227,20 @@ var __exports__ = (() => {
|
|
|
222
227
|
return null;
|
|
223
228
|
}
|
|
224
229
|
async function loadAsArrayBuffer(url) {
|
|
225
|
-
|
|
230
|
+
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
231
|
+
if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
226
232
|
const response = await fetch(url);
|
|
227
233
|
return await response.arrayBuffer();
|
|
228
234
|
}
|
|
229
|
-
return await (
|
|
235
|
+
return await readFileAsArrayBuffer(url);
|
|
230
236
|
}
|
|
231
237
|
async function loadAsText(url) {
|
|
232
|
-
|
|
238
|
+
const { readFileAsText } = globalThis.loaders || {};
|
|
239
|
+
if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
|
|
233
240
|
const response = await fetch(url);
|
|
234
241
|
return await response.text();
|
|
235
242
|
}
|
|
236
|
-
return await (
|
|
243
|
+
return await readFileAsText(url);
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
// ../loader-utils/src/lib/binary-utils/get-first-characters.ts
|
|
@@ -712,6 +719,8 @@ var __exports__ = (() => {
|
|
|
712
719
|
// imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
|
|
713
720
|
};
|
|
714
721
|
var ImageLoader = {
|
|
722
|
+
dataType: null,
|
|
723
|
+
batchType: null,
|
|
715
724
|
id: "image",
|
|
716
725
|
module: "images",
|
|
717
726
|
name: "Images",
|
|
@@ -920,6 +929,10 @@ var __exports__ = (() => {
|
|
|
920
929
|
};
|
|
921
930
|
}
|
|
922
931
|
var GLTFScenegraph = class {
|
|
932
|
+
// internal
|
|
933
|
+
gltf;
|
|
934
|
+
sourceBuffers;
|
|
935
|
+
byteLength;
|
|
923
936
|
// TODO - why is this not GLTFWithBuffers - what happens to images?
|
|
924
937
|
constructor(gltf) {
|
|
925
938
|
this.gltf = {
|
|
@@ -1167,8 +1180,8 @@ var __exports__ = (() => {
|
|
|
1167
1180
|
* `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`
|
|
1168
1181
|
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node
|
|
1169
1182
|
*/
|
|
1170
|
-
addNode(
|
|
1171
|
-
const { meshIndex, matrix } =
|
|
1183
|
+
addNode(node) {
|
|
1184
|
+
const { meshIndex, matrix } = node;
|
|
1172
1185
|
this.json.nodes = this.json.nodes || [];
|
|
1173
1186
|
const nodeData = { mesh: meshIndex };
|
|
1174
1187
|
if (matrix) {
|
|
@@ -2290,11 +2303,12 @@ var __exports__ = (() => {
|
|
|
2290
2303
|
};
|
|
2291
2304
|
var loadBasisTranscoderPromise;
|
|
2292
2305
|
async function loadBasisTranscoderModule(options) {
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2306
|
+
registerJSModules(options.modules);
|
|
2307
|
+
const basis = getJSModuleOrNull("basis");
|
|
2308
|
+
if (basis) {
|
|
2309
|
+
return basis;
|
|
2296
2310
|
}
|
|
2297
|
-
loadBasisTranscoderPromise
|
|
2311
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
2298
2312
|
return await loadBasisTranscoderPromise;
|
|
2299
2313
|
}
|
|
2300
2314
|
async function loadBasisTranscoder(options) {
|
|
@@ -2726,6 +2740,8 @@ var __exports__ = (() => {
|
|
|
2726
2740
|
|
|
2727
2741
|
// ../textures/src/basis-loader.ts
|
|
2728
2742
|
var BasisWorkerLoader = {
|
|
2743
|
+
dataType: null,
|
|
2744
|
+
batchType: null,
|
|
2729
2745
|
name: "Basis",
|
|
2730
2746
|
id: "basis",
|
|
2731
2747
|
module: "textures",
|
|
@@ -2738,12 +2754,9 @@ var __exports__ = (() => {
|
|
|
2738
2754
|
options: {
|
|
2739
2755
|
basis: {
|
|
2740
2756
|
format: "auto",
|
|
2741
|
-
// gl context doesn't exist on a worker thread
|
|
2742
2757
|
libraryPath: "libs/",
|
|
2743
2758
|
containerFormat: "auto",
|
|
2744
|
-
// 'basis' || 'ktx2' || 'auto'
|
|
2745
2759
|
module: "transcoder"
|
|
2746
|
-
// 'transcoder' || 'encoder'
|
|
2747
2760
|
}
|
|
2748
2761
|
}
|
|
2749
2762
|
};
|
|
@@ -3191,6 +3204,8 @@ var __exports__ = (() => {
|
|
|
3191
3204
|
|
|
3192
3205
|
// ../draco/src/draco-loader.ts
|
|
3193
3206
|
var DracoLoader = {
|
|
3207
|
+
dataType: null,
|
|
3208
|
+
batchType: null,
|
|
3194
3209
|
name: "Draco",
|
|
3195
3210
|
id: "draco",
|
|
3196
3211
|
module: "draco",
|
|
@@ -3345,10 +3360,17 @@ var __exports__ = (() => {
|
|
|
3345
3360
|
4: Uint16Array,
|
|
3346
3361
|
5: Int32Array,
|
|
3347
3362
|
6: Uint32Array,
|
|
3363
|
+
// 7: BigInt64Array,
|
|
3364
|
+
// 8: BigUint64Array,
|
|
3348
3365
|
9: Float32Array
|
|
3366
|
+
// 10: Float64Array
|
|
3367
|
+
// 11: BOOL - What array type do we use for this?
|
|
3349
3368
|
};
|
|
3350
3369
|
var INDEX_ITEM_SIZE = 4;
|
|
3351
3370
|
var DracoParser = class {
|
|
3371
|
+
draco;
|
|
3372
|
+
decoder;
|
|
3373
|
+
metadataQuerier;
|
|
3352
3374
|
// draco - the draco decoder, either import `draco3d` or load dynamically
|
|
3353
3375
|
constructor(draco) {
|
|
3354
3376
|
this.draco = draco;
|
|
@@ -3515,14 +3537,17 @@ var __exports__ = (() => {
|
|
|
3515
3537
|
for (const loaderAttribute of Object.values(loaderData.attributes)) {
|
|
3516
3538
|
const attributeName = this._deduceAttributeName(loaderAttribute, options);
|
|
3517
3539
|
loaderAttribute.name = attributeName;
|
|
3518
|
-
const
|
|
3519
|
-
|
|
3520
|
-
value,
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3540
|
+
const values = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
3541
|
+
if (values) {
|
|
3542
|
+
const { value, size } = values;
|
|
3543
|
+
attributes[attributeName] = {
|
|
3544
|
+
value,
|
|
3545
|
+
size,
|
|
3546
|
+
byteOffset: loaderAttribute.byte_offset,
|
|
3547
|
+
byteStride: loaderAttribute.byte_stride,
|
|
3548
|
+
normalized: loaderAttribute.normalized
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3526
3551
|
}
|
|
3527
3552
|
return attributes;
|
|
3528
3553
|
}
|
|
@@ -3564,6 +3589,10 @@ var __exports__ = (() => {
|
|
|
3564
3589
|
*/
|
|
3565
3590
|
_getAttributeValues(dracoGeometry, attribute) {
|
|
3566
3591
|
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
|
|
3592
|
+
if (!TypedArrayCtor) {
|
|
3593
|
+
console.warn(`DRACO: Unsupported attribute type ${attribute.data_type}`);
|
|
3594
|
+
return null;
|
|
3595
|
+
}
|
|
3567
3596
|
const numComponents = attribute.num_components;
|
|
3568
3597
|
const numPoints = dracoGeometry.num_points();
|
|
3569
3598
|
const numValues = numPoints * numComponents;
|
|
@@ -3794,11 +3823,11 @@ var __exports__ = (() => {
|
|
|
3794
3823
|
async function loadDracoDecoderModule(options) {
|
|
3795
3824
|
const modules = options.modules || {};
|
|
3796
3825
|
if (modules.draco3d) {
|
|
3797
|
-
loadDecoderPromise
|
|
3826
|
+
loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
3798
3827
|
return { draco };
|
|
3799
3828
|
});
|
|
3800
3829
|
} else {
|
|
3801
|
-
loadDecoderPromise
|
|
3830
|
+
loadDecoderPromise ||= loadDracoDecoder(options);
|
|
3802
3831
|
}
|
|
3803
3832
|
return await loadDecoderPromise;
|
|
3804
3833
|
}
|
|
@@ -5186,14 +5215,14 @@ var __exports__ = (() => {
|
|
|
5186
5215
|
}
|
|
5187
5216
|
|
|
5188
5217
|
// src/lib/extensions/KHR_texture_transform.ts
|
|
5189
|
-
var
|
|
5190
|
-
var name8 =
|
|
5218
|
+
var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
|
|
5219
|
+
var name8 = KHR_TEXTURE_TRANSFORM;
|
|
5191
5220
|
var scratchVector = new Vector3();
|
|
5192
5221
|
var scratchRotationMatrix = new Matrix3();
|
|
5193
5222
|
var scratchScaleMatrix = new Matrix3();
|
|
5194
5223
|
async function decode7(gltfData, options) {
|
|
5195
5224
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
5196
|
-
const hasExtension = gltfScenegraph.hasExtension(
|
|
5225
|
+
const hasExtension = gltfScenegraph.hasExtension(KHR_TEXTURE_TRANSFORM);
|
|
5197
5226
|
if (!hasExtension || !options.gltf?.loadBuffers) {
|
|
5198
5227
|
return;
|
|
5199
5228
|
}
|
|
@@ -5203,27 +5232,19 @@ var __exports__ = (() => {
|
|
|
5203
5232
|
}
|
|
5204
5233
|
}
|
|
5205
5234
|
function transformTexCoords(materialIndex, gltfData) {
|
|
5206
|
-
const processedTexCoords = [];
|
|
5207
5235
|
const material = gltfData.json.materials?.[materialIndex];
|
|
5208
|
-
const
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
const
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
const occlusionTexture = material?.occlusionTexture;
|
|
5221
|
-
if (occlusionTexture) {
|
|
5222
|
-
transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);
|
|
5223
|
-
}
|
|
5224
|
-
const metallicRoughnessTexture = material?.pbrMetallicRoughness?.metallicRoughnessTexture;
|
|
5225
|
-
if (metallicRoughnessTexture) {
|
|
5226
|
-
transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);
|
|
5236
|
+
const materialTextures = [
|
|
5237
|
+
material?.pbrMetallicRoughness?.baseColorTexture,
|
|
5238
|
+
material?.emissiveTexture,
|
|
5239
|
+
material?.normalTexture,
|
|
5240
|
+
material?.occlusionTexture,
|
|
5241
|
+
material?.pbrMetallicRoughness?.metallicRoughnessTexture
|
|
5242
|
+
];
|
|
5243
|
+
const processedTexCoords = [];
|
|
5244
|
+
for (const textureInfo of materialTextures) {
|
|
5245
|
+
if (textureInfo && textureInfo?.extensions?.[KHR_TEXTURE_TRANSFORM]) {
|
|
5246
|
+
transformPrimitives(gltfData, materialIndex, textureInfo, processedTexCoords);
|
|
5247
|
+
}
|
|
5227
5248
|
}
|
|
5228
5249
|
}
|
|
5229
5250
|
function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) {
|
|
@@ -5242,7 +5263,7 @@ var __exports__ = (() => {
|
|
|
5242
5263
|
}
|
|
5243
5264
|
}
|
|
5244
5265
|
function getTransformParameters(texture, processedTexCoords) {
|
|
5245
|
-
const textureInfo = texture.extensions?.[
|
|
5266
|
+
const textureInfo = texture.extensions?.[KHR_TEXTURE_TRANSFORM];
|
|
5246
5267
|
const { texCoord: originalTexCoord = 0 } = texture;
|
|
5247
5268
|
const { texCoord = originalTexCoord } = textureInfo;
|
|
5248
5269
|
const isProcessed = processedTexCoords.findIndex(
|
|
@@ -5363,12 +5384,12 @@ var __exports__ = (() => {
|
|
|
5363
5384
|
gltfScenegraph.json.lights = extension.lights;
|
|
5364
5385
|
gltfScenegraph.removeExtension(KHR_LIGHTS_PUNCTUAL);
|
|
5365
5386
|
}
|
|
5366
|
-
for (const
|
|
5367
|
-
const nodeExtension = gltfScenegraph.getObjectExtension(
|
|
5387
|
+
for (const node of json.nodes || []) {
|
|
5388
|
+
const nodeExtension = gltfScenegraph.getObjectExtension(node, KHR_LIGHTS_PUNCTUAL);
|
|
5368
5389
|
if (nodeExtension) {
|
|
5369
|
-
|
|
5390
|
+
node.light = nodeExtension.light;
|
|
5370
5391
|
}
|
|
5371
|
-
gltfScenegraph.removeObjectExtension(
|
|
5392
|
+
gltfScenegraph.removeObjectExtension(node, KHR_LIGHTS_PUNCTUAL);
|
|
5372
5393
|
}
|
|
5373
5394
|
}
|
|
5374
5395
|
async function encode2(gltfData) {
|
|
@@ -5382,8 +5403,8 @@ var __exports__ = (() => {
|
|
|
5382
5403
|
}
|
|
5383
5404
|
if (gltfScenegraph.json.lights) {
|
|
5384
5405
|
for (const light of gltfScenegraph.json.lights) {
|
|
5385
|
-
const
|
|
5386
|
-
gltfScenegraph.addObjectExtension(
|
|
5406
|
+
const node = light.node;
|
|
5407
|
+
gltfScenegraph.addObjectExtension(node, KHR_LIGHTS_PUNCTUAL, light);
|
|
5387
5408
|
}
|
|
5388
5409
|
delete gltfScenegraph.json.lights;
|
|
5389
5410
|
}
|
|
@@ -5581,22 +5602,21 @@ var __exports__ = (() => {
|
|
|
5581
5602
|
texture: "textures"
|
|
5582
5603
|
};
|
|
5583
5604
|
var GLTFV1Normalizer = class {
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
}
|
|
5605
|
+
idToIndexMap = {
|
|
5606
|
+
animations: {},
|
|
5607
|
+
accessors: {},
|
|
5608
|
+
buffers: {},
|
|
5609
|
+
bufferViews: {},
|
|
5610
|
+
images: {},
|
|
5611
|
+
materials: {},
|
|
5612
|
+
meshes: {},
|
|
5613
|
+
nodes: {},
|
|
5614
|
+
samplers: {},
|
|
5615
|
+
scenes: {},
|
|
5616
|
+
skins: {},
|
|
5617
|
+
textures: {}
|
|
5618
|
+
};
|
|
5619
|
+
json;
|
|
5600
5620
|
// constructor() {}
|
|
5601
5621
|
/**
|
|
5602
5622
|
* Convert (normalize) glTF < 2.0 to glTF 2.0
|
|
@@ -5668,11 +5688,11 @@ var __exports__ = (() => {
|
|
|
5668
5688
|
for (const mesh of json.meshes) {
|
|
5669
5689
|
this._convertMeshIds(mesh);
|
|
5670
5690
|
}
|
|
5671
|
-
for (const
|
|
5672
|
-
this._convertNodeIds(
|
|
5691
|
+
for (const node of json.nodes) {
|
|
5692
|
+
this._convertNodeIds(node);
|
|
5673
5693
|
}
|
|
5674
|
-
for (const
|
|
5675
|
-
this._convertSceneIds(
|
|
5694
|
+
for (const node of json.scenes) {
|
|
5695
|
+
this._convertSceneIds(node);
|
|
5676
5696
|
}
|
|
5677
5697
|
}
|
|
5678
5698
|
_convertTextureIds(texture) {
|
|
@@ -5694,17 +5714,17 @@ var __exports__ = (() => {
|
|
|
5694
5714
|
}
|
|
5695
5715
|
}
|
|
5696
5716
|
}
|
|
5697
|
-
_convertNodeIds(
|
|
5698
|
-
if (
|
|
5699
|
-
|
|
5717
|
+
_convertNodeIds(node) {
|
|
5718
|
+
if (node.children) {
|
|
5719
|
+
node.children = node.children.map((child) => this._convertIdToIndex(child, "node"));
|
|
5700
5720
|
}
|
|
5701
|
-
if (
|
|
5702
|
-
|
|
5721
|
+
if (node.meshes) {
|
|
5722
|
+
node.meshes = node.meshes.map((mesh) => this._convertIdToIndex(mesh, "mesh"));
|
|
5703
5723
|
}
|
|
5704
5724
|
}
|
|
5705
5725
|
_convertSceneIds(scene) {
|
|
5706
5726
|
if (scene.nodes) {
|
|
5707
|
-
scene.nodes = scene.nodes.map((
|
|
5727
|
+
scene.nodes = scene.nodes.map((node) => this._convertIdToIndex(node, "node"));
|
|
5708
5728
|
}
|
|
5709
5729
|
}
|
|
5710
5730
|
/** Go through all objects in a top-level array and replace ids with indices */
|
|
@@ -5896,6 +5916,8 @@ var __exports__ = (() => {
|
|
|
5896
5916
|
|
|
5897
5917
|
// src/gltf-loader.ts
|
|
5898
5918
|
var GLTFLoader = {
|
|
5919
|
+
dataType: null,
|
|
5920
|
+
batchType: null,
|
|
5899
5921
|
name: "glTF",
|
|
5900
5922
|
id: "gltf",
|
|
5901
5923
|
module: "gltf",
|
|
@@ -5990,6 +6012,8 @@ var __exports__ = (() => {
|
|
|
5990
6012
|
|
|
5991
6013
|
// src/gltf-writer.ts
|
|
5992
6014
|
var GLTFWriter = {
|
|
6015
|
+
dataType: null,
|
|
6016
|
+
batchType: null,
|
|
5993
6017
|
name: "glTF",
|
|
5994
6018
|
id: "gltf",
|
|
5995
6019
|
module: "gltf",
|
|
@@ -6016,6 +6040,8 @@ var __exports__ = (() => {
|
|
|
6016
6040
|
|
|
6017
6041
|
// src/glb-loader.ts
|
|
6018
6042
|
var GLBLoader = {
|
|
6043
|
+
dataType: null,
|
|
6044
|
+
batchType: null,
|
|
6019
6045
|
name: "GLB",
|
|
6020
6046
|
id: "glb",
|
|
6021
6047
|
module: "gltf",
|
|
@@ -6126,11 +6152,13 @@ var __exports__ = (() => {
|
|
|
6126
6152
|
return COMPONENTS2[type];
|
|
6127
6153
|
}
|
|
6128
6154
|
var GLTFPostProcessor = class {
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6155
|
+
baseUri = "";
|
|
6156
|
+
// @ts-expect-error
|
|
6157
|
+
jsonUnprocessed;
|
|
6158
|
+
// @ts-expect-error
|
|
6159
|
+
json;
|
|
6160
|
+
buffers = [];
|
|
6161
|
+
images = [];
|
|
6134
6162
|
postProcess(gltf, options = {}) {
|
|
6135
6163
|
const { json, buffers = [], images = [] } = gltf;
|
|
6136
6164
|
const { baseUri = "" } = gltf;
|
|
@@ -6170,8 +6198,8 @@ var __exports__ = (() => {
|
|
|
6170
6198
|
json.meshes = gltf.meshes.map((mesh, i2) => this._resolveMesh(mesh, i2));
|
|
6171
6199
|
}
|
|
6172
6200
|
if (gltf.nodes) {
|
|
6173
|
-
json.nodes = gltf.nodes.map((
|
|
6174
|
-
json.nodes = json.nodes.map((
|
|
6201
|
+
json.nodes = gltf.nodes.map((node, i2) => this._resolveNode(node, i2));
|
|
6202
|
+
json.nodes = json.nodes.map((node, i2) => this._resolveNodeChildren(node));
|
|
6175
6203
|
}
|
|
6176
6204
|
if (gltf.skins) {
|
|
6177
6205
|
json.skins = gltf.skins.map((skin, i2) => this._resolveSkin(skin, i2));
|
|
@@ -6236,26 +6264,26 @@ var __exports__ = (() => {
|
|
|
6236
6264
|
...scene,
|
|
6237
6265
|
// @ts-ignore
|
|
6238
6266
|
id: scene.id || `scene-${index}`,
|
|
6239
|
-
nodes: (scene.nodes || []).map((
|
|
6267
|
+
nodes: (scene.nodes || []).map((node) => this.getNode(node))
|
|
6240
6268
|
};
|
|
6241
6269
|
}
|
|
6242
6270
|
_resolveNode(gltfNode, index) {
|
|
6243
|
-
const
|
|
6271
|
+
const node = {
|
|
6244
6272
|
...gltfNode,
|
|
6245
6273
|
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6246
6274
|
id: gltfNode?.id || `node-${index}`
|
|
6247
6275
|
};
|
|
6248
6276
|
if (gltfNode.mesh !== void 0) {
|
|
6249
|
-
|
|
6277
|
+
node.mesh = this.getMesh(gltfNode.mesh);
|
|
6250
6278
|
}
|
|
6251
6279
|
if (gltfNode.camera !== void 0) {
|
|
6252
|
-
|
|
6280
|
+
node.camera = this.getCamera(gltfNode.camera);
|
|
6253
6281
|
}
|
|
6254
6282
|
if (gltfNode.skin !== void 0) {
|
|
6255
|
-
|
|
6283
|
+
node.skin = this.getSkin(gltfNode.skin);
|
|
6256
6284
|
}
|
|
6257
6285
|
if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) {
|
|
6258
|
-
|
|
6286
|
+
node.mesh = gltfNode.meshes.reduce(
|
|
6259
6287
|
(accum, meshIndex) => {
|
|
6260
6288
|
const mesh = this.getMesh(meshIndex);
|
|
6261
6289
|
accum.id = mesh.id;
|
|
@@ -6265,13 +6293,13 @@ var __exports__ = (() => {
|
|
|
6265
6293
|
{ primitives: [] }
|
|
6266
6294
|
);
|
|
6267
6295
|
}
|
|
6268
|
-
return
|
|
6296
|
+
return node;
|
|
6269
6297
|
}
|
|
6270
|
-
_resolveNodeChildren(
|
|
6271
|
-
if (
|
|
6272
|
-
|
|
6298
|
+
_resolveNodeChildren(node) {
|
|
6299
|
+
if (node.children) {
|
|
6300
|
+
node.children = node.children.map((child) => this.getNode(child));
|
|
6273
6301
|
}
|
|
6274
|
-
return
|
|
6302
|
+
return node;
|
|
6275
6303
|
}
|
|
6276
6304
|
_resolveSkin(gltfSkin, index) {
|
|
6277
6305
|
const inverseBindMatrices = typeof gltfSkin.inverseBindMatrices === "number" ? this.getAccessor(gltfSkin.inverseBindMatrices) : void 0;
|