@babylonjs/loaders 5.0.0-rc.2 → 5.0.0-rc.5
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +7 -6
- package/OBJ/mtlFileLoader.js +15 -14
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +11 -18
- package/OBJ/objFileLoader.js +19 -23
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +6 -5
- package/OBJ/solidParser.js +15 -21
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +7 -14
- package/STL/stlFileLoader.js +15 -21
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +4 -4
- package/glTF/1.0/glTFBinaryExtension.js +4 -5
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +80 -50
- package/glTF/1.0/glTFLoader.js +265 -146
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +10 -10
- package/glTF/1.0/glTFLoaderInterfaces.js +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +25 -25
- package/glTF/1.0/glTFLoaderUtils.js +70 -52
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +2 -2
- package/glTF/1.0/glTFMaterialsCommonExtension.js +13 -11
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +11 -4
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +9 -2
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +13 -5
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +12 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +12 -4
- package/glTF/2.0/Extensions/EXT_texture_webp.js +11 -3
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +26 -8
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -4
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +14 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +17 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +11 -3
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_specular.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +11 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +24 -13
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +17 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js +19 -8
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_volume.js +12 -5
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +5 -3
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +11 -3
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_transform.js +10 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +23 -7
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +38 -14
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +45 -11
- package/glTF/2.0/Extensions/MSFT_lod.js +44 -8
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +70 -22
- package/glTF/2.0/glTFLoader.js +180 -93
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +11 -11
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +7 -7
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +87 -27
- package/glTF/glTFFileLoader.js +102 -45
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +1 -1
- package/glTF/glTFValidation.js +12 -12
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.js.map +1 -1
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +1 -1
- package/legacy/legacy-glTF1.js +2 -2
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.js +1 -0
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +1 -1
- package/legacy/legacy-glTF2.js +11 -11
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.js +1 -0
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.js +1 -0
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +3 -3
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +3 -3
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +2 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +23 -198
- package/readme.md +2 -2
package/glTF/glTFFileLoader.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
2
2
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
3
|
-
import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
|
3
|
+
import { SceneLoader, } from "@babylonjs/core/Loading/sceneLoader.js";
|
4
4
|
import { AssetContainer } from "@babylonjs/core/assetContainer.js";
|
5
5
|
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
6
6
|
import { DataReader } from "@babylonjs/core/Misc/dataReader.js";
|
@@ -86,8 +86,8 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
86
86
|
*/
|
87
87
|
this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
|
88
88
|
/**
|
89
|
-
|
90
|
-
|
89
|
+
* The animation start mode. Defaults to FIRST.
|
90
|
+
*/
|
91
91
|
this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
|
92
92
|
/**
|
93
93
|
* Defines if the loader should compile materials before raising the success callback. Defaults to false.
|
@@ -125,6 +125,14 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
125
125
|
* If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
|
126
126
|
*/
|
127
127
|
this.loadAllMaterials = false;
|
128
|
+
/**
|
129
|
+
* If true, load only the materials defined in the file. Defaults to false.
|
130
|
+
*/
|
131
|
+
this.loadOnlyMaterials = false;
|
132
|
+
/**
|
133
|
+
* If true, do not load any materials defined in the file. Defaults to false.
|
134
|
+
*/
|
135
|
+
this.skipMaterials = false;
|
128
136
|
/**
|
129
137
|
* If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
|
130
138
|
*/
|
@@ -139,8 +147,9 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
139
147
|
*/
|
140
148
|
this.alwaysComputeSkeletonRootNode = false;
|
141
149
|
/**
|
142
|
-
|
143
|
-
|
150
|
+
* Function called before loading a url referenced by the asset.
|
151
|
+
* @param url
|
152
|
+
*/
|
144
153
|
this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
|
145
154
|
/**
|
146
155
|
* Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
|
@@ -196,7 +205,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
196
205
|
/** @hidden */
|
197
206
|
this.extensions = {
|
198
207
|
".gltf": { isBinary: false },
|
199
|
-
".glb": { isBinary: true }
|
208
|
+
".glb": { isBinary: true },
|
200
209
|
};
|
201
210
|
/**
|
202
211
|
* Observable raised when the loader state changes.
|
@@ -415,7 +424,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
415
424
|
this.onDisposeObservable.notifyObservers(undefined);
|
416
425
|
this.onDisposeObservable.clear();
|
417
426
|
};
|
418
|
-
/**
|
427
|
+
/**
|
428
|
+
* @param scene
|
429
|
+
* @param fileOrUrl
|
430
|
+
* @param onSuccess
|
431
|
+
* @param onProgress
|
432
|
+
* @param useArrayBuffer
|
433
|
+
* @param onError
|
434
|
+
* @hidden
|
435
|
+
*/
|
419
436
|
GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, onSuccess, onProgress, useArrayBuffer, onError) {
|
420
437
|
var _this = this;
|
421
438
|
this._progressCallback = onProgress;
|
@@ -428,7 +445,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
428
445
|
}
|
429
446
|
var fileRequest_1 = {
|
430
447
|
abort: function () { },
|
431
|
-
onCompleteObservable: new Observable()
|
448
|
+
onCompleteObservable: new Observable(),
|
432
449
|
};
|
433
450
|
var dataBuffer = {
|
434
451
|
readAsync: function (byteOffset, byteLength) {
|
@@ -442,7 +459,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
442
459
|
});
|
443
460
|
});
|
444
461
|
},
|
445
|
-
byteLength: 0
|
462
|
+
byteLength: 0,
|
446
463
|
};
|
447
464
|
this._unpackBinaryAsync(new DataReader(dataBuffer)).then(function (loaderData) {
|
448
465
|
fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1);
|
@@ -454,7 +471,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
454
471
|
_this._validate(scene, data, rootUrl, fileName);
|
455
472
|
_this._unpackBinaryAsync(new DataReader({
|
456
473
|
readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); },
|
457
|
-
byteLength: data.byteLength
|
474
|
+
byteLength: data.byteLength,
|
458
475
|
})).then(function (loaderData) {
|
459
476
|
onSuccess(loaderData);
|
460
477
|
}, onError ? function (error) { return onError(undefined, error); } : undefined);
|
@@ -465,7 +482,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
465
482
|
onSuccess({ json: _this._parseJson(data) });
|
466
483
|
}, useArrayBuffer, onError);
|
467
484
|
};
|
468
|
-
/**
|
485
|
+
/**
|
486
|
+
* @param meshesNames
|
487
|
+
* @param scene
|
488
|
+
* @param data
|
489
|
+
* @param rootUrl
|
490
|
+
* @param onProgress
|
491
|
+
* @param fileName
|
492
|
+
* @hidden
|
493
|
+
*/
|
469
494
|
GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
|
470
495
|
var _this = this;
|
471
496
|
return Promise.resolve().then(function () {
|
@@ -476,7 +501,14 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
476
501
|
return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
|
477
502
|
});
|
478
503
|
};
|
479
|
-
/**
|
504
|
+
/**
|
505
|
+
* @param scene
|
506
|
+
* @param data
|
507
|
+
* @param rootUrl
|
508
|
+
* @param onProgress
|
509
|
+
* @param fileName
|
510
|
+
* @hidden
|
511
|
+
*/
|
480
512
|
GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
|
481
513
|
var _this = this;
|
482
514
|
return Promise.resolve().then(function () {
|
@@ -487,7 +519,14 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
487
519
|
return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
|
488
520
|
});
|
489
521
|
};
|
490
|
-
/**
|
522
|
+
/**
|
523
|
+
* @param scene
|
524
|
+
* @param data
|
525
|
+
* @param rootUrl
|
526
|
+
* @param onProgress
|
527
|
+
* @param fileName
|
528
|
+
* @hidden
|
529
|
+
*/
|
491
530
|
GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
|
492
531
|
var _this = this;
|
493
532
|
return Promise.resolve().then(function () {
|
@@ -525,25 +564,32 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
525
564
|
});
|
526
565
|
});
|
527
566
|
};
|
528
|
-
/**
|
567
|
+
/**
|
568
|
+
* @param data
|
569
|
+
* @hidden
|
570
|
+
*/
|
529
571
|
GLTFFileLoader.prototype.canDirectLoad = function (data) {
|
530
|
-
return (data.indexOf("asset") !== -1 && data.indexOf("version") !== -1)
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
572
|
+
return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) ||
|
573
|
+
StringTools.StartsWith(data, "data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
|
574
|
+
StringTools.StartsWith(data, "data:;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
575
|
+
StringTools.StartsWith(data, "data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
576
|
+
StringTools.StartsWith(data, "data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded));
|
535
577
|
};
|
536
|
-
/**
|
578
|
+
/**
|
579
|
+
* @param scene
|
580
|
+
* @param data
|
581
|
+
* @hidden
|
582
|
+
*/
|
537
583
|
GLTFFileLoader.prototype.directLoad = function (scene, data) {
|
538
|
-
if (StringTools.StartsWith(data, "base64," + GLTFFileLoader.
|
539
|
-
StringTools.StartsWith(data, ";base64," + GLTFFileLoader.
|
540
|
-
StringTools.StartsWith(data, "application/octet-stream;base64," + GLTFFileLoader.
|
541
|
-
StringTools.StartsWith(data, "model/gltf-binary;base64," + GLTFFileLoader.
|
584
|
+
if (StringTools.StartsWith(data, "base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
|
585
|
+
StringTools.StartsWith(data, ";base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
586
|
+
StringTools.StartsWith(data, "application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
587
|
+
StringTools.StartsWith(data, "model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) {
|
542
588
|
var arrayBuffer_1 = DecodeBase64UrlToBinary(data);
|
543
589
|
this._validate(scene, arrayBuffer_1);
|
544
590
|
return this._unpackBinaryAsync(new DataReader({
|
545
591
|
readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); },
|
546
|
-
byteLength: arrayBuffer_1.byteLength
|
592
|
+
byteLength: arrayBuffer_1.byteLength,
|
547
593
|
}));
|
548
594
|
}
|
549
595
|
this._validate(scene, data);
|
@@ -578,7 +624,10 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
578
624
|
});
|
579
625
|
});
|
580
626
|
};
|
581
|
-
/**
|
627
|
+
/**
|
628
|
+
* @param state
|
629
|
+
* @hidden
|
630
|
+
*/
|
582
631
|
GLTFFileLoader.prototype._setState = function (state) {
|
583
632
|
if (this._state === state) {
|
584
633
|
return;
|
@@ -587,7 +636,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
587
636
|
this.onLoaderStateChangedObservable.notifyObservers(this._state);
|
588
637
|
this._log(GLTFLoaderState[this._state]);
|
589
638
|
};
|
590
|
-
/**
|
639
|
+
/**
|
640
|
+
* @param scene
|
641
|
+
* @param fileOrUrl
|
642
|
+
* @param onSuccess
|
643
|
+
* @param useArrayBuffer
|
644
|
+
* @param onError
|
645
|
+
* @param onOpened
|
646
|
+
* @hidden
|
647
|
+
*/
|
591
648
|
GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) {
|
592
649
|
var _this = this;
|
593
650
|
var request = scene._loadFile(fileOrUrl, onSuccess, function (event) {
|
@@ -621,7 +678,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
621
678
|
this._progressCallback({
|
622
679
|
lengthComputable: lengthComputable,
|
623
680
|
loaded: loaded,
|
624
|
-
total: lengthComputable ? total : 0
|
681
|
+
total: lengthComputable ? total : 0,
|
625
682
|
});
|
626
683
|
};
|
627
684
|
GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) {
|
@@ -664,7 +721,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
664
721
|
}
|
665
722
|
var createLoaders = {
|
666
723
|
1: GLTFFileLoader._CreateGLTF1Loader,
|
667
|
-
2: GLTFFileLoader._CreateGLTF2Loader
|
724
|
+
2: GLTFFileLoader._CreateGLTF2Loader,
|
668
725
|
};
|
669
726
|
var createLoader = createLoaders[version.major];
|
670
727
|
if (!createLoader) {
|
@@ -685,7 +742,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
685
742
|
// Read magic + version + length + json length + json format
|
686
743
|
return dataReader.loadAsync(20).then(function () {
|
687
744
|
var Binary = {
|
688
|
-
Magic:
|
745
|
+
Magic: 0x46546c67,
|
689
746
|
};
|
690
747
|
var magic = dataReader.readUint32();
|
691
748
|
if (magic !== Binary.Magic) {
|
@@ -719,7 +776,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
719
776
|
};
|
720
777
|
GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) {
|
721
778
|
var ContentFormat = {
|
722
|
-
JSON: 0
|
779
|
+
JSON: 0,
|
723
780
|
};
|
724
781
|
var contentLength = dataReader.readUint32();
|
725
782
|
var contentFormat = dataReader.readUint32();
|
@@ -732,7 +789,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
732
789
|
var startByteOffset_1 = dataReader.byteOffset;
|
733
790
|
data.bin = {
|
734
791
|
readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); },
|
735
|
-
byteLength: bodyLength
|
792
|
+
byteLength: bodyLength,
|
736
793
|
};
|
737
794
|
}
|
738
795
|
return Promise.resolve(data);
|
@@ -740,8 +797,8 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
740
797
|
GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) {
|
741
798
|
var _this = this;
|
742
799
|
var ChunkFormat = {
|
743
|
-
JSON:
|
744
|
-
BIN:
|
800
|
+
JSON: 0x4e4f534a,
|
801
|
+
BIN: 0x004e4942,
|
745
802
|
};
|
746
803
|
// Read the JSON chunk header.
|
747
804
|
var chunkLength = dataReader.readUint32();
|
@@ -769,7 +826,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
769
826
|
var startByteOffset_2 = dataReader.byteOffset;
|
770
827
|
data.bin = {
|
771
828
|
readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); },
|
772
|
-
byteLength: chunkLength
|
829
|
+
byteLength: chunkLength,
|
773
830
|
};
|
774
831
|
dataReader.skipBytes(chunkLength);
|
775
832
|
break;
|
@@ -792,7 +849,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
792
849
|
if (version === "1.0" || version === "1.0.1") {
|
793
850
|
return {
|
794
851
|
major: 1,
|
795
|
-
minor: 0
|
852
|
+
minor: 0,
|
796
853
|
};
|
797
854
|
}
|
798
855
|
var match = (version + "").match(/^(\d+)\.(\d+)/);
|
@@ -801,7 +858,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
801
858
|
}
|
802
859
|
return {
|
803
860
|
major: parseInt(match[1]),
|
804
|
-
minor: parseInt(match[2])
|
861
|
+
minor: parseInt(match[2]),
|
805
862
|
};
|
806
863
|
};
|
807
864
|
GLTFFileLoader._compareVersion = function (a, b) {
|
@@ -819,7 +876,10 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
819
876
|
}
|
820
877
|
return 0;
|
821
878
|
};
|
822
|
-
/**
|
879
|
+
/**
|
880
|
+
* @param message
|
881
|
+
* @hidden
|
882
|
+
*/
|
823
883
|
GLTFFileLoader.prototype._logOpen = function (message) {
|
824
884
|
this._log(message);
|
825
885
|
this._logIndentLevel++;
|
@@ -832,18 +892,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
832
892
|
var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
|
833
893
|
Logger.Log("".concat(spaces).concat(message));
|
834
894
|
};
|
835
|
-
GLTFFileLoader.prototype._logDisabled = function (message) {
|
836
|
-
};
|
895
|
+
GLTFFileLoader.prototype._logDisabled = function (message) { };
|
837
896
|
GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
|
838
897
|
Tools.StartPerformanceCounter(counterName);
|
839
898
|
};
|
840
|
-
GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
|
841
|
-
};
|
899
|
+
GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { };
|
842
900
|
GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
|
843
901
|
Tools.EndPerformanceCounter(counterName);
|
844
902
|
};
|
845
|
-
GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
|
846
|
-
};
|
903
|
+
GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { };
|
847
904
|
// ----------
|
848
905
|
// V1 options
|
849
906
|
// ----------
|
@@ -860,7 +917,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
860
917
|
* @hidden
|
861
918
|
*/
|
862
919
|
GLTFFileLoader.HomogeneousCoordinates = false;
|
863
|
-
GLTFFileLoader.
|
920
|
+
GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
|
864
921
|
GLTFFileLoader._logSpaces = " ";
|
865
922
|
return GLTFFileLoader;
|
866
923
|
}());
|