@babylonjs/loaders 5.0.0-alpha.6 → 5.0.0-alpha.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. package/OBJ/index.d.ts +2 -0
  2. package/OBJ/index.js +4 -2
  3. package/OBJ/index.js.map +1 -1
  4. package/OBJ/mtlFileLoader.d.ts +4 -2
  5. package/OBJ/mtlFileLoader.js +7 -6
  6. package/OBJ/mtlFileLoader.js.map +1 -1
  7. package/OBJ/objFileLoader.d.ts +12 -84
  8. package/OBJ/objFileLoader.js +50 -667
  9. package/OBJ/objFileLoader.js.map +1 -1
  10. package/OBJ/objLoadingOptions.d.ts +43 -0
  11. package/OBJ/objLoadingOptions.js +2 -0
  12. package/OBJ/objLoadingOptions.js.map +1 -0
  13. package/OBJ/solidParser.d.ts +153 -0
  14. package/OBJ/solidParser.js +700 -0
  15. package/OBJ/solidParser.js.map +1 -0
  16. package/STL/index.js +1 -1
  17. package/STL/stlFileLoader.d.ts +6 -0
  18. package/STL/stlFileLoader.js +38 -11
  19. package/STL/stlFileLoader.js.map +1 -1
  20. package/glTF/1.0/glTFBinaryExtension.js +4 -4
  21. package/glTF/1.0/glTFLoader.d.ts +4 -4
  22. package/glTF/1.0/glTFLoader.js +60 -55
  23. package/glTF/1.0/glTFLoader.js.map +1 -1
  24. package/glTF/1.0/glTFLoaderInterfaces.d.ts +3 -1
  25. package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
  26. package/glTF/1.0/glTFLoaderUtils.js +6 -6
  27. package/glTF/1.0/glTFMaterialsCommonExtension.js +12 -12
  28. package/glTF/1.0/index.js +5 -5
  29. package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -5
  30. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  31. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +3 -3
  32. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  33. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +1 -5
  34. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +5 -21
  35. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  36. package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
  37. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  38. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +1 -1
  39. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +8 -4
  40. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  41. package/glTF/2.0/Extensions/KHR_lights_punctual.js +9 -8
  42. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  43. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +2 -2
  44. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +30 -0
  45. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +46 -0
  46. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -0
  47. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +1 -2
  48. package/glTF/2.0/Extensions/KHR_materials_ior.js +3 -4
  49. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  50. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +3 -4
  51. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  52. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -1
  53. package/glTF/2.0/Extensions/KHR_materials_sheen.js +3 -4
  54. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +1 -2
  56. package/glTF/2.0/Extensions/KHR_materials_specular.js +12 -6
  57. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  58. package/glTF/2.0/Extensions/KHR_materials_translucency.js +6 -6
  59. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  60. package/glTF/2.0/Extensions/KHR_materials_transmission.js +92 -84
  61. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  62. package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
  63. package/glTF/2.0/Extensions/KHR_materials_variants.js +86 -22
  64. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  65. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +31 -0
  66. package/glTF/2.0/Extensions/KHR_materials_volume.js +79 -0
  67. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -0
  68. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +1 -1
  69. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +1 -2
  70. package/glTF/2.0/Extensions/KHR_texture_basisu.js +3 -4
  71. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  72. package/glTF/2.0/Extensions/KHR_texture_transform.js +2 -2
  73. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +2 -2
  74. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +3 -3
  75. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  76. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +6 -7
  77. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  78. package/glTF/2.0/Extensions/MSFT_lod.d.ts +2 -1
  79. package/glTF/2.0/Extensions/MSFT_lod.js +48 -8
  80. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  81. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +2 -2
  82. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +2 -2
  83. package/glTF/2.0/Extensions/index.d.ts +2 -0
  84. package/glTF/2.0/Extensions/index.js +26 -24
  85. package/glTF/2.0/Extensions/index.js.map +1 -1
  86. package/glTF/2.0/glTFLoader.d.ts +5 -10
  87. package/glTF/2.0/glTFLoader.js +125 -92
  88. package/glTF/2.0/glTFLoader.js.map +1 -1
  89. package/glTF/2.0/glTFLoaderInterfaces.d.ts +4 -2
  90. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  91. package/glTF/2.0/index.d.ts +1 -1
  92. package/glTF/2.0/index.js +4 -4
  93. package/glTF/2.0/index.js.map +1 -1
  94. package/glTF/glTFFileLoader.d.ts +15 -9
  95. package/glTF/glTFFileLoader.js +62 -76
  96. package/glTF/glTFFileLoader.js.map +1 -1
  97. package/glTF/glTFValidation.js +1 -1
  98. package/glTF/glTFValidation.js.map +1 -1
  99. package/glTF/index.d.ts +2 -2
  100. package/glTF/index.js +4 -4
  101. package/glTF/index.js.map +1 -1
  102. package/index.d.ts +3 -3
  103. package/index.js +3 -3
  104. package/index.js.map +1 -1
  105. package/legacy/legacy-glTF.js +4 -4
  106. package/legacy/legacy-glTF1.d.ts +1 -1
  107. package/legacy/legacy-glTF1.js +1 -1
  108. package/legacy/legacy-glTF1.js.map +1 -1
  109. package/legacy/legacy-glTF1FileLoader.js +2 -2
  110. package/legacy/legacy-glTF2.d.ts +1 -1
  111. package/legacy/legacy-glTF2.js +3 -3
  112. package/legacy/legacy-glTF2.js.map +1 -1
  113. package/legacy/legacy-glTF2FileLoader.js +2 -2
  114. package/legacy/legacy-glTFFileLoader.js +3 -3
  115. package/legacy/legacy-objFileLoader.d.ts +1 -1
  116. package/legacy/legacy-objFileLoader.js +2 -2
  117. package/legacy/legacy-objFileLoader.js.map +1 -1
  118. package/legacy/legacy-stlFileLoader.d.ts +1 -1
  119. package/legacy/legacy-stlFileLoader.js +2 -2
  120. package/legacy/legacy-stlFileLoader.js.map +1 -1
  121. package/legacy/legacy.js +6 -6
  122. package/package.json +16 -4
@@ -1,5 +1,5 @@
1
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
2
- import { GLTFLoader } from "../glTFLoader";
1
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
+ import { GLTFLoader } from "../glTFLoader.js";
3
3
  var NAME = "MSFT_sRGBFactors";
4
4
  /** @hidden */
5
5
  var MSFT_sRGBFactors = /** @class */ (function () {
@@ -7,12 +7,14 @@ export * from "./KHR_lights_punctual";
7
7
  export * from "./KHR_materials_pbrSpecularGlossiness";
8
8
  export * from "./KHR_materials_unlit";
9
9
  export * from "./KHR_materials_clearcoat";
10
+ export * from "./KHR_materials_emissive_strength";
10
11
  export * from "./KHR_materials_sheen";
11
12
  export * from "./KHR_materials_specular";
12
13
  export * from "./KHR_materials_ior";
13
14
  export * from "./KHR_materials_variants";
14
15
  export * from "./KHR_materials_transmission";
15
16
  export * from "./KHR_materials_translucency";
17
+ export * from "./KHR_materials_volume";
16
18
  export * from "./KHR_mesh_quantization";
17
19
  export * from "./KHR_texture_basisu";
18
20
  export * from "./KHR_texture_transform";
@@ -1,25 +1,27 @@
1
- export * from "./EXT_lights_image_based";
2
- export * from "./EXT_mesh_gpu_instancing";
3
- export * from "./EXT_meshopt_compression";
4
- export * from "./EXT_texture_webp";
5
- export * from "./KHR_draco_mesh_compression";
6
- export * from "./KHR_lights_punctual";
7
- export * from "./KHR_materials_pbrSpecularGlossiness";
8
- export * from "./KHR_materials_unlit";
9
- export * from "./KHR_materials_clearcoat";
10
- export * from "./KHR_materials_sheen";
11
- export * from "./KHR_materials_specular";
12
- export * from "./KHR_materials_ior";
13
- export * from "./KHR_materials_variants";
14
- export * from "./KHR_materials_transmission";
15
- export * from "./KHR_materials_translucency";
16
- export * from "./KHR_mesh_quantization";
17
- export * from "./KHR_texture_basisu";
18
- export * from "./KHR_texture_transform";
19
- export * from "./KHR_xmp_json_ld";
20
- export * from "./MSFT_audio_emitter";
21
- export * from "./MSFT_lod";
22
- export * from "./MSFT_minecraftMesh";
23
- export * from "./MSFT_sRGBFactors";
24
- export * from "./ExtrasAsMetadata";
1
+ export * from "./EXT_lights_image_based.js";
2
+ export * from "./EXT_mesh_gpu_instancing.js";
3
+ export * from "./EXT_meshopt_compression.js";
4
+ export * from "./EXT_texture_webp.js";
5
+ export * from "./KHR_draco_mesh_compression.js";
6
+ export * from "./KHR_lights_punctual.js";
7
+ export * from "./KHR_materials_pbrSpecularGlossiness.js";
8
+ export * from "./KHR_materials_unlit.js";
9
+ export * from "./KHR_materials_clearcoat.js";
10
+ export * from "./KHR_materials_emissive_strength.js";
11
+ export * from "./KHR_materials_sheen.js";
12
+ export * from "./KHR_materials_specular.js";
13
+ export * from "./KHR_materials_ior.js";
14
+ export * from "./KHR_materials_variants.js";
15
+ export * from "./KHR_materials_transmission.js";
16
+ export * from "./KHR_materials_translucency.js";
17
+ export * from "./KHR_materials_volume.js";
18
+ export * from "./KHR_mesh_quantization.js";
19
+ export * from "./KHR_texture_basisu.js";
20
+ export * from "./KHR_texture_transform.js";
21
+ export * from "./KHR_xmp_json_ld.js";
22
+ export * from "./MSFT_audio_emitter.js";
23
+ export * from "./MSFT_lod.js";
24
+ export * from "./MSFT_minecraftMesh.js";
25
+ export * from "./MSFT_sRGBFactors.js";
26
+ export * from "./ExtrasAsMetadata.js";
25
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
@@ -11,10 +11,11 @@ import { Scene } from "@babylonjs/core/scene";
11
11
  import { IProperty } from "babylonjs-gltf2interface";
12
12
  import { IGLTF, ISampler, INode, IScene, IMesh, IAccessor, ICamera, IAnimation, IAnimationChannel, IBuffer, IBufferView, IMaterial, ITextureInfo, ITexture, IImage, IMeshPrimitive, IArrayItem as IArrItem } from "./glTFLoaderInterfaces";
13
13
  import { IGLTFLoaderExtension } from "./glTFLoaderExtension";
14
- import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "../glTFFileLoader";
14
+ import { IGLTFLoader, GLTFFileLoader, IGLTFLoaderData } from "../glTFFileLoader";
15
15
  import { IAnimatable } from '@babylonjs/core/Animations/animatable.interface';
16
16
  import { IDataBuffer } from '@babylonjs/core/Misc/dataReader';
17
17
  import { Light } from '@babylonjs/core/Lights/light';
18
+ import { AssetContainer } from "@babylonjs/core/assetContainer";
18
19
  /**
19
20
  * Helper class for working with arrays when loading the glTF asset
20
21
  */
@@ -40,14 +41,13 @@ export declare class GLTFLoader implements IGLTFLoader {
40
41
  /** @hidden */
41
42
  _completePromises: Promise<any>[];
42
43
  /** @hidden */
43
- _forAssetContainer: boolean;
44
+ _assetContainer: Nullable<AssetContainer>;
44
45
  /** Storage */
45
46
  _babylonLights: Light[];
46
47
  /** @hidden */
47
48
  _disableInstancedMesh: number;
48
49
  private _disposed;
49
50
  private _parent;
50
- private _state;
51
51
  private _extensions;
52
52
  private _rootUrl;
53
53
  private _fileName;
@@ -74,10 +74,6 @@ export declare class GLTFLoader implements IGLTFLoader {
74
74
  * @returns A boolean indicating whether the extension has been unregistered
75
75
  */
76
76
  static UnregisterExtension(name: string): boolean;
77
- /**
78
- * The loader state.
79
- */
80
- get state(): Nullable<GLTFLoaderState>;
81
77
  /**
82
78
  * The object that represents the glTF JSON.
83
79
  */
@@ -103,7 +99,7 @@ export declare class GLTFLoader implements IGLTFLoader {
103
99
  /** @hidden */
104
100
  dispose(): void;
105
101
  /** @hidden */
106
- importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
102
+ importMeshAsync(meshesNames: any, scene: Scene, container: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
107
103
  /** @hidden */
108
104
  loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
109
105
  private _loadAsync;
@@ -111,7 +107,6 @@ export declare class GLTFLoader implements IGLTFLoader {
111
107
  private _setupData;
112
108
  private _loadExtensions;
113
109
  private _checkExtensions;
114
- private _setState;
115
110
  private _createRootNode;
116
111
  /**
117
112
  * Loads a glTF scene.
@@ -255,7 +250,7 @@ export declare class GLTFLoader implements IGLTFLoader {
255
250
  /** @hidden */
256
251
  _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
257
252
  /** @hidden */
258
- _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
253
+ _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any, useSRGBBuffer?: boolean): Promise<BaseTexture>;
259
254
  private _loadSampler;
260
255
  /**
261
256
  * Loads a glTF image.
@@ -1,29 +1,29 @@
1
- import { Deferred } from "@babylonjs/core/Misc/deferred";
2
- import { Quaternion, Vector3, Matrix } from "@babylonjs/core/Maths/math.vector";
3
- import { Color3 } from '@babylonjs/core/Maths/math.color';
4
- import { Tools } from "@babylonjs/core/Misc/tools";
5
- import { Camera } from "@babylonjs/core/Cameras/camera";
6
- import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
7
- import { AnimationGroup } from "@babylonjs/core/Animations/animationGroup";
8
- import { Animation } from "@babylonjs/core/Animations/animation";
9
- import { Bone } from "@babylonjs/core/Bones/bone";
10
- import { Skeleton } from "@babylonjs/core/Bones/skeleton";
11
- import { Material } from "@babylonjs/core/Materials/material";
12
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
13
- import { Texture } from "@babylonjs/core/Materials/Textures/texture";
14
- import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
15
- import { Buffer, VertexBuffer } from "@babylonjs/core/Meshes/buffer";
16
- import { Geometry } from "@babylonjs/core/Meshes/geometry";
17
- import { Mesh } from "@babylonjs/core/Meshes/mesh";
18
- import { MorphTarget } from "@babylonjs/core/Morph/morphTarget";
19
- import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager";
20
- import { GLTFFileLoader, GLTFLoaderState, GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode } from "../glTFFileLoader";
21
- import { AnimationKeyInterpolation } from '@babylonjs/core/Animations/animationKey';
22
- import { LoadFileError } from '@babylonjs/core/Misc/fileTools';
23
- import { Logger } from '@babylonjs/core/Misc/logger';
24
- import { TmpVectors } from '@babylonjs/core/Maths/math.vector';
25
- import { BoundingInfo } from '@babylonjs/core/Culling/boundingInfo';
26
- import { StringTools } from '@babylonjs/core/Misc/stringTools';
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';
4
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
5
+ import { Camera } from "@babylonjs/core/Cameras/camera.js";
6
+ import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera.js";
7
+ import { AnimationGroup } from "@babylonjs/core/Animations/animationGroup.js";
8
+ import { Animation } from "@babylonjs/core/Animations/animation.js";
9
+ import { Bone } from "@babylonjs/core/Bones/bone.js";
10
+ import { Skeleton } from "@babylonjs/core/Bones/skeleton.js";
11
+ import { Material } from "@babylonjs/core/Materials/material.js";
12
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
13
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
14
+ import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
15
+ import { Buffer, VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
16
+ import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
17
+ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
18
+ import { MorphTarget } from "@babylonjs/core/Morph/morphTarget.js";
19
+ import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager.js";
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';
27
27
  /**
28
28
  * Helper class for working with arrays when loading the glTF asset
29
29
  */
@@ -66,13 +66,12 @@ var GLTFLoader = /** @class */ (function () {
66
66
  /** @hidden */
67
67
  this._completePromises = new Array();
68
68
  /** @hidden */
69
- this._forAssetContainer = false;
69
+ this._assetContainer = null;
70
70
  /** Storage */
71
71
  this._babylonLights = [];
72
72
  /** @hidden */
73
73
  this._disableInstancedMesh = 0;
74
74
  this._disposed = false;
75
- this._state = null;
76
75
  this._extensions = new Array();
77
76
  this._defaultBabylonMaterialData = {};
78
77
  this._parent = parent;
@@ -102,16 +101,6 @@ var GLTFLoader = /** @class */ (function () {
102
101
  delete GLTFLoader._RegisteredExtensions[name];
103
102
  return true;
104
103
  };
105
- Object.defineProperty(GLTFLoader.prototype, "state", {
106
- /**
107
- * The loader state.
108
- */
109
- get: function () {
110
- return this._state;
111
- },
112
- enumerable: false,
113
- configurable: true
114
- });
115
104
  Object.defineProperty(GLTFLoader.prototype, "gltf", {
116
105
  /**
117
106
  * The object that represents the glTF JSON.
@@ -180,12 +169,12 @@ var GLTFLoader = /** @class */ (function () {
180
169
  this._parent.dispose();
181
170
  };
182
171
  /** @hidden */
183
- GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress, fileName) {
172
+ GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) {
184
173
  var _this = this;
185
174
  if (fileName === void 0) { fileName = ""; }
186
175
  return Promise.resolve().then(function () {
187
176
  _this._babylonScene = scene;
188
- _this._forAssetContainer = forAssetContainer;
177
+ _this._assetContainer = container;
189
178
  _this._loadData(data);
190
179
  var nodes = null;
191
180
  if (meshesNames) {
@@ -242,7 +231,7 @@ var GLTFLoader = /** @class */ (function () {
242
231
  var loadingToCompleteCounterName = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.COMPLETE];
243
232
  _this._parent._startPerformanceCounter(loadingToReadyCounterName);
244
233
  _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
245
- _this._setState(GLTFLoaderState.LOADING);
234
+ _this._parent._setState(GLTFLoaderState.LOADING);
246
235
  _this._extensionsOnLoading();
247
236
  var promises = new Array();
248
237
  // Block the marking of materials dirty until the scene is loaded.
@@ -276,7 +265,7 @@ var GLTFLoader = /** @class */ (function () {
276
265
  _this._rootBabylonMesh.setEnabled(true);
277
266
  }
278
267
  _this._extensionsOnReady();
279
- _this._setState(GLTFLoaderState.READY);
268
+ _this._parent._setState(GLTFLoaderState.READY);
280
269
  _this._startAnimations();
281
270
  return resultFunc();
282
271
  });
@@ -286,7 +275,7 @@ var GLTFLoader = /** @class */ (function () {
286
275
  if (!_this._disposed) {
287
276
  Promise.all(_this._completePromises).then(function () {
288
277
  _this._parent._endPerformanceCounter(loadingToCompleteCounterName);
289
- _this._setState(GLTFLoaderState.COMPLETE);
278
+ _this._parent._setState(GLTFLoaderState.COMPLETE);
290
279
  _this._parent.onCompleteObservable.notifyObservers(undefined);
291
280
  _this._parent.onCompleteObservable.clear();
292
281
  _this.dispose();
@@ -385,13 +374,10 @@ var GLTFLoader = /** @class */ (function () {
385
374
  }
386
375
  }
387
376
  };
388
- GLTFLoader.prototype._setState = function (state) {
389
- this._state = state;
390
- this.log(GLTFLoaderState[this._state]);
391
- };
392
377
  GLTFLoader.prototype._createRootNode = function () {
393
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
378
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
394
379
  this._rootBabylonMesh = new Mesh("__root__", this._babylonScene);
380
+ this._rootBabylonMesh._parentContainer = this._assetContainer;
395
381
  this._babylonScene._blockEntityCollection = false;
396
382
  this._rootBabylonMesh.setEnabled(false);
397
383
  var rootNode = {
@@ -604,8 +590,9 @@ var GLTFLoader = /** @class */ (function () {
604
590
  };
605
591
  if (node.mesh == undefined) {
606
592
  var nodeName = node.name || "node" + node.index;
607
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
593
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
608
594
  node._babylonTransformNode = new TransformNode(nodeName, this._babylonScene);
595
+ node._babylonTransformNode._parentContainer = this._assetContainer;
609
596
  this._babylonScene._blockEntityCollection = false;
610
597
  loadNode(node._babylonTransformNode);
611
598
  }
@@ -646,8 +633,9 @@ var GLTFLoader = /** @class */ (function () {
646
633
  }));
647
634
  }
648
635
  else {
649
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
636
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
650
637
  node._babylonTransformNode = new TransformNode(name, this._babylonScene);
638
+ node._babylonTransformNode._parentContainer = this._assetContainer;
651
639
  this._babylonScene._blockEntityCollection = false;
652
640
  node._primitiveBabylonMeshes = [];
653
641
  for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) {
@@ -689,20 +677,25 @@ var GLTFLoader = /** @class */ (function () {
689
677
  var babylonAbstractMesh;
690
678
  var promise;
691
679
  if (shouldInstance && primitive._instanceData) {
680
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
692
681
  babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name);
682
+ babylonAbstractMesh._parentContainer = this._assetContainer;
683
+ this._babylonScene._blockEntityCollection = false;
693
684
  promise = primitive._instanceData.promise;
694
685
  }
695
686
  else {
696
687
  var promises = new Array();
697
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
688
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
698
689
  var babylonMesh_1 = new Mesh(name, this._babylonScene);
690
+ babylonMesh_1._parentContainer = this._assetContainer;
699
691
  this._babylonScene._blockEntityCollection = false;
700
692
  babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation;
701
693
  this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1);
702
694
  promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) {
703
695
  return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () {
704
- _this._babylonScene._blockEntityCollection = _this._forAssetContainer;
696
+ _this._babylonScene._blockEntityCollection = !!_this._assetContainer;
705
697
  babylonGeometry.applyToMesh(babylonMesh_1);
698
+ babylonGeometry._parentContainer = _this._assetContainer;
706
699
  _this._babylonScene._blockEntityCollection = false;
707
700
  });
708
701
  }));
@@ -773,6 +766,27 @@ var GLTFLoader = /** @class */ (function () {
773
766
  if (babylonVertexBuffer.getKind() === VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {
774
767
  var mmin = accessor.min, mmax = accessor.max;
775
768
  if (mmin !== undefined && mmax !== undefined) {
769
+ if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
770
+ var divider = 1;
771
+ switch (accessor.componentType) {
772
+ case 5120 /* BYTE */:
773
+ divider = 127.0;
774
+ break;
775
+ case 5121 /* UNSIGNED_BYTE */:
776
+ divider = 255.0;
777
+ break;
778
+ case 5122 /* SHORT */:
779
+ divider = 32767.0;
780
+ break;
781
+ case 5123 /* UNSIGNED_SHORT */:
782
+ divider = 65535.0;
783
+ break;
784
+ }
785
+ for (var i = 0; i < 3; ++i) {
786
+ mmin[i] = Math.max(mmin[i] / divider, -1.0);
787
+ mmax[i] = Math.max(mmax[i] / divider, -1.0);
788
+ }
789
+ }
776
790
  var min = TmpVectors.Vector3[0], max = TmpVectors.Vector3[1];
777
791
  min.copyFromFloats.apply(min, mmin);
778
792
  max.copyFromFloats.apply(max, mmax);
@@ -794,6 +808,10 @@ var GLTFLoader = /** @class */ (function () {
794
808
  loadAttribute("TANGENT", VertexBuffer.TangentKind);
795
809
  loadAttribute("TEXCOORD_0", VertexBuffer.UVKind);
796
810
  loadAttribute("TEXCOORD_1", VertexBuffer.UV2Kind);
811
+ loadAttribute("TEXCOORD_2", VertexBuffer.UV3Kind);
812
+ loadAttribute("TEXCOORD_3", VertexBuffer.UV4Kind);
813
+ loadAttribute("TEXCOORD_4", VertexBuffer.UV5Kind);
814
+ loadAttribute("TEXCOORD_5", VertexBuffer.UV6Kind);
797
815
  loadAttribute("JOINTS_0", VertexBuffer.MatricesIndicesKind);
798
816
  loadAttribute("WEIGHTS_0", VertexBuffer.MatricesWeightsKind);
799
817
  loadAttribute("JOINTS_1", VertexBuffer.MatricesIndicesExtraKind);
@@ -819,6 +837,7 @@ var GLTFLoader = /** @class */ (function () {
819
837
  }
820
838
  var targetNames = mesh.extras ? mesh.extras.targetNames : null;
821
839
  babylonMesh.morphTargetManager = new MorphTargetManager(babylonMesh.getScene());
840
+ babylonMesh.morphTargetManager.areUpdatesFrozen = true;
822
841
  for (var index = 0; index < primitive.targets.length; index++) {
823
842
  var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0;
824
843
  var name_4 = targetNames ? targetNames[index] : "morphTarget" + index;
@@ -836,7 +855,9 @@ var GLTFLoader = /** @class */ (function () {
836
855
  var babylonMorphTarget = morphTargetManager.getTarget(index);
837
856
  promises.push(this._loadMorphTargetVertexDataAsync(context + "/targets/" + index, babylonGeometry, primitive.targets[index], babylonMorphTarget));
838
857
  }
839
- return Promise.all(promises).then(function () { });
858
+ return Promise.all(promises).then(function () {
859
+ morphTargetManager.areUpdatesFrozen = false;
860
+ });
840
861
  };
841
862
  GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) {
842
863
  var _this = this;
@@ -928,8 +949,9 @@ var GLTFLoader = /** @class */ (function () {
928
949
  return skin._data.promise;
929
950
  }
930
951
  var skeletonId = "skeleton" + skin.index;
931
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
952
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
932
953
  var babylonSkeleton = new Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
954
+ babylonSkeleton._parentContainer = this._assetContainer;
933
955
  this._babylonScene._blockEntityCollection = false;
934
956
  // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
935
957
  babylonSkeleton.overrideMesh = this._rootBabylonMesh;
@@ -988,7 +1010,6 @@ var GLTFLoader = /** @class */ (function () {
988
1010
  if (babylonParentBone) {
989
1011
  baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
990
1012
  }
991
- babylonBone.setBindPose(baseMatrix);
992
1013
  babylonBone.updateMatrix(baseMatrix, false, false);
993
1014
  babylonBone._updateDifferenceMatrix(undefined, false);
994
1015
  }
@@ -1013,8 +1034,9 @@ var GLTFLoader = /** @class */ (function () {
1013
1034
  }
1014
1035
  var promises = new Array();
1015
1036
  this.logOpen(context + " " + (camera.name || ""));
1016
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
1037
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
1017
1038
  var babylonCamera = new FreeCamera(camera.name || "camera" + camera.index, Vector3.Zero(), this._babylonScene, false);
1039
+ babylonCamera._parentContainer = this._assetContainer;
1018
1040
  this._babylonScene._blockEntityCollection = false;
1019
1041
  babylonCamera.ignoreParentScaling = true;
1020
1042
  babylonCamera.rotation = new Vector3(0, Math.PI, 0);
@@ -1082,8 +1104,9 @@ var GLTFLoader = /** @class */ (function () {
1082
1104
  if (promise) {
1083
1105
  return promise;
1084
1106
  }
1085
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
1107
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
1086
1108
  var babylonAnimationGroup = new AnimationGroup(animation.name || "animation" + animation.index, this._babylonScene);
1109
+ babylonAnimationGroup._parentContainer = this._assetContainer;
1087
1110
  this._babylonScene._blockEntityCollection = false;
1088
1111
  animation._babylonAnimationGroup = babylonAnimationGroup;
1089
1112
  var promises = new Array();
@@ -1439,36 +1462,33 @@ var GLTFLoader = /** @class */ (function () {
1439
1462
  };
1440
1463
  GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) {
1441
1464
  var _this = this;
1442
- if (accessor._babylonVertexBuffer) {
1443
- return accessor._babylonVertexBuffer;
1465
+ var _a;
1466
+ if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) {
1467
+ return accessor._babylonVertexBuffer[kind];
1444
1468
  }
1445
- if (accessor.sparse) {
1446
- accessor._babylonVertexBuffer = this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
1447
- return new VertexBuffer(_this._babylonScene.getEngine(), data, kind, false);
1448
- });
1469
+ if (!accessor._babylonVertexBuffer) {
1470
+ accessor._babylonVertexBuffer = {};
1449
1471
  }
1450
- // HACK: If byte offset is not a multiple of component type byte length then load as a float array instead of using Babylon buffers.
1451
- else if (accessor.byteOffset && accessor.byteOffset % VertexBuffer.GetTypeByteLength(accessor.componentType) !== 0) {
1452
- Logger.Warn("Accessor byte offset is not a multiple of component type byte length");
1453
- accessor._babylonVertexBuffer = this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
1472
+ if (accessor.sparse) {
1473
+ accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) {
1454
1474
  return new VertexBuffer(_this._babylonScene.getEngine(), data, kind, false);
1455
1475
  });
1456
1476
  }
1457
1477
  // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short.
1458
1478
  // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly.
1459
1479
  else if (kind === VertexBuffer.MatricesIndicesKind || kind === VertexBuffer.MatricesIndicesExtraKind) {
1460
- accessor._babylonVertexBuffer = this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
1480
+ accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) {
1461
1481
  return new VertexBuffer(_this._babylonScene.getEngine(), data, kind, false);
1462
1482
  });
1463
1483
  }
1464
1484
  else {
1465
1485
  var bufferView_2 = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
1466
- accessor._babylonVertexBuffer = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
1486
+ accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
1467
1487
  var size = GLTFLoader._GetNumComponents(context, accessor.type);
1468
1488
  return new VertexBuffer(_this._babylonScene.getEngine(), babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true);
1469
1489
  });
1470
1490
  }
1471
- return accessor._babylonVertexBuffer;
1491
+ return accessor._babylonVertexBuffer[kind];
1472
1492
  };
1473
1493
  GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) {
1474
1494
  if (!(babylonMaterial instanceof PBRMaterial)) {
@@ -1541,8 +1561,9 @@ var GLTFLoader = /** @class */ (function () {
1541
1561
  });
1542
1562
  };
1543
1563
  GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) {
1544
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
1564
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
1545
1565
  var babylonMaterial = new PBRMaterial(name, this._babylonScene);
1566
+ babylonMaterial._parentContainer = this._assetContainer;
1546
1567
  this._babylonScene._blockEntityCollection = false;
1547
1568
  // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation;
1548
1569
  babylonMaterial.fillMode = babylonDrawMode;
@@ -1692,7 +1713,7 @@ var GLTFLoader = /** @class */ (function () {
1692
1713
  return extensionPromise;
1693
1714
  }
1694
1715
  this.logOpen("" + context);
1695
- if (textureInfo.texCoord >= 2) {
1716
+ if (textureInfo.texCoord >= 6) {
1696
1717
  throw new Error(context + "/texCoord: Invalid value (" + textureInfo.texCoord + ")");
1697
1718
  }
1698
1719
  var texture = ArrayItem.Get(context + "/index", this._gltf.textures, textureInfo.index);
@@ -1716,27 +1737,38 @@ var GLTFLoader = /** @class */ (function () {
1716
1737
  this.logOpen(context + " " + (texture.name || ""));
1717
1738
  var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(context + "/sampler", this._gltf.samplers, texture.sampler));
1718
1739
  var image = ArrayItem.Get(context + "/source", this._gltf.images, texture.source);
1719
- var promise = this._createTextureAsync(context, sampler, image, assign);
1740
+ var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData);
1720
1741
  this.logClose();
1721
1742
  return promise;
1722
1743
  };
1723
1744
  /** @hidden */
1724
- GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions) {
1745
+ GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) {
1725
1746
  var _this = this;
1726
1747
  if (assign === void 0) { assign = function () { }; }
1727
1748
  var samplerData = this._loadSampler("/samplers/" + sampler.index, sampler);
1728
1749
  var promises = new Array();
1729
1750
  var deferred = new Deferred();
1730
- this._babylonScene._blockEntityCollection = this._forAssetContainer;
1731
- var babylonTexture = new Texture(null, this._babylonScene, samplerData.noMipMaps, false, samplerData.samplingMode, function () {
1732
- if (!_this._disposed) {
1733
- deferred.resolve();
1734
- }
1735
- }, function (message, exception) {
1736
- if (!_this._disposed) {
1737
- deferred.reject(new Error(context + ": " + ((exception && exception.message) ? exception.message : message || "Failed to load texture")));
1738
- }
1739
- }, undefined, undefined, undefined, image.mimeType, textureLoaderOptions);
1751
+ this._babylonScene._blockEntityCollection = !!this._assetContainer;
1752
+ var textureCreationOptions = {
1753
+ noMipmap: samplerData.noMipMaps,
1754
+ invertY: false,
1755
+ samplingMode: samplerData.samplingMode,
1756
+ onLoad: function () {
1757
+ if (!_this._disposed) {
1758
+ deferred.resolve();
1759
+ }
1760
+ },
1761
+ onError: function (message, exception) {
1762
+ if (!_this._disposed) {
1763
+ deferred.reject(new Error(context + ": " + ((exception && exception.message) ? exception.message : message || "Failed to load texture")));
1764
+ }
1765
+ },
1766
+ mimeType: image.mimeType,
1767
+ loaderOptions: textureLoaderOptions,
1768
+ useSRGBBuffer: !!useSRGBBuffer && this._parent.useSRGBBuffers,
1769
+ };
1770
+ var babylonTexture = new Texture(null, this._babylonScene, textureCreationOptions);
1771
+ babylonTexture._parentContainer = this._assetContainer;
1740
1772
  this._babylonScene._blockEntityCollection = false;
1741
1773
  promises.push(deferred.promise);
1742
1774
  promises.push(this.loadImageAsync("/images/" + image.index, image).then(function (data) {
@@ -1798,15 +1830,15 @@ var GLTFLoader = /** @class */ (function () {
1798
1830
  if (!GLTFLoader._ValidateUri(uri)) {
1799
1831
  throw new Error(context + ": '" + uri + "' is invalid");
1800
1832
  }
1801
- if (Tools.IsBase64(uri)) {
1802
- var data = new Uint8Array(Tools.DecodeBase64(uri));
1833
+ if (IsBase64DataUrl(uri)) {
1834
+ var data = new Uint8Array(DecodeBase64UrlToBinary(uri));
1803
1835
  this.log(context + ": Decoded " + uri.substr(0, 64) + "... (" + data.length + " bytes)");
1804
1836
  return Promise.resolve(data);
1805
1837
  }
1806
1838
  this.log(context + ": Loading " + uri);
1807
1839
  return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) {
1808
1840
  return new Promise(function (resolve, reject) {
1809
- _this._parent._loadFile(url, _this._babylonScene, function (data) {
1841
+ _this._parent._loadFile(_this._babylonScene, url, function (data) {
1810
1842
  if (!_this._disposed) {
1811
1843
  _this.log(context + ": Loaded " + uri + " (" + data.byteLength + " bytes)");
1812
1844
  resolve(new Uint8Array(data));
@@ -1889,12 +1921,13 @@ var GLTFLoader = /** @class */ (function () {
1889
1921
  var buffer = bufferView.buffer;
1890
1922
  byteOffset = bufferView.byteOffset + (byteOffset || 0);
1891
1923
  var constructor = GLTFLoader._GetTypedArrayConstructor(context + "/componentType", componentType);
1892
- try {
1893
- return new constructor(buffer, byteOffset, length);
1894
- }
1895
- catch (e) {
1896
- throw new Error(context + ": " + e);
1924
+ var componentTypeLength = VertexBuffer.GetTypeByteLength(componentType);
1925
+ if (byteOffset % componentTypeLength !== 0) {
1926
+ // HACK: Copy the buffer if byte offset is not a multiple of component type byte length.
1927
+ Logger.Warn(context + ": Copying buffer as byte offset (" + byteOffset + ") is not a multiple of component type byte length (" + componentTypeLength + ")");
1928
+ return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0);
1897
1929
  }
1930
+ return new constructor(buffer, byteOffset, length);
1898
1931
  };
1899
1932
  GLTFLoader._GetNumComponents = function (context, type) {
1900
1933
  switch (type) {