@babylonjs/loaders 5.19.0 → 5.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/OBJ/mtlFileLoader.js +25 -27
  2. package/OBJ/mtlFileLoader.js.map +1 -1
  3. package/OBJ/objFileLoader.js +112 -124
  4. package/OBJ/objFileLoader.js.map +1 -1
  5. package/OBJ/solidParser.js +118 -125
  6. package/OBJ/solidParser.js.map +1 -1
  7. package/STL/stlFileLoader.js +61 -63
  8. package/STL/stlFileLoader.js.map +1 -1
  9. package/glTF/1.0/glTFBinaryExtension.js +26 -30
  10. package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
  11. package/glTF/1.0/glTFLoader.js +409 -432
  12. package/glTF/1.0/glTFLoader.js.map +1 -1
  13. package/glTF/1.0/glTFLoaderUtils.js +33 -37
  14. package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
  15. package/glTF/1.0/glTFMaterialsCommonExtension.js +27 -31
  16. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
  17. package/glTF/2.0/Extensions/EXT_lights_image_based.js +48 -59
  18. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  19. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +24 -29
  20. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  21. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +13 -16
  22. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  23. package/glTF/2.0/Extensions/EXT_texture_webp.js +13 -16
  24. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  25. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -26
  26. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_animation_pointer.js +63 -76
  28. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_animation_pointer.map.js +90 -120
  30. package/glTF/2.0/Extensions/KHR_animation_pointer.map.js.map +1 -1
  31. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +25 -28
  32. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  33. package/glTF/2.0/Extensions/KHR_lights_punctual.js +27 -30
  34. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  35. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +25 -28
  36. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  37. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +15 -18
  38. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  39. package/glTF/2.0/Extensions/KHR_materials_ior.js +21 -24
  40. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  41. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +27 -31
  42. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  43. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +24 -27
  44. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  45. package/glTF/2.0/Extensions/KHR_materials_sheen.js +23 -26
  46. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  47. package/glTF/2.0/Extensions/KHR_materials_specular.js +23 -26
  48. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  49. package/glTF/2.0/Extensions/KHR_materials_translucency.js +20 -23
  50. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  51. package/glTF/2.0/Extensions/KHR_materials_transmission.js +82 -86
  52. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  53. package/glTF/2.0/Extensions/KHR_materials_unlit.js +19 -22
  54. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_materials_variants.js +79 -97
  56. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  57. package/glTF/2.0/Extensions/KHR_materials_volume.js +20 -23
  58. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  59. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +6 -8
  60. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
  61. package/glTF/2.0/Extensions/KHR_texture_basisu.js +13 -16
  62. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  63. package/glTF/2.0/Extensions/KHR_texture_transform.js +12 -15
  64. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  65. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +12 -15
  66. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  67. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +77 -95
  68. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  69. package/glTF/2.0/Extensions/MSFT_lod.js +114 -139
  70. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  71. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +12 -15
  72. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  73. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +12 -15
  74. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  75. package/glTF/2.0/glTFLoader.js +739 -823
  76. package/glTF/2.0/glTFLoader.js.map +1 -1
  77. package/glTF/glTFFileLoader.js +337 -404
  78. package/glTF/glTFFileLoader.js.map +1 -1
  79. package/glTF/glTFValidation.js +32 -39
  80. package/glTF/glTFValidation.js.map +1 -1
  81. package/legacy/legacy-glTF.js +3 -3
  82. package/legacy/legacy-glTF.js.map +1 -1
  83. package/legacy/legacy-glTF1.js +2 -2
  84. package/legacy/legacy-glTF1.js.map +1 -1
  85. package/legacy/legacy-glTF2.js +12 -12
  86. package/legacy/legacy-glTF2.js.map +1 -1
  87. package/legacy/legacy-objFileLoader.js +2 -2
  88. package/legacy/legacy-objFileLoader.js.map +1 -1
  89. package/legacy/legacy-stlFileLoader.js +2 -2
  90. package/legacy/legacy-stlFileLoader.js.map +1 -1
  91. package/package.json +3 -6
@@ -68,8 +68,8 @@ export var GLTFLoaderState;
68
68
  /**
69
69
  * File loader for loading glTF files into a scene.
70
70
  */
71
- var GLTFFileLoader = /** @class */ (function () {
72
- function GLTFFileLoader() {
71
+ export class GLTFFileLoader {
72
+ constructor() {
73
73
  // --------------
74
74
  // Common options
75
75
  // --------------
@@ -149,7 +149,7 @@ var GLTFFileLoader = /** @class */ (function () {
149
149
  * Function called before loading a url referenced by the asset.
150
150
  * @param url
151
151
  */
152
- this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
152
+ this.preprocessUrlAsync = (url) => Promise.resolve(url);
153
153
  /**
154
154
  * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
155
155
  * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
@@ -227,200 +227,151 @@ var GLTFFileLoader = /** @class */ (function () {
227
227
  /** @hidden */
228
228
  this._endPerformanceCounter = this._endPerformanceCounterDisabled;
229
229
  }
230
- Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
231
- /**
232
- * Raised when the asset has been parsed
233
- */
234
- set: function (callback) {
235
- if (this._onParsedObserver) {
236
- this.onParsedObservable.remove(this._onParsedObserver);
237
- }
238
- this._onParsedObserver = this.onParsedObservable.add(callback);
239
- },
240
- enumerable: false,
241
- configurable: true
242
- });
243
- Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
244
- /**
245
- * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
246
- * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
247
- */
248
- set: function (callback) {
249
- if (this._onMeshLoadedObserver) {
250
- this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
251
- }
252
- this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
253
- },
254
- enumerable: false,
255
- configurable: true
256
- });
257
- Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", {
258
- /**
259
- * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
260
- */
261
- set: function (callback) {
262
- if (this._onTextureLoadedObserver) {
263
- this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
264
- }
265
- this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
266
- },
267
- enumerable: false,
268
- configurable: true
269
- });
270
- Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", {
271
- /**
272
- * Callback raised when the loader creates a material after parsing the glTF properties of the material.
273
- */
274
- set: function (callback) {
275
- if (this._onMaterialLoadedObserver) {
276
- this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
277
- }
278
- this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
279
- },
280
- enumerable: false,
281
- configurable: true
282
- });
283
- Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", {
284
- /**
285
- * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
286
- */
287
- set: function (callback) {
288
- if (this._onCameraLoadedObserver) {
289
- this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
290
- }
291
- this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
292
- },
293
- enumerable: false,
294
- configurable: true
295
- });
296
- Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
297
- /**
298
- * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
299
- * For assets with LODs, raised when all of the LODs are complete.
300
- * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
301
- */
302
- set: function (callback) {
303
- if (this._onCompleteObserver) {
304
- this.onCompleteObservable.remove(this._onCompleteObserver);
305
- }
306
- this._onCompleteObserver = this.onCompleteObservable.add(callback);
307
- },
308
- enumerable: false,
309
- configurable: true
310
- });
311
- Object.defineProperty(GLTFFileLoader.prototype, "onError", {
312
- /**
313
- * Callback raised when an error occurs.
314
- */
315
- set: function (callback) {
316
- if (this._onErrorObserver) {
317
- this.onErrorObservable.remove(this._onErrorObserver);
318
- }
319
- this._onErrorObserver = this.onErrorObservable.add(callback);
320
- },
321
- enumerable: false,
322
- configurable: true
323
- });
324
- Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
325
- /**
326
- * Callback raised after the loader is disposed.
327
- */
328
- set: function (callback) {
329
- if (this._onDisposeObserver) {
330
- this.onDisposeObservable.remove(this._onDisposeObserver);
331
- }
332
- this._onDisposeObserver = this.onDisposeObservable.add(callback);
333
- },
334
- enumerable: false,
335
- configurable: true
336
- });
337
- Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", {
338
- /**
339
- * Callback raised after a loader extension is created.
340
- */
341
- set: function (callback) {
342
- if (this._onExtensionLoadedObserver) {
343
- this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
344
- }
345
- this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
346
- },
347
- enumerable: false,
348
- configurable: true
349
- });
350
- Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
351
- /**
352
- * Defines if the loader logging is enabled.
353
- */
354
- get: function () {
355
- return this._loggingEnabled;
356
- },
357
- set: function (value) {
358
- if (this._loggingEnabled === value) {
359
- return;
360
- }
361
- this._loggingEnabled = value;
362
- if (this._loggingEnabled) {
363
- this._log = this._logEnabled;
364
- }
365
- else {
366
- this._log = this._logDisabled;
367
- }
368
- },
369
- enumerable: false,
370
- configurable: true
371
- });
372
- Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
373
- /**
374
- * Defines if the loader should capture performance counters.
375
- */
376
- get: function () {
377
- return this._capturePerformanceCounters;
378
- },
379
- set: function (value) {
380
- if (this._capturePerformanceCounters === value) {
381
- return;
382
- }
383
- this._capturePerformanceCounters = value;
384
- if (this._capturePerformanceCounters) {
385
- this._startPerformanceCounter = this._startPerformanceCounterEnabled;
386
- this._endPerformanceCounter = this._endPerformanceCounterEnabled;
387
- }
388
- else {
389
- this._startPerformanceCounter = this._startPerformanceCounterDisabled;
390
- this._endPerformanceCounter = this._endPerformanceCounterDisabled;
391
- }
392
- },
393
- enumerable: false,
394
- configurable: true
395
- });
396
- Object.defineProperty(GLTFFileLoader.prototype, "onValidated", {
397
- /**
398
- * Callback raised after a loader extension is created.
399
- */
400
- set: function (callback) {
401
- if (this._onValidatedObserver) {
402
- this.onValidatedObservable.remove(this._onValidatedObserver);
403
- }
404
- this._onValidatedObserver = this.onValidatedObservable.add(callback);
405
- },
406
- enumerable: false,
407
- configurable: true
408
- });
230
+ /**
231
+ * Raised when the asset has been parsed
232
+ */
233
+ set onParsed(callback) {
234
+ if (this._onParsedObserver) {
235
+ this.onParsedObservable.remove(this._onParsedObserver);
236
+ }
237
+ this._onParsedObserver = this.onParsedObservable.add(callback);
238
+ }
239
+ /**
240
+ * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
241
+ * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
242
+ */
243
+ set onMeshLoaded(callback) {
244
+ if (this._onMeshLoadedObserver) {
245
+ this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
246
+ }
247
+ this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
248
+ }
249
+ /**
250
+ * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
251
+ */
252
+ set onTextureLoaded(callback) {
253
+ if (this._onTextureLoadedObserver) {
254
+ this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
255
+ }
256
+ this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
257
+ }
258
+ /**
259
+ * Callback raised when the loader creates a material after parsing the glTF properties of the material.
260
+ */
261
+ set onMaterialLoaded(callback) {
262
+ if (this._onMaterialLoadedObserver) {
263
+ this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
264
+ }
265
+ this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
266
+ }
267
+ /**
268
+ * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
269
+ */
270
+ set onCameraLoaded(callback) {
271
+ if (this._onCameraLoadedObserver) {
272
+ this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
273
+ }
274
+ this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
275
+ }
276
+ /**
277
+ * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
278
+ * For assets with LODs, raised when all of the LODs are complete.
279
+ * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
280
+ */
281
+ set onComplete(callback) {
282
+ if (this._onCompleteObserver) {
283
+ this.onCompleteObservable.remove(this._onCompleteObserver);
284
+ }
285
+ this._onCompleteObserver = this.onCompleteObservable.add(callback);
286
+ }
287
+ /**
288
+ * Callback raised when an error occurs.
289
+ */
290
+ set onError(callback) {
291
+ if (this._onErrorObserver) {
292
+ this.onErrorObservable.remove(this._onErrorObserver);
293
+ }
294
+ this._onErrorObserver = this.onErrorObservable.add(callback);
295
+ }
296
+ /**
297
+ * Callback raised after the loader is disposed.
298
+ */
299
+ set onDispose(callback) {
300
+ if (this._onDisposeObserver) {
301
+ this.onDisposeObservable.remove(this._onDisposeObserver);
302
+ }
303
+ this._onDisposeObserver = this.onDisposeObservable.add(callback);
304
+ }
305
+ /**
306
+ * Callback raised after a loader extension is created.
307
+ */
308
+ set onExtensionLoaded(callback) {
309
+ if (this._onExtensionLoadedObserver) {
310
+ this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
311
+ }
312
+ this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
313
+ }
314
+ /**
315
+ * Defines if the loader logging is enabled.
316
+ */
317
+ get loggingEnabled() {
318
+ return this._loggingEnabled;
319
+ }
320
+ set loggingEnabled(value) {
321
+ if (this._loggingEnabled === value) {
322
+ return;
323
+ }
324
+ this._loggingEnabled = value;
325
+ if (this._loggingEnabled) {
326
+ this._log = this._logEnabled;
327
+ }
328
+ else {
329
+ this._log = this._logDisabled;
330
+ }
331
+ }
332
+ /**
333
+ * Defines if the loader should capture performance counters.
334
+ */
335
+ get capturePerformanceCounters() {
336
+ return this._capturePerformanceCounters;
337
+ }
338
+ set capturePerformanceCounters(value) {
339
+ if (this._capturePerformanceCounters === value) {
340
+ return;
341
+ }
342
+ this._capturePerformanceCounters = value;
343
+ if (this._capturePerformanceCounters) {
344
+ this._startPerformanceCounter = this._startPerformanceCounterEnabled;
345
+ this._endPerformanceCounter = this._endPerformanceCounterEnabled;
346
+ }
347
+ else {
348
+ this._startPerformanceCounter = this._startPerformanceCounterDisabled;
349
+ this._endPerformanceCounter = this._endPerformanceCounterDisabled;
350
+ }
351
+ }
352
+ /**
353
+ * Callback raised after a loader extension is created.
354
+ */
355
+ set onValidated(callback) {
356
+ if (this._onValidatedObserver) {
357
+ this.onValidatedObservable.remove(this._onValidatedObserver);
358
+ }
359
+ this._onValidatedObserver = this.onValidatedObservable.add(callback);
360
+ }
409
361
  /**
410
362
  * Disposes the loader, releases resources during load, and cancels any outstanding requests.
411
363
  */
412
- GLTFFileLoader.prototype.dispose = function () {
364
+ dispose() {
413
365
  if (this._loader) {
414
366
  this._loader.dispose();
415
367
  this._loader = null;
416
368
  }
417
- for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
418
- var request = _a[_i];
369
+ for (const request of this._requests) {
419
370
  request.abort();
420
371
  }
421
372
  this._requests.length = 0;
422
373
  delete this._progressCallback;
423
- this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
374
+ this.preprocessUrlAsync = (url) => Promise.resolve(url);
424
375
  this.onMeshLoadedObservable.clear();
425
376
  this.onSkinLoadedObservable.clear();
426
377
  this.onTextureLoadedObservable.clear();
@@ -430,7 +381,7 @@ var GLTFFileLoader = /** @class */ (function () {
430
381
  this.onExtensionLoadedObservable.clear();
431
382
  this.onDisposeObservable.notifyObservers(undefined);
432
383
  this.onDisposeObservable.clear();
433
- };
384
+ }
434
385
  /**
435
386
  * @param scene
436
387
  * @param fileOrUrl
@@ -440,55 +391,54 @@ var GLTFFileLoader = /** @class */ (function () {
440
391
  * @param onError
441
392
  * @hidden
442
393
  */
443
- GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, onSuccess, onProgress, useArrayBuffer, onError) {
444
- var _this = this;
394
+ loadFile(scene, fileOrUrl, onSuccess, onProgress, useArrayBuffer, onError) {
445
395
  this._progressCallback = onProgress;
446
- var rootUrl = fileOrUrl.name ? "file:" : Tools.GetFolderPath(fileOrUrl);
447
- var fileName = fileOrUrl.name || Tools.GetFilename(fileOrUrl);
396
+ const rootUrl = fileOrUrl.name ? "file:" : Tools.GetFolderPath(fileOrUrl);
397
+ const fileName = fileOrUrl.name || Tools.GetFilename(fileOrUrl);
448
398
  if (useArrayBuffer) {
449
399
  if (this.useRangeRequests) {
450
400
  if (this.validate) {
451
401
  Logger.Warn("glTF validation is not supported when range requests are enabled");
452
402
  }
453
- var fileRequest_1 = {
454
- abort: function () { },
403
+ const fileRequest = {
404
+ abort: () => { },
455
405
  onCompleteObservable: new Observable(),
456
406
  };
457
- var dataBuffer = {
458
- readAsync: function (byteOffset, byteLength) {
459
- return new Promise(function (resolve, reject) {
460
- _this._loadFile(scene, fileOrUrl, function (data) {
407
+ const dataBuffer = {
408
+ readAsync: (byteOffset, byteLength) => {
409
+ return new Promise((resolve, reject) => {
410
+ this._loadFile(scene, fileOrUrl, (data) => {
461
411
  resolve(new Uint8Array(data));
462
- }, true, function (error) {
412
+ }, true, (error) => {
463
413
  reject(error);
464
- }, function (webRequest) {
465
- webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1));
414
+ }, (webRequest) => {
415
+ webRequest.setRequestHeader("Range", `bytes=${byteOffset}-${byteOffset + byteLength - 1}`);
466
416
  });
467
417
  });
468
418
  },
469
419
  byteLength: 0,
470
420
  };
471
- this._unpackBinaryAsync(new DataReader(dataBuffer)).then(function (loaderData) {
472
- fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1);
421
+ this._unpackBinaryAsync(new DataReader(dataBuffer)).then((loaderData) => {
422
+ fileRequest.onCompleteObservable.notifyObservers(fileRequest);
473
423
  onSuccess(loaderData);
474
- }, onError ? function (error) { return onError(undefined, error); } : undefined);
475
- return fileRequest_1;
424
+ }, onError ? (error) => onError(undefined, error) : undefined);
425
+ return fileRequest;
476
426
  }
477
- return this._loadFile(scene, fileOrUrl, function (data) {
478
- _this._validate(scene, data, rootUrl, fileName);
479
- _this._unpackBinaryAsync(new DataReader({
480
- readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); },
427
+ return this._loadFile(scene, fileOrUrl, (data) => {
428
+ this._validate(scene, data, rootUrl, fileName);
429
+ this._unpackBinaryAsync(new DataReader({
430
+ readAsync: (byteOffset, byteLength) => readAsync(data, byteOffset, byteLength),
481
431
  byteLength: data.byteLength,
482
- })).then(function (loaderData) {
432
+ })).then((loaderData) => {
483
433
  onSuccess(loaderData);
484
- }, onError ? function (error) { return onError(undefined, error); } : undefined);
434
+ }, onError ? (error) => onError(undefined, error) : undefined);
485
435
  }, true, onError);
486
436
  }
487
- return this._loadFile(scene, fileOrUrl, function (data) {
488
- _this._validate(scene, data, rootUrl, fileName);
489
- onSuccess({ json: _this._parseJson(data) });
437
+ return this._loadFile(scene, fileOrUrl, (data) => {
438
+ this._validate(scene, data, rootUrl, fileName);
439
+ onSuccess({ json: this._parseJson(data) });
490
440
  }, useArrayBuffer, onError);
491
- };
441
+ }
492
442
  /**
493
443
  * @param meshesNames
494
444
  * @param scene
@@ -498,16 +448,15 @@ var GLTFFileLoader = /** @class */ (function () {
498
448
  * @param fileName
499
449
  * @hidden
500
450
  */
501
- GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
502
- var _this = this;
503
- return Promise.resolve().then(function () {
504
- _this.onParsedObservable.notifyObservers(data);
505
- _this.onParsedObservable.clear();
506
- _this._log("Loading ".concat(fileName || ""));
507
- _this._loader = _this._getLoader(data);
508
- return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
451
+ importMeshAsync(meshesNames, scene, data, rootUrl, onProgress, fileName) {
452
+ return Promise.resolve().then(() => {
453
+ this.onParsedObservable.notifyObservers(data);
454
+ this.onParsedObservable.clear();
455
+ this._log(`Loading ${fileName || ""}`);
456
+ this._loader = this._getLoader(data);
457
+ return this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
509
458
  });
510
- };
459
+ }
511
460
  /**
512
461
  * @param scene
513
462
  * @param data
@@ -516,16 +465,15 @@ var GLTFFileLoader = /** @class */ (function () {
516
465
  * @param fileName
517
466
  * @hidden
518
467
  */
519
- GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
520
- var _this = this;
521
- return Promise.resolve().then(function () {
522
- _this.onParsedObservable.notifyObservers(data);
523
- _this.onParsedObservable.clear();
524
- _this._log("Loading ".concat(fileName || ""));
525
- _this._loader = _this._getLoader(data);
526
- return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
468
+ loadAsync(scene, data, rootUrl, onProgress, fileName) {
469
+ return Promise.resolve().then(() => {
470
+ this.onParsedObservable.notifyObservers(data);
471
+ this.onParsedObservable.clear();
472
+ this._log(`Loading ${fileName || ""}`);
473
+ this._loader = this._getLoader(data);
474
+ return this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
527
475
  });
528
- };
476
+ }
529
477
  /**
530
478
  * @param scene
531
479
  * @param data
@@ -534,29 +482,28 @@ var GLTFFileLoader = /** @class */ (function () {
534
482
  * @param fileName
535
483
  * @hidden
536
484
  */
537
- GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
538
- var _this = this;
539
- return Promise.resolve().then(function () {
540
- _this.onParsedObservable.notifyObservers(data);
541
- _this.onParsedObservable.clear();
542
- _this._log("Loading ".concat(fileName || ""));
543
- _this._loader = _this._getLoader(data);
485
+ loadAssetContainerAsync(scene, data, rootUrl, onProgress, fileName) {
486
+ return Promise.resolve().then(() => {
487
+ this.onParsedObservable.notifyObservers(data);
488
+ this.onParsedObservable.clear();
489
+ this._log(`Loading ${fileName || ""}`);
490
+ this._loader = this._getLoader(data);
544
491
  // Prepare the asset container.
545
- var container = new AssetContainer(scene);
492
+ const container = new AssetContainer(scene);
546
493
  // Get materials/textures when loading to add to container
547
- var materials = [];
548
- _this.onMaterialLoadedObservable.add(function (material) {
494
+ const materials = [];
495
+ this.onMaterialLoadedObservable.add((material) => {
549
496
  materials.push(material);
550
497
  });
551
- var textures = [];
552
- _this.onTextureLoadedObservable.add(function (texture) {
498
+ const textures = [];
499
+ this.onTextureLoadedObservable.add((texture) => {
553
500
  textures.push(texture);
554
501
  });
555
- var cameras = [];
556
- _this.onCameraLoadedObservable.add(function (camera) {
502
+ const cameras = [];
503
+ this.onCameraLoadedObservable.add((camera) => {
557
504
  cameras.push(camera);
558
505
  });
559
- return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) {
506
+ return this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then((result) => {
560
507
  Array.prototype.push.apply(container.geometries, result.geometries);
561
508
  Array.prototype.push.apply(container.meshes, result.meshes);
562
509
  Array.prototype.push.apply(container.particleSystems, result.particleSystems);
@@ -570,79 +517,74 @@ var GLTFFileLoader = /** @class */ (function () {
570
517
  return container;
571
518
  });
572
519
  });
573
- };
520
+ }
574
521
  /**
575
522
  * @param data
576
523
  * @hidden
577
524
  */
578
- GLTFFileLoader.prototype.canDirectLoad = function (data) {
525
+ canDirectLoad(data) {
579
526
  return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) ||
580
527
  data.startsWith("data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
581
528
  data.startsWith("data:;base64," + GLTFFileLoader._MagicBase64Encoded) ||
582
529
  data.startsWith("data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
583
530
  data.startsWith("data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded));
584
- };
531
+ }
585
532
  /**
586
533
  * @param scene
587
534
  * @param data
588
535
  * @hidden
589
536
  */
590
- GLTFFileLoader.prototype.directLoad = function (scene, data) {
537
+ directLoad(scene, data) {
591
538
  if (data.startsWith("base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
592
539
  data.startsWith(";base64," + GLTFFileLoader._MagicBase64Encoded) ||
593
540
  data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
594
541
  data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) {
595
- var arrayBuffer_1 = DecodeBase64UrlToBinary(data);
596
- this._validate(scene, arrayBuffer_1);
542
+ const arrayBuffer = DecodeBase64UrlToBinary(data);
543
+ this._validate(scene, arrayBuffer);
597
544
  return this._unpackBinaryAsync(new DataReader({
598
- readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); },
599
- byteLength: arrayBuffer_1.byteLength,
545
+ readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),
546
+ byteLength: arrayBuffer.byteLength,
600
547
  }));
601
548
  }
602
549
  this._validate(scene, data);
603
550
  return Promise.resolve({ json: this._parseJson(data) });
604
- };
551
+ }
605
552
  /** @hidden */
606
- GLTFFileLoader.prototype.createPlugin = function () {
553
+ createPlugin() {
607
554
  return new GLTFFileLoader();
608
- };
609
- Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
610
- /**
611
- * The loader state or null if the loader is not active.
612
- */
613
- get: function () {
614
- return this._state;
615
- },
616
- enumerable: false,
617
- configurable: true
618
- });
555
+ }
556
+ /**
557
+ * The loader state or null if the loader is not active.
558
+ */
559
+ get loaderState() {
560
+ return this._state;
561
+ }
619
562
  /**
620
563
  * Returns a promise that resolves when the asset is completely loaded.
621
564
  * @returns a promise that resolves when the asset is completely loaded.
622
565
  */
623
- GLTFFileLoader.prototype.whenCompleteAsync = function () {
624
- var _this = this;
625
- return new Promise(function (resolve, reject) {
626
- _this.onCompleteObservable.addOnce(function () {
566
+ whenCompleteAsync() {
567
+ return new Promise((resolve, reject) => {
568
+ this.onCompleteObservable.addOnce(() => {
627
569
  resolve();
628
570
  });
629
- _this.onErrorObservable.addOnce(function (reason) {
571
+ this.onErrorObservable.addOnce((reason) => {
630
572
  reject(reason);
631
573
  });
632
574
  });
633
- };
575
+ }
634
576
  /**
635
577
  * @param state
636
578
  * @hidden
637
579
  */
638
- GLTFFileLoader.prototype._setState = function (state) {
580
+ _setState(state) {
639
581
  if (this._state === state) {
640
582
  return;
641
583
  }
642
584
  this._state = state;
643
585
  this.onLoaderStateChangedObservable.notifyObservers(this._state);
644
586
  this._log(GLTFLoaderState[this._state]);
645
- };
587
+ }
646
588
  /**
647
589
  * @param scene
648
590
  * @param fileOrUrl
@@ -652,73 +594,68 @@ var GLTFFileLoader = /** @class */ (function () {
652
594
  * @param onOpened
653
595
  * @hidden
654
596
  */
655
- GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) {
656
- var _this = this;
657
- var request = scene._loadFile(fileOrUrl, onSuccess, function (event) {
658
- _this._onProgress(event, request);
597
+ _loadFile(scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) {
598
+ const request = scene._loadFile(fileOrUrl, onSuccess, (event) => {
599
+ this._onProgress(event, request);
659
600
  }, true, useArrayBuffer, onError, onOpened);
660
- request.onCompleteObservable.add(function (request) {
661
- _this._requests.splice(_this._requests.indexOf(request), 1);
601
+ request.onCompleteObservable.add((request) => {
602
+ this._requests.splice(this._requests.indexOf(request), 1);
662
603
  });
663
604
  this._requests.push(request);
664
605
  return request;
665
- };
666
- GLTFFileLoader.prototype._onProgress = function (event, request) {
606
+ }
607
+ _onProgress(event, request) {
667
608
  if (!this._progressCallback) {
668
609
  return;
669
610
  }
670
611
  request._lengthComputable = event.lengthComputable;
671
612
  request._loaded = event.loaded;
672
613
  request._total = event.total;
673
- var lengthComputable = true;
674
- var loaded = 0;
675
- var total = 0;
676
- for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
677
- var request_1 = _a[_i];
678
- if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) {
614
+ let lengthComputable = true;
615
+ let loaded = 0;
616
+ let total = 0;
617
+ for (const request of this._requests) {
618
+ if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
679
619
  return;
680
620
  }
681
- lengthComputable = lengthComputable && request_1._lengthComputable;
682
- loaded += request_1._loaded;
683
- total += request_1._total;
621
+ lengthComputable = lengthComputable && request._lengthComputable;
622
+ loaded += request._loaded;
623
+ total += request._total;
684
624
  }
685
625
  this._progressCallback({
686
626
  lengthComputable: lengthComputable,
687
627
  loaded: loaded,
688
628
  total: lengthComputable ? total : 0,
689
629
  });
690
- };
691
- GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) {
692
- var _this = this;
693
- if (rootUrl === void 0) { rootUrl = ""; }
694
- if (fileName === void 0) { fileName = ""; }
630
+ }
631
+ _validate(scene, data, rootUrl = "", fileName = "") {
695
632
  if (!this.validate) {
696
633
  return;
697
634
  }
698
635
  this._startPerformanceCounter("Validate JSON");
699
- GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) {
700
- return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); });
701
- }).then(function (result) {
702
- _this._endPerformanceCounter("Validate JSON");
703
- _this.onValidatedObservable.notifyObservers(result);
704
- _this.onValidatedObservable.clear();
705
- }, function (reason) {
706
- _this._endPerformanceCounter("Validate JSON");
707
- Tools.Warn("Failed to validate: ".concat(reason.message));
708
- _this.onValidatedObservable.clear();
636
+ GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {
637
+ return this.preprocessUrlAsync(rootUrl + uri).then((url) => scene._loadFileAsync(url, undefined, true, true));
638
+ }).then((result) => {
639
+ this._endPerformanceCounter("Validate JSON");
640
+ this.onValidatedObservable.notifyObservers(result);
641
+ this.onValidatedObservable.clear();
642
+ }, (reason) => {
643
+ this._endPerformanceCounter("Validate JSON");
644
+ Tools.Warn(`Failed to validate: ${reason.message}`);
645
+ this.onValidatedObservable.clear();
709
646
  });
710
- };
711
- GLTFFileLoader.prototype._getLoader = function (loaderData) {
712
- var asset = loaderData.json.asset || {};
713
- this._log("Asset version: ".concat(asset.version));
714
- asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion));
715
- asset.generator && this._log("Asset generator: ".concat(asset.generator));
716
- var version = GLTFFileLoader._parseVersion(asset.version);
647
+ }
648
+ _getLoader(loaderData) {
649
+ const asset = loaderData.json.asset || {};
650
+ this._log(`Asset version: ${asset.version}`);
651
+ asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);
652
+ asset.generator && this._log(`Asset generator: ${asset.generator}`);
653
+ const version = GLTFFileLoader._parseVersion(asset.version);
717
654
  if (!version) {
718
655
  throw new Error("Invalid version: " + asset.version);
719
656
  }
720
657
  if (asset.minVersion !== undefined) {
721
- var minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
658
+ const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
722
659
  if (!minVersion) {
723
660
  throw new Error("Invalid minimum version: " + asset.minVersion);
724
661
  }
@@ -726,113 +663,111 @@ var GLTFFileLoader = /** @class */ (function () {
726
663
  throw new Error("Incompatible minimum version: " + asset.minVersion);
727
664
  }
728
665
  }
729
- var createLoaders = {
666
+ const createLoaders = {
730
667
  1: GLTFFileLoader._CreateGLTF1Loader,
731
668
  2: GLTFFileLoader._CreateGLTF2Loader,
732
669
  };
733
- var createLoader = createLoaders[version.major];
670
+ const createLoader = createLoaders[version.major];
734
671
  if (!createLoader) {
735
672
  throw new Error("Unsupported version: " + asset.version);
736
673
  }
737
674
  return createLoader(this);
738
- };
739
- GLTFFileLoader.prototype._parseJson = function (json) {
675
+ }
676
+ _parseJson(json) {
740
677
  this._startPerformanceCounter("Parse JSON");
741
- this._log("JSON length: ".concat(json.length));
742
- var parsed = JSON.parse(json);
678
+ this._log(`JSON length: ${json.length}`);
679
+ const parsed = JSON.parse(json);
743
680
  this._endPerformanceCounter("Parse JSON");
744
681
  return parsed;
745
- };
746
- GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) {
747
- var _this = this;
682
+ }
683
+ _unpackBinaryAsync(dataReader) {
748
684
  this._startPerformanceCounter("Unpack Binary");
749
685
  // Read magic + version + length + json length + json format
750
- return dataReader.loadAsync(20).then(function () {
751
- var Binary = {
686
+ return dataReader.loadAsync(20).then(() => {
687
+ const Binary = {
752
688
  Magic: 0x46546c67,
753
689
  };
754
- var magic = dataReader.readUint32();
690
+ const magic = dataReader.readUint32();
755
691
  if (magic !== Binary.Magic) {
756
692
  throw new RuntimeError("Unexpected magic: " + magic, ErrorCodes.GLTFLoaderUnexpectedMagicError);
757
693
  }
758
- var version = dataReader.readUint32();
759
- if (_this.loggingEnabled) {
760
- _this._log("Binary version: ".concat(version));
694
+ const version = dataReader.readUint32();
695
+ if (this.loggingEnabled) {
696
+ this._log(`Binary version: ${version}`);
761
697
  }
762
- var length = dataReader.readUint32();
698
+ const length = dataReader.readUint32();
763
699
  if (dataReader.buffer.byteLength !== 0 && length !== dataReader.buffer.byteLength) {
764
- throw new Error("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength));
700
+ throw new Error(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);
765
701
  }
766
- var unpacked;
702
+ let unpacked;
767
703
  switch (version) {
768
704
  case 1: {
769
- unpacked = _this._unpackBinaryV1Async(dataReader, length);
705
+ unpacked = this._unpackBinaryV1Async(dataReader, length);
770
706
  break;
771
707
  }
772
708
  case 2: {
773
- unpacked = _this._unpackBinaryV2Async(dataReader, length);
709
+ unpacked = this._unpackBinaryV2Async(dataReader, length);
774
710
  break;
775
711
  }
776
712
  default: {
777
713
  throw new Error("Unsupported version: " + version);
778
714
  }
779
715
  }
780
- _this._endPerformanceCounter("Unpack Binary");
716
+ this._endPerformanceCounter("Unpack Binary");
781
717
  return unpacked;
782
718
  });
783
- };
784
- GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) {
785
- var ContentFormat = {
719
+ }
720
+ _unpackBinaryV1Async(dataReader, length) {
721
+ const ContentFormat = {
786
722
  JSON: 0,
787
723
  };
788
- var contentLength = dataReader.readUint32();
789
- var contentFormat = dataReader.readUint32();
724
+ const contentLength = dataReader.readUint32();
725
+ const contentFormat = dataReader.readUint32();
790
726
  if (contentFormat !== ContentFormat.JSON) {
791
- throw new Error("Unexpected content format: ".concat(contentFormat));
727
+ throw new Error(`Unexpected content format: ${contentFormat}`);
792
728
  }
793
- var bodyLength = length - dataReader.byteOffset;
794
- var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
729
+ const bodyLength = length - dataReader.byteOffset;
730
+ const data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
795
731
  if (bodyLength !== 0) {
796
- var startByteOffset_1 = dataReader.byteOffset;
732
+ const startByteOffset = dataReader.byteOffset;
797
733
  data.bin = {
798
- readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); },
734
+ readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),
799
735
  byteLength: bodyLength,
800
736
  };
801
737
  }
802
738
  return Promise.resolve(data);
803
- };
804
- GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) {
805
- var _this = this;
806
- var ChunkFormat = {
739
+ }
740
+ _unpackBinaryV2Async(dataReader, length) {
741
+ const ChunkFormat = {
807
742
  JSON: 0x4e4f534a,
808
743
  BIN: 0x004e4942,
809
744
  };
810
745
  // Read the JSON chunk header.
811
- var chunkLength = dataReader.readUint32();
812
- var chunkFormat = dataReader.readUint32();
746
+ const chunkLength = dataReader.readUint32();
747
+ const chunkFormat = dataReader.readUint32();
813
748
  if (chunkFormat !== ChunkFormat.JSON) {
814
749
  throw new Error("First chunk format is not JSON");
815
750
  }
816
751
  // Bail if there are no other chunks.
817
752
  if (dataReader.byteOffset + chunkLength === length) {
818
- return dataReader.loadAsync(chunkLength).then(function () {
819
- return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
753
+ return dataReader.loadAsync(chunkLength).then(() => {
754
+ return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };
820
755
  });
821
756
  }
822
757
  // Read the JSON chunk and the length and type of the next chunk.
823
- return dataReader.loadAsync(chunkLength + 8).then(function () {
824
- var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
825
- var readAsync = function () {
826
- var chunkLength = dataReader.readUint32();
827
- var chunkFormat = dataReader.readUint32();
758
+ return dataReader.loadAsync(chunkLength + 8).then(() => {
759
+ const data = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };
760
+ const readAsync = () => {
761
+ const chunkLength = dataReader.readUint32();
762
+ const chunkFormat = dataReader.readUint32();
828
763
  switch (chunkFormat) {
829
764
  case ChunkFormat.JSON: {
830
765
  throw new Error("Unexpected JSON chunk");
831
766
  }
832
767
  case ChunkFormat.BIN: {
833
- var startByteOffset_2 = dataReader.byteOffset;
768
+ const startByteOffset = dataReader.byteOffset;
834
769
  data.bin = {
835
- readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); },
770
+ readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),
836
771
  byteLength: chunkLength,
837
772
  };
838
773
  dataReader.skipBytes(chunkLength);
@@ -851,15 +786,15 @@ var GLTFFileLoader = /** @class */ (function () {
851
786
  };
852
787
  return readAsync();
853
788
  });
854
- };
855
- GLTFFileLoader._parseVersion = function (version) {
789
+ }
790
+ static _parseVersion(version) {
856
791
  if (version === "1.0" || version === "1.0.1") {
857
792
  return {
858
793
  major: 1,
859
794
  minor: 0,
860
795
  };
861
796
  }
862
- var match = (version + "").match(/^(\d+)\.(\d+)/);
797
+ const match = (version + "").match(/^(\d+)\.(\d+)/);
863
798
  if (!match) {
864
799
  return null;
865
800
  }
@@ -867,8 +802,8 @@ var GLTFFileLoader = /** @class */ (function () {
867
802
  major: parseInt(match[1]),
868
803
  minor: parseInt(match[2]),
869
804
  };
870
- };
871
- GLTFFileLoader._compareVersion = function (a, b) {
805
+ }
806
+ static _compareVersion(a, b) {
872
807
  if (a.major > b.major) {
873
808
  return 1;
874
809
  }
@@ -882,53 +817,51 @@ var GLTFFileLoader = /** @class */ (function () {
882
817
  return -1;
883
818
  }
884
819
  return 0;
885
- };
820
+ }
886
821
  /**
887
822
  * @param message
888
823
  * @hidden
889
824
  */
890
- GLTFFileLoader.prototype._logOpen = function (message) {
825
+ _logOpen(message) {
891
826
  this._log(message);
892
827
  this._logIndentLevel++;
893
- };
828
+ }
894
829
  /** @hidden */
895
- GLTFFileLoader.prototype._logClose = function () {
830
+ _logClose() {
896
831
  --this._logIndentLevel;
897
- };
898
- GLTFFileLoader.prototype._logEnabled = function (message) {
899
- var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
900
- Logger.Log("".concat(spaces).concat(message));
901
- };
902
- GLTFFileLoader.prototype._logDisabled = function (message) { };
903
- GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
832
+ }
833
+ _logEnabled(message) {
834
+ const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
835
+ Logger.Log(`${spaces}${message}`);
836
+ }
837
+ _logDisabled(message) { }
838
+ _startPerformanceCounterEnabled(counterName) {
904
839
  Tools.StartPerformanceCounter(counterName);
905
- };
906
- GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { };
907
- GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
840
+ }
841
+ _startPerformanceCounterDisabled(counterName) { }
842
+ _endPerformanceCounterEnabled(counterName) {
908
843
  Tools.EndPerformanceCounter(counterName);
909
- };
910
- GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { };
911
- // ----------
912
- // V1 options
913
- // ----------
914
- /**
915
- * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
916
- * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
917
- * Defaults to true.
918
- * @hidden
919
- */
920
- GLTFFileLoader.IncrementalLoading = true;
921
- /**
922
- * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
923
- * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
924
- * @hidden
925
- */
926
- GLTFFileLoader.HomogeneousCoordinates = false;
927
- GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
928
- GLTFFileLoader._logSpaces = " ";
929
- return GLTFFileLoader;
930
- }());
931
- export { GLTFFileLoader };
844
+ }
845
+ _endPerformanceCounterDisabled(counterName) { }
846
+ }
847
+ // ----------
848
+ // V1 options
849
+ // ----------
850
+ /**
851
+ * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
852
+ * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
853
+ * Defaults to true.
854
+ * @hidden
855
+ */
856
+ GLTFFileLoader.IncrementalLoading = true;
857
+ /**
858
+ * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
859
+ * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
860
+ * @hidden
861
+ */
862
+ GLTFFileLoader.HomogeneousCoordinates = false;
863
+ GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
864
+ GLTFFileLoader._logSpaces = " ";
932
865
  if (SceneLoader) {
933
866
  SceneLoader.RegisterPlugin(new GLTFFileLoader());
934
867
  }