@babylonjs/loaders 5.0.0-beta.3 → 5.0.0-beta.7
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/objFileLoader.js +2 -2
- package/OBJ/objFileLoader.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -8
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +4 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +2 -2
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +27 -7
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +7 -7
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +5 -5
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -5
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -5
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.js +6 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +2 -2
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +13 -13
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -1
- package/glTF/2.0/Extensions/MSFT_lod.js +17 -54
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/glTFLoader.js +141 -141
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/glTFFileLoader.js +13 -13
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.js +1 -1
- package/glTF/glTFValidation.js.map +1 -1
- package/package.json +3 -3
package/glTF/2.0/glTFLoader.js
CHANGED
@@ -39,7 +39,7 @@ var ArrayItem = /** @class */ (function () {
|
|
39
39
|
*/
|
40
40
|
ArrayItem.Get = function (context, array, index) {
|
41
41
|
if (!array || index == undefined || !array[index]) {
|
42
|
-
throw new Error(context
|
42
|
+
throw new Error("".concat(context, ": Failed to find index (").concat(index, ")"));
|
43
43
|
}
|
44
44
|
return array[index];
|
45
45
|
};
|
@@ -84,7 +84,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
84
84
|
*/
|
85
85
|
GLTFLoader.RegisterExtension = function (name, factory) {
|
86
86
|
if (GLTFLoader.UnregisterExtension(name)) {
|
87
|
-
Logger.Warn("Extension with the name '"
|
87
|
+
Logger.Warn("Extension with the name '".concat(name, "' already exists"));
|
88
88
|
}
|
89
89
|
GLTFLoader._RegisteredExtensions[name] = {
|
90
90
|
factory: factory
|
@@ -192,7 +192,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
192
192
|
nodes = names.map(function (name) {
|
193
193
|
var node = nodeMap_1[name];
|
194
194
|
if (node === undefined) {
|
195
|
-
throw new Error("Failed to find node '"
|
195
|
+
throw new Error("Failed to find node '".concat(name, "'"));
|
196
196
|
}
|
197
197
|
return node;
|
198
198
|
});
|
@@ -224,12 +224,12 @@ var GLTFLoader = /** @class */ (function () {
|
|
224
224
|
var _this = this;
|
225
225
|
return Promise.resolve().then(function () {
|
226
226
|
_this._rootUrl = rootUrl;
|
227
|
-
_this._uniqueRootUrl = (!StringTools.StartsWith(rootUrl, "file:") && fileName) ? rootUrl : ""
|
227
|
+
_this._uniqueRootUrl = (!StringTools.StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/");
|
228
228
|
_this._fileName = fileName;
|
229
229
|
_this._loadExtensions();
|
230
230
|
_this._checkExtensions();
|
231
|
-
var loadingToReadyCounterName = GLTFLoaderState[GLTFLoaderState.LOADING]
|
232
|
-
var loadingToCompleteCounterName = GLTFLoaderState[GLTFLoaderState.LOADING]
|
231
|
+
var loadingToReadyCounterName = "".concat(GLTFLoaderState[GLTFLoaderState.LOADING], " => ").concat(GLTFLoaderState[GLTFLoaderState.READY]);
|
232
|
+
var loadingToCompleteCounterName = "".concat(GLTFLoaderState[GLTFLoaderState.LOADING], " => ").concat(GLTFLoaderState[GLTFLoaderState.COMPLETE]);
|
233
233
|
_this._parent._startPerformanceCounter(loadingToReadyCounterName);
|
234
234
|
_this._parent._startPerformanceCounter(loadingToCompleteCounterName);
|
235
235
|
_this._parent._setState(GLTFLoaderState.LOADING);
|
@@ -243,7 +243,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
243
243
|
}
|
244
244
|
else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
|
245
245
|
var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
|
246
|
-
promises.push(_this.loadSceneAsync("/scenes/"
|
246
|
+
promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
|
247
247
|
}
|
248
248
|
if (_this.parent.loadAllMaterials && _this._gltf.materials) {
|
249
249
|
for (var m = 0; m < _this._gltf.materials.length; ++m) {
|
@@ -306,7 +306,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
306
306
|
if (buffers && buffers[0] && !buffers[0].uri) {
|
307
307
|
var binaryBuffer = buffers[0];
|
308
308
|
if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) {
|
309
|
-
Logger.Warn("Binary buffer length ("
|
309
|
+
Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")"));
|
310
310
|
}
|
311
311
|
this._bin = data.bin;
|
312
312
|
}
|
@@ -352,7 +352,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
352
352
|
for (var name_2 in GLTFLoader._RegisteredExtensions) {
|
353
353
|
var extension = GLTFLoader._RegisteredExtensions[name_2].factory(this);
|
354
354
|
if (extension.name !== name_2) {
|
355
|
-
Logger.Warn("The name of the glTF loader extension instance does not match the registered name: "
|
355
|
+
Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_2));
|
356
356
|
}
|
357
357
|
this._extensions.push(extension);
|
358
358
|
this._parent.onExtensionLoadedObservable.notifyObservers(extension);
|
@@ -365,7 +365,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
365
365
|
var _loop_1 = function (name_3) {
|
366
366
|
var available = this_1._extensions.some(function (extension) { return extension.name === name_3 && extension.enabled; });
|
367
367
|
if (!available) {
|
368
|
-
throw new Error("Require extension "
|
368
|
+
throw new Error("Require extension ".concat(name_3, " is not available"));
|
369
369
|
}
|
370
370
|
};
|
371
371
|
var this_1 = this;
|
@@ -399,7 +399,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
399
399
|
break;
|
400
400
|
}
|
401
401
|
default: {
|
402
|
-
throw new Error("Invalid coordinate system mode ("
|
402
|
+
throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")"));
|
403
403
|
}
|
404
404
|
}
|
405
405
|
this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
|
@@ -418,12 +418,12 @@ var GLTFLoader = /** @class */ (function () {
|
|
418
418
|
return extensionPromise;
|
419
419
|
}
|
420
420
|
var promises = new Array();
|
421
|
-
this.logOpen(context
|
421
|
+
this.logOpen("".concat(context, " ").concat(scene.name || ""));
|
422
422
|
if (scene.nodes) {
|
423
423
|
for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) {
|
424
424
|
var index = _a[_i];
|
425
|
-
var node = ArrayItem.Get(context
|
426
|
-
promises.push(this.loadNodeAsync("/nodes/"
|
425
|
+
var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index);
|
426
|
+
promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) {
|
427
427
|
babylonMesh.parent = _this._rootBabylonMesh;
|
428
428
|
}));
|
429
429
|
}
|
@@ -547,7 +547,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
547
547
|
break;
|
548
548
|
}
|
549
549
|
default: {
|
550
|
-
Logger.Error("Invalid animation start mode ("
|
550
|
+
Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")"));
|
551
551
|
return;
|
552
552
|
}
|
553
553
|
}
|
@@ -567,24 +567,24 @@ var GLTFLoader = /** @class */ (function () {
|
|
567
567
|
return extensionPromise;
|
568
568
|
}
|
569
569
|
if (node._babylonTransformNode) {
|
570
|
-
throw new Error(context
|
570
|
+
throw new Error("".concat(context, ": Invalid recursive node hierarchy"));
|
571
571
|
}
|
572
572
|
var promises = new Array();
|
573
|
-
this.logOpen(context
|
573
|
+
this.logOpen("".concat(context, " ").concat(node.name || ""));
|
574
574
|
var loadNode = function (babylonTransformNode) {
|
575
575
|
GLTFLoader.AddPointerMetadata(babylonTransformNode, context);
|
576
576
|
GLTFLoader._LoadTransform(node, babylonTransformNode);
|
577
577
|
if (node.camera != undefined) {
|
578
|
-
var camera = ArrayItem.Get(context
|
579
|
-
promises.push(_this.loadCameraAsync("/cameras/"
|
578
|
+
var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera);
|
579
|
+
promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) {
|
580
580
|
babylonCamera.parent = babylonTransformNode;
|
581
581
|
}));
|
582
582
|
}
|
583
583
|
if (node.children) {
|
584
584
|
for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
|
585
585
|
var index = _a[_i];
|
586
|
-
var childNode = ArrayItem.Get(context
|
587
|
-
promises.push(_this.loadNodeAsync("/nodes/"
|
586
|
+
var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index);
|
587
|
+
promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) {
|
588
588
|
childBabylonMesh.parent = babylonTransformNode;
|
589
589
|
}));
|
590
590
|
}
|
@@ -592,7 +592,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
592
592
|
assign(babylonTransformNode);
|
593
593
|
};
|
594
594
|
if (node.mesh == undefined) {
|
595
|
-
var nodeName = node.name || "node"
|
595
|
+
var nodeName = node.name || "node".concat(node.index);
|
596
596
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
597
597
|
node._babylonTransformNode = new TransformNode(nodeName, this._babylonScene);
|
598
598
|
node._babylonTransformNode._parentContainer = this._assetContainer;
|
@@ -600,8 +600,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
600
600
|
loadNode(node._babylonTransformNode);
|
601
601
|
}
|
602
602
|
else {
|
603
|
-
var mesh = ArrayItem.Get(context
|
604
|
-
promises.push(this._loadMeshAsync("/meshes/"
|
603
|
+
var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh);
|
604
|
+
promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode));
|
605
605
|
}
|
606
606
|
this.logClose();
|
607
607
|
return Promise.all(promises).then(function () {
|
@@ -620,17 +620,17 @@ var GLTFLoader = /** @class */ (function () {
|
|
620
620
|
GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) {
|
621
621
|
var primitives = mesh.primitives;
|
622
622
|
if (!primitives || !primitives.length) {
|
623
|
-
throw new Error(context
|
623
|
+
throw new Error("".concat(context, ": Primitives are missing"));
|
624
624
|
}
|
625
625
|
if (primitives[0].index == undefined) {
|
626
626
|
ArrayItem.Assign(primitives);
|
627
627
|
}
|
628
628
|
var promises = new Array();
|
629
|
-
this.logOpen(context
|
630
|
-
var name = node.name || "node"
|
629
|
+
this.logOpen("".concat(context, " ").concat(mesh.name || ""));
|
630
|
+
var name = node.name || "node".concat(node.index);
|
631
631
|
if (primitives.length === 1) {
|
632
632
|
var primitive = mesh.primitives[0];
|
633
|
-
promises.push(this._loadMeshPrimitiveAsync(context
|
633
|
+
promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) {
|
634
634
|
node._babylonTransformNode = babylonMesh;
|
635
635
|
node._primitiveBabylonMeshes = [babylonMesh];
|
636
636
|
}));
|
@@ -643,15 +643,15 @@ var GLTFLoader = /** @class */ (function () {
|
|
643
643
|
node._primitiveBabylonMeshes = [];
|
644
644
|
for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) {
|
645
645
|
var primitive = primitives_1[_i];
|
646
|
-
promises.push(this._loadMeshPrimitiveAsync(context
|
646
|
+
promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) {
|
647
647
|
babylonMesh.parent = node._babylonTransformNode;
|
648
648
|
node._primitiveBabylonMeshes.push(babylonMesh);
|
649
649
|
}));
|
650
650
|
}
|
651
651
|
}
|
652
652
|
if (node.skin != undefined) {
|
653
|
-
var skin = ArrayItem.Get(context
|
654
|
-
promises.push(this._loadSkinAsync("/skins/"
|
653
|
+
var skin = ArrayItem.Get("".concat(context, "/skin"), this._gltf.skins, node.skin);
|
654
|
+
promises.push(this._loadSkinAsync("/skins/".concat(skin.index), node, skin));
|
655
655
|
}
|
656
656
|
assign(node._babylonTransformNode);
|
657
657
|
this.logClose();
|
@@ -675,7 +675,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
675
675
|
if (extensionPromise) {
|
676
676
|
return extensionPromise;
|
677
677
|
}
|
678
|
-
this.logOpen(""
|
678
|
+
this.logOpen("".concat(context));
|
679
679
|
var shouldInstance = (this._disableInstancedMesh === 0) && this._parent.createInstances && (node.skin == undefined && !mesh.primitives[0].targets);
|
680
680
|
var babylonAbstractMesh;
|
681
681
|
var promise;
|
@@ -713,8 +713,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
713
713
|
babylonMesh_1.material = babylonMaterial;
|
714
714
|
}
|
715
715
|
else {
|
716
|
-
var material = ArrayItem.Get(context
|
717
|
-
promises.push(this._loadMaterialAsync("/materials/"
|
716
|
+
var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material);
|
717
|
+
promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
|
718
718
|
babylonMesh_1.material = babylonMaterial;
|
719
719
|
}));
|
720
720
|
}
|
@@ -743,7 +743,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
743
743
|
}
|
744
744
|
var attributes = primitive.attributes;
|
745
745
|
if (!attributes) {
|
746
|
-
throw new Error(context
|
746
|
+
throw new Error("".concat(context, ": Attributes are missing"));
|
747
747
|
}
|
748
748
|
var promises = new Array();
|
749
749
|
var babylonGeometry = new Geometry(babylonMesh.name, this._babylonScene);
|
@@ -751,8 +751,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
751
751
|
babylonMesh.isUnIndexed = true;
|
752
752
|
}
|
753
753
|
else {
|
754
|
-
var accessor = ArrayItem.Get(context
|
755
|
-
promises.push(this._loadIndicesAccessorAsync("/accessors/"
|
754
|
+
var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices);
|
755
|
+
promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) {
|
756
756
|
babylonGeometry.setIndices(data);
|
757
757
|
}));
|
758
758
|
}
|
@@ -764,8 +764,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
764
764
|
if (babylonMesh._delayInfo.indexOf(kind) === -1) {
|
765
765
|
babylonMesh._delayInfo.push(kind);
|
766
766
|
}
|
767
|
-
var accessor = ArrayItem.Get(context
|
768
|
-
promises.push(_this._loadVertexAccessorAsync("/accessors/"
|
767
|
+
var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
|
768
|
+
promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) {
|
769
769
|
if (babylonVertexBuffer.getKind() === VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {
|
770
770
|
var mmin = accessor.min, mmax = accessor.max;
|
771
771
|
if (mmin !== undefined && mmax !== undefined) {
|
@@ -836,14 +836,14 @@ var GLTFLoader = /** @class */ (function () {
|
|
836
836
|
node._numMorphTargets = primitive.targets.length;
|
837
837
|
}
|
838
838
|
else if (primitive.targets.length !== node._numMorphTargets) {
|
839
|
-
throw new Error(context
|
839
|
+
throw new Error("".concat(context, ": Primitives do not have the same number of targets"));
|
840
840
|
}
|
841
841
|
var targetNames = mesh.extras ? mesh.extras.targetNames : null;
|
842
842
|
babylonMesh.morphTargetManager = new MorphTargetManager(babylonMesh.getScene());
|
843
843
|
babylonMesh.morphTargetManager.areUpdatesFrozen = true;
|
844
844
|
for (var index = 0; index < primitive.targets.length; index++) {
|
845
845
|
var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0;
|
846
|
-
var name_4 = targetNames ? targetNames[index] : "morphTarget"
|
846
|
+
var name_4 = targetNames ? targetNames[index] : "morphTarget".concat(index);
|
847
847
|
babylonMesh.morphTargetManager.addTarget(new MorphTarget(name_4, weight, babylonMesh.getScene()));
|
848
848
|
// TODO: tell the target whether it has positions, normals, tangents
|
849
849
|
}
|
@@ -856,7 +856,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
856
856
|
var morphTargetManager = babylonMesh.morphTargetManager;
|
857
857
|
for (var index = 0; index < morphTargetManager.numTargets; index++) {
|
858
858
|
var babylonMorphTarget = morphTargetManager.getTarget(index);
|
859
|
-
promises.push(this._loadMorphTargetVertexDataAsync(context
|
859
|
+
promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget));
|
860
860
|
}
|
861
861
|
return Promise.all(promises).then(function () {
|
862
862
|
morphTargetManager.areUpdatesFrozen = false;
|
@@ -873,8 +873,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
873
873
|
if (!babylonVertexBuffer) {
|
874
874
|
return;
|
875
875
|
}
|
876
|
-
var accessor = ArrayItem.Get(context
|
877
|
-
promises.push(_this._loadFloatAccessorAsync("/accessors/"
|
876
|
+
var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
|
877
|
+
promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) {
|
878
878
|
setData(babylonVertexBuffer, data);
|
879
879
|
}));
|
880
880
|
};
|
@@ -951,7 +951,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
951
951
|
assignSkeleton(skin._data.babylonSkeleton);
|
952
952
|
return skin._data.promise;
|
953
953
|
}
|
954
|
-
var skeletonId = "skeleton"
|
954
|
+
var skeletonId = "skeleton".concat(skin.index);
|
955
955
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
956
956
|
var babylonSkeleton = new Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
|
957
957
|
babylonSkeleton._parentContainer = this._assetContainer;
|
@@ -973,7 +973,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
973
973
|
var babylonBones = {};
|
974
974
|
for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) {
|
975
975
|
var index = _a[_i];
|
976
|
-
var node = ArrayItem.Get(context
|
976
|
+
var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index);
|
977
977
|
this._loadBone(node, skin, babylonSkeleton, babylonBones);
|
978
978
|
}
|
979
979
|
};
|
@@ -987,7 +987,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
987
987
|
babylonParentBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
|
988
988
|
}
|
989
989
|
var boneIndex = skin.joints.indexOf(node.index);
|
990
|
-
babylonBone = new Bone(node.name || "joint"
|
990
|
+
babylonBone = new Bone(node.name || "joint".concat(node.index), babylonSkeleton, babylonParentBone, this._getNodeMatrix(node), null, null, boneIndex);
|
991
991
|
babylonBones[node.index] = babylonBone;
|
992
992
|
node._babylonBones = node._babylonBones || [];
|
993
993
|
node._babylonBones.push(babylonBone);
|
@@ -997,8 +997,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
997
997
|
if (skin.inverseBindMatrices == undefined) {
|
998
998
|
return Promise.resolve(null);
|
999
999
|
}
|
1000
|
-
var accessor = ArrayItem.Get(context
|
1001
|
-
return this._loadFloatAccessorAsync("/accessors/"
|
1000
|
+
var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices);
|
1001
|
+
return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor);
|
1002
1002
|
};
|
1003
1003
|
GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) {
|
1004
1004
|
for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) {
|
@@ -1036,9 +1036,9 @@ var GLTFLoader = /** @class */ (function () {
|
|
1036
1036
|
return extensionPromise;
|
1037
1037
|
}
|
1038
1038
|
var promises = new Array();
|
1039
|
-
this.logOpen(context
|
1039
|
+
this.logOpen("".concat(context, " ").concat(camera.name || ""));
|
1040
1040
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
1041
|
-
var babylonCamera = new FreeCamera(camera.name || "camera"
|
1041
|
+
var babylonCamera = new FreeCamera(camera.name || "camera".concat(camera.index), Vector3.Zero(), this._babylonScene, false);
|
1042
1042
|
babylonCamera._parentContainer = this._assetContainer;
|
1043
1043
|
this._babylonScene._blockEntityCollection = false;
|
1044
1044
|
babylonCamera.ignoreParentScaling = true;
|
@@ -1047,7 +1047,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1047
1047
|
case "perspective" /* PERSPECTIVE */: {
|
1048
1048
|
var perspective = camera.perspective;
|
1049
1049
|
if (!perspective) {
|
1050
|
-
throw new Error(context
|
1050
|
+
throw new Error("".concat(context, ": Camera perspective properties are missing"));
|
1051
1051
|
}
|
1052
1052
|
babylonCamera.fov = perspective.yfov;
|
1053
1053
|
babylonCamera.minZ = perspective.znear;
|
@@ -1056,7 +1056,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1056
1056
|
}
|
1057
1057
|
case "orthographic" /* ORTHOGRAPHIC */: {
|
1058
1058
|
if (!camera.orthographic) {
|
1059
|
-
throw new Error(context
|
1059
|
+
throw new Error("".concat(context, ": Camera orthographic properties are missing"));
|
1060
1060
|
}
|
1061
1061
|
babylonCamera.mode = Camera.ORTHOGRAPHIC_CAMERA;
|
1062
1062
|
babylonCamera.orthoLeft = -camera.orthographic.xmag;
|
@@ -1068,7 +1068,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1068
1068
|
break;
|
1069
1069
|
}
|
1070
1070
|
default: {
|
1071
|
-
throw new Error(context
|
1071
|
+
throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")"));
|
1072
1072
|
}
|
1073
1073
|
}
|
1074
1074
|
GLTFLoader.AddPointerMetadata(babylonCamera, context);
|
@@ -1087,7 +1087,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1087
1087
|
var promises = new Array();
|
1088
1088
|
for (var index = 0; index < animations.length; index++) {
|
1089
1089
|
var animation = animations[index];
|
1090
|
-
promises.push(this.loadAnimationAsync("/animations/"
|
1090
|
+
promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) {
|
1091
1091
|
// Delete the animation group if it ended up not having any animations in it.
|
1092
1092
|
if (animationGroup.targetedAnimations.length === 0) {
|
1093
1093
|
animationGroup.dispose();
|
@@ -1108,7 +1108,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1108
1108
|
return promise;
|
1109
1109
|
}
|
1110
1110
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
1111
|
-
var babylonAnimationGroup = new AnimationGroup(animation.name || "animation"
|
1111
|
+
var babylonAnimationGroup = new AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene);
|
1112
1112
|
babylonAnimationGroup._parentContainer = this._assetContainer;
|
1113
1113
|
this._babylonScene._blockEntityCollection = false;
|
1114
1114
|
animation._babylonAnimationGroup = babylonAnimationGroup;
|
@@ -1117,7 +1117,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1117
1117
|
ArrayItem.Assign(animation.samplers);
|
1118
1118
|
for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
|
1119
1119
|
var channel = _a[_i];
|
1120
|
-
promises.push(this._loadAnimationChannelAsync(context
|
1120
|
+
promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, babylonAnimationGroup));
|
1121
1121
|
}
|
1122
1122
|
return Promise.all(promises).then(function () {
|
1123
1123
|
babylonAnimationGroup.normalize(0);
|
@@ -1140,14 +1140,14 @@ var GLTFLoader = /** @class */ (function () {
|
|
1140
1140
|
if (channel.target.node == undefined) {
|
1141
1141
|
return Promise.resolve();
|
1142
1142
|
}
|
1143
|
-
var targetNode = ArrayItem.Get(context
|
1143
|
+
var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node);
|
1144
1144
|
// Ignore animations that have no animation targets.
|
1145
1145
|
if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
|
1146
1146
|
(channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonTransformNode)) {
|
1147
1147
|
return Promise.resolve();
|
1148
1148
|
}
|
1149
|
-
var sampler = ArrayItem.Get(context
|
1150
|
-
return this._loadAnimationSamplerAsync(animationContext
|
1149
|
+
var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler);
|
1150
|
+
return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) {
|
1151
1151
|
var targetPath;
|
1152
1152
|
var animationType;
|
1153
1153
|
switch (channel.target.path) {
|
@@ -1172,7 +1172,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1172
1172
|
break;
|
1173
1173
|
}
|
1174
1174
|
default: {
|
1175
|
-
throw new Error(context
|
1175
|
+
throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")"));
|
1176
1176
|
}
|
1177
1177
|
}
|
1178
1178
|
var outputBufferOffset = 0;
|
@@ -1246,7 +1246,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1246
1246
|
}
|
1247
1247
|
if (targetPath === "influence") {
|
1248
1248
|
var _loop_2 = function (targetIndex) {
|
1249
|
-
var animationName = babylonAnimationGroup.name
|
1249
|
+
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
1250
1250
|
var babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
|
1251
1251
|
babylonAnimation.setKeys(keys.map(function (key) { return ({
|
1252
1252
|
frame: key.frame,
|
@@ -1267,7 +1267,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1267
1267
|
}
|
1268
1268
|
}
|
1269
1269
|
else {
|
1270
|
-
var animationName = babylonAnimationGroup.name
|
1270
|
+
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
1271
1271
|
var babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
|
1272
1272
|
babylonAnimation.setKeys(keys);
|
1273
1273
|
if (animationTargetOverride != null && animationTargetOverride.animations != null) {
|
@@ -1293,14 +1293,14 @@ var GLTFLoader = /** @class */ (function () {
|
|
1293
1293
|
break;
|
1294
1294
|
}
|
1295
1295
|
default: {
|
1296
|
-
throw new Error(context
|
1296
|
+
throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")"));
|
1297
1297
|
}
|
1298
1298
|
}
|
1299
|
-
var inputAccessor = ArrayItem.Get(context
|
1300
|
-
var outputAccessor = ArrayItem.Get(context
|
1299
|
+
var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input);
|
1300
|
+
var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
|
1301
1301
|
sampler._data = Promise.all([
|
1302
|
-
this._loadFloatAccessorAsync("/accessors/"
|
1303
|
-
this._loadFloatAccessorAsync("/accessors/"
|
1302
|
+
this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
|
1303
|
+
this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor)
|
1304
1304
|
]).then(function (_a) {
|
1305
1305
|
var inputData = _a[0], outputData = _a[1];
|
1306
1306
|
return {
|
@@ -1326,11 +1326,11 @@ var GLTFLoader = /** @class */ (function () {
|
|
1326
1326
|
}
|
1327
1327
|
if (!buffer._data) {
|
1328
1328
|
if (buffer.uri) {
|
1329
|
-
buffer._data = this.loadUriAsync(context
|
1329
|
+
buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri);
|
1330
1330
|
}
|
1331
1331
|
else {
|
1332
1332
|
if (!this._bin) {
|
1333
|
-
throw new Error(context
|
1333
|
+
throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
|
1334
1334
|
}
|
1335
1335
|
buffer._data = this._bin.readAsync(0, buffer.byteLength);
|
1336
1336
|
}
|
@@ -1340,7 +1340,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1340
1340
|
return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
|
1341
1341
|
}
|
1342
1342
|
catch (e) {
|
1343
|
-
throw new Error(context
|
1343
|
+
throw new Error("".concat(context, ": ").concat(e.message));
|
1344
1344
|
}
|
1345
1345
|
});
|
1346
1346
|
};
|
@@ -1358,8 +1358,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1358
1358
|
if (bufferView._data) {
|
1359
1359
|
return bufferView._data;
|
1360
1360
|
}
|
1361
|
-
var buffer = ArrayItem.Get(context
|
1362
|
-
bufferView._data = this.loadBufferAsync("/buffers/"
|
1361
|
+
var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer);
|
1362
|
+
bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, (bufferView.byteOffset || 0), bufferView.byteLength);
|
1363
1363
|
return bufferView._data;
|
1364
1364
|
};
|
1365
1365
|
GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) {
|
@@ -1374,8 +1374,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1374
1374
|
accessor._data = Promise.resolve(new constructor(length));
|
1375
1375
|
}
|
1376
1376
|
else {
|
1377
|
-
var bufferView_1 = ArrayItem.Get(context
|
1378
|
-
accessor._data = this.loadBufferViewAsync("/bufferViews/"
|
1377
|
+
var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
|
1378
|
+
accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) {
|
1379
1379
|
if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) {
|
1380
1380
|
return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length);
|
1381
1381
|
}
|
@@ -1392,21 +1392,21 @@ var GLTFLoader = /** @class */ (function () {
|
|
1392
1392
|
var sparse_1 = accessor.sparse;
|
1393
1393
|
accessor._data = accessor._data.then(function (data) {
|
1394
1394
|
var typedArray = data;
|
1395
|
-
var indicesBufferView = ArrayItem.Get(context
|
1396
|
-
var valuesBufferView = ArrayItem.Get(context
|
1395
|
+
var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView);
|
1396
|
+
var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView);
|
1397
1397
|
return Promise.all([
|
1398
|
-
_this.loadBufferViewAsync("/bufferViews/"
|
1399
|
-
_this.loadBufferViewAsync("/bufferViews/"
|
1398
|
+
_this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView),
|
1399
|
+
_this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView)
|
1400
1400
|
]).then(function (_a) {
|
1401
1401
|
var indicesData = _a[0], valuesData = _a[1];
|
1402
|
-
var indices = GLTFLoader._GetTypedArray(context
|
1402
|
+
var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
|
1403
1403
|
var sparseLength = numComponents * sparse_1.count;
|
1404
1404
|
var values;
|
1405
1405
|
if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized) {
|
1406
|
-
values = GLTFLoader._GetTypedArray(context
|
1406
|
+
values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
|
1407
1407
|
}
|
1408
1408
|
else {
|
1409
|
-
var sparseData = GLTFLoader._GetTypedArray(context
|
1409
|
+
var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
|
1410
1410
|
values = new constructor(sparseLength);
|
1411
1411
|
VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) {
|
1412
1412
|
values[index] = value;
|
@@ -1431,23 +1431,23 @@ var GLTFLoader = /** @class */ (function () {
|
|
1431
1431
|
};
|
1432
1432
|
GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) {
|
1433
1433
|
if (accessor.type !== "SCALAR" /* SCALAR */) {
|
1434
|
-
throw new Error(context
|
1434
|
+
throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type));
|
1435
1435
|
}
|
1436
1436
|
if (accessor.componentType !== 5121 /* UNSIGNED_BYTE */ &&
|
1437
1437
|
accessor.componentType !== 5123 /* UNSIGNED_SHORT */ &&
|
1438
1438
|
accessor.componentType !== 5125 /* UNSIGNED_INT */) {
|
1439
|
-
throw new Error(context
|
1439
|
+
throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType));
|
1440
1440
|
}
|
1441
1441
|
if (accessor._data) {
|
1442
1442
|
return accessor._data;
|
1443
1443
|
}
|
1444
1444
|
if (accessor.sparse) {
|
1445
|
-
var constructor = GLTFLoader._GetTypedArrayConstructor(context
|
1445
|
+
var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType);
|
1446
1446
|
accessor._data = this._loadAccessorAsync(context, accessor, constructor);
|
1447
1447
|
}
|
1448
1448
|
else {
|
1449
|
-
var bufferView = ArrayItem.Get(context
|
1450
|
-
accessor._data = this.loadBufferViewAsync("/bufferViews/"
|
1449
|
+
var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
|
1450
|
+
accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
|
1451
1451
|
return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count);
|
1452
1452
|
});
|
1453
1453
|
}
|
@@ -1458,7 +1458,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1458
1458
|
if (bufferView._babylonBuffer) {
|
1459
1459
|
return bufferView._babylonBuffer;
|
1460
1460
|
}
|
1461
|
-
bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/"
|
1461
|
+
bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
|
1462
1462
|
return new Buffer(_this._babylonScene.getEngine(), data, false);
|
1463
1463
|
});
|
1464
1464
|
return bufferView._babylonBuffer;
|
@@ -1485,7 +1485,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1485
1485
|
});
|
1486
1486
|
}
|
1487
1487
|
else {
|
1488
|
-
var bufferView_2 = ArrayItem.Get(context
|
1488
|
+
var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
|
1489
1489
|
accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
|
1490
1490
|
var size = GLTFLoader._GetNumComponents(context, accessor.type);
|
1491
1491
|
return new VertexBuffer(_this._babylonScene.getEngine(), babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true);
|
@@ -1495,7 +1495,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1495
1495
|
};
|
1496
1496
|
GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) {
|
1497
1497
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
1498
|
-
throw new Error(context
|
1498
|
+
throw new Error("".concat(context, ": Material type not supported"));
|
1499
1499
|
}
|
1500
1500
|
var promises = new Array();
|
1501
1501
|
if (properties) {
|
@@ -1509,15 +1509,15 @@ var GLTFLoader = /** @class */ (function () {
|
|
1509
1509
|
babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor;
|
1510
1510
|
babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor;
|
1511
1511
|
if (properties.baseColorTexture) {
|
1512
|
-
promises.push(this.loadTextureInfoAsync(context
|
1513
|
-
texture.name = babylonMaterial.name
|
1512
|
+
promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) {
|
1513
|
+
texture.name = "".concat(babylonMaterial.name, " (Base Color)");
|
1514
1514
|
babylonMaterial.albedoTexture = texture;
|
1515
1515
|
}));
|
1516
1516
|
}
|
1517
1517
|
if (properties.metallicRoughnessTexture) {
|
1518
1518
|
properties.metallicRoughnessTexture.nonColorData = true;
|
1519
|
-
promises.push(this.loadTextureInfoAsync(context
|
1520
|
-
texture.name = babylonMaterial.name
|
1519
|
+
promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) {
|
1520
|
+
texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)");
|
1521
1521
|
babylonMaterial.metallicTexture = texture;
|
1522
1522
|
}));
|
1523
1523
|
babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
|
@@ -1537,7 +1537,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1537
1537
|
material._data = material._data || {};
|
1538
1538
|
var babylonData = material._data[babylonDrawMode];
|
1539
1539
|
if (!babylonData) {
|
1540
|
-
this.logOpen(context
|
1540
|
+
this.logOpen("".concat(context, " ").concat(material.name || ""));
|
1541
1541
|
var babylonMaterial = this.createMaterial(context, material, babylonDrawMode);
|
1542
1542
|
babylonData = {
|
1543
1543
|
babylonMaterial: babylonMaterial,
|
@@ -1590,7 +1590,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1590
1590
|
if (extensionPromise) {
|
1591
1591
|
return extensionPromise;
|
1592
1592
|
}
|
1593
|
-
var name = material.name || "material"
|
1593
|
+
var name = material.name || "material".concat(material.index);
|
1594
1594
|
var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode);
|
1595
1595
|
return babylonMaterial;
|
1596
1596
|
};
|
@@ -1609,7 +1609,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1609
1609
|
var promises = new Array();
|
1610
1610
|
promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
|
1611
1611
|
if (material.pbrMetallicRoughness) {
|
1612
|
-
promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync(context
|
1612
|
+
promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial));
|
1613
1613
|
}
|
1614
1614
|
this.loadMaterialAlphaProperties(context, material, babylonMaterial);
|
1615
1615
|
return Promise.all(promises).then(function () { });
|
@@ -1623,7 +1623,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1623
1623
|
*/
|
1624
1624
|
GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) {
|
1625
1625
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
1626
|
-
throw new Error(context
|
1626
|
+
throw new Error("".concat(context, ": Material type not supported"));
|
1627
1627
|
}
|
1628
1628
|
var promises = new Array();
|
1629
1629
|
babylonMaterial.emissiveColor = material.emissiveFactor ? Color3.FromArray(material.emissiveFactor) : new Color3(0, 0, 0);
|
@@ -1633,8 +1633,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1633
1633
|
}
|
1634
1634
|
if (material.normalTexture) {
|
1635
1635
|
material.normalTexture.nonColorData = true;
|
1636
|
-
promises.push(this.loadTextureInfoAsync(context
|
1637
|
-
texture.name = babylonMaterial.name
|
1636
|
+
promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) {
|
1637
|
+
texture.name = "".concat(babylonMaterial.name, " (Normal)");
|
1638
1638
|
babylonMaterial.bumpTexture = texture;
|
1639
1639
|
}));
|
1640
1640
|
babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem;
|
@@ -1646,8 +1646,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1646
1646
|
}
|
1647
1647
|
if (material.occlusionTexture) {
|
1648
1648
|
material.occlusionTexture.nonColorData = true;
|
1649
|
-
promises.push(this.loadTextureInfoAsync(context
|
1650
|
-
texture.name = babylonMaterial.name
|
1649
|
+
promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) {
|
1650
|
+
texture.name = "".concat(babylonMaterial.name, " (Occlusion)");
|
1651
1651
|
babylonMaterial.ambientTexture = texture;
|
1652
1652
|
}));
|
1653
1653
|
babylonMaterial.useAmbientInGrayScale = true;
|
@@ -1656,8 +1656,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1656
1656
|
}
|
1657
1657
|
}
|
1658
1658
|
if (material.emissiveTexture) {
|
1659
|
-
promises.push(this.loadTextureInfoAsync(context
|
1660
|
-
texture.name = babylonMaterial.name
|
1659
|
+
promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) {
|
1660
|
+
texture.name = "".concat(babylonMaterial.name, " (Emissive)");
|
1661
1661
|
babylonMaterial.emissiveTexture = texture;
|
1662
1662
|
}));
|
1663
1663
|
}
|
@@ -1672,7 +1672,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1672
1672
|
*/
|
1673
1673
|
GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) {
|
1674
1674
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
1675
|
-
throw new Error(context
|
1675
|
+
throw new Error("".concat(context, ": Material type not supported"));
|
1676
1676
|
}
|
1677
1677
|
var alphaMode = material.alphaMode || "OPAQUE" /* OPAQUE */;
|
1678
1678
|
switch (alphaMode) {
|
@@ -1697,7 +1697,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1697
1697
|
break;
|
1698
1698
|
}
|
1699
1699
|
default: {
|
1700
|
-
throw new Error(context
|
1700
|
+
throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")"));
|
1701
1701
|
}
|
1702
1702
|
}
|
1703
1703
|
};
|
@@ -1715,13 +1715,13 @@ var GLTFLoader = /** @class */ (function () {
|
|
1715
1715
|
if (extensionPromise) {
|
1716
1716
|
return extensionPromise;
|
1717
1717
|
}
|
1718
|
-
this.logOpen(""
|
1718
|
+
this.logOpen("".concat(context));
|
1719
1719
|
if (textureInfo.texCoord >= 6) {
|
1720
|
-
throw new Error(context
|
1720
|
+
throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")"));
|
1721
1721
|
}
|
1722
|
-
var texture = ArrayItem.Get(context
|
1722
|
+
var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index);
|
1723
1723
|
texture._textureInfo = textureInfo;
|
1724
|
-
var promise = this._loadTextureAsync("/textures/"
|
1724
|
+
var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) {
|
1725
1725
|
babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
|
1726
1726
|
GLTFLoader.AddPointerMetadata(babylonTexture, context);
|
1727
1727
|
_this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
|
@@ -1737,9 +1737,9 @@ var GLTFLoader = /** @class */ (function () {
|
|
1737
1737
|
if (extensionPromise) {
|
1738
1738
|
return extensionPromise;
|
1739
1739
|
}
|
1740
|
-
this.logOpen(context
|
1741
|
-
var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(context
|
1742
|
-
var image = ArrayItem.Get(context
|
1740
|
+
this.logOpen("".concat(context, " ").concat(texture.name || ""));
|
1741
|
+
var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler));
|
1742
|
+
var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source);
|
1743
1743
|
var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData);
|
1744
1744
|
this.logClose();
|
1745
1745
|
return promise;
|
@@ -1748,7 +1748,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1748
1748
|
GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) {
|
1749
1749
|
var _this = this;
|
1750
1750
|
if (assign === void 0) { assign = function () { }; }
|
1751
|
-
var samplerData = this._loadSampler("/samplers/"
|
1751
|
+
var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler);
|
1752
1752
|
var promises = new Array();
|
1753
1753
|
var deferred = new Deferred();
|
1754
1754
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
@@ -1763,7 +1763,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1763
1763
|
},
|
1764
1764
|
onError: function (message, exception) {
|
1765
1765
|
if (!_this._disposed) {
|
1766
|
-
deferred.reject(new Error(context
|
1766
|
+
deferred.reject(new Error("".concat(context, ": ").concat((exception && exception.message) ? exception.message : message || "Failed to load texture")));
|
1767
1767
|
}
|
1768
1768
|
},
|
1769
1769
|
mimeType: image.mimeType,
|
@@ -1774,9 +1774,9 @@ var GLTFLoader = /** @class */ (function () {
|
|
1774
1774
|
babylonTexture._parentContainer = this._assetContainer;
|
1775
1775
|
this._babylonScene._blockEntityCollection = false;
|
1776
1776
|
promises.push(deferred.promise);
|
1777
|
-
promises.push(this.loadImageAsync("/images/"
|
1778
|
-
var name = image.uri || _this._fileName
|
1779
|
-
var dataUrl = "data:"
|
1777
|
+
promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) {
|
1778
|
+
var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index);
|
1779
|
+
var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name);
|
1780
1780
|
babylonTexture.updateURL(dataUrl, data);
|
1781
1781
|
}));
|
1782
1782
|
babylonTexture.wrapU = samplerData.wrapU;
|
@@ -1791,8 +1791,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1791
1791
|
sampler._data = {
|
1792
1792
|
noMipMaps: (sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */),
|
1793
1793
|
samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler),
|
1794
|
-
wrapU: GLTFLoader._GetTextureWrapMode(context
|
1795
|
-
wrapV: GLTFLoader._GetTextureWrapMode(context
|
1794
|
+
wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS),
|
1795
|
+
wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT)
|
1796
1796
|
};
|
1797
1797
|
}
|
1798
1798
|
return sampler._data;
|
@@ -1805,13 +1805,13 @@ var GLTFLoader = /** @class */ (function () {
|
|
1805
1805
|
*/
|
1806
1806
|
GLTFLoader.prototype.loadImageAsync = function (context, image) {
|
1807
1807
|
if (!image._data) {
|
1808
|
-
this.logOpen(context
|
1808
|
+
this.logOpen("".concat(context, " ").concat(image.name || ""));
|
1809
1809
|
if (image.uri) {
|
1810
|
-
image._data = this.loadUriAsync(context
|
1810
|
+
image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri);
|
1811
1811
|
}
|
1812
1812
|
else {
|
1813
|
-
var bufferView = ArrayItem.Get(context
|
1814
|
-
image._data = this.loadBufferViewAsync("/bufferViews/"
|
1813
|
+
var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView);
|
1814
|
+
image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView);
|
1815
1815
|
}
|
1816
1816
|
this.logClose();
|
1817
1817
|
}
|
@@ -1831,23 +1831,23 @@ var GLTFLoader = /** @class */ (function () {
|
|
1831
1831
|
return extensionPromise;
|
1832
1832
|
}
|
1833
1833
|
if (!GLTFLoader._ValidateUri(uri)) {
|
1834
|
-
throw new Error(context
|
1834
|
+
throw new Error("".concat(context, ": '").concat(uri, "' is invalid"));
|
1835
1835
|
}
|
1836
1836
|
if (IsBase64DataUrl(uri)) {
|
1837
1837
|
var data = new Uint8Array(DecodeBase64UrlToBinary(uri));
|
1838
|
-
this.log(context
|
1838
|
+
this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)"));
|
1839
1839
|
return Promise.resolve(data);
|
1840
1840
|
}
|
1841
|
-
this.log(context
|
1841
|
+
this.log("".concat(context, ": Loading ").concat(uri));
|
1842
1842
|
return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) {
|
1843
1843
|
return new Promise(function (resolve, reject) {
|
1844
1844
|
_this._parent._loadFile(_this._babylonScene, url, function (data) {
|
1845
1845
|
if (!_this._disposed) {
|
1846
|
-
_this.log(context
|
1846
|
+
_this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)"));
|
1847
1847
|
resolve(new Uint8Array(data));
|
1848
1848
|
}
|
1849
1849
|
}, true, function (request) {
|
1850
|
-
reject(new LoadFileError(context
|
1850
|
+
reject(new LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request));
|
1851
1851
|
});
|
1852
1852
|
});
|
1853
1853
|
});
|
@@ -1871,7 +1871,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1871
1871
|
case 33648 /* MIRRORED_REPEAT */: return Texture.MIRROR_ADDRESSMODE;
|
1872
1872
|
case 10497 /* REPEAT */: return Texture.WRAP_ADDRESSMODE;
|
1873
1873
|
default:
|
1874
|
-
Logger.Warn(context
|
1874
|
+
Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")"));
|
1875
1875
|
return Texture.WRAP_ADDRESSMODE;
|
1876
1876
|
}
|
1877
1877
|
};
|
@@ -1888,13 +1888,13 @@ var GLTFLoader = /** @class */ (function () {
|
|
1888
1888
|
case 9986 /* NEAREST_MIPMAP_LINEAR */: return Texture.LINEAR_NEAREST_MIPLINEAR;
|
1889
1889
|
case 9987 /* LINEAR_MIPMAP_LINEAR */: return Texture.LINEAR_LINEAR_MIPLINEAR;
|
1890
1890
|
default:
|
1891
|
-
Logger.Warn(context
|
1891
|
+
Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
|
1892
1892
|
return Texture.LINEAR_LINEAR_MIPLINEAR;
|
1893
1893
|
}
|
1894
1894
|
}
|
1895
1895
|
else {
|
1896
1896
|
if (magFilter !== 9728 /* NEAREST */) {
|
1897
|
-
Logger.Warn(context
|
1897
|
+
Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")"));
|
1898
1898
|
}
|
1899
1899
|
switch (minFilter) {
|
1900
1900
|
case 9728 /* NEAREST */: return Texture.NEAREST_NEAREST;
|
@@ -1904,7 +1904,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1904
1904
|
case 9986 /* NEAREST_MIPMAP_LINEAR */: return Texture.NEAREST_NEAREST_MIPLINEAR;
|
1905
1905
|
case 9987 /* LINEAR_MIPMAP_LINEAR */: return Texture.NEAREST_LINEAR_MIPLINEAR;
|
1906
1906
|
default:
|
1907
|
-
Logger.Warn(context
|
1907
|
+
Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
|
1908
1908
|
return Texture.NEAREST_NEAREST_MIPNEAREST;
|
1909
1909
|
}
|
1910
1910
|
}
|
@@ -1917,17 +1917,17 @@ var GLTFLoader = /** @class */ (function () {
|
|
1917
1917
|
case 5123 /* UNSIGNED_SHORT */: return Uint16Array;
|
1918
1918
|
case 5125 /* UNSIGNED_INT */: return Uint32Array;
|
1919
1919
|
case 5126 /* FLOAT */: return Float32Array;
|
1920
|
-
default: throw new Error(context
|
1920
|
+
default: throw new Error("".concat(context, ": Invalid component type ").concat(componentType));
|
1921
1921
|
}
|
1922
1922
|
};
|
1923
1923
|
GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) {
|
1924
1924
|
var buffer = bufferView.buffer;
|
1925
1925
|
byteOffset = bufferView.byteOffset + (byteOffset || 0);
|
1926
|
-
var constructor = GLTFLoader._GetTypedArrayConstructor(context
|
1926
|
+
var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType);
|
1927
1927
|
var componentTypeLength = VertexBuffer.GetTypeByteLength(componentType);
|
1928
1928
|
if (byteOffset % componentTypeLength !== 0) {
|
1929
1929
|
// HACK: Copy the buffer if byte offset is not a multiple of component type byte length.
|
1930
|
-
Logger.Warn(context
|
1930
|
+
Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")"));
|
1931
1931
|
return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0);
|
1932
1932
|
}
|
1933
1933
|
return new constructor(buffer, byteOffset, length);
|
@@ -1942,7 +1942,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1942
1942
|
case "MAT3": return 9;
|
1943
1943
|
case "MAT4": return 16;
|
1944
1944
|
}
|
1945
|
-
throw new Error(context
|
1945
|
+
throw new Error("".concat(context, ": Invalid type (").concat(type, ")"));
|
1946
1946
|
};
|
1947
1947
|
GLTFLoader._ValidateUri = function (uri) {
|
1948
1948
|
return (Tools.IsBase64(uri) || uri.indexOf("..") === -1);
|
@@ -1961,7 +1961,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1961
1961
|
case 5 /* TRIANGLE_STRIP */: return Material.TriangleStripDrawMode;
|
1962
1962
|
case 6 /* TRIANGLE_FAN */: return Material.TriangleFanDrawMode;
|
1963
1963
|
}
|
1964
|
-
throw new Error(context
|
1964
|
+
throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")"));
|
1965
1965
|
};
|
1966
1966
|
GLTFLoader.prototype._compileMaterialsAsync = function () {
|
1967
1967
|
var _this = this;
|
@@ -2021,7 +2021,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
2021
2021
|
for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) {
|
2022
2022
|
var extension = _a[_i];
|
2023
2023
|
if (extension.enabled) {
|
2024
|
-
var id = extension.name
|
2024
|
+
var id = "".concat(extension.name, ".").concat(functionName);
|
2025
2025
|
var loaderProperty = property;
|
2026
2026
|
loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {};
|
2027
2027
|
var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions;
|
@@ -2109,7 +2109,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
2109
2109
|
if (!extension) {
|
2110
2110
|
return null;
|
2111
2111
|
}
|
2112
|
-
return actionAsync(context
|
2112
|
+
return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension);
|
2113
2113
|
};
|
2114
2114
|
/**
|
2115
2115
|
* Helper method called by a loader extension to load a glTF extra.
|
@@ -2128,7 +2128,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
2128
2128
|
if (!extra) {
|
2129
2129
|
return null;
|
2130
2130
|
}
|
2131
|
-
return actionAsync(context
|
2131
|
+
return actionAsync("".concat(context, "/extras/").concat(extensionName), extra);
|
2132
2132
|
};
|
2133
2133
|
/**
|
2134
2134
|
* Checks for presence of an extension.
|