@babylonjs/loaders 5.0.0-rc.2 → 5.0.0-rc.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. package/OBJ/index.js.map +1 -1
  2. package/OBJ/mtlFileLoader.d.ts +7 -6
  3. package/OBJ/mtlFileLoader.js +15 -14
  4. package/OBJ/mtlFileLoader.js.map +1 -1
  5. package/OBJ/objFileLoader.d.ts +11 -18
  6. package/OBJ/objFileLoader.js +19 -23
  7. package/OBJ/objFileLoader.js.map +1 -1
  8. package/OBJ/objLoadingOptions.d.ts +1 -1
  9. package/OBJ/objLoadingOptions.js.map +1 -1
  10. package/OBJ/solidParser.d.ts +6 -5
  11. package/OBJ/solidParser.js +15 -21
  12. package/OBJ/solidParser.js.map +1 -1
  13. package/STL/index.js.map +1 -1
  14. package/STL/stlFileLoader.d.ts +7 -14
  15. package/STL/stlFileLoader.js +15 -21
  16. package/STL/stlFileLoader.js.map +1 -1
  17. package/glTF/1.0/glTFBinaryExtension.d.ts +4 -4
  18. package/glTF/1.0/glTFBinaryExtension.js +4 -5
  19. package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
  20. package/glTF/1.0/glTFLoader.d.ts +80 -50
  21. package/glTF/1.0/glTFLoader.js +265 -146
  22. package/glTF/1.0/glTFLoader.js.map +1 -1
  23. package/glTF/1.0/glTFLoaderInterfaces.d.ts +10 -10
  24. package/glTF/1.0/glTFLoaderInterfaces.js +3 -3
  25. package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
  26. package/glTF/1.0/glTFLoaderUtils.d.ts +25 -25
  27. package/glTF/1.0/glTFLoaderUtils.js +70 -52
  28. package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
  29. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +2 -2
  30. package/glTF/1.0/glTFMaterialsCommonExtension.js +13 -11
  31. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
  32. package/glTF/1.0/index.js.map +1 -1
  33. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +11 -4
  34. package/glTF/2.0/Extensions/EXT_lights_image_based.js +9 -2
  35. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  36. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +13 -5
  37. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +12 -4
  38. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  39. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +10 -3
  40. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +10 -3
  41. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  42. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +12 -4
  43. package/glTF/2.0/Extensions/EXT_texture_webp.js +11 -3
  44. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  45. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +26 -8
  46. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -4
  47. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
  48. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +14 -6
  49. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +17 -6
  50. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  51. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +12 -4
  52. package/glTF/2.0/Extensions/KHR_lights_punctual.js +11 -3
  53. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  54. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +12 -4
  55. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +10 -2
  56. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  57. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +12 -4
  58. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +10 -2
  59. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  60. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +12 -4
  61. package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -2
  62. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  63. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +12 -4
  64. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +10 -2
  65. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  66. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +12 -4
  67. package/glTF/2.0/Extensions/KHR_materials_sheen.js +11 -3
  68. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  69. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +12 -4
  70. package/glTF/2.0/Extensions/KHR_materials_specular.js +11 -3
  71. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  72. package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +12 -4
  73. package/glTF/2.0/Extensions/KHR_materials_translucency.js +11 -4
  74. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  75. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +12 -4
  76. package/glTF/2.0/Extensions/KHR_materials_transmission.js +24 -13
  77. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  78. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +12 -4
  79. package/glTF/2.0/Extensions/KHR_materials_unlit.js +10 -2
  80. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  81. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +17 -6
  82. package/glTF/2.0/Extensions/KHR_materials_variants.js +19 -8
  83. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  84. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +12 -4
  85. package/glTF/2.0/Extensions/KHR_materials_volume.js +12 -5
  86. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  87. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +4 -1
  88. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +5 -3
  89. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
  90. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +12 -4
  91. package/glTF/2.0/Extensions/KHR_texture_basisu.js +11 -3
  92. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  93. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +12 -4
  94. package/glTF/2.0/Extensions/KHR_texture_transform.js +10 -2
  95. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  96. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +4 -1
  97. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +4 -1
  98. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  99. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +23 -7
  100. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +38 -14
  101. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  102. package/glTF/2.0/Extensions/MSFT_lod.d.ts +45 -11
  103. package/glTF/2.0/Extensions/MSFT_lod.js +44 -8
  104. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  105. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +2 -2
  106. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  107. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +2 -2
  108. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  109. package/glTF/2.0/Extensions/index.js.map +1 -1
  110. package/glTF/2.0/glTFLoader.d.ts +70 -22
  111. package/glTF/2.0/glTFLoader.js +180 -93
  112. package/glTF/2.0/glTFLoader.js.map +1 -1
  113. package/glTF/2.0/glTFLoaderExtension.d.ts +11 -11
  114. package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
  115. package/glTF/2.0/glTFLoaderInterfaces.d.ts +7 -7
  116. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  117. package/glTF/2.0/index.js.map +1 -1
  118. package/glTF/glTFFileLoader.d.ts +87 -27
  119. package/glTF/glTFFileLoader.js +102 -45
  120. package/glTF/glTFFileLoader.js.map +1 -1
  121. package/glTF/glTFValidation.d.ts +1 -1
  122. package/glTF/glTFValidation.js +12 -12
  123. package/glTF/glTFValidation.js.map +1 -1
  124. package/glTF/index.js.map +1 -1
  125. package/index.js.map +1 -1
  126. package/legacy/legacy-glTF.d.ts +2 -2
  127. package/legacy/legacy-glTF.js +5 -5
  128. package/legacy/legacy-glTF.js.map +1 -1
  129. package/legacy/legacy-glTF1.d.ts +1 -1
  130. package/legacy/legacy-glTF1.js +2 -2
  131. package/legacy/legacy-glTF1.js.map +1 -1
  132. package/legacy/legacy-glTF1FileLoader.js +1 -0
  133. package/legacy/legacy-glTF1FileLoader.js.map +1 -1
  134. package/legacy/legacy-glTF2.d.ts +1 -1
  135. package/legacy/legacy-glTF2.js +11 -11
  136. package/legacy/legacy-glTF2.js.map +1 -1
  137. package/legacy/legacy-glTF2FileLoader.js +1 -0
  138. package/legacy/legacy-glTF2FileLoader.js.map +1 -1
  139. package/legacy/legacy-glTFFileLoader.js +1 -0
  140. package/legacy/legacy-glTFFileLoader.js.map +1 -1
  141. package/legacy/legacy-objFileLoader.d.ts +1 -1
  142. package/legacy/legacy-objFileLoader.js +3 -3
  143. package/legacy/legacy-objFileLoader.js.map +1 -1
  144. package/legacy/legacy-stlFileLoader.d.ts +1 -1
  145. package/legacy/legacy-stlFileLoader.js +3 -3
  146. package/legacy/legacy-stlFileLoader.js.map +1 -1
  147. package/legacy/legacy.d.ts +1 -1
  148. package/legacy/legacy.js +2 -1
  149. package/legacy/legacy.js.map +1 -1
  150. package/package.json +23 -198
  151. package/readme.md +2 -2
@@ -1,6 +1,6 @@
1
1
  import { Deferred } from "@babylonjs/core/Misc/deferred.js";
2
- import { Quaternion, Vector3, Matrix } from "@babylonjs/core/Maths/math.vector.js";
3
- import { Color3 } from '@babylonjs/core/Maths/math.color.js';
2
+ import { Quaternion, Vector3, Matrix, TmpVectors } from "@babylonjs/core/Maths/math.vector.js";
3
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
4
  import { Tools } from "@babylonjs/core/Misc/tools.js";
5
5
  import { Camera } from "@babylonjs/core/Cameras/camera.js";
6
6
  import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera.js";
@@ -18,12 +18,11 @@ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
18
18
  import { MorphTarget } from "@babylonjs/core/Morph/morphTarget.js";
19
19
  import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager.js";
20
20
  import { GLTFFileLoader, GLTFLoaderState, GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode } from "../glTFFileLoader.js";
21
- import { AnimationKeyInterpolation } from '@babylonjs/core/Animations/animationKey.js';
22
- import { DecodeBase64UrlToBinary, IsBase64DataUrl, LoadFileError } from '@babylonjs/core/Misc/fileTools.js';
23
- import { Logger } from '@babylonjs/core/Misc/logger.js';
24
- import { TmpVectors } from '@babylonjs/core/Maths/math.vector.js';
25
- import { BoundingInfo } from '@babylonjs/core/Culling/boundingInfo.js';
26
- import { StringTools } from '@babylonjs/core/Misc/stringTools.js';
21
+ import { AnimationKeyInterpolation } from "@babylonjs/core/Animations/animationKey.js";
22
+ import { DecodeBase64UrlToBinary, IsBase64DataUrl, LoadFileError } from "@babylonjs/core/Misc/fileTools.js";
23
+ import { Logger } from "@babylonjs/core/Misc/logger.js";
24
+ import { BoundingInfo } from "@babylonjs/core/Culling/boundingInfo.js";
25
+ import { StringTools } from "@babylonjs/core/Misc/stringTools.js";
27
26
  /**
28
27
  * Helper class for working with arrays when loading the glTF asset
29
28
  */
@@ -61,7 +60,10 @@ export { ArrayItem };
61
60
  * The glTF 2.0 loader
62
61
  */
63
62
  var GLTFLoader = /** @class */ (function () {
64
- /** @hidden */
63
+ /**
64
+ * @param parent
65
+ * @hidden
66
+ */
65
67
  function GLTFLoader(parent) {
66
68
  /** @hidden */
67
69
  this._completePromises = new Array();
@@ -92,7 +94,7 @@ var GLTFLoader = /** @class */ (function () {
92
94
  Logger.Warn("Extension with the name '".concat(name, "' already exists"));
93
95
  }
94
96
  GLTFLoader._RegisteredExtensions[name] = {
95
- factory: factory
97
+ factory: factory,
96
98
  };
97
99
  };
98
100
  /**
@@ -180,7 +182,16 @@ var GLTFLoader = /** @class */ (function () {
180
182
  this._postSceneLoadActions.length = 0;
181
183
  this._parent.dispose();
182
184
  };
183
- /** @hidden */
185
+ /**
186
+ * @param meshesNames
187
+ * @param scene
188
+ * @param container
189
+ * @param data
190
+ * @param rootUrl
191
+ * @param onProgress
192
+ * @param fileName
193
+ * @hidden
194
+ */
184
195
  GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) {
185
196
  var _this = this;
186
197
  if (fileName === void 0) { fileName = ""; }
@@ -199,7 +210,7 @@ var GLTFLoader = /** @class */ (function () {
199
210
  }
200
211
  }
201
212
  }
202
- var names = (meshesNames instanceof Array) ? meshesNames : [meshesNames];
213
+ var names = meshesNames instanceof Array ? meshesNames : [meshesNames];
203
214
  nodes = names.map(function (name) {
204
215
  var node = nodeMap_1[name];
205
216
  if (node === undefined) {
@@ -216,12 +227,19 @@ var GLTFLoader = /** @class */ (function () {
216
227
  animationGroups: _this._getAnimationGroups(),
217
228
  lights: _this._babylonLights,
218
229
  transformNodes: _this._getTransformNodes(),
219
- geometries: _this._getGeometries()
230
+ geometries: _this._getGeometries(),
220
231
  };
221
232
  });
222
233
  });
223
234
  };
224
- /** @hidden */
235
+ /**
236
+ * @param scene
237
+ * @param data
238
+ * @param rootUrl
239
+ * @param onProgress
240
+ * @param fileName
241
+ * @hidden
242
+ */
225
243
  GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
226
244
  var _this = this;
227
245
  if (fileName === void 0) { fileName = ""; }
@@ -233,9 +251,10 @@ var GLTFLoader = /** @class */ (function () {
233
251
  };
234
252
  GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) {
235
253
  var _this = this;
236
- return Promise.resolve().then(function () {
254
+ return Promise.resolve()
255
+ .then(function () {
237
256
  _this._rootUrl = rootUrl;
238
- _this._uniqueRootUrl = (!StringTools.StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/");
257
+ _this._uniqueRootUrl = !StringTools.StartsWith(rootUrl, "file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/");
239
258
  _this._fileName = fileName;
240
259
  _this._loadExtensions();
241
260
  _this._checkExtensions();
@@ -249,19 +268,21 @@ var GLTFLoader = /** @class */ (function () {
249
268
  // Block the marking of materials dirty until the scene is loaded.
250
269
  var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism;
251
270
  _this._babylonScene.blockMaterialDirtyMechanism = true;
252
- if (nodes) {
253
- promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 }));
254
- }
255
- else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
256
- var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
257
- promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
271
+ if (!_this.parent.loadOnlyMaterials) {
272
+ if (nodes) {
273
+ promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 }));
274
+ }
275
+ else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
276
+ var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
277
+ promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
278
+ }
258
279
  }
259
- if (_this.parent.loadAllMaterials && _this._gltf.materials) {
280
+ if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) {
260
281
  for (var m = 0; m < _this._gltf.materials.length; ++m) {
261
282
  var material = _this._gltf.materials[m];
262
283
  var context_1 = "/materials/" + m;
263
284
  var babylonDrawMode = Material.TriangleFillMode;
264
- promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function (material) { }));
285
+ promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function () { }));
265
286
  }
266
287
  }
267
288
  // Restore the blocking of material dirty.
@@ -300,7 +321,8 @@ var GLTFLoader = /** @class */ (function () {
300
321
  });
301
322
  return result;
302
323
  });
303
- }).catch(function (error) {
324
+ })
325
+ .catch(function (error) {
304
326
  if (!_this._disposed) {
305
327
  _this._parent.onErrorObservable.notifyObservers(error);
306
328
  _this._parent.onErrorObservable.clear();
@@ -394,7 +416,7 @@ var GLTFLoader = /** @class */ (function () {
394
416
  this._rootBabylonMesh.setEnabled(false);
395
417
  var rootNode = {
396
418
  _babylonTransformNode: this._rootBabylonMesh,
397
- index: -1
419
+ index: -1,
398
420
  };
399
421
  switch (this._parent.coordinateSystemMode) {
400
422
  case GLTFLoaderCoordinateSystemMode.AUTO: {
@@ -712,7 +734,7 @@ var GLTFLoader = /** @class */ (function () {
712
734
  return extensionPromise;
713
735
  }
714
736
  this.logOpen("".concat(context));
715
- var shouldInstance = (this._disableInstancedMesh === 0) && this._parent.createInstances && (node.skin == undefined && !mesh.primitives[0].targets);
737
+ var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets;
716
738
  var babylonAbstractMesh;
717
739
  var promise;
718
740
  if (shouldInstance && primitive._instanceData) {
@@ -748,7 +770,7 @@ var GLTFLoader = /** @class */ (function () {
748
770
  }
749
771
  babylonMesh_1.material = babylonMaterial;
750
772
  }
751
- else {
773
+ else if (!this.parent.skipMaterials) {
752
774
  var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material);
753
775
  promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
754
776
  babylonMesh_1.material = babylonMaterial;
@@ -758,7 +780,7 @@ var GLTFLoader = /** @class */ (function () {
758
780
  if (shouldInstance) {
759
781
  primitive._instanceData = {
760
782
  babylonSourceMesh: babylonMesh_1,
761
- promise: promise
783
+ promise: promise,
762
784
  };
763
785
  }
764
786
  babylonAbstractMesh = babylonMesh_1;
@@ -929,13 +951,13 @@ var GLTFLoader = /** @class */ (function () {
929
951
  babylonMorphTarget.setNormals(normals);
930
952
  });
931
953
  loadAttribute("TANGENT", VertexBuffer.TangentKind, function (babylonVertexBuffer, data) {
932
- var tangents = new Float32Array(data.length / 3 * 4);
954
+ var tangents = new Float32Array((data.length / 3) * 4);
933
955
  var dataIndex = 0;
934
- babylonVertexBuffer.forEach(data.length / 3 * 4, function (value, index) {
956
+ babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) {
935
957
  // Tangent data for morph targets is stored as xyz delta.
936
958
  // The vertexData.tangent is stored as xyzw.
937
959
  // So we need to skip every fourth vertexData.tangent.
938
- if (((index + 1) % 4) !== 0) {
960
+ if ((index + 1) % 4 !== 0) {
939
961
  tangents[dataIndex] = data[dataIndex] + value;
940
962
  dataIndex++;
941
963
  }
@@ -993,7 +1015,7 @@ var GLTFLoader = /** @class */ (function () {
993
1015
  });
994
1016
  skin._data = {
995
1017
  babylonSkeleton: babylonSkeleton,
996
- promise: promise
1018
+ promise: promise,
997
1019
  };
998
1020
  assign(babylonSkeleton);
999
1021
  return promise;
@@ -1113,9 +1135,9 @@ var GLTFLoader = /** @class */ (function () {
1113
1135
  }
1114
1136
  };
1115
1137
  GLTFLoader.prototype._getNodeMatrix = function (node) {
1116
- return node.matrix ?
1117
- Matrix.FromArray(node.matrix) :
1118
- Matrix.Compose(node.scale ? Vector3.FromArray(node.scale) : Vector3.One(), node.rotation ? Quaternion.FromArray(node.rotation) : Quaternion.Identity(), node.translation ? Vector3.FromArray(node.translation) : Vector3.Zero());
1138
+ return node.matrix
1139
+ ? Matrix.FromArray(node.matrix)
1140
+ : Matrix.Compose(node.scale ? Vector3.FromArray(node.scale) : Vector3.One(), node.rotation ? Quaternion.FromArray(node.rotation) : Quaternion.Identity(), node.translation ? Vector3.FromArray(node.translation) : Vector3.Zero());
1119
1141
  };
1120
1142
  /**
1121
1143
  * Loads a glTF camera.
@@ -1314,14 +1336,14 @@ var GLTFLoader = /** @class */ (function () {
1314
1336
  getNextKey = function (frameIndex) { return ({
1315
1337
  frame: data.input[frameIndex] * _this.parent.targetFps,
1316
1338
  value: getNextOutputValue(1),
1317
- interpolation: AnimationKeyInterpolation.STEP
1339
+ interpolation: AnimationKeyInterpolation.STEP,
1318
1340
  }); };
1319
1341
  break;
1320
1342
  }
1321
1343
  case "LINEAR" /* LINEAR */: {
1322
1344
  getNextKey = function (frameIndex) { return ({
1323
1345
  frame: data.input[frameIndex] * _this.parent.targetFps,
1324
- value: getNextOutputValue(1)
1346
+ value: getNextOutputValue(1),
1325
1347
  }); };
1326
1348
  break;
1327
1349
  }
@@ -1331,7 +1353,7 @@ var GLTFLoader = /** @class */ (function () {
1331
1353
  frame: data.input[frameIndex] * _this.parent.targetFps,
1332
1354
  inTangent: getNextOutputValue(invTargetFps_1),
1333
1355
  value: getNextOutputValue(1),
1334
- outTangent: getNextOutputValue(invTargetFps_1)
1356
+ outTangent: getNextOutputValue(invTargetFps_1),
1335
1357
  }); };
1336
1358
  break;
1337
1359
  }
@@ -1348,7 +1370,7 @@ var GLTFLoader = /** @class */ (function () {
1348
1370
  frame: key.frame,
1349
1371
  inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
1350
1372
  value: key.value[targetIndex],
1351
- outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined
1373
+ outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,
1352
1374
  }); }));
1353
1375
  _this._forEachPrimitive(targetNode, function (babylonAbstractMesh) {
1354
1376
  var babylonMesh = babylonAbstractMesh;
@@ -1396,7 +1418,7 @@ var GLTFLoader = /** @class */ (function () {
1396
1418
  var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
1397
1419
  sampler._data = Promise.all([
1398
1420
  this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
1399
- this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor)
1421
+ this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor),
1400
1422
  ]).then(function (_a) {
1401
1423
  var inputData = _a[0], outputData = _a[1];
1402
1424
  return {
@@ -1455,7 +1477,7 @@ var GLTFLoader = /** @class */ (function () {
1455
1477
  return bufferView._data;
1456
1478
  }
1457
1479
  var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer);
1458
- bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, (bufferView.byteOffset || 0), bufferView.byteLength);
1480
+ bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength);
1459
1481
  return bufferView._data;
1460
1482
  };
1461
1483
  GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) {
@@ -1492,7 +1514,7 @@ var GLTFLoader = /** @class */ (function () {
1492
1514
  var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView);
1493
1515
  return Promise.all([
1494
1516
  _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView),
1495
- _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView)
1517
+ _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView),
1496
1518
  ]).then(function (_a) {
1497
1519
  var indicesData = _a[0], valuesData = _a[1];
1498
1520
  var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
@@ -1521,7 +1543,11 @@ var GLTFLoader = /** @class */ (function () {
1521
1543
  }
1522
1544
  return accessor._data;
1523
1545
  };
1524
- /** @hidden */
1546
+ /**
1547
+ * @param context
1548
+ * @param accessor
1549
+ * @hidden
1550
+ */
1525
1551
  GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) {
1526
1552
  return this._loadAccessorAsync(context, accessor, Float32Array);
1527
1553
  };
@@ -1549,7 +1575,7 @@ var GLTFLoader = /** @class */ (function () {
1549
1575
  }
1550
1576
  return accessor._data;
1551
1577
  };
1552
- GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView, kind) {
1578
+ GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView) {
1553
1579
  var _this = this;
1554
1580
  if (bufferView._babylonBuffer) {
1555
1581
  return bufferView._babylonBuffer;
@@ -1582,7 +1608,7 @@ var GLTFLoader = /** @class */ (function () {
1582
1608
  }
1583
1609
  else {
1584
1610
  var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
1585
- accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
1611
+ accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2).then(function (babylonBuffer) {
1586
1612
  var size = GLTFLoader._GetNumComponents(context, accessor.type);
1587
1613
  return new VertexBuffer(_this._babylonScene.getEngine(), babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true);
1588
1614
  });
@@ -1623,7 +1649,14 @@ var GLTFLoader = /** @class */ (function () {
1623
1649
  }
1624
1650
  return Promise.all(promises).then(function () { });
1625
1651
  };
1626
- /** @hidden */
1652
+ /**
1653
+ * @param context
1654
+ * @param material
1655
+ * @param babylonMesh
1656
+ * @param babylonDrawMode
1657
+ * @param assign
1658
+ * @hidden
1659
+ */
1627
1660
  GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
1628
1661
  if (assign === void 0) { assign = function () { }; }
1629
1662
  var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
@@ -1638,7 +1671,7 @@ var GLTFLoader = /** @class */ (function () {
1638
1671
  babylonData = {
1639
1672
  babylonMaterial: babylonMaterial,
1640
1673
  babylonMeshes: [],
1641
- promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial)
1674
+ promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial),
1642
1675
  };
1643
1676
  material._data[babylonDrawMode] = babylonData;
1644
1677
  GLTFLoader.AddPointerMetadata(babylonMaterial, context);
@@ -1778,7 +1811,7 @@ var GLTFLoader = /** @class */ (function () {
1778
1811
  }
1779
1812
  case "MASK" /* MASK */: {
1780
1813
  babylonMaterial.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHATEST;
1781
- babylonMaterial.alphaCutOff = (material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff);
1814
+ babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff;
1782
1815
  if (babylonMaterial.albedoTexture) {
1783
1816
  babylonMaterial.albedoTexture.hasAlpha = true;
1784
1817
  }
@@ -1826,7 +1859,12 @@ var GLTFLoader = /** @class */ (function () {
1826
1859
  this.logClose();
1827
1860
  return promise;
1828
1861
  };
1829
- /** @hidden */
1862
+ /**
1863
+ * @param context
1864
+ * @param texture
1865
+ * @param assign
1866
+ * @hidden
1867
+ */
1830
1868
  GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) {
1831
1869
  if (assign === void 0) { assign = function () { }; }
1832
1870
  var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign);
@@ -1834,13 +1872,21 @@ var GLTFLoader = /** @class */ (function () {
1834
1872
  return extensionPromise;
1835
1873
  }
1836
1874
  this.logOpen("".concat(context, " ").concat(texture.name || ""));
1837
- var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler));
1875
+ var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler);
1838
1876
  var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source);
1839
1877
  var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData);
1840
1878
  this.logClose();
1841
1879
  return promise;
1842
1880
  };
1843
- /** @hidden */
1881
+ /**
1882
+ * @param context
1883
+ * @param sampler
1884
+ * @param image
1885
+ * @param assign
1886
+ * @param textureLoaderOptions
1887
+ * @param useSRGBBuffer
1888
+ * @hidden
1889
+ */
1844
1890
  GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) {
1845
1891
  var _this = this;
1846
1892
  if (assign === void 0) { assign = function () { }; }
@@ -1859,7 +1905,7 @@ var GLTFLoader = /** @class */ (function () {
1859
1905
  },
1860
1906
  onError: function (message, exception) {
1861
1907
  if (!_this._disposed) {
1862
- deferred.reject(new Error("".concat(context, ": ").concat((exception && exception.message) ? exception.message : message || "Failed to load texture")));
1908
+ deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture")));
1863
1909
  }
1864
1910
  },
1865
1911
  mimeType: image.mimeType,
@@ -1885,10 +1931,10 @@ var GLTFLoader = /** @class */ (function () {
1885
1931
  GLTFLoader.prototype._loadSampler = function (context, sampler) {
1886
1932
  if (!sampler._data) {
1887
1933
  sampler._data = {
1888
- noMipMaps: (sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */),
1934
+ noMipMaps: sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */,
1889
1935
  samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler),
1890
1936
  wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS),
1891
- wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT)
1937
+ wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT),
1892
1938
  };
1893
1939
  }
1894
1940
  return sampler._data;
@@ -1951,6 +1997,7 @@ var GLTFLoader = /** @class */ (function () {
1951
1997
  /**
1952
1998
  * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
1953
1999
  * @param babylonObject the Babylon object with metadata
2000
+ * @param babylonObject.metadata
1954
2001
  * @param pointer the JSON pointer
1955
2002
  */
1956
2003
  GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) {
@@ -1963,9 +2010,12 @@ var GLTFLoader = /** @class */ (function () {
1963
2010
  // Set defaults if undefined
1964
2011
  mode = mode == undefined ? 10497 /* REPEAT */ : mode;
1965
2012
  switch (mode) {
1966
- case 33071 /* CLAMP_TO_EDGE */: return Texture.CLAMP_ADDRESSMODE;
1967
- case 33648 /* MIRRORED_REPEAT */: return Texture.MIRROR_ADDRESSMODE;
1968
- case 10497 /* REPEAT */: return Texture.WRAP_ADDRESSMODE;
2013
+ case 33071 /* CLAMP_TO_EDGE */:
2014
+ return Texture.CLAMP_ADDRESSMODE;
2015
+ case 33648 /* MIRRORED_REPEAT */:
2016
+ return Texture.MIRROR_ADDRESSMODE;
2017
+ case 10497 /* REPEAT */:
2018
+ return Texture.WRAP_ADDRESSMODE;
1969
2019
  default:
1970
2020
  Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")"));
1971
2021
  return Texture.WRAP_ADDRESSMODE;
@@ -1977,12 +2027,18 @@ var GLTFLoader = /** @class */ (function () {
1977
2027
  var minFilter = sampler.minFilter == undefined ? 9987 /* LINEAR_MIPMAP_LINEAR */ : sampler.minFilter;
1978
2028
  if (magFilter === 9729 /* LINEAR */) {
1979
2029
  switch (minFilter) {
1980
- case 9728 /* NEAREST */: return Texture.LINEAR_NEAREST;
1981
- case 9729 /* LINEAR */: return Texture.LINEAR_LINEAR;
1982
- case 9984 /* NEAREST_MIPMAP_NEAREST */: return Texture.LINEAR_NEAREST_MIPNEAREST;
1983
- case 9985 /* LINEAR_MIPMAP_NEAREST */: return Texture.LINEAR_LINEAR_MIPNEAREST;
1984
- case 9986 /* NEAREST_MIPMAP_LINEAR */: return Texture.LINEAR_NEAREST_MIPLINEAR;
1985
- case 9987 /* LINEAR_MIPMAP_LINEAR */: return Texture.LINEAR_LINEAR_MIPLINEAR;
2030
+ case 9728 /* NEAREST */:
2031
+ return Texture.LINEAR_NEAREST;
2032
+ case 9729 /* LINEAR */:
2033
+ return Texture.LINEAR_LINEAR;
2034
+ case 9984 /* NEAREST_MIPMAP_NEAREST */:
2035
+ return Texture.LINEAR_NEAREST_MIPNEAREST;
2036
+ case 9985 /* LINEAR_MIPMAP_NEAREST */:
2037
+ return Texture.LINEAR_LINEAR_MIPNEAREST;
2038
+ case 9986 /* NEAREST_MIPMAP_LINEAR */:
2039
+ return Texture.LINEAR_NEAREST_MIPLINEAR;
2040
+ case 9987 /* LINEAR_MIPMAP_LINEAR */:
2041
+ return Texture.LINEAR_LINEAR_MIPLINEAR;
1986
2042
  default:
1987
2043
  Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
1988
2044
  return Texture.LINEAR_LINEAR_MIPLINEAR;
@@ -1993,12 +2049,18 @@ var GLTFLoader = /** @class */ (function () {
1993
2049
  Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")"));
1994
2050
  }
1995
2051
  switch (minFilter) {
1996
- case 9728 /* NEAREST */: return Texture.NEAREST_NEAREST;
1997
- case 9729 /* LINEAR */: return Texture.NEAREST_LINEAR;
1998
- case 9984 /* NEAREST_MIPMAP_NEAREST */: return Texture.NEAREST_NEAREST_MIPNEAREST;
1999
- case 9985 /* LINEAR_MIPMAP_NEAREST */: return Texture.NEAREST_LINEAR_MIPNEAREST;
2000
- case 9986 /* NEAREST_MIPMAP_LINEAR */: return Texture.NEAREST_NEAREST_MIPLINEAR;
2001
- case 9987 /* LINEAR_MIPMAP_LINEAR */: return Texture.NEAREST_LINEAR_MIPLINEAR;
2052
+ case 9728 /* NEAREST */:
2053
+ return Texture.NEAREST_NEAREST;
2054
+ case 9729 /* LINEAR */:
2055
+ return Texture.NEAREST_LINEAR;
2056
+ case 9984 /* NEAREST_MIPMAP_NEAREST */:
2057
+ return Texture.NEAREST_NEAREST_MIPNEAREST;
2058
+ case 9985 /* LINEAR_MIPMAP_NEAREST */:
2059
+ return Texture.NEAREST_LINEAR_MIPNEAREST;
2060
+ case 9986 /* NEAREST_MIPMAP_LINEAR */:
2061
+ return Texture.NEAREST_NEAREST_MIPLINEAR;
2062
+ case 9987 /* LINEAR_MIPMAP_LINEAR */:
2063
+ return Texture.NEAREST_LINEAR_MIPLINEAR;
2002
2064
  default:
2003
2065
  Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
2004
2066
  return Texture.NEAREST_NEAREST_MIPNEAREST;
@@ -2007,13 +2069,20 @@ var GLTFLoader = /** @class */ (function () {
2007
2069
  };
2008
2070
  GLTFLoader._GetTypedArrayConstructor = function (context, componentType) {
2009
2071
  switch (componentType) {
2010
- case 5120 /* BYTE */: return Int8Array;
2011
- case 5121 /* UNSIGNED_BYTE */: return Uint8Array;
2012
- case 5122 /* SHORT */: return Int16Array;
2013
- case 5123 /* UNSIGNED_SHORT */: return Uint16Array;
2014
- case 5125 /* UNSIGNED_INT */: return Uint32Array;
2015
- case 5126 /* FLOAT */: return Float32Array;
2016
- default: throw new Error("".concat(context, ": Invalid component type ").concat(componentType));
2072
+ case 5120 /* BYTE */:
2073
+ return Int8Array;
2074
+ case 5121 /* UNSIGNED_BYTE */:
2075
+ return Uint8Array;
2076
+ case 5122 /* SHORT */:
2077
+ return Int16Array;
2078
+ case 5123 /* UNSIGNED_SHORT */:
2079
+ return Uint16Array;
2080
+ case 5125 /* UNSIGNED_INT */:
2081
+ return Uint32Array;
2082
+ case 5126 /* FLOAT */:
2083
+ return Float32Array;
2084
+ default:
2085
+ throw new Error("".concat(context, ": Invalid component type ").concat(componentType));
2017
2086
  }
2018
2087
  };
2019
2088
  GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) {
@@ -2030,32 +2099,50 @@ var GLTFLoader = /** @class */ (function () {
2030
2099
  };
2031
2100
  GLTFLoader._GetNumComponents = function (context, type) {
2032
2101
  switch (type) {
2033
- case "SCALAR": return 1;
2034
- case "VEC2": return 2;
2035
- case "VEC3": return 3;
2036
- case "VEC4": return 4;
2037
- case "MAT2": return 4;
2038
- case "MAT3": return 9;
2039
- case "MAT4": return 16;
2102
+ case "SCALAR":
2103
+ return 1;
2104
+ case "VEC2":
2105
+ return 2;
2106
+ case "VEC3":
2107
+ return 3;
2108
+ case "VEC4":
2109
+ return 4;
2110
+ case "MAT2":
2111
+ return 4;
2112
+ case "MAT3":
2113
+ return 9;
2114
+ case "MAT4":
2115
+ return 16;
2040
2116
  }
2041
2117
  throw new Error("".concat(context, ": Invalid type (").concat(type, ")"));
2042
2118
  };
2043
2119
  GLTFLoader._ValidateUri = function (uri) {
2044
- return (Tools.IsBase64(uri) || uri.indexOf("..") === -1);
2120
+ return Tools.IsBase64(uri) || uri.indexOf("..") === -1;
2045
2121
  };
2046
- /** @hidden */
2122
+ /**
2123
+ * @param context
2124
+ * @param mode
2125
+ * @hidden
2126
+ */
2047
2127
  GLTFLoader._GetDrawMode = function (context, mode) {
2048
2128
  if (mode == undefined) {
2049
2129
  mode = 4 /* TRIANGLES */;
2050
2130
  }
2051
2131
  switch (mode) {
2052
- case 0 /* POINTS */: return Material.PointListDrawMode;
2053
- case 1 /* LINES */: return Material.LineListDrawMode;
2054
- case 2 /* LINE_LOOP */: return Material.LineLoopDrawMode;
2055
- case 3 /* LINE_STRIP */: return Material.LineStripDrawMode;
2056
- case 4 /* TRIANGLES */: return Material.TriangleFillMode;
2057
- case 5 /* TRIANGLE_STRIP */: return Material.TriangleStripDrawMode;
2058
- case 6 /* TRIANGLE_FAN */: return Material.TriangleFanDrawMode;
2132
+ case 0 /* POINTS */:
2133
+ return Material.PointListDrawMode;
2134
+ case 1 /* LINES */:
2135
+ return Material.LineListDrawMode;
2136
+ case 2 /* LINE_LOOP */:
2137
+ return Material.LineLoopDrawMode;
2138
+ case 3 /* LINE_STRIP */:
2139
+ return Material.LineStripDrawMode;
2140
+ case 4 /* TRIANGLES */:
2141
+ return Material.TriangleFillMode;
2142
+ case 5 /* TRIANGLE_STRIP */:
2143
+ return Material.TriangleStripDrawMode;
2144
+ case 6 /* TRIANGLE_FAN */:
2145
+ return Material.TriangleFanDrawMode;
2059
2146
  }
2060
2147
  throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")"));
2061
2148
  };