@babylonjs/loaders 5.0.0-beta.4 → 5.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/OBJ/objFileLoader.js +2 -2
  2. package/OBJ/objFileLoader.js.map +1 -1
  3. package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -8
  4. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  5. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +4 -4
  6. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  7. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +2 -2
  8. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  9. package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
  10. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  11. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +27 -7
  12. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  13. package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -1
  14. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  15. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +7 -7
  16. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +1 -1
  18. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  19. package/glTF/2.0/Extensions/KHR_materials_ior.js +1 -1
  20. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  21. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +5 -5
  22. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  23. package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -5
  24. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  25. package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -5
  26. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_materials_translucency.js +2 -2
  28. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_materials_transmission.js +2 -2
  30. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  31. package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
  32. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  33. package/glTF/2.0/Extensions/KHR_materials_variants.js +6 -6
  34. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  35. package/glTF/2.0/Extensions/KHR_materials_volume.js +2 -2
  36. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  37. package/glTF/2.0/Extensions/KHR_texture_basisu.js +2 -2
  38. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  39. package/glTF/2.0/Extensions/KHR_texture_transform.js +1 -1
  40. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  41. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +13 -13
  42. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  43. package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -1
  44. package/glTF/2.0/Extensions/MSFT_lod.js +17 -54
  45. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  46. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +1 -1
  47. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  48. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +1 -1
  49. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  50. package/glTF/2.0/glTFLoader.d.ts +4 -2
  51. package/glTF/2.0/glTFLoader.js +258 -193
  52. package/glTF/2.0/glTFLoader.js.map +1 -1
  53. package/glTF/2.0/glTFLoaderInterfaces.d.ts +0 -3
  54. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  55. package/glTF/glTFFileLoader.d.ts +4 -0
  56. package/glTF/glTFFileLoader.js +17 -13
  57. package/glTF/glTFFileLoader.js.map +1 -1
  58. package/glTF/glTFValidation.js +1 -1
  59. package/glTF/glTFValidation.js.map +1 -1
  60. package/package.json +3 -3
@@ -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 + ": Failed to find index (" + index + ")");
42
+ throw new Error("".concat(context, ": Failed to find index (").concat(index, ")"));
43
43
  }
44
44
  return array[index];
45
45
  };
@@ -71,10 +71,15 @@ var GLTFLoader = /** @class */ (function () {
71
71
  this._babylonLights = [];
72
72
  /** @hidden */
73
73
  this._disableInstancedMesh = 0;
74
- this._disposed = false;
75
74
  this._extensions = new Array();
75
+ this._disposed = false;
76
+ this._rootUrl = null;
77
+ this._fileName = null;
78
+ this._uniqueRootUrl = null;
79
+ this._bin = null;
76
80
  this._rootBabylonMesh = null;
77
81
  this._defaultBabylonMaterialData = {};
82
+ this._postSceneLoadActions = new Array();
78
83
  this._parent = parent;
79
84
  }
80
85
  /**
@@ -84,7 +89,7 @@ var GLTFLoader = /** @class */ (function () {
84
89
  */
85
90
  GLTFLoader.RegisterExtension = function (name, factory) {
86
91
  if (GLTFLoader.UnregisterExtension(name)) {
87
- Logger.Warn("Extension with the name '" + name + "' already exists");
92
+ Logger.Warn("Extension with the name '".concat(name, "' already exists"));
88
93
  }
89
94
  GLTFLoader._RegisteredExtensions[name] = {
90
95
  factory: factory
@@ -107,6 +112,9 @@ var GLTFLoader = /** @class */ (function () {
107
112
  * The object that represents the glTF JSON.
108
113
  */
109
114
  get: function () {
115
+ if (!this._gltf) {
116
+ throw new Error("glTF JSON is not available");
117
+ }
110
118
  return this._gltf;
111
119
  },
112
120
  enumerable: false,
@@ -137,6 +145,9 @@ var GLTFLoader = /** @class */ (function () {
137
145
  * The Babylon scene when loading the asset.
138
146
  */
139
147
  get: function () {
148
+ if (!this._babylonScene) {
149
+ throw new Error("Scene is not available");
150
+ }
140
151
  return this._babylonScene;
141
152
  },
142
153
  enumerable: false,
@@ -159,14 +170,14 @@ var GLTFLoader = /** @class */ (function () {
159
170
  }
160
171
  this._disposed = true;
161
172
  this._completePromises.length = 0;
162
- for (var name_1 in this._extensions) {
163
- var extension = this._extensions[name_1];
164
- extension.dispose && extension.dispose();
165
- delete this._extensions[name_1];
166
- }
167
- this._gltf = null;
168
- this._babylonScene = null;
173
+ this._extensions.forEach(function (extension) { return extension.dispose && extension.dispose(); });
174
+ this._extensions.length = 0;
175
+ this._gltf = null; // TODO
176
+ this._bin = null;
177
+ this._babylonScene = null; // TODO
169
178
  this._rootBabylonMesh = null;
179
+ this._defaultBabylonMaterialData = {};
180
+ this._postSceneLoadActions.length = 0;
170
181
  this._parent.dispose();
171
182
  };
172
183
  /** @hidden */
@@ -192,7 +203,7 @@ var GLTFLoader = /** @class */ (function () {
192
203
  nodes = names.map(function (name) {
193
204
  var node = nodeMap_1[name];
194
205
  if (node === undefined) {
195
- throw new Error("Failed to find node '" + name + "'");
206
+ throw new Error("Failed to find node '".concat(name, "'"));
196
207
  }
197
208
  return node;
198
209
  });
@@ -224,12 +235,12 @@ var GLTFLoader = /** @class */ (function () {
224
235
  var _this = this;
225
236
  return Promise.resolve().then(function () {
226
237
  _this._rootUrl = rootUrl;
227
- _this._uniqueRootUrl = (!StringTools.StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "" + rootUrl + Date.now() + "/";
238
+ _this._uniqueRootUrl = (!StringTools.StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/");
228
239
  _this._fileName = fileName;
229
240
  _this._loadExtensions();
230
241
  _this._checkExtensions();
231
- var loadingToReadyCounterName = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.READY];
232
- var loadingToCompleteCounterName = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.COMPLETE];
242
+ var loadingToReadyCounterName = "".concat(GLTFLoaderState[GLTFLoaderState.LOADING], " => ").concat(GLTFLoaderState[GLTFLoaderState.READY]);
243
+ var loadingToCompleteCounterName = "".concat(GLTFLoaderState[GLTFLoaderState.LOADING], " => ").concat(GLTFLoaderState[GLTFLoaderState.COMPLETE]);
233
244
  _this._parent._startPerformanceCounter(loadingToReadyCounterName);
234
245
  _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
235
246
  _this._parent._setState(GLTFLoaderState.LOADING);
@@ -243,7 +254,7 @@ var GLTFLoader = /** @class */ (function () {
243
254
  }
244
255
  else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
245
256
  var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
246
- promises.push(_this.loadSceneAsync("/scenes/" + scene.index, scene));
257
+ promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
247
258
  }
248
259
  if (_this.parent.loadAllMaterials && _this._gltf.materials) {
249
260
  for (var m = 0; m < _this._gltf.materials.length; ++m) {
@@ -306,7 +317,7 @@ var GLTFLoader = /** @class */ (function () {
306
317
  if (buffers && buffers[0] && !buffers[0].uri) {
307
318
  var binaryBuffer = buffers[0];
308
319
  if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) {
309
- Logger.Warn("Binary buffer length (" + binaryBuffer.byteLength + ") from JSON does not match chunk length (" + data.bin.byteLength + ")");
320
+ Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")"));
310
321
  }
311
322
  this._bin = data.bin;
312
323
  }
@@ -349,10 +360,10 @@ var GLTFLoader = /** @class */ (function () {
349
360
  }
350
361
  };
351
362
  GLTFLoader.prototype._loadExtensions = function () {
352
- for (var name_2 in GLTFLoader._RegisteredExtensions) {
353
- var extension = GLTFLoader._RegisteredExtensions[name_2].factory(this);
354
- if (extension.name !== name_2) {
355
- Logger.Warn("The name of the glTF loader extension instance does not match the registered name: " + extension.name + " !== " + name_2);
363
+ for (var name_1 in GLTFLoader._RegisteredExtensions) {
364
+ var extension = GLTFLoader._RegisteredExtensions[name_1].factory(this);
365
+ if (extension.name !== name_1) {
366
+ Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_1));
356
367
  }
357
368
  this._extensions.push(extension);
358
369
  this._parent.onExtensionLoadedObservable.notifyObservers(extension);
@@ -362,16 +373,16 @@ var GLTFLoader = /** @class */ (function () {
362
373
  };
363
374
  GLTFLoader.prototype._checkExtensions = function () {
364
375
  if (this._gltf.extensionsRequired) {
365
- var _loop_1 = function (name_3) {
366
- var available = this_1._extensions.some(function (extension) { return extension.name === name_3 && extension.enabled; });
376
+ var _loop_1 = function (name_2) {
377
+ var available = this_1._extensions.some(function (extension) { return extension.name === name_2 && extension.enabled; });
367
378
  if (!available) {
368
- throw new Error("Require extension " + name_3 + " is not available");
379
+ throw new Error("Require extension ".concat(name_2, " is not available"));
369
380
  }
370
381
  };
371
382
  var this_1 = this;
372
383
  for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) {
373
- var name_3 = _a[_i];
374
- _loop_1(name_3);
384
+ var name_2 = _a[_i];
385
+ _loop_1(name_2);
375
386
  }
376
387
  }
377
388
  };
@@ -399,7 +410,7 @@ var GLTFLoader = /** @class */ (function () {
399
410
  break;
400
411
  }
401
412
  default: {
402
- throw new Error("Invalid coordinate system mode (" + this._parent.coordinateSystemMode + ")");
413
+ throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")"));
403
414
  }
404
415
  }
405
416
  this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
@@ -418,28 +429,19 @@ var GLTFLoader = /** @class */ (function () {
418
429
  return extensionPromise;
419
430
  }
420
431
  var promises = new Array();
421
- this.logOpen(context + " " + (scene.name || ""));
432
+ this.logOpen("".concat(context, " ").concat(scene.name || ""));
422
433
  if (scene.nodes) {
423
434
  for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) {
424
435
  var index = _a[_i];
425
- var node = ArrayItem.Get(context + "/nodes/" + index, this._gltf.nodes, index);
426
- promises.push(this.loadNodeAsync("/nodes/" + node.index, node, function (babylonMesh) {
436
+ var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index);
437
+ promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) {
427
438
  babylonMesh.parent = _this._rootBabylonMesh;
428
439
  }));
429
440
  }
430
441
  }
431
- // Link all Babylon bones for each glTF node with the corresponding Babylon transform node.
432
- // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D.
433
- if (this._gltf.nodes) {
434
- for (var _b = 0, _c = this._gltf.nodes; _b < _c.length; _b++) {
435
- var node = _c[_b];
436
- if (node._babylonTransformNode && node._babylonBones) {
437
- for (var _d = 0, _e = node._babylonBones; _d < _e.length; _d++) {
438
- var babylonBone = _e[_d];
439
- babylonBone.linkTransformNode(node._babylonTransformNode);
440
- }
441
- }
442
- }
442
+ for (var _b = 0, _c = this._postSceneLoadActions; _b < _c.length; _b++) {
443
+ var action = _c[_b];
444
+ action();
443
445
  }
444
446
  promises.push(this._loadAnimationsAsync());
445
447
  this.logClose();
@@ -547,7 +549,7 @@ var GLTFLoader = /** @class */ (function () {
547
549
  break;
548
550
  }
549
551
  default: {
550
- Logger.Error("Invalid animation start mode (" + this._parent.animationStartMode + ")");
552
+ Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")"));
551
553
  return;
552
554
  }
553
555
  }
@@ -567,41 +569,69 @@ var GLTFLoader = /** @class */ (function () {
567
569
  return extensionPromise;
568
570
  }
569
571
  if (node._babylonTransformNode) {
570
- throw new Error(context + ": Invalid recursive node hierarchy");
572
+ throw new Error("".concat(context, ": Invalid recursive node hierarchy"));
571
573
  }
572
574
  var promises = new Array();
573
- this.logOpen(context + " " + (node.name || ""));
575
+ this.logOpen("".concat(context, " ").concat(node.name || ""));
574
576
  var loadNode = function (babylonTransformNode) {
575
577
  GLTFLoader.AddPointerMetadata(babylonTransformNode, context);
576
578
  GLTFLoader._LoadTransform(node, babylonTransformNode);
577
579
  if (node.camera != undefined) {
578
- var camera = ArrayItem.Get(context + "/camera", _this._gltf.cameras, node.camera);
579
- promises.push(_this.loadCameraAsync("/cameras/" + camera.index, camera, function (babylonCamera) {
580
+ var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera);
581
+ promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) {
580
582
  babylonCamera.parent = babylonTransformNode;
581
583
  }));
582
584
  }
583
585
  if (node.children) {
584
586
  for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
585
587
  var index = _a[_i];
586
- var childNode = ArrayItem.Get(context + "/children/" + index, _this._gltf.nodes, index);
587
- promises.push(_this.loadNodeAsync("/nodes/" + childNode.index, childNode, function (childBabylonMesh) {
588
+ var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index);
589
+ promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) {
588
590
  childBabylonMesh.parent = babylonTransformNode;
589
591
  }));
590
592
  }
591
593
  }
592
594
  assign(babylonTransformNode);
593
595
  };
594
- if (node.mesh == undefined) {
595
- var nodeName = node.name || "node" + node.index;
596
+ if (node.mesh == undefined || node.skin != undefined) {
597
+ var nodeName = node.name || "node".concat(node.index);
596
598
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
597
599
  node._babylonTransformNode = new TransformNode(nodeName, this._babylonScene);
598
600
  node._babylonTransformNode._parentContainer = this._assetContainer;
599
601
  this._babylonScene._blockEntityCollection = false;
600
602
  loadNode(node._babylonTransformNode);
601
603
  }
602
- else {
603
- var mesh = ArrayItem.Get(context + "/mesh", this._gltf.meshes, node.mesh);
604
- promises.push(this._loadMeshAsync("/meshes/" + mesh.index, node, mesh, loadNode));
604
+ if (node.mesh != undefined) {
605
+ if (node.skin == undefined) {
606
+ var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh);
607
+ promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode));
608
+ }
609
+ else {
610
+ // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
611
+ // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the
612
+ // transform, which effectively ignores the transform of the skinned mesh, as per spec.
613
+ var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh);
614
+ promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) {
615
+ GLTFLoader.AddPointerMetadata(babylonTransformNode, context);
616
+ var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin);
617
+ promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) {
618
+ _this._forEachPrimitive(node, function (babylonMesh) {
619
+ babylonMesh.skeleton = babylonSkeleton;
620
+ });
621
+ // Wait until the scene is loaded to ensure the skeleton root node has been loaded.
622
+ _this._postSceneLoadActions.push(function () {
623
+ if (skin.skeleton != undefined) {
624
+ // Place the skinned mesh node as a sibling of the skeleton root node.
625
+ var skeletonRootNode = ArrayItem.Get("/skins/".concat(skin.index, "/skeleton"), _this._gltf.nodes, skin.skeleton);
626
+ babylonTransformNode.parent = skeletonRootNode.parent._babylonTransformNode;
627
+ }
628
+ else {
629
+ babylonTransformNode.parent = _this._rootBabylonMesh;
630
+ }
631
+ });
632
+ }));
633
+ }));
634
+ }
605
635
  }
606
636
  this.logClose();
607
637
  return Promise.all(promises).then(function () {
@@ -620,17 +650,17 @@ var GLTFLoader = /** @class */ (function () {
620
650
  GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) {
621
651
  var primitives = mesh.primitives;
622
652
  if (!primitives || !primitives.length) {
623
- throw new Error(context + ": Primitives are missing");
653
+ throw new Error("".concat(context, ": Primitives are missing"));
624
654
  }
625
655
  if (primitives[0].index == undefined) {
626
656
  ArrayItem.Assign(primitives);
627
657
  }
628
658
  var promises = new Array();
629
- this.logOpen(context + " " + (mesh.name || ""));
630
- var name = node.name || "node" + node.index;
659
+ this.logOpen("".concat(context, " ").concat(mesh.name || ""));
660
+ var name = node.name || "node".concat(node.index);
631
661
  if (primitives.length === 1) {
632
662
  var primitive = mesh.primitives[0];
633
- promises.push(this._loadMeshPrimitiveAsync(context + "/primitives/" + primitive.index, name, node, mesh, primitive, function (babylonMesh) {
663
+ promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) {
634
664
  node._babylonTransformNode = babylonMesh;
635
665
  node._primitiveBabylonMeshes = [babylonMesh];
636
666
  }));
@@ -643,16 +673,12 @@ var GLTFLoader = /** @class */ (function () {
643
673
  node._primitiveBabylonMeshes = [];
644
674
  for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) {
645
675
  var primitive = primitives_1[_i];
646
- promises.push(this._loadMeshPrimitiveAsync(context + "/primitives/" + primitive.index, name + "_primitive" + primitive.index, node, mesh, primitive, function (babylonMesh) {
676
+ promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) {
647
677
  babylonMesh.parent = node._babylonTransformNode;
648
678
  node._primitiveBabylonMeshes.push(babylonMesh);
649
679
  }));
650
680
  }
651
681
  }
652
- if (node.skin != undefined) {
653
- var skin = ArrayItem.Get(context + "/skin", this._gltf.skins, node.skin);
654
- promises.push(this._loadSkinAsync("/skins/" + skin.index, node, skin));
655
- }
656
682
  assign(node._babylonTransformNode);
657
683
  this.logClose();
658
684
  return Promise.all(promises).then(function () {
@@ -675,7 +701,7 @@ var GLTFLoader = /** @class */ (function () {
675
701
  if (extensionPromise) {
676
702
  return extensionPromise;
677
703
  }
678
- this.logOpen("" + context);
704
+ this.logOpen("".concat(context));
679
705
  var shouldInstance = (this._disableInstancedMesh === 0) && this._parent.createInstances && (node.skin == undefined && !mesh.primitives[0].targets);
680
706
  var babylonAbstractMesh;
681
707
  var promise;
@@ -713,8 +739,8 @@ var GLTFLoader = /** @class */ (function () {
713
739
  babylonMesh_1.material = babylonMaterial;
714
740
  }
715
741
  else {
716
- var material = ArrayItem.Get(context + "/material", this._gltf.materials, primitive.material);
717
- promises.push(this._loadMaterialAsync("/materials/" + material.index, material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
742
+ var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material);
743
+ promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
718
744
  babylonMesh_1.material = babylonMaterial;
719
745
  }));
720
746
  }
@@ -743,7 +769,7 @@ var GLTFLoader = /** @class */ (function () {
743
769
  }
744
770
  var attributes = primitive.attributes;
745
771
  if (!attributes) {
746
- throw new Error(context + ": Attributes are missing");
772
+ throw new Error("".concat(context, ": Attributes are missing"));
747
773
  }
748
774
  var promises = new Array();
749
775
  var babylonGeometry = new Geometry(babylonMesh.name, this._babylonScene);
@@ -751,8 +777,8 @@ var GLTFLoader = /** @class */ (function () {
751
777
  babylonMesh.isUnIndexed = true;
752
778
  }
753
779
  else {
754
- var accessor = ArrayItem.Get(context + "/indices", this._gltf.accessors, primitive.indices);
755
- promises.push(this._loadIndicesAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
780
+ var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices);
781
+ promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) {
756
782
  babylonGeometry.setIndices(data);
757
783
  }));
758
784
  }
@@ -764,8 +790,8 @@ var GLTFLoader = /** @class */ (function () {
764
790
  if (babylonMesh._delayInfo.indexOf(kind) === -1) {
765
791
  babylonMesh._delayInfo.push(kind);
766
792
  }
767
- var accessor = ArrayItem.Get(context + "/attributes/" + attribute, _this._gltf.accessors, attributes[attribute]);
768
- promises.push(_this._loadVertexAccessorAsync("/accessors/" + accessor.index, accessor, kind).then(function (babylonVertexBuffer) {
793
+ var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
794
+ promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) {
769
795
  if (babylonVertexBuffer.getKind() === VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {
770
796
  var mmin = accessor.min, mmax = accessor.max;
771
797
  if (mmin !== undefined && mmax !== undefined) {
@@ -836,15 +862,15 @@ var GLTFLoader = /** @class */ (function () {
836
862
  node._numMorphTargets = primitive.targets.length;
837
863
  }
838
864
  else if (primitive.targets.length !== node._numMorphTargets) {
839
- throw new Error(context + ": Primitives do not have the same number of targets");
865
+ throw new Error("".concat(context, ": Primitives do not have the same number of targets"));
840
866
  }
841
867
  var targetNames = mesh.extras ? mesh.extras.targetNames : null;
842
868
  babylonMesh.morphTargetManager = new MorphTargetManager(babylonMesh.getScene());
843
869
  babylonMesh.morphTargetManager.areUpdatesFrozen = true;
844
870
  for (var index = 0; index < primitive.targets.length; index++) {
845
871
  var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0;
846
- var name_4 = targetNames ? targetNames[index] : "morphTarget" + index;
847
- babylonMesh.morphTargetManager.addTarget(new MorphTarget(name_4, weight, babylonMesh.getScene()));
872
+ var name_3 = targetNames ? targetNames[index] : "morphTarget".concat(index);
873
+ babylonMesh.morphTargetManager.addTarget(new MorphTarget(name_3, weight, babylonMesh.getScene()));
848
874
  // TODO: tell the target whether it has positions, normals, tangents
849
875
  }
850
876
  };
@@ -856,7 +882,7 @@ var GLTFLoader = /** @class */ (function () {
856
882
  var morphTargetManager = babylonMesh.morphTargetManager;
857
883
  for (var index = 0; index < morphTargetManager.numTargets; index++) {
858
884
  var babylonMorphTarget = morphTargetManager.getTarget(index);
859
- promises.push(this._loadMorphTargetVertexDataAsync(context + "/targets/" + index, babylonGeometry, primitive.targets[index], babylonMorphTarget));
885
+ promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget));
860
886
  }
861
887
  return Promise.all(promises).then(function () {
862
888
  morphTargetManager.areUpdatesFrozen = false;
@@ -873,8 +899,8 @@ var GLTFLoader = /** @class */ (function () {
873
899
  if (!babylonVertexBuffer) {
874
900
  return;
875
901
  }
876
- var accessor = ArrayItem.Get(context + "/" + attribute, _this._gltf.accessors, attributes[attribute]);
877
- promises.push(_this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
902
+ var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
903
+ promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) {
878
904
  setData(babylonVertexBuffer, data);
879
905
  }));
880
906
  };
@@ -936,30 +962,22 @@ var GLTFLoader = /** @class */ (function () {
936
962
  babylonNode.rotationQuaternion = rotation;
937
963
  babylonNode.scaling = scaling;
938
964
  };
939
- GLTFLoader.prototype._loadSkinAsync = function (context, node, skin) {
965
+ GLTFLoader.prototype._loadSkinAsync = function (context, node, skin, assign) {
940
966
  var _this = this;
941
967
  var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin);
942
968
  if (extensionPromise) {
943
969
  return extensionPromise;
944
970
  }
945
- var assignSkeleton = function (skeleton) {
946
- _this._forEachPrimitive(node, function (babylonMesh) {
947
- babylonMesh.skeleton = skeleton;
948
- });
949
- };
950
971
  if (skin._data) {
951
- assignSkeleton(skin._data.babylonSkeleton);
972
+ assign(skin._data.babylonSkeleton);
952
973
  return skin._data.promise;
953
974
  }
954
- var skeletonId = "skeleton" + skin.index;
975
+ var skeletonId = "skeleton".concat(skin.index);
955
976
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
956
977
  var babylonSkeleton = new Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
957
978
  babylonSkeleton._parentContainer = this._assetContainer;
958
979
  this._babylonScene._blockEntityCollection = false;
959
- // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
960
- babylonSkeleton.overrideMesh = this._rootBabylonMesh;
961
980
  this._loadBones(context, skin, babylonSkeleton);
962
- assignSkeleton(babylonSkeleton);
963
981
  var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) {
964
982
  _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
965
983
  });
@@ -967,38 +985,85 @@ var GLTFLoader = /** @class */ (function () {
967
985
  babylonSkeleton: babylonSkeleton,
968
986
  promise: promise
969
987
  };
988
+ assign(babylonSkeleton);
970
989
  return promise;
971
990
  };
972
991
  GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) {
992
+ if (skin.skeleton == undefined) {
993
+ var rootNode = this._findSkeletonRootNode("".concat(context, "/joints"), skin.joints);
994
+ if (rootNode) {
995
+ skin.skeleton = rootNode.index;
996
+ }
997
+ else {
998
+ Logger.Warn("".concat(context, ": Failed to find common root"));
999
+ }
1000
+ }
973
1001
  var babylonBones = {};
974
1002
  for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) {
975
1003
  var index = _a[_i];
976
- var node = ArrayItem.Get(context + "/joints/" + index, this._gltf.nodes, index);
1004
+ var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index);
977
1005
  this._loadBone(node, skin, babylonSkeleton, babylonBones);
978
1006
  }
979
1007
  };
1008
+ GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) {
1009
+ var paths = {};
1010
+ for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) {
1011
+ var index = joints_1[_i];
1012
+ var path = new Array();
1013
+ var node = ArrayItem.Get("".concat(context, "/").concat(index), this._gltf.nodes, index);
1014
+ while (node.index !== -1) {
1015
+ path.unshift(node);
1016
+ node = node.parent;
1017
+ }
1018
+ paths[index] = path;
1019
+ }
1020
+ var rootNode = null;
1021
+ for (var i = 0;; ++i) {
1022
+ var path = paths[joints[0]];
1023
+ if (i >= path.length) {
1024
+ return rootNode;
1025
+ }
1026
+ var node = path[i];
1027
+ for (var j = 1; j < joints.length; ++j) {
1028
+ path = paths[joints[j]];
1029
+ if (i >= path.length || node !== path[i]) {
1030
+ return rootNode;
1031
+ }
1032
+ }
1033
+ rootNode = node;
1034
+ }
1035
+ };
980
1036
  GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) {
981
1037
  var babylonBone = babylonBones[node.index];
982
1038
  if (babylonBone) {
983
1039
  return babylonBone;
984
1040
  }
985
- var babylonParentBone = null;
986
- if (node.parent && node.parent._babylonTransformNode !== this._rootBabylonMesh) {
987
- babylonParentBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
1041
+ var parentBabylonBone = null;
1042
+ if (node.index !== skin.skeleton) {
1043
+ if (node.parent && node.parent.index !== -1) {
1044
+ parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
1045
+ }
1046
+ else if (skin.skeleton !== undefined) {
1047
+ Logger.Warn("/skins/".concat(skin.index, "/skeleton: Skeleton node is not a common root"));
1048
+ }
988
1049
  }
989
1050
  var boneIndex = skin.joints.indexOf(node.index);
990
- babylonBone = new Bone(node.name || "joint" + node.index, babylonSkeleton, babylonParentBone, this._getNodeMatrix(node), null, null, boneIndex);
1051
+ babylonBone = new Bone(node.name || "joint".concat(node.index), babylonSkeleton, parentBabylonBone, this._getNodeMatrix(node), null, null, boneIndex);
991
1052
  babylonBones[node.index] = babylonBone;
992
- node._babylonBones = node._babylonBones || [];
993
- node._babylonBones.push(babylonBone);
1053
+ // Wait until the scene is loaded to ensure the transform nodes are loaded.
1054
+ this._postSceneLoadActions.push(function () {
1055
+ // Link the Babylon bone with the corresponding Babylon transform node.
1056
+ // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D.
1057
+ babylonBone.linkTransformNode(node._babylonTransformNode);
1058
+ });
994
1059
  return babylonBone;
995
1060
  };
996
1061
  GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
997
1062
  if (skin.inverseBindMatrices == undefined) {
998
1063
  return Promise.resolve(null);
999
1064
  }
1000
- var accessor = ArrayItem.Get(context + "/inverseBindMatrices", this._gltf.accessors, skin.inverseBindMatrices);
1001
- return this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor);
1065
+ var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices);
1066
+ return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor);
1002
1067
  };
1003
1068
  GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) {
1004
1069
  for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) {
@@ -1036,9 +1101,9 @@ var GLTFLoader = /** @class */ (function () {
1036
1101
  return extensionPromise;
1037
1102
  }
1038
1103
  var promises = new Array();
1039
- this.logOpen(context + " " + (camera.name || ""));
1104
+ this.logOpen("".concat(context, " ").concat(camera.name || ""));
1040
1105
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
1041
- var babylonCamera = new FreeCamera(camera.name || "camera" + camera.index, Vector3.Zero(), this._babylonScene, false);
1106
+ var babylonCamera = new FreeCamera(camera.name || "camera".concat(camera.index), Vector3.Zero(), this._babylonScene, false);
1042
1107
  babylonCamera._parentContainer = this._assetContainer;
1043
1108
  this._babylonScene._blockEntityCollection = false;
1044
1109
  babylonCamera.ignoreParentScaling = true;
@@ -1047,7 +1112,7 @@ var GLTFLoader = /** @class */ (function () {
1047
1112
  case "perspective" /* PERSPECTIVE */: {
1048
1113
  var perspective = camera.perspective;
1049
1114
  if (!perspective) {
1050
- throw new Error(context + ": Camera perspective properties are missing");
1115
+ throw new Error("".concat(context, ": Camera perspective properties are missing"));
1051
1116
  }
1052
1117
  babylonCamera.fov = perspective.yfov;
1053
1118
  babylonCamera.minZ = perspective.znear;
@@ -1056,7 +1121,7 @@ var GLTFLoader = /** @class */ (function () {
1056
1121
  }
1057
1122
  case "orthographic" /* ORTHOGRAPHIC */: {
1058
1123
  if (!camera.orthographic) {
1059
- throw new Error(context + ": Camera orthographic properties are missing");
1124
+ throw new Error("".concat(context, ": Camera orthographic properties are missing"));
1060
1125
  }
1061
1126
  babylonCamera.mode = Camera.ORTHOGRAPHIC_CAMERA;
1062
1127
  babylonCamera.orthoLeft = -camera.orthographic.xmag;
@@ -1068,7 +1133,7 @@ var GLTFLoader = /** @class */ (function () {
1068
1133
  break;
1069
1134
  }
1070
1135
  default: {
1071
- throw new Error(context + ": Invalid camera type (" + camera.type + ")");
1136
+ throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")"));
1072
1137
  }
1073
1138
  }
1074
1139
  GLTFLoader.AddPointerMetadata(babylonCamera, context);
@@ -1087,7 +1152,7 @@ var GLTFLoader = /** @class */ (function () {
1087
1152
  var promises = new Array();
1088
1153
  for (var index = 0; index < animations.length; index++) {
1089
1154
  var animation = animations[index];
1090
- promises.push(this.loadAnimationAsync("/animations/" + animation.index, animation).then(function (animationGroup) {
1155
+ promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) {
1091
1156
  // Delete the animation group if it ended up not having any animations in it.
1092
1157
  if (animationGroup.targetedAnimations.length === 0) {
1093
1158
  animationGroup.dispose();
@@ -1108,7 +1173,7 @@ var GLTFLoader = /** @class */ (function () {
1108
1173
  return promise;
1109
1174
  }
1110
1175
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
1111
- var babylonAnimationGroup = new AnimationGroup(animation.name || "animation" + animation.index, this._babylonScene);
1176
+ var babylonAnimationGroup = new AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene);
1112
1177
  babylonAnimationGroup._parentContainer = this._assetContainer;
1113
1178
  this._babylonScene._blockEntityCollection = false;
1114
1179
  animation._babylonAnimationGroup = babylonAnimationGroup;
@@ -1117,7 +1182,7 @@ var GLTFLoader = /** @class */ (function () {
1117
1182
  ArrayItem.Assign(animation.samplers);
1118
1183
  for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
1119
1184
  var channel = _a[_i];
1120
- promises.push(this._loadAnimationChannelAsync(context + "/channels/" + channel.index, context, animation, channel, babylonAnimationGroup));
1185
+ promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, babylonAnimationGroup));
1121
1186
  }
1122
1187
  return Promise.all(promises).then(function () {
1123
1188
  babylonAnimationGroup.normalize(0);
@@ -1140,14 +1205,14 @@ var GLTFLoader = /** @class */ (function () {
1140
1205
  if (channel.target.node == undefined) {
1141
1206
  return Promise.resolve();
1142
1207
  }
1143
- var targetNode = ArrayItem.Get(context + "/target/node", this._gltf.nodes, channel.target.node);
1208
+ var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node);
1144
1209
  // Ignore animations that have no animation targets.
1145
1210
  if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
1146
1211
  (channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonTransformNode)) {
1147
1212
  return Promise.resolve();
1148
1213
  }
1149
- var sampler = ArrayItem.Get(context + "/sampler", animation.samplers, channel.sampler);
1150
- return this._loadAnimationSamplerAsync(animationContext + "/samplers/" + channel.sampler, sampler).then(function (data) {
1214
+ var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler);
1215
+ return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) {
1151
1216
  var targetPath;
1152
1217
  var animationType;
1153
1218
  switch (channel.target.path) {
@@ -1172,7 +1237,7 @@ var GLTFLoader = /** @class */ (function () {
1172
1237
  break;
1173
1238
  }
1174
1239
  default: {
1175
- throw new Error(context + "/target/path: Invalid value (" + channel.target.path + ")");
1240
+ throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")"));
1176
1241
  }
1177
1242
  }
1178
1243
  var outputBufferOffset = 0;
@@ -1217,7 +1282,7 @@ var GLTFLoader = /** @class */ (function () {
1217
1282
  switch (data.interpolation) {
1218
1283
  case "STEP" /* STEP */: {
1219
1284
  getNextKey = function (frameIndex) { return ({
1220
- frame: data.input[frameIndex],
1285
+ frame: data.input[frameIndex] * _this.parent.targetFps,
1221
1286
  value: getNextOutputValue(),
1222
1287
  interpolation: AnimationKeyInterpolation.STEP
1223
1288
  }); };
@@ -1225,14 +1290,14 @@ var GLTFLoader = /** @class */ (function () {
1225
1290
  }
1226
1291
  case "LINEAR" /* LINEAR */: {
1227
1292
  getNextKey = function (frameIndex) { return ({
1228
- frame: data.input[frameIndex],
1293
+ frame: data.input[frameIndex] * _this.parent.targetFps,
1229
1294
  value: getNextOutputValue()
1230
1295
  }); };
1231
1296
  break;
1232
1297
  }
1233
1298
  case "CUBICSPLINE" /* CUBICSPLINE */: {
1234
1299
  getNextKey = function (frameIndex) { return ({
1235
- frame: data.input[frameIndex],
1300
+ frame: data.input[frameIndex] * _this.parent.targetFps,
1236
1301
  inTangent: getNextOutputValue(),
1237
1302
  value: getNextOutputValue(),
1238
1303
  outTangent: getNextOutputValue()
@@ -1246,8 +1311,8 @@ var GLTFLoader = /** @class */ (function () {
1246
1311
  }
1247
1312
  if (targetPath === "influence") {
1248
1313
  var _loop_2 = function (targetIndex) {
1249
- var animationName = babylonAnimationGroup.name + "_channel" + babylonAnimationGroup.targetedAnimations.length;
1250
- var babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
1314
+ var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
1315
+ var babylonAnimation = new Animation(animationName, targetPath, _this.parent.targetFps, animationType);
1251
1316
  babylonAnimation.setKeys(keys.map(function (key) { return ({
1252
1317
  frame: key.frame,
1253
1318
  inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
@@ -1267,8 +1332,8 @@ var GLTFLoader = /** @class */ (function () {
1267
1332
  }
1268
1333
  }
1269
1334
  else {
1270
- var animationName = babylonAnimationGroup.name + "_channel" + babylonAnimationGroup.targetedAnimations.length;
1271
- var babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
1335
+ var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
1336
+ var babylonAnimation = new Animation(animationName, targetPath, _this.parent.targetFps, animationType);
1272
1337
  babylonAnimation.setKeys(keys);
1273
1338
  if (animationTargetOverride != null && animationTargetOverride.animations != null) {
1274
1339
  animationTargetOverride.animations.push(babylonAnimation);
@@ -1293,14 +1358,14 @@ var GLTFLoader = /** @class */ (function () {
1293
1358
  break;
1294
1359
  }
1295
1360
  default: {
1296
- throw new Error(context + "/interpolation: Invalid value (" + sampler.interpolation + ")");
1361
+ throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")"));
1297
1362
  }
1298
1363
  }
1299
- var inputAccessor = ArrayItem.Get(context + "/input", this._gltf.accessors, sampler.input);
1300
- var outputAccessor = ArrayItem.Get(context + "/output", this._gltf.accessors, sampler.output);
1364
+ var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input);
1365
+ var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
1301
1366
  sampler._data = Promise.all([
1302
- this._loadFloatAccessorAsync("/accessors/" + inputAccessor.index, inputAccessor),
1303
- this._loadFloatAccessorAsync("/accessors/" + outputAccessor.index, outputAccessor)
1367
+ this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
1368
+ this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor)
1304
1369
  ]).then(function (_a) {
1305
1370
  var inputData = _a[0], outputData = _a[1];
1306
1371
  return {
@@ -1326,11 +1391,11 @@ var GLTFLoader = /** @class */ (function () {
1326
1391
  }
1327
1392
  if (!buffer._data) {
1328
1393
  if (buffer.uri) {
1329
- buffer._data = this.loadUriAsync(context + "/uri", buffer, buffer.uri);
1394
+ buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri);
1330
1395
  }
1331
1396
  else {
1332
1397
  if (!this._bin) {
1333
- throw new Error(context + ": Uri is missing or the binary glTF is missing its binary chunk");
1398
+ throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
1334
1399
  }
1335
1400
  buffer._data = this._bin.readAsync(0, buffer.byteLength);
1336
1401
  }
@@ -1340,7 +1405,7 @@ var GLTFLoader = /** @class */ (function () {
1340
1405
  return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
1341
1406
  }
1342
1407
  catch (e) {
1343
- throw new Error(context + ": " + e.message);
1408
+ throw new Error("".concat(context, ": ").concat(e.message));
1344
1409
  }
1345
1410
  });
1346
1411
  };
@@ -1358,8 +1423,8 @@ var GLTFLoader = /** @class */ (function () {
1358
1423
  if (bufferView._data) {
1359
1424
  return bufferView._data;
1360
1425
  }
1361
- var buffer = ArrayItem.Get(context + "/buffer", this._gltf.buffers, bufferView.buffer);
1362
- bufferView._data = this.loadBufferAsync("/buffers/" + buffer.index, buffer, (bufferView.byteOffset || 0), bufferView.byteLength);
1426
+ var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer);
1427
+ bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, (bufferView.byteOffset || 0), bufferView.byteLength);
1363
1428
  return bufferView._data;
1364
1429
  };
1365
1430
  GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) {
@@ -1374,8 +1439,8 @@ var GLTFLoader = /** @class */ (function () {
1374
1439
  accessor._data = Promise.resolve(new constructor(length));
1375
1440
  }
1376
1441
  else {
1377
- var bufferView_1 = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
1378
- accessor._data = this.loadBufferViewAsync("/bufferViews/" + bufferView_1.index, bufferView_1).then(function (data) {
1442
+ var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
1443
+ accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) {
1379
1444
  if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) {
1380
1445
  return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length);
1381
1446
  }
@@ -1392,21 +1457,21 @@ var GLTFLoader = /** @class */ (function () {
1392
1457
  var sparse_1 = accessor.sparse;
1393
1458
  accessor._data = accessor._data.then(function (data) {
1394
1459
  var typedArray = data;
1395
- var indicesBufferView = ArrayItem.Get(context + "/sparse/indices/bufferView", _this._gltf.bufferViews, sparse_1.indices.bufferView);
1396
- var valuesBufferView = ArrayItem.Get(context + "/sparse/values/bufferView", _this._gltf.bufferViews, sparse_1.values.bufferView);
1460
+ var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView);
1461
+ var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView);
1397
1462
  return Promise.all([
1398
- _this.loadBufferViewAsync("/bufferViews/" + indicesBufferView.index, indicesBufferView),
1399
- _this.loadBufferViewAsync("/bufferViews/" + valuesBufferView.index, valuesBufferView)
1463
+ _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView),
1464
+ _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView)
1400
1465
  ]).then(function (_a) {
1401
1466
  var indicesData = _a[0], valuesData = _a[1];
1402
- var indices = GLTFLoader._GetTypedArray(context + "/sparse/indices", sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
1467
+ var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
1403
1468
  var sparseLength = numComponents * sparse_1.count;
1404
1469
  var values;
1405
1470
  if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized) {
1406
- values = GLTFLoader._GetTypedArray(context + "/sparse/values", accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
1471
+ values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
1407
1472
  }
1408
1473
  else {
1409
- var sparseData = GLTFLoader._GetTypedArray(context + "/sparse/values", accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
1474
+ var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
1410
1475
  values = new constructor(sparseLength);
1411
1476
  VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) {
1412
1477
  values[index] = value;
@@ -1431,23 +1496,23 @@ var GLTFLoader = /** @class */ (function () {
1431
1496
  };
1432
1497
  GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) {
1433
1498
  if (accessor.type !== "SCALAR" /* SCALAR */) {
1434
- throw new Error(context + "/type: Invalid value " + accessor.type);
1499
+ throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type));
1435
1500
  }
1436
1501
  if (accessor.componentType !== 5121 /* UNSIGNED_BYTE */ &&
1437
1502
  accessor.componentType !== 5123 /* UNSIGNED_SHORT */ &&
1438
1503
  accessor.componentType !== 5125 /* UNSIGNED_INT */) {
1439
- throw new Error(context + "/componentType: Invalid value " + accessor.componentType);
1504
+ throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType));
1440
1505
  }
1441
1506
  if (accessor._data) {
1442
1507
  return accessor._data;
1443
1508
  }
1444
1509
  if (accessor.sparse) {
1445
- var constructor = GLTFLoader._GetTypedArrayConstructor(context + "/componentType", accessor.componentType);
1510
+ var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType);
1446
1511
  accessor._data = this._loadAccessorAsync(context, accessor, constructor);
1447
1512
  }
1448
1513
  else {
1449
- var bufferView = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
1450
- accessor._data = this.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView).then(function (data) {
1514
+ var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
1515
+ accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
1451
1516
  return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count);
1452
1517
  });
1453
1518
  }
@@ -1458,7 +1523,7 @@ var GLTFLoader = /** @class */ (function () {
1458
1523
  if (bufferView._babylonBuffer) {
1459
1524
  return bufferView._babylonBuffer;
1460
1525
  }
1461
- bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView).then(function (data) {
1526
+ bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
1462
1527
  return new Buffer(_this._babylonScene.getEngine(), data, false);
1463
1528
  });
1464
1529
  return bufferView._babylonBuffer;
@@ -1485,7 +1550,7 @@ var GLTFLoader = /** @class */ (function () {
1485
1550
  });
1486
1551
  }
1487
1552
  else {
1488
- var bufferView_2 = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
1553
+ var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
1489
1554
  accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
1490
1555
  var size = GLTFLoader._GetNumComponents(context, accessor.type);
1491
1556
  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 +1560,7 @@ var GLTFLoader = /** @class */ (function () {
1495
1560
  };
1496
1561
  GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) {
1497
1562
  if (!(babylonMaterial instanceof PBRMaterial)) {
1498
- throw new Error(context + ": Material type not supported");
1563
+ throw new Error("".concat(context, ": Material type not supported"));
1499
1564
  }
1500
1565
  var promises = new Array();
1501
1566
  if (properties) {
@@ -1509,15 +1574,15 @@ var GLTFLoader = /** @class */ (function () {
1509
1574
  babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor;
1510
1575
  babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor;
1511
1576
  if (properties.baseColorTexture) {
1512
- promises.push(this.loadTextureInfoAsync(context + "/baseColorTexture", properties.baseColorTexture, function (texture) {
1513
- texture.name = babylonMaterial.name + " (Base Color)";
1577
+ promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) {
1578
+ texture.name = "".concat(babylonMaterial.name, " (Base Color)");
1514
1579
  babylonMaterial.albedoTexture = texture;
1515
1580
  }));
1516
1581
  }
1517
1582
  if (properties.metallicRoughnessTexture) {
1518
1583
  properties.metallicRoughnessTexture.nonColorData = true;
1519
- promises.push(this.loadTextureInfoAsync(context + "/metallicRoughnessTexture", properties.metallicRoughnessTexture, function (texture) {
1520
- texture.name = babylonMaterial.name + " (Metallic Roughness)";
1584
+ promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) {
1585
+ texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)");
1521
1586
  babylonMaterial.metallicTexture = texture;
1522
1587
  }));
1523
1588
  babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
@@ -1537,7 +1602,7 @@ var GLTFLoader = /** @class */ (function () {
1537
1602
  material._data = material._data || {};
1538
1603
  var babylonData = material._data[babylonDrawMode];
1539
1604
  if (!babylonData) {
1540
- this.logOpen(context + " " + (material.name || ""));
1605
+ this.logOpen("".concat(context, " ").concat(material.name || ""));
1541
1606
  var babylonMaterial = this.createMaterial(context, material, babylonDrawMode);
1542
1607
  babylonData = {
1543
1608
  babylonMaterial: babylonMaterial,
@@ -1590,7 +1655,7 @@ var GLTFLoader = /** @class */ (function () {
1590
1655
  if (extensionPromise) {
1591
1656
  return extensionPromise;
1592
1657
  }
1593
- var name = material.name || "material" + material.index;
1658
+ var name = material.name || "material".concat(material.index);
1594
1659
  var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode);
1595
1660
  return babylonMaterial;
1596
1661
  };
@@ -1609,7 +1674,7 @@ var GLTFLoader = /** @class */ (function () {
1609
1674
  var promises = new Array();
1610
1675
  promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
1611
1676
  if (material.pbrMetallicRoughness) {
1612
- promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync(context + "/pbrMetallicRoughness", material.pbrMetallicRoughness, babylonMaterial));
1677
+ promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial));
1613
1678
  }
1614
1679
  this.loadMaterialAlphaProperties(context, material, babylonMaterial);
1615
1680
  return Promise.all(promises).then(function () { });
@@ -1623,7 +1688,7 @@ var GLTFLoader = /** @class */ (function () {
1623
1688
  */
1624
1689
  GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) {
1625
1690
  if (!(babylonMaterial instanceof PBRMaterial)) {
1626
- throw new Error(context + ": Material type not supported");
1691
+ throw new Error("".concat(context, ": Material type not supported"));
1627
1692
  }
1628
1693
  var promises = new Array();
1629
1694
  babylonMaterial.emissiveColor = material.emissiveFactor ? Color3.FromArray(material.emissiveFactor) : new Color3(0, 0, 0);
@@ -1633,8 +1698,8 @@ var GLTFLoader = /** @class */ (function () {
1633
1698
  }
1634
1699
  if (material.normalTexture) {
1635
1700
  material.normalTexture.nonColorData = true;
1636
- promises.push(this.loadTextureInfoAsync(context + "/normalTexture", material.normalTexture, function (texture) {
1637
- texture.name = babylonMaterial.name + " (Normal)";
1701
+ promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) {
1702
+ texture.name = "".concat(babylonMaterial.name, " (Normal)");
1638
1703
  babylonMaterial.bumpTexture = texture;
1639
1704
  }));
1640
1705
  babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem;
@@ -1646,8 +1711,8 @@ var GLTFLoader = /** @class */ (function () {
1646
1711
  }
1647
1712
  if (material.occlusionTexture) {
1648
1713
  material.occlusionTexture.nonColorData = true;
1649
- promises.push(this.loadTextureInfoAsync(context + "/occlusionTexture", material.occlusionTexture, function (texture) {
1650
- texture.name = babylonMaterial.name + " (Occlusion)";
1714
+ promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) {
1715
+ texture.name = "".concat(babylonMaterial.name, " (Occlusion)");
1651
1716
  babylonMaterial.ambientTexture = texture;
1652
1717
  }));
1653
1718
  babylonMaterial.useAmbientInGrayScale = true;
@@ -1656,8 +1721,8 @@ var GLTFLoader = /** @class */ (function () {
1656
1721
  }
1657
1722
  }
1658
1723
  if (material.emissiveTexture) {
1659
- promises.push(this.loadTextureInfoAsync(context + "/emissiveTexture", material.emissiveTexture, function (texture) {
1660
- texture.name = babylonMaterial.name + " (Emissive)";
1724
+ promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) {
1725
+ texture.name = "".concat(babylonMaterial.name, " (Emissive)");
1661
1726
  babylonMaterial.emissiveTexture = texture;
1662
1727
  }));
1663
1728
  }
@@ -1672,7 +1737,7 @@ var GLTFLoader = /** @class */ (function () {
1672
1737
  */
1673
1738
  GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) {
1674
1739
  if (!(babylonMaterial instanceof PBRMaterial)) {
1675
- throw new Error(context + ": Material type not supported");
1740
+ throw new Error("".concat(context, ": Material type not supported"));
1676
1741
  }
1677
1742
  var alphaMode = material.alphaMode || "OPAQUE" /* OPAQUE */;
1678
1743
  switch (alphaMode) {
@@ -1697,7 +1762,7 @@ var GLTFLoader = /** @class */ (function () {
1697
1762
  break;
1698
1763
  }
1699
1764
  default: {
1700
- throw new Error(context + "/alphaMode: Invalid value (" + material.alphaMode + ")");
1765
+ throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")"));
1701
1766
  }
1702
1767
  }
1703
1768
  };
@@ -1715,13 +1780,13 @@ var GLTFLoader = /** @class */ (function () {
1715
1780
  if (extensionPromise) {
1716
1781
  return extensionPromise;
1717
1782
  }
1718
- this.logOpen("" + context);
1783
+ this.logOpen("".concat(context));
1719
1784
  if (textureInfo.texCoord >= 6) {
1720
- throw new Error(context + "/texCoord: Invalid value (" + textureInfo.texCoord + ")");
1785
+ throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")"));
1721
1786
  }
1722
- var texture = ArrayItem.Get(context + "/index", this._gltf.textures, textureInfo.index);
1787
+ var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index);
1723
1788
  texture._textureInfo = textureInfo;
1724
- var promise = this._loadTextureAsync("/textures/" + textureInfo.index, texture, function (babylonTexture) {
1789
+ var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) {
1725
1790
  babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
1726
1791
  GLTFLoader.AddPointerMetadata(babylonTexture, context);
1727
1792
  _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
@@ -1737,9 +1802,9 @@ var GLTFLoader = /** @class */ (function () {
1737
1802
  if (extensionPromise) {
1738
1803
  return extensionPromise;
1739
1804
  }
1740
- this.logOpen(context + " " + (texture.name || ""));
1741
- var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(context + "/sampler", this._gltf.samplers, texture.sampler));
1742
- var image = ArrayItem.Get(context + "/source", this._gltf.images, texture.source);
1805
+ this.logOpen("".concat(context, " ").concat(texture.name || ""));
1806
+ var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler));
1807
+ var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source);
1743
1808
  var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData);
1744
1809
  this.logClose();
1745
1810
  return promise;
@@ -1748,7 +1813,7 @@ var GLTFLoader = /** @class */ (function () {
1748
1813
  GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) {
1749
1814
  var _this = this;
1750
1815
  if (assign === void 0) { assign = function () { }; }
1751
- var samplerData = this._loadSampler("/samplers/" + sampler.index, sampler);
1816
+ var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler);
1752
1817
  var promises = new Array();
1753
1818
  var deferred = new Deferred();
1754
1819
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
@@ -1763,7 +1828,7 @@ var GLTFLoader = /** @class */ (function () {
1763
1828
  },
1764
1829
  onError: function (message, exception) {
1765
1830
  if (!_this._disposed) {
1766
- deferred.reject(new Error(context + ": " + ((exception && exception.message) ? exception.message : message || "Failed to load texture")));
1831
+ deferred.reject(new Error("".concat(context, ": ").concat((exception && exception.message) ? exception.message : message || "Failed to load texture")));
1767
1832
  }
1768
1833
  },
1769
1834
  mimeType: image.mimeType,
@@ -1774,9 +1839,9 @@ var GLTFLoader = /** @class */ (function () {
1774
1839
  babylonTexture._parentContainer = this._assetContainer;
1775
1840
  this._babylonScene._blockEntityCollection = false;
1776
1841
  promises.push(deferred.promise);
1777
- promises.push(this.loadImageAsync("/images/" + image.index, image).then(function (data) {
1778
- var name = image.uri || _this._fileName + "#image" + image.index;
1779
- var dataUrl = "data:" + _this._uniqueRootUrl + name;
1842
+ promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) {
1843
+ var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index);
1844
+ var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name);
1780
1845
  babylonTexture.updateURL(dataUrl, data);
1781
1846
  }));
1782
1847
  babylonTexture.wrapU = samplerData.wrapU;
@@ -1791,8 +1856,8 @@ var GLTFLoader = /** @class */ (function () {
1791
1856
  sampler._data = {
1792
1857
  noMipMaps: (sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */),
1793
1858
  samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler),
1794
- wrapU: GLTFLoader._GetTextureWrapMode(context + "/wrapS", sampler.wrapS),
1795
- wrapV: GLTFLoader._GetTextureWrapMode(context + "/wrapT", sampler.wrapT)
1859
+ wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS),
1860
+ wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT)
1796
1861
  };
1797
1862
  }
1798
1863
  return sampler._data;
@@ -1805,13 +1870,13 @@ var GLTFLoader = /** @class */ (function () {
1805
1870
  */
1806
1871
  GLTFLoader.prototype.loadImageAsync = function (context, image) {
1807
1872
  if (!image._data) {
1808
- this.logOpen(context + " " + (image.name || ""));
1873
+ this.logOpen("".concat(context, " ").concat(image.name || ""));
1809
1874
  if (image.uri) {
1810
- image._data = this.loadUriAsync(context + "/uri", image, image.uri);
1875
+ image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri);
1811
1876
  }
1812
1877
  else {
1813
- var bufferView = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, image.bufferView);
1814
- image._data = this.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView);
1878
+ var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView);
1879
+ image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView);
1815
1880
  }
1816
1881
  this.logClose();
1817
1882
  }
@@ -1831,23 +1896,23 @@ var GLTFLoader = /** @class */ (function () {
1831
1896
  return extensionPromise;
1832
1897
  }
1833
1898
  if (!GLTFLoader._ValidateUri(uri)) {
1834
- throw new Error(context + ": '" + uri + "' is invalid");
1899
+ throw new Error("".concat(context, ": '").concat(uri, "' is invalid"));
1835
1900
  }
1836
1901
  if (IsBase64DataUrl(uri)) {
1837
1902
  var data = new Uint8Array(DecodeBase64UrlToBinary(uri));
1838
- this.log(context + ": Decoded " + uri.substr(0, 64) + "... (" + data.length + " bytes)");
1903
+ this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)"));
1839
1904
  return Promise.resolve(data);
1840
1905
  }
1841
- this.log(context + ": Loading " + uri);
1906
+ this.log("".concat(context, ": Loading ").concat(uri));
1842
1907
  return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) {
1843
1908
  return new Promise(function (resolve, reject) {
1844
1909
  _this._parent._loadFile(_this._babylonScene, url, function (data) {
1845
1910
  if (!_this._disposed) {
1846
- _this.log(context + ": Loaded " + uri + " (" + data.byteLength + " bytes)");
1911
+ _this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)"));
1847
1912
  resolve(new Uint8Array(data));
1848
1913
  }
1849
1914
  }, true, function (request) {
1850
- reject(new LoadFileError(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request));
1915
+ reject(new LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request));
1851
1916
  });
1852
1917
  });
1853
1918
  });
@@ -1871,7 +1936,7 @@ var GLTFLoader = /** @class */ (function () {
1871
1936
  case 33648 /* MIRRORED_REPEAT */: return Texture.MIRROR_ADDRESSMODE;
1872
1937
  case 10497 /* REPEAT */: return Texture.WRAP_ADDRESSMODE;
1873
1938
  default:
1874
- Logger.Warn(context + ": Invalid value (" + mode + ")");
1939
+ Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")"));
1875
1940
  return Texture.WRAP_ADDRESSMODE;
1876
1941
  }
1877
1942
  };
@@ -1888,13 +1953,13 @@ var GLTFLoader = /** @class */ (function () {
1888
1953
  case 9986 /* NEAREST_MIPMAP_LINEAR */: return Texture.LINEAR_NEAREST_MIPLINEAR;
1889
1954
  case 9987 /* LINEAR_MIPMAP_LINEAR */: return Texture.LINEAR_LINEAR_MIPLINEAR;
1890
1955
  default:
1891
- Logger.Warn(context + "/minFilter: Invalid value (" + minFilter + ")");
1956
+ Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
1892
1957
  return Texture.LINEAR_LINEAR_MIPLINEAR;
1893
1958
  }
1894
1959
  }
1895
1960
  else {
1896
1961
  if (magFilter !== 9728 /* NEAREST */) {
1897
- Logger.Warn(context + "/magFilter: Invalid value (" + magFilter + ")");
1962
+ Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")"));
1898
1963
  }
1899
1964
  switch (minFilter) {
1900
1965
  case 9728 /* NEAREST */: return Texture.NEAREST_NEAREST;
@@ -1904,7 +1969,7 @@ var GLTFLoader = /** @class */ (function () {
1904
1969
  case 9986 /* NEAREST_MIPMAP_LINEAR */: return Texture.NEAREST_NEAREST_MIPLINEAR;
1905
1970
  case 9987 /* LINEAR_MIPMAP_LINEAR */: return Texture.NEAREST_LINEAR_MIPLINEAR;
1906
1971
  default:
1907
- Logger.Warn(context + "/minFilter: Invalid value (" + minFilter + ")");
1972
+ Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
1908
1973
  return Texture.NEAREST_NEAREST_MIPNEAREST;
1909
1974
  }
1910
1975
  }
@@ -1917,17 +1982,17 @@ var GLTFLoader = /** @class */ (function () {
1917
1982
  case 5123 /* UNSIGNED_SHORT */: return Uint16Array;
1918
1983
  case 5125 /* UNSIGNED_INT */: return Uint32Array;
1919
1984
  case 5126 /* FLOAT */: return Float32Array;
1920
- default: throw new Error(context + ": Invalid component type " + componentType);
1985
+ default: throw new Error("".concat(context, ": Invalid component type ").concat(componentType));
1921
1986
  }
1922
1987
  };
1923
1988
  GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) {
1924
1989
  var buffer = bufferView.buffer;
1925
1990
  byteOffset = bufferView.byteOffset + (byteOffset || 0);
1926
- var constructor = GLTFLoader._GetTypedArrayConstructor(context + "/componentType", componentType);
1991
+ var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType);
1927
1992
  var componentTypeLength = VertexBuffer.GetTypeByteLength(componentType);
1928
1993
  if (byteOffset % componentTypeLength !== 0) {
1929
1994
  // HACK: Copy the buffer if byte offset is not a multiple of component type byte length.
1930
- Logger.Warn(context + ": Copying buffer as byte offset (" + byteOffset + ") is not a multiple of component type byte length (" + componentTypeLength + ")");
1995
+ Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")"));
1931
1996
  return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0);
1932
1997
  }
1933
1998
  return new constructor(buffer, byteOffset, length);
@@ -1942,7 +2007,7 @@ var GLTFLoader = /** @class */ (function () {
1942
2007
  case "MAT3": return 9;
1943
2008
  case "MAT4": return 16;
1944
2009
  }
1945
- throw new Error(context + ": Invalid type (" + type + ")");
2010
+ throw new Error("".concat(context, ": Invalid type (").concat(type, ")"));
1946
2011
  };
1947
2012
  GLTFLoader._ValidateUri = function (uri) {
1948
2013
  return (Tools.IsBase64(uri) || uri.indexOf("..") === -1);
@@ -1961,7 +2026,7 @@ var GLTFLoader = /** @class */ (function () {
1961
2026
  case 5 /* TRIANGLE_STRIP */: return Material.TriangleStripDrawMode;
1962
2027
  case 6 /* TRIANGLE_FAN */: return Material.TriangleFanDrawMode;
1963
2028
  }
1964
- throw new Error(context + ": Invalid mesh primitive mode (" + mode + ")");
2029
+ throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")"));
1965
2030
  };
1966
2031
  GLTFLoader.prototype._compileMaterialsAsync = function () {
1967
2032
  var _this = this;
@@ -2021,7 +2086,7 @@ var GLTFLoader = /** @class */ (function () {
2021
2086
  for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) {
2022
2087
  var extension = _a[_i];
2023
2088
  if (extension.enabled) {
2024
- var id = extension.name + "." + functionName;
2089
+ var id = "".concat(extension.name, ".").concat(functionName);
2025
2090
  var loaderProperty = property;
2026
2091
  loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {};
2027
2092
  var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions;
@@ -2109,7 +2174,7 @@ var GLTFLoader = /** @class */ (function () {
2109
2174
  if (!extension) {
2110
2175
  return null;
2111
2176
  }
2112
- return actionAsync(context + "/extensions/" + extensionName, extension);
2177
+ return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension);
2113
2178
  };
2114
2179
  /**
2115
2180
  * Helper method called by a loader extension to load a glTF extra.
@@ -2128,7 +2193,7 @@ var GLTFLoader = /** @class */ (function () {
2128
2193
  if (!extra) {
2129
2194
  return null;
2130
2195
  }
2131
- return actionAsync(context + "/extras/" + extensionName, extra);
2196
+ return actionAsync("".concat(context, "/extras/").concat(extensionName), extra);
2132
2197
  };
2133
2198
  /**
2134
2199
  * Checks for presence of an extension.