@babylonjs/loaders 7.23.0 → 7.23.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/OBJ/objFileLoader.d.ts +4 -5
  2. package/OBJ/objFileLoader.js +3 -4
  3. package/OBJ/objFileLoader.js.map +1 -1
  4. package/OBJ/objFileLoader.metadata.d.ts +4 -0
  5. package/OBJ/objFileLoader.metadata.js +5 -0
  6. package/OBJ/objFileLoader.metadata.js.map +1 -0
  7. package/SPLAT/index.d.ts +1 -0
  8. package/SPLAT/index.js +1 -0
  9. package/SPLAT/index.js.map +1 -1
  10. package/SPLAT/splatFileLoader.d.ts +36 -29
  11. package/SPLAT/splatFileLoader.js +354 -52
  12. package/SPLAT/splatFileLoader.js.map +1 -1
  13. package/SPLAT/splatFileLoader.metadata.d.ts +11 -0
  14. package/SPLAT/splatFileLoader.metadata.js +10 -0
  15. package/SPLAT/splatFileLoader.metadata.js.map +1 -0
  16. package/SPLAT/splatLoadingOptions.d.ts +9 -0
  17. package/SPLAT/splatLoadingOptions.js +2 -0
  18. package/SPLAT/splatLoadingOptions.js.map +1 -0
  19. package/STL/stlFileLoader.d.ts +3 -4
  20. package/STL/stlFileLoader.js +3 -5
  21. package/STL/stlFileLoader.js.map +1 -1
  22. package/STL/stlFileLoader.metadata.d.ts +8 -0
  23. package/STL/stlFileLoader.metadata.js +8 -0
  24. package/STL/stlFileLoader.metadata.js.map +1 -0
  25. package/dynamic.d.ts +5 -0
  26. package/dynamic.js +48 -0
  27. package/dynamic.js.map +1 -0
  28. package/glTF/2.0/Extensions/EXT_lights_image_based.js +3 -1
  29. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  30. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +3 -1
  31. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  32. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +3 -1
  33. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  34. package/glTF/2.0/Extensions/EXT_texture_avif.js +3 -1
  35. package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -1
  36. package/glTF/2.0/Extensions/EXT_texture_webp.js +3 -1
  37. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  38. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +1 -1
  39. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +3 -2
  40. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
  41. package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +1 -1
  42. package/glTF/2.0/Extensions/KHR_animation_pointer.js +3 -2
  43. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  44. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +3 -1
  45. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  46. package/glTF/2.0/Extensions/KHR_interactivity.d.ts +1 -1
  47. package/glTF/2.0/Extensions/KHR_interactivity.js +3 -2
  48. package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
  49. package/glTF/2.0/Extensions/KHR_lights_punctual.js +3 -1
  50. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  51. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +3 -1
  52. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  53. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +3 -1
  54. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +3 -1
  56. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  57. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +3 -1
  58. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  59. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +3 -1
  60. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  61. package/glTF/2.0/Extensions/KHR_materials_ior.js +3 -1
  62. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  63. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +3 -1
  64. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  65. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +3 -1
  66. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  67. package/glTF/2.0/Extensions/KHR_materials_sheen.js +3 -1
  68. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  69. package/glTF/2.0/Extensions/KHR_materials_specular.js +3 -1
  70. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  71. package/glTF/2.0/Extensions/KHR_materials_transmission.js +3 -1
  72. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  73. package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -1
  74. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  75. package/glTF/2.0/Extensions/KHR_materials_variants.js +3 -1
  76. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  77. package/glTF/2.0/Extensions/KHR_materials_volume.js +3 -1
  78. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  79. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +1 -1
  80. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +3 -2
  81. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
  82. package/glTF/2.0/Extensions/KHR_texture_basisu.js +3 -1
  83. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  84. package/glTF/2.0/Extensions/KHR_texture_transform.js +3 -1
  85. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  86. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +1 -1
  87. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +3 -2
  88. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  89. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +3 -1
  90. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  91. package/glTF/2.0/Extensions/MSFT_lod.js +3 -1
  92. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  93. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +3 -1
  94. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  95. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +3 -1
  96. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  97. package/glTF/2.0/Extensions/dynamic.d.ts +4 -0
  98. package/glTF/2.0/Extensions/dynamic.js +136 -0
  99. package/glTF/2.0/Extensions/dynamic.js.map +1 -0
  100. package/glTF/2.0/glTFLoader.d.ts +6 -6
  101. package/glTF/2.0/glTFLoader.js +24 -28
  102. package/glTF/2.0/glTFLoader.js.map +1 -1
  103. package/glTF/2.0/glTFLoaderExtensionRegistry.d.ts +25 -0
  104. package/glTF/2.0/glTFLoaderExtensionRegistry.js +30 -0
  105. package/glTF/2.0/glTFLoaderExtensionRegistry.js.map +1 -0
  106. package/glTF/glTFFileLoader.d.ts +4 -6
  107. package/glTF/glTFFileLoader.js +9 -17
  108. package/glTF/glTFFileLoader.js.map +1 -1
  109. package/glTF/glTFFileLoader.metadata.d.ts +13 -0
  110. package/glTF/glTFFileLoader.metadata.js +18 -0
  111. package/glTF/glTFFileLoader.metadata.js.map +1 -0
  112. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
1
  import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
2
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
2
3
  const NAME = "KHR_texture_basisu";
3
4
  /**
4
5
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)
@@ -31,5 +32,6 @@ export class KHR_texture_basisu {
31
32
  });
32
33
  }
33
34
  }
34
- GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_texture_basisu(loader));
35
+ unregisterGLTFExtension(NAME);
36
+ registerGLTFExtension(NAME, true, (loader) => new KHR_texture_basisu(loader));
35
37
  //# sourceMappingURL=KHR_texture_basisu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_texture_basisu.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAMtD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAalC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAS3B;;OAEG;IACH,YAAY,MAAkB;QAX9B,kCAAkC;QAClB,SAAI,GAAG,IAAI,CAAC;QAWxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,iBAAiB,CAAC,OAAe,EAAE,OAAiB,EAAE,MAA6C;QACtG,OAAO,UAAU,CAAC,kBAAkB,CAAiC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YAC9H,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5J,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,gBAAgB,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;YACtG,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CACnC,OAAO,EACP,OAAO,EACP,KAAK,EACL,CAAC,cAAc,EAAE,EAAE;gBACf,MAAM,CAAC,cAAc,CAAC,CAAC;YAC3B,CAAC,EACD,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,qCAAqC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,EAC/F,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport type { ITexture } from \"../glTFLoaderInterfaces\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { IKHRTextureBasisU } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_texture_basisu\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_texture_basisu extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_texture_basisu\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_texture_basisu implements IGLTFLoaderExtension {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRTextureBasisU, BaseTexture>(context, texture, this.name, (extensionContext, extension) => {\r\n const sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(`${context}/sampler`, this._loader.gltf.samplers, texture.sampler);\r\n const image = ArrayItem.Get(`${extensionContext}/source`, this._loader.gltf.images, extension.source);\r\n return this._loader._createTextureAsync(\r\n context,\r\n sampler,\r\n image,\r\n (babylonTexture) => {\r\n assign(babylonTexture);\r\n },\r\n texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined,\r\n !texture._textureInfo.nonColorData\r\n );\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_texture_basisu(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_texture_basisu.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAalC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAS3B;;OAEG;IACH,YAAY,MAAkB;QAX9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qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport type { ITexture } from \"../glTFLoaderInterfaces\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { IKHRTextureBasisU } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_texture_basisu\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_texture_basisu extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_texture_basisu\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_texture_basisu implements IGLTFLoaderExtension {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRTextureBasisU, BaseTexture>(context, texture, this.name, (extensionContext, extension) => {\r\n const sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(`${context}/sampler`, this._loader.gltf.samplers, texture.sampler);\r\n const image = ArrayItem.Get(`${extensionContext}/source`, this._loader.gltf.images, extension.source);\r\n return this._loader._createTextureAsync(\r\n context,\r\n sampler,\r\n image,\r\n (babylonTexture) => {\r\n assign(babylonTexture);\r\n },\r\n texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined,\r\n !texture._textureInfo.nonColorData\r\n );\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_texture_basisu(loader));\r\n"]}
@@ -1,5 +1,6 @@
1
1
  import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
3
4
  const NAME = "KHR_texture_transform";
4
5
  /**
5
6
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md)
@@ -52,5 +53,6 @@ export class KHR_texture_transform {
52
53
  });
53
54
  }
54
55
  }
55
- GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_texture_transform(loader));
56
+ unregisterGLTFExtension(NAME);
57
+ registerGLTFExtension(NAME, true, (loader) => new KHR_texture_transform(loader));
56
58
  //# sourceMappingURL=KHR_texture_transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_texture_transform.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,uBAAuB,CAAC;AAarC;;GAEG;AACH,gEA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AAC,CAAC,CAAC,CAAC;oBAC3C,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBAC9C;gBAED,IAAI,SAAS,CAAC,QAAQ,IAAI,SAAS,EAAE;oBACjC,cAAc,CAAC,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC;iBACxD;gBAED,MAAM,CAAC,cAAc,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\nimport type { ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRTextureTransform } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_texture_transform\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_texture_transform extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_texture_transform\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_texture_transform implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRTextureTransform, BaseTexture>(context, textureInfo, this.name, (extensionContext, extension) => {\r\n return this._loader.loadTextureInfoAsync(context, textureInfo, (babylonTexture) => {\r\n if (!(babylonTexture instanceof Texture)) {\r\n throw new Error(`${extensionContext}: Texture type not supported`);\r\n }\r\n\r\n if (extension.offset) {\r\n babylonTexture.uOffset = extension.offset[0];\r\n babylonTexture.vOffset = extension.offset[1];\r\n }\r\n\r\n // Always rotate around the origin.\r\n babylonTexture.uRotationCenter = 0;\r\n babylonTexture.vRotationCenter = 0;\r\n\r\n if (extension.rotation) {\r\n babylonTexture.wAng = -extension.rotation;\r\n }\r\n\r\n if (extension.scale) {\r\n babylonTexture.uScale = extension.scale[0];\r\n babylonTexture.vScale = extension.scale[1];\r\n }\r\n\r\n if (extension.texCoord != undefined) {\r\n babylonTexture.coordinatesIndex = extension.texCoord;\r\n }\r\n\r\n assign(babylonTexture);\r\n });\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_texture_transform(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_texture_transform.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEh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EAAE;oBACjB,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC3C,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBAC9C;gBAED,IAAI,SAAS,CAAC,QAAQ,IAAI,SAAS,EAAE;oBACjC,cAAc,CAAC,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC;iBACxD;gBAED,MAAM,CAAC,cAAc,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\nimport type { ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRTextureTransform } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_texture_transform\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_texture_transform extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_texture_transform\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_texture_transform implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRTextureTransform, BaseTexture>(context, textureInfo, this.name, (extensionContext, extension) => {\r\n return this._loader.loadTextureInfoAsync(context, textureInfo, (babylonTexture) => {\r\n if (!(babylonTexture instanceof Texture)) {\r\n throw new Error(`${extensionContext}: Texture type not supported`);\r\n }\r\n\r\n if (extension.offset) {\r\n babylonTexture.uOffset = extension.offset[0];\r\n babylonTexture.vOffset = extension.offset[1];\r\n }\r\n\r\n // Always rotate around the origin.\r\n babylonTexture.uRotationCenter = 0;\r\n babylonTexture.vRotationCenter = 0;\r\n\r\n if (extension.rotation) {\r\n babylonTexture.wAng = -extension.rotation;\r\n }\r\n\r\n if (extension.scale) {\r\n babylonTexture.uScale = extension.scale[0];\r\n babylonTexture.vScale = extension.scale[1];\r\n }\r\n\r\n if (extension.texCoord != undefined) {\r\n babylonTexture.coordinatesIndex = extension.texCoord;\r\n }\r\n\r\n assign(babylonTexture);\r\n });\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_texture_transform(loader));\r\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
2
- import { GLTFLoader } from "../glTFLoader";
2
+ import type { GLTFLoader } from "../glTFLoader";
3
3
  declare module "../../glTFFileLoader" {
4
4
  interface GLTFLoaderExtensionOptions {
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { GLTFLoader } from "../glTFLoader.js";
1
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
2
2
  const NAME = "KHR_xmp_json_ld";
3
3
  /**
4
4
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md)
@@ -43,5 +43,6 @@ export class KHR_xmp_json_ld {
43
43
  }
44
44
  }
45
45
  }
46
- GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_xmp_json_ld(loader));
46
+ unregisterGLTFExtension(NAME);
47
+ registerGLTFExtension(NAME, true, (loader) => new KHR_xmp_json_ld(loader));
47
48
  //# sourceMappingURL=KHR_xmp_json_ld.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_xmp_json_ld.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAa/B;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,eAAe;IAkBxB;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,SAAS;QACZ,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,KAAK,IAAI,EAAE;YACvC,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,eAAqC,CAAC;QACrF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,eAAqC,CAAC;QAC5F,IAAI,QAAQ,IAAI,QAAQ,EAAE;YACtB,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChC,IAAI,QAAQ,CAAC,OAAO,IAAI,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE;gBACtD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACpF,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACxE;SACJ;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRXmpJsonLd_Gltf, IKHRXmpJsonLd_Node } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_xmp_json_ld\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_xmp_json_ld extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_xmp_json_ld\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md)\r\n * @since 5.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_xmp_json_ld implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 100;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * Called after the loader state changes to LOADING.\r\n */\r\n public onLoading(): void {\r\n if (this._loader.rootBabylonMesh === null) {\r\n return;\r\n }\r\n\r\n const xmp_gltf = this._loader.gltf.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Gltf;\r\n const xmp_node = this._loader.gltf.asset?.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Node;\r\n if (xmp_gltf && xmp_node) {\r\n const packet = +xmp_node.packet;\r\n if (xmp_gltf.packets && packet < xmp_gltf.packets.length) {\r\n this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {};\r\n this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet];\r\n }\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_xmp_json_ld(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_xmp_json_ld.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAa/B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CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport type { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRXmpJsonLd_Gltf, IKHRXmpJsonLd_Node } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_xmp_json_ld\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_xmp_json_ld extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_xmp_json_ld\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md)\r\n * @since 5.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_xmp_json_ld implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 100;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * Called after the loader state changes to LOADING.\r\n */\r\n public onLoading(): void {\r\n if (this._loader.rootBabylonMesh === null) {\r\n return;\r\n }\r\n\r\n const xmp_gltf = this._loader.gltf.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Gltf;\r\n const xmp_node = this._loader.gltf.asset?.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Node;\r\n if (xmp_gltf && xmp_node) {\r\n const packet = +xmp_node.packet;\r\n if (xmp_gltf.packets && packet < xmp_gltf.packets.length) {\r\n this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {};\r\n this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet];\r\n }\r\n }\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_xmp_json_ld(loader));\r\n"]}
@@ -4,6 +4,7 @@ import { AnimationEvent } from "@babylonjs/core/Animations/animationEvent.js";
4
4
  import { Sound } from "@babylonjs/core/Audio/sound.js";
5
5
  import { WeightedSound } from "@babylonjs/core/Audio/weightedsound.js";
6
6
  import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
7
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
7
8
  const NAME = "MSFT_audio_emitter";
8
9
  /**
9
10
  * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md)
@@ -213,5 +214,6 @@ export class MSFT_audio_emitter {
213
214
  });
214
215
  }
215
216
  }
216
- GLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_audio_emitter(loader));
217
+ unregisterGLTFExtension(NAME);
218
+ registerGLTFExtension(NAME, true, (loader) => new MSFT_audio_emitter(loader));
217
219
  //# sourceMappingURL=MSFT_audio_emitter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_audio_emitter.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,EAAE,cAAc,EAAE,qDAAuC;AAEhE,OAAO,EAAE,KAAK,EAAE,uCAAyB;AACzC,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,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport { AnimationEvent } from \"core/Animations/animationEvent\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { Sound } from \"core/Audio/sound\";\r\nimport { WeightedSound } from \"core/Audio/weightedsound\";\r\n\r\nimport type { IArrayItem, IScene, INode, IAnimation } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport type { IMSFTAudioEmitter_Clip, IMSFTAudioEmitter_Emitter, IMSFTAudioEmitter_EmittersReference, IMSFTAudioEmitter_AnimationEvent } from \"babylonjs-gltf2interface\";\r\nimport { IMSFTAudioEmitter_AnimationEventAction } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"MSFT_audio_emitter\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_audio_emitter extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_audio_emitter\"]: {};\r\n }\r\n}\r\n\r\ninterface ILoaderClip extends IMSFTAudioEmitter_Clip, IArrayItem {\r\n _objectURL?: Promise<string>;\r\n}\r\n\r\ninterface ILoaderEmitter extends IMSFTAudioEmitter_Emitter, IArrayItem {\r\n _babylonData?: {\r\n sound?: WeightedSound;\r\n loaded: Promise<void>;\r\n };\r\n _babylonSounds: Sound[];\r\n}\r\n\r\ninterface IMSFTAudioEmitter {\r\n clips: ILoaderClip[];\r\n emitters: ILoaderEmitter[];\r\n}\r\n\r\ninterface ILoaderAnimationEvent extends IMSFTAudioEmitter_AnimationEvent, IArrayItem {}\r\n\r\ninterface ILoaderAnimationEvents {\r\n events: ILoaderAnimationEvent[];\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_audio_emitter implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n private _clips: Array<ILoaderClip>;\r\n private _emitters: Array<ILoaderEmitter>;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n (this._clips as any) = null;\r\n (this._emitters as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IMSFTAudioEmitter;\r\n\r\n this._clips = extension.clips;\r\n this._emitters = extension.emitters;\r\n\r\n ArrayItem.Assign(this._clips);\r\n ArrayItem.Assign(this._emitters);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference>(context, scene, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n promises.push(this._loader.loadSceneAsync(context, scene));\r\n\r\n for (const emitterIndex of extension.emitters) {\r\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\r\n if (\r\n emitter.refDistance != undefined ||\r\n emitter.maxDistance != undefined ||\r\n emitter.rolloffFactor != undefined ||\r\n emitter.distanceModel != undefined ||\r\n emitter.innerAngle != undefined ||\r\n emitter.outerAngle != undefined\r\n ) {\r\n throw new Error(`${extensionContext}: Direction or Distance properties are not allowed on emitters attached to a scene`);\r\n }\r\n\r\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter));\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\r\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n return this._loader\r\n .loadNodeAsync(extensionContext, node, (babylonMesh) => {\r\n for (const emitterIndex of extension.emitters) {\r\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\r\n promises.push(\r\n this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter).then(() => {\r\n for (const sound of emitter._babylonSounds) {\r\n sound.attachToMesh(babylonMesh);\r\n if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\r\n sound.setLocalDirectionToMesh(Vector3.Forward());\r\n sound.setDirectionalCone(\r\n 2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle),\r\n 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle),\r\n 0\r\n );\r\n }\r\n }\r\n })\r\n );\r\n }\r\n\r\n assign(babylonMesh);\r\n })\r\n .then((babylonMesh) => {\r\n return Promise.all(promises).then(() => {\r\n return babylonMesh;\r\n });\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {\r\n return GLTFLoader.LoadExtensionAsync<ILoaderAnimationEvents, AnimationGroup>(context, animation, this.name, (extensionContext, extension) => {\r\n return this._loader.loadAnimationAsync(context, animation).then((babylonAnimationGroup) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n ArrayItem.Assign(extension.events);\r\n for (const event of extension.events) {\r\n promises.push(this._loadAnimationEventAsync(`${extensionContext}/events/${event.index}`, context, animation, event, babylonAnimationGroup));\r\n }\r\n\r\n return Promise.all(promises).then(() => {\r\n return babylonAnimationGroup;\r\n });\r\n });\r\n });\r\n }\r\n\r\n private _loadClipAsync(context: string, clip: ILoaderClip): Promise<string> {\r\n if (clip._objectURL) {\r\n return clip._objectURL;\r\n }\r\n\r\n let promise: Promise<ArrayBufferView>;\r\n if (clip.uri) {\r\n promise = this._loader.loadUriAsync(context, clip, clip.uri);\r\n } else {\r\n const bufferView = ArrayItem.Get(`${context}/bufferView`, this._loader.gltf.bufferViews, clip.bufferView);\r\n promise = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView);\r\n }\r\n\r\n clip._objectURL = promise.then((data) => {\r\n return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));\r\n });\r\n\r\n return clip._objectURL;\r\n }\r\n\r\n private _loadEmitterAsync(context: string, emitter: ILoaderEmitter): Promise<void> {\r\n emitter._babylonSounds = emitter._babylonSounds || [];\r\n if (!emitter._babylonData) {\r\n const clipPromises = new Array<Promise<any>>();\r\n const name = emitter.name || `emitter${emitter.index}`;\r\n const options = {\r\n loop: false,\r\n autoplay: false,\r\n volume: emitter.volume == undefined ? 1 : emitter.volume,\r\n };\r\n\r\n for (let i = 0; i < emitter.clips.length; i++) {\r\n const clipContext = `/extensions/${this.name}/clips`;\r\n const clip = ArrayItem.Get(clipContext, this._clips, emitter.clips[i].clip);\r\n clipPromises.push(\r\n this._loadClipAsync(`${clipContext}/${emitter.clips[i].clip}`, clip).then((objectURL: string) => {\r\n const sound = (emitter._babylonSounds[i] = new Sound(name, objectURL, this._loader.babylonScene, null, options));\r\n sound.refDistance = emitter.refDistance || 1;\r\n sound.maxDistance = emitter.maxDistance || 256;\r\n sound.rolloffFactor = emitter.rolloffFactor || 1;\r\n sound.distanceModel = emitter.distanceModel || \"exponential\";\r\n })\r\n );\r\n }\r\n\r\n const promise = Promise.all(clipPromises).then(() => {\r\n const weights = emitter.clips.map((clip) => {\r\n return clip.weight || 1;\r\n });\r\n const weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);\r\n if (emitter.innerAngle) {\r\n weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle);\r\n }\r\n if (emitter.outerAngle) {\r\n weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle);\r\n }\r\n if (emitter.volume) {\r\n weightedSound.volume = emitter.volume;\r\n }\r\n emitter._babylonData!.sound = weightedSound;\r\n });\r\n\r\n emitter._babylonData = {\r\n loaded: promise,\r\n };\r\n }\r\n\r\n return emitter._babylonData.loaded;\r\n }\r\n\r\n private _getEventAction(\r\n context: string,\r\n sound: WeightedSound,\r\n action: IMSFTAudioEmitter_AnimationEventAction,\r\n time: number,\r\n startOffset?: number\r\n ): (currentFrame: number) => void {\r\n switch (action) {\r\n case IMSFTAudioEmitter_AnimationEventAction.play: {\r\n return (currentFrame: number) => {\r\n const frameOffset = (startOffset || 0) + (currentFrame - time);\r\n sound.play(frameOffset);\r\n };\r\n }\r\n case IMSFTAudioEmitter_AnimationEventAction.stop: {\r\n return () => {\r\n sound.stop();\r\n };\r\n }\r\n case IMSFTAudioEmitter_AnimationEventAction.pause: {\r\n return () => {\r\n sound.pause();\r\n };\r\n }\r\n default: {\r\n throw new Error(`${context}: Unsupported action ${action}`);\r\n }\r\n }\r\n }\r\n\r\n private _loadAnimationEventAsync(\r\n context: string,\r\n animationContext: string,\r\n animation: IAnimation,\r\n event: ILoaderAnimationEvent,\r\n babylonAnimationGroup: AnimationGroup\r\n ): Promise<void> {\r\n if (babylonAnimationGroup.targetedAnimations.length == 0) {\r\n return Promise.resolve();\r\n }\r\n const babylonAnimation = babylonAnimationGroup.targetedAnimations[0];\r\n const emitterIndex = event.emitter;\r\n const emitter = ArrayItem.Get(`/extensions/${this.name}/emitters`, this._emitters, emitterIndex);\r\n return this._loadEmitterAsync(context, emitter).then(() => {\r\n const sound = emitter._babylonData!.sound;\r\n if (sound) {\r\n const babylonAnimationEvent = new AnimationEvent(event.time, this._getEventAction(context, sound, event.action, event.time, event.startOffset));\r\n babylonAnimation.animation.addEvent(babylonAnimationEvent);\r\n // Make sure all started audio stops when this animation is terminated.\r\n babylonAnimationGroup.onAnimationGroupEndObservable.add(() => {\r\n sound.stop();\r\n });\r\n babylonAnimationGroup.onAnimationGroupPauseObservable.add(() => {\r\n sound.pause();\r\n });\r\n }\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_audio_emitter(loader));\r\n"]}
1
+ {"version":3,"file":"MSFT_audio_emitter.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,EAAE,cAAc,EAAE,qDAAuC;AAEhE,OAAO,EAAE,KAAK,EAAE,uCAAyB;AACzC,OAAO,EAAE,aAAa,EAAE,+CAAiC;AAIzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAoClC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAe3B;;OAEG;IACH,YAAY,MAAkB;QAjB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAexB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI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AI,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACtD,MAAM,KAAK,GAAG,OAAO,CAAC,YAAa,CAAC,KAAK,CAAC;YAC1C,IAAI,KAAK,EAAE;gBACP,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAChJ,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;gBAC3D,uEAAuE;gBACvE,qBAAqB,CAAC,6BAA6B,CAAC,GAAG,CAAC,GAAG,EAAE;oBACzD,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,qBAAqB,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,EAAE;oBAC3D,KAAK,CAAC,KAAK,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport { AnimationEvent } from \"core/Animations/animationEvent\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { Sound } from \"core/Audio/sound\";\r\nimport { WeightedSound } from \"core/Audio/weightedsound\";\r\n\r\nimport type { IArrayItem, IScene, INode, IAnimation } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport type { IMSFTAudioEmitter_Clip, IMSFTAudioEmitter_Emitter, IMSFTAudioEmitter_EmittersReference, IMSFTAudioEmitter_AnimationEvent } from \"babylonjs-gltf2interface\";\r\nimport { IMSFTAudioEmitter_AnimationEventAction } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"MSFT_audio_emitter\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_audio_emitter extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_audio_emitter\"]: {};\r\n }\r\n}\r\n\r\ninterface ILoaderClip extends IMSFTAudioEmitter_Clip, IArrayItem {\r\n _objectURL?: Promise<string>;\r\n}\r\n\r\ninterface ILoaderEmitter extends IMSFTAudioEmitter_Emitter, IArrayItem {\r\n _babylonData?: {\r\n sound?: WeightedSound;\r\n loaded: Promise<void>;\r\n };\r\n _babylonSounds: Sound[];\r\n}\r\n\r\ninterface IMSFTAudioEmitter {\r\n clips: ILoaderClip[];\r\n emitters: ILoaderEmitter[];\r\n}\r\n\r\ninterface ILoaderAnimationEvent extends IMSFTAudioEmitter_AnimationEvent, IArrayItem {}\r\n\r\ninterface ILoaderAnimationEvents {\r\n events: ILoaderAnimationEvent[];\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_audio_emitter implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n private _clips: Array<ILoaderClip>;\r\n private _emitters: Array<ILoaderEmitter>;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n (this._clips as any) = null;\r\n (this._emitters as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IMSFTAudioEmitter;\r\n\r\n this._clips = extension.clips;\r\n this._emitters = extension.emitters;\r\n\r\n ArrayItem.Assign(this._clips);\r\n ArrayItem.Assign(this._emitters);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference>(context, scene, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n promises.push(this._loader.loadSceneAsync(context, scene));\r\n\r\n for (const emitterIndex of extension.emitters) {\r\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\r\n if (\r\n emitter.refDistance != undefined ||\r\n emitter.maxDistance != undefined ||\r\n emitter.rolloffFactor != undefined ||\r\n emitter.distanceModel != undefined ||\r\n emitter.innerAngle != undefined ||\r\n emitter.outerAngle != undefined\r\n ) {\r\n throw new Error(`${extensionContext}: Direction or Distance properties are not allowed on emitters attached to a scene`);\r\n }\r\n\r\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter));\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\r\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n return this._loader\r\n .loadNodeAsync(extensionContext, node, (babylonMesh) => {\r\n for (const emitterIndex of extension.emitters) {\r\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\r\n promises.push(\r\n this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter).then(() => {\r\n for (const sound of emitter._babylonSounds) {\r\n sound.attachToMesh(babylonMesh);\r\n if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\r\n sound.setLocalDirectionToMesh(Vector3.Forward());\r\n sound.setDirectionalCone(\r\n 2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle),\r\n 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle),\r\n 0\r\n );\r\n }\r\n }\r\n })\r\n );\r\n }\r\n\r\n assign(babylonMesh);\r\n })\r\n .then((babylonMesh) => {\r\n return Promise.all(promises).then(() => {\r\n return babylonMesh;\r\n });\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {\r\n return GLTFLoader.LoadExtensionAsync<ILoaderAnimationEvents, AnimationGroup>(context, animation, this.name, (extensionContext, extension) => {\r\n return this._loader.loadAnimationAsync(context, animation).then((babylonAnimationGroup) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n ArrayItem.Assign(extension.events);\r\n for (const event of extension.events) {\r\n promises.push(this._loadAnimationEventAsync(`${extensionContext}/events/${event.index}`, context, animation, event, babylonAnimationGroup));\r\n }\r\n\r\n return Promise.all(promises).then(() => {\r\n return babylonAnimationGroup;\r\n });\r\n });\r\n });\r\n }\r\n\r\n private _loadClipAsync(context: string, clip: ILoaderClip): Promise<string> {\r\n if (clip._objectURL) {\r\n return clip._objectURL;\r\n }\r\n\r\n let promise: Promise<ArrayBufferView>;\r\n if (clip.uri) {\r\n promise = this._loader.loadUriAsync(context, clip, clip.uri);\r\n } else {\r\n const bufferView = ArrayItem.Get(`${context}/bufferView`, this._loader.gltf.bufferViews, clip.bufferView);\r\n promise = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView);\r\n }\r\n\r\n clip._objectURL = promise.then((data) => {\r\n return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));\r\n });\r\n\r\n return clip._objectURL;\r\n }\r\n\r\n private _loadEmitterAsync(context: string, emitter: ILoaderEmitter): Promise<void> {\r\n emitter._babylonSounds = emitter._babylonSounds || [];\r\n if (!emitter._babylonData) {\r\n const clipPromises = new Array<Promise<any>>();\r\n const name = emitter.name || `emitter${emitter.index}`;\r\n const options = {\r\n loop: false,\r\n autoplay: false,\r\n volume: emitter.volume == undefined ? 1 : emitter.volume,\r\n };\r\n\r\n for (let i = 0; i < emitter.clips.length; i++) {\r\n const clipContext = `/extensions/${this.name}/clips`;\r\n const clip = ArrayItem.Get(clipContext, this._clips, emitter.clips[i].clip);\r\n clipPromises.push(\r\n this._loadClipAsync(`${clipContext}/${emitter.clips[i].clip}`, clip).then((objectURL: string) => {\r\n const sound = (emitter._babylonSounds[i] = new Sound(name, objectURL, this._loader.babylonScene, null, options));\r\n sound.refDistance = emitter.refDistance || 1;\r\n sound.maxDistance = emitter.maxDistance || 256;\r\n sound.rolloffFactor = emitter.rolloffFactor || 1;\r\n sound.distanceModel = emitter.distanceModel || \"exponential\";\r\n })\r\n );\r\n }\r\n\r\n const promise = Promise.all(clipPromises).then(() => {\r\n const weights = emitter.clips.map((clip) => {\r\n return clip.weight || 1;\r\n });\r\n const weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);\r\n if (emitter.innerAngle) {\r\n weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle);\r\n }\r\n if (emitter.outerAngle) {\r\n weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle);\r\n }\r\n if (emitter.volume) {\r\n weightedSound.volume = emitter.volume;\r\n }\r\n emitter._babylonData!.sound = weightedSound;\r\n });\r\n\r\n emitter._babylonData = {\r\n loaded: promise,\r\n };\r\n }\r\n\r\n return emitter._babylonData.loaded;\r\n }\r\n\r\n private _getEventAction(\r\n context: string,\r\n sound: WeightedSound,\r\n action: IMSFTAudioEmitter_AnimationEventAction,\r\n time: number,\r\n startOffset?: number\r\n ): (currentFrame: number) => void {\r\n switch (action) {\r\n case IMSFTAudioEmitter_AnimationEventAction.play: {\r\n return (currentFrame: number) => {\r\n const frameOffset = (startOffset || 0) + (currentFrame - time);\r\n sound.play(frameOffset);\r\n };\r\n }\r\n case IMSFTAudioEmitter_AnimationEventAction.stop: {\r\n return () => {\r\n sound.stop();\r\n };\r\n }\r\n case IMSFTAudioEmitter_AnimationEventAction.pause: {\r\n return () => {\r\n sound.pause();\r\n };\r\n }\r\n default: {\r\n throw new Error(`${context}: Unsupported action ${action}`);\r\n }\r\n }\r\n }\r\n\r\n private _loadAnimationEventAsync(\r\n context: string,\r\n animationContext: string,\r\n animation: IAnimation,\r\n event: ILoaderAnimationEvent,\r\n babylonAnimationGroup: AnimationGroup\r\n ): Promise<void> {\r\n if (babylonAnimationGroup.targetedAnimations.length == 0) {\r\n return Promise.resolve();\r\n }\r\n const babylonAnimation = babylonAnimationGroup.targetedAnimations[0];\r\n const emitterIndex = event.emitter;\r\n const emitter = ArrayItem.Get(`/extensions/${this.name}/emitters`, this._emitters, emitterIndex);\r\n return this._loadEmitterAsync(context, emitter).then(() => {\r\n const sound = emitter._babylonData!.sound;\r\n if (sound) {\r\n const babylonAnimationEvent = new AnimationEvent(event.time, this._getEventAction(context, sound, event.action, event.time, event.startOffset));\r\n babylonAnimation.animation.addEvent(babylonAnimationEvent);\r\n // Make sure all started audio stops when this animation is terminated.\r\n babylonAnimationGroup.onAnimationGroupEndObservable.add(() => {\r\n sound.stop();\r\n });\r\n babylonAnimationGroup.onAnimationGroupPauseObservable.add(() => {\r\n sound.pause();\r\n });\r\n }\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new MSFT_audio_emitter(loader));\r\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Observable } from "@babylonjs/core/Misc/observable.js";
2
2
  import { Deferred } from "@babylonjs/core/Misc/deferred.js";
3
3
  import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
4
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
4
5
  const NAME = "MSFT_lod";
5
6
  /**
6
7
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md)
@@ -327,5 +328,6 @@ export class MSFT_lod {
327
328
  }
328
329
  }
329
330
  }
330
- GLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_lod(loader));
331
+ unregisterGLTFExtension(NAME);
332
+ registerGLTFExtension(NAME, true, (loader) => new MSFT_lod(loader));
331
333
  //# sourceMappingURL=MSFT_lod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,QAAQ,EAAE,yCAA2B;AAO9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,MAAM,IAAI,GAAG,UAAU,CAAC;AAwBxB;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,QAAQ;IAiDjB;;OAEG;IACH,YAAY,MAAkB;QAnD9B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GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,eAAe,CAAC,CAAC,CAAC;QACnK,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAEO,iBAAiB,CAAC,gBAA4B;QAClD,MAAM,eAAe,GAAwC,EAAE,CAAC;QAEhE,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE;YAC5C,KAAK,MAAM,cAAc,IAAI,eAAe,CAAC,iBAAiB,EAAE,EAAE;gBAC9D,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC;aAC7D;YAED,eAAe,CAAC,OAAO,EAAE,CAAC;SAC7B;QAED,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE;YACpC,KAAK,MAAM,eAAe,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE;gBAC/D,IAAI,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACvD,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;iBACpC;aACJ;SACJ;QAED,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE;YACpC,eAAe,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;SACvC;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Deferred } from \"core/Misc/deferred\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { INode, IMaterial, IBuffer, IScene } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport type { IProperty, IMSFTLOD } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"MSFT_lod\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_lod extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_lod\"]: Partial<{\r\n /**\r\n * Maximum number of LODs to load, starting from the lowest LOD.\r\n */\r\n maxLODsToLoad: number;\r\n }>;\r\n }\r\n}\r\n\r\ninterface IBufferInfo {\r\n start: number;\r\n end: number;\r\n loaded: Deferred<ArrayBufferView>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_lod implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 100;\r\n\r\n /**\r\n * Maximum number of LODs to load, starting from the lowest LOD.\r\n */\r\n public maxLODsToLoad = 10;\r\n\r\n /**\r\n * Observable raised when all node LODs of one level are loaded.\r\n * The event data is the index of the loaded LOD starting from zero.\r\n * Dispose the loader to cancel the loading of the next level of LODs.\r\n */\r\n public onNodeLODsLoadedObservable = new Observable<number>();\r\n\r\n /**\r\n * Observable raised when all material LODs of one level are loaded.\r\n * The event data is the index of the loaded LOD starting from zero.\r\n * Dispose the loader to cancel the loading of the next level of LODs.\r\n */\r\n public onMaterialLODsLoadedObservable = new Observable<number>();\r\n\r\n private _loader: GLTFLoader;\r\n\r\n private _bufferLODs = new Array<IBufferInfo>();\r\n\r\n private _nodeIndexLOD: Nullable<number> = null;\r\n private _nodeSignalLODs = new Array<Deferred<void>>();\r\n private _nodePromiseLODs = new Array<Array<Promise<any>>>();\r\n private _nodeBufferLODs = new Array<IBufferInfo>();\r\n\r\n private _materialIndexLOD: Nullable<number> = null;\r\n private _materialSignalLODs = new Array<Deferred<void>>();\r\n private _materialPromiseLODs = new Array<Array<Promise<any>>>();\r\n private _materialBufferLODs = new Array<IBufferInfo>();\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n // Options takes precedence. The maxLODsToLoad extension property is retained for back compat.\r\n // For new extensions, they should only use options.\r\n this.maxLODsToLoad = this._loader.parent.extensionOptions[NAME]?.maxLODsToLoad ?? this.maxLODsToLoad;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n\r\n this._nodeIndexLOD = null;\r\n this._nodeSignalLODs.length = 0;\r\n this._nodePromiseLODs.length = 0;\r\n this._nodeBufferLODs.length = 0;\r\n\r\n this._materialIndexLOD = null;\r\n this._materialSignalLODs.length = 0;\r\n this._materialPromiseLODs.length = 0;\r\n this._materialBufferLODs.length = 0;\r\n\r\n this.onMaterialLODsLoadedObservable.clear();\r\n this.onNodeLODsLoadedObservable.clear();\r\n }\r\n\r\n /** @internal */\r\n public onReady(): void {\r\n for (let indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {\r\n const promise = Promise.all(this._nodePromiseLODs[indexLOD]).then(() => {\r\n if (indexLOD !== 0) {\r\n this._loader.endPerformanceCounter(`Node LOD ${indexLOD}`);\r\n this._loader.log(`Loaded node LOD ${indexLOD}`);\r\n }\r\n\r\n this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);\r\n\r\n if (indexLOD !== this._nodePromiseLODs.length - 1) {\r\n this._loader.startPerformanceCounter(`Node LOD ${indexLOD + 1}`);\r\n this._loadBufferLOD(this._nodeBufferLODs, indexLOD + 1);\r\n if (this._nodeSignalLODs[indexLOD]) {\r\n this._nodeSignalLODs[indexLOD].resolve();\r\n }\r\n }\r\n });\r\n\r\n this._loader._completePromises.push(promise);\r\n }\r\n\r\n for (let indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {\r\n const promise = Promise.all(this._materialPromiseLODs[indexLOD]).then(() => {\r\n if (indexLOD !== 0) {\r\n this._loader.endPerformanceCounter(`Material LOD ${indexLOD}`);\r\n this._loader.log(`Loaded material LOD ${indexLOD}`);\r\n }\r\n\r\n this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);\r\n\r\n if (indexLOD !== this._materialPromiseLODs.length - 1) {\r\n this._loader.startPerformanceCounter(`Material LOD ${indexLOD + 1}`);\r\n this._loadBufferLOD(this._materialBufferLODs, indexLOD + 1);\r\n if (this._materialSignalLODs[indexLOD]) {\r\n this._materialSignalLODs[indexLOD].resolve();\r\n }\r\n }\r\n });\r\n\r\n this._loader._completePromises.push(promise);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n const promise = this._loader.loadSceneAsync(context, scene);\r\n this._loadBufferLOD(this._bufferLODs, 0);\r\n return promise;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\r\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, TransformNode>(context, node, this.name, (extensionContext, extension) => {\r\n let firstPromise: Promise<TransformNode>;\r\n\r\n const nodeLODs = this._getLODs(extensionContext, node, this._loader.gltf.nodes, extension.ids);\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\r\n const nodeLOD = nodeLODs[indexLOD];\r\n\r\n if (indexLOD !== 0) {\r\n this._nodeIndexLOD = indexLOD;\r\n this._nodeSignalLODs[indexLOD] = this._nodeSignalLODs[indexLOD] || new Deferred();\r\n }\r\n\r\n const assignWrap = (babylonTransformNode: TransformNode) => {\r\n assign(babylonTransformNode);\r\n babylonTransformNode.setEnabled(false);\r\n };\r\n\r\n const promise = this._loader.loadNodeAsync(`/nodes/${nodeLOD.index}`, nodeLOD, assignWrap).then((babylonMesh) => {\r\n if (indexLOD !== 0) {\r\n // TODO: should not rely on _babylonTransformNode\r\n const previousNodeLOD = nodeLODs[indexLOD - 1];\r\n if (previousNodeLOD._babylonTransformNode) {\r\n this._disposeTransformNode(previousNodeLOD._babylonTransformNode);\r\n delete previousNodeLOD._babylonTransformNode;\r\n }\r\n }\r\n\r\n babylonMesh.setEnabled(true);\r\n return babylonMesh;\r\n });\r\n\r\n this._nodePromiseLODs[indexLOD] = this._nodePromiseLODs[indexLOD] || [];\r\n\r\n if (indexLOD === 0) {\r\n firstPromise = promise;\r\n } else {\r\n this._nodeIndexLOD = null;\r\n this._nodePromiseLODs[indexLOD].push(promise);\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n return firstPromise!;\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadMaterialAsync(\r\n context: string,\r\n material: IMaterial,\r\n babylonMesh: Nullable<Mesh>,\r\n babylonDrawMode: number,\r\n assign: (babylonMaterial: Material) => void\r\n ): Nullable<Promise<Material>> {\r\n // Don't load material LODs if already loading a node LOD.\r\n if (this._nodeIndexLOD) {\r\n return null;\r\n }\r\n\r\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, Material>(context, material, this.name, (extensionContext, extension) => {\r\n let firstPromise: Promise<Material>;\r\n\r\n const materialLODs = this._getLODs(extensionContext, material, this._loader.gltf.materials, extension.ids);\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n for (let indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {\r\n const materialLOD = materialLODs[indexLOD];\r\n\r\n if (indexLOD !== 0) {\r\n this._materialIndexLOD = indexLOD;\r\n }\r\n\r\n const promise = this._loader\r\n ._loadMaterialAsync(`/materials/${materialLOD.index}`, materialLOD, babylonMesh, babylonDrawMode, (babylonMaterial) => {\r\n if (indexLOD === 0) {\r\n assign(babylonMaterial);\r\n }\r\n })\r\n .then((babylonMaterial) => {\r\n if (indexLOD !== 0) {\r\n assign(babylonMaterial);\r\n\r\n // TODO: should not rely on _data\r\n const previousDataLOD = materialLODs[indexLOD - 1]._data!;\r\n if (previousDataLOD[babylonDrawMode]) {\r\n this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);\r\n delete previousDataLOD[babylonDrawMode];\r\n }\r\n }\r\n\r\n return babylonMaterial;\r\n });\r\n\r\n this._materialPromiseLODs[indexLOD] = this._materialPromiseLODs[indexLOD] || [];\r\n\r\n if (indexLOD === 0) {\r\n firstPromise = promise;\r\n } else {\r\n this._materialIndexLOD = null;\r\n this._materialPromiseLODs[indexLOD].push(promise);\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n return firstPromise!;\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>> {\r\n // Defer the loading of uris if loading a node or material LOD.\r\n if (this._nodeIndexLOD !== null) {\r\n this._loader.log(`deferred`);\r\n const previousIndexLOD = this._nodeIndexLOD - 1;\r\n this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred<void>();\r\n return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(() => {\r\n return this._loader.loadUriAsync(context, property, uri);\r\n });\r\n } else if (this._materialIndexLOD !== null) {\r\n this._loader.log(`deferred`);\r\n const previousIndexLOD = this._materialIndexLOD - 1;\r\n this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred<void>();\r\n return this._materialSignalLODs[previousIndexLOD].promise.then(() => {\r\n return this._loader.loadUriAsync(context, property, uri);\r\n });\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>> {\r\n if (this._loader.parent.useRangeRequests && !buffer.uri) {\r\n if (!this._loader.bin) {\r\n throw new Error(`${context}: Uri is missing or the binary glTF is missing its binary chunk`);\r\n }\r\n\r\n const loadAsync = (bufferLODs: Array<IBufferInfo>, indexLOD: number) => {\r\n const start = byteOffset;\r\n const end = start + byteLength - 1;\r\n let bufferLOD = bufferLODs[indexLOD];\r\n if (bufferLOD) {\r\n bufferLOD.start = Math.min(bufferLOD.start, start);\r\n bufferLOD.end = Math.max(bufferLOD.end, end);\r\n } else {\r\n bufferLOD = { start: start, end: end, loaded: new Deferred() };\r\n bufferLODs[indexLOD] = bufferLOD;\r\n }\r\n\r\n return bufferLOD.loaded.promise.then((data) => {\r\n return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);\r\n });\r\n };\r\n\r\n this._loader.log(`deferred`);\r\n\r\n if (this._nodeIndexLOD !== null) {\r\n return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);\r\n } else if (this._materialIndexLOD !== null) {\r\n return loadAsync(this._materialBufferLODs, this._materialIndexLOD);\r\n } else {\r\n return loadAsync(this._bufferLODs, 0);\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private _loadBufferLOD(bufferLODs: Array<IBufferInfo>, indexLOD: number): void {\r\n const bufferLOD = bufferLODs[indexLOD];\r\n if (bufferLOD) {\r\n this._loader.log(`Loading buffer range [${bufferLOD.start}-${bufferLOD.end}]`);\r\n this._loader.bin!.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(\r\n (data) => {\r\n bufferLOD.loaded.resolve(data);\r\n },\r\n (error) => {\r\n bufferLOD.loaded.reject(error);\r\n }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * @returns an array of LOD properties from lowest to highest.\r\n * @param context\r\n * @param property\r\n * @param array\r\n * @param ids\r\n */\r\n private _getLODs<T>(context: string, property: T, array: ArrayLike<T> | undefined, ids: number[]): T[] {\r\n if (this.maxLODsToLoad <= 0) {\r\n throw new Error(\"maxLODsToLoad must be greater than zero\");\r\n }\r\n\r\n const properties: T[] = [];\r\n\r\n for (let i = ids.length - 1; i >= 0; i--) {\r\n properties.push(ArrayItem.Get(`${context}/ids/${ids[i]}`, array, ids[i]));\r\n if (properties.length === this.maxLODsToLoad) {\r\n return properties;\r\n }\r\n }\r\n\r\n properties.push(property);\r\n return properties;\r\n }\r\n\r\n private _disposeTransformNode(babylonTransformNode: TransformNode): void {\r\n const babylonMaterials: Material[] = [];\r\n const babylonMaterial = (babylonTransformNode as Mesh).material;\r\n if (babylonMaterial) {\r\n babylonMaterials.push(babylonMaterial);\r\n }\r\n for (const babylonMesh of babylonTransformNode.getChildMeshes()) {\r\n if (babylonMesh.material) {\r\n babylonMaterials.push(babylonMesh.material);\r\n }\r\n }\r\n\r\n babylonTransformNode.dispose();\r\n\r\n const babylonMaterialsToDispose = babylonMaterials.filter((babylonMaterial) => this._loader.babylonScene.meshes.every((mesh) => mesh.material != babylonMaterial));\r\n this._disposeMaterials(babylonMaterialsToDispose);\r\n }\r\n\r\n private _disposeMaterials(babylonMaterials: Material[]): void {\r\n const babylonTextures: { [uniqueId: number]: BaseTexture } = {};\r\n\r\n for (const babylonMaterial of babylonMaterials) {\r\n for (const babylonTexture of babylonMaterial.getActiveTextures()) {\r\n babylonTextures[babylonTexture.uniqueId] = babylonTexture;\r\n }\r\n\r\n babylonMaterial.dispose();\r\n }\r\n\r\n for (const uniqueId in babylonTextures) {\r\n for (const babylonMaterial of this._loader.babylonScene.materials) {\r\n if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {\r\n delete babylonTextures[uniqueId];\r\n }\r\n }\r\n }\r\n\r\n for (const uniqueId in babylonTextures) {\r\n babylonTextures[uniqueId].dispose();\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_lod(loader));\r\n"]}
1
+ {"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,QAAQ,EAAE,yCAA2B;AAO9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,UAAU,CAAC;AAwBxB;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,QAAQ;IAiDjB;;OAEG;IACH,YAAY,MAAkB;QAnD9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAEnB;;WAEG;QACI,kBAAa,GAAG,EAAE,CAAC;QAE1B;;;;WAIG;QACI,+BAA0B,GAAG,IAAI,UAAU,EAAU,CAAC;QAE7D;;;;WAIG;QACI,mCAA8B,GAAG,IAAI,UAAU,EAAU,CAAC;QAIzD,gBAAW,GAAG,IAAI,KAAK,EAAe,CAAC;QAEvC,kBAAa,GAAqB,IAAI,CAAC;QACvC,oBAAe,GAAG,IAAI,KAAK,EAAkB,CAAC;QAC9C,qBAAgB,GAAG,IAAI,KAAK,EAAuB,CAAC;QACpD,oBAAe,GAAG,IAAI,KAAK,EAAe,CAAC;QAE3C,sBAAiB,GAAqB,IAAI,CAAC;QAC3C,wBAAmB,GAAG,IAAI,KAAK,EAAkB,CAAC;QAClD,yBAAoB,GAAG,IAAI,KAAK,EAAuB,CAAC;QACxD,wBAAmB,GAAG,IAAI,KAAK,EAAe,C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I,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE;gBAC/D,IAAI,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACvD,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;iBACpC;aACJ;SACJ;QAED,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE;YACpC,eAAe,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;SACvC;IACL,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Deferred } from \"core/Misc/deferred\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { INode, IMaterial, IBuffer, IScene } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport type { IProperty, IMSFTLOD } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"MSFT_lod\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_lod extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_lod\"]: Partial<{\r\n /**\r\n * Maximum number of LODs to load, starting from the lowest LOD.\r\n */\r\n maxLODsToLoad: number;\r\n }>;\r\n }\r\n}\r\n\r\ninterface IBufferInfo {\r\n start: number;\r\n end: number;\r\n loaded: Deferred<ArrayBufferView>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_lod implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 100;\r\n\r\n /**\r\n * Maximum number of LODs to load, starting from the lowest LOD.\r\n */\r\n public maxLODsToLoad = 10;\r\n\r\n /**\r\n * Observable raised when all node LODs of one level are loaded.\r\n * The event data is the index of the loaded LOD starting from zero.\r\n * Dispose the loader to cancel the loading of the next level of LODs.\r\n */\r\n public onNodeLODsLoadedObservable = new Observable<number>();\r\n\r\n /**\r\n * Observable raised when all material LODs of one level are loaded.\r\n * The event data is the index of the loaded LOD starting from zero.\r\n * Dispose the loader to cancel the loading of the next level of LODs.\r\n */\r\n public onMaterialLODsLoadedObservable = new Observable<number>();\r\n\r\n private _loader: GLTFLoader;\r\n\r\n private _bufferLODs = new Array<IBufferInfo>();\r\n\r\n private _nodeIndexLOD: Nullable<number> = null;\r\n private _nodeSignalLODs = new Array<Deferred<void>>();\r\n private _nodePromiseLODs = new Array<Array<Promise<any>>>();\r\n private _nodeBufferLODs = new Array<IBufferInfo>();\r\n\r\n private _materialIndexLOD: Nullable<number> = null;\r\n private _materialSignalLODs = new Array<Deferred<void>>();\r\n private _materialPromiseLODs = new Array<Array<Promise<any>>>();\r\n private _materialBufferLODs = new Array<IBufferInfo>();\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n // Options takes precedence. The maxLODsToLoad extension property is retained for back compat.\r\n // For new extensions, they should only use options.\r\n this.maxLODsToLoad = this._loader.parent.extensionOptions[NAME]?.maxLODsToLoad ?? this.maxLODsToLoad;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n\r\n this._nodeIndexLOD = null;\r\n this._nodeSignalLODs.length = 0;\r\n this._nodePromiseLODs.length = 0;\r\n this._nodeBufferLODs.length = 0;\r\n\r\n this._materialIndexLOD = null;\r\n this._materialSignalLODs.length = 0;\r\n this._materialPromiseLODs.length = 0;\r\n this._materialBufferLODs.length = 0;\r\n\r\n this.onMaterialLODsLoadedObservable.clear();\r\n this.onNodeLODsLoadedObservable.clear();\r\n }\r\n\r\n /** @internal */\r\n public onReady(): void {\r\n for (let indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {\r\n const promise = Promise.all(this._nodePromiseLODs[indexLOD]).then(() => {\r\n if (indexLOD !== 0) {\r\n this._loader.endPerformanceCounter(`Node LOD ${indexLOD}`);\r\n this._loader.log(`Loaded node LOD ${indexLOD}`);\r\n }\r\n\r\n this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);\r\n\r\n if (indexLOD !== this._nodePromiseLODs.length - 1) {\r\n this._loader.startPerformanceCounter(`Node LOD ${indexLOD + 1}`);\r\n this._loadBufferLOD(this._nodeBufferLODs, indexLOD + 1);\r\n if (this._nodeSignalLODs[indexLOD]) {\r\n this._nodeSignalLODs[indexLOD].resolve();\r\n }\r\n }\r\n });\r\n\r\n this._loader._completePromises.push(promise);\r\n }\r\n\r\n for (let indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {\r\n const promise = Promise.all(this._materialPromiseLODs[indexLOD]).then(() => {\r\n if (indexLOD !== 0) {\r\n this._loader.endPerformanceCounter(`Material LOD ${indexLOD}`);\r\n this._loader.log(`Loaded material LOD ${indexLOD}`);\r\n }\r\n\r\n this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);\r\n\r\n if (indexLOD !== this._materialPromiseLODs.length - 1) {\r\n this._loader.startPerformanceCounter(`Material LOD ${indexLOD + 1}`);\r\n this._loadBufferLOD(this._materialBufferLODs, indexLOD + 1);\r\n if (this._materialSignalLODs[indexLOD]) {\r\n this._materialSignalLODs[indexLOD].resolve();\r\n }\r\n }\r\n });\r\n\r\n this._loader._completePromises.push(promise);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n const promise = this._loader.loadSceneAsync(context, scene);\r\n this._loadBufferLOD(this._bufferLODs, 0);\r\n return promise;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\r\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, TransformNode>(context, node, this.name, (extensionContext, extension) => {\r\n let firstPromise: Promise<TransformNode>;\r\n\r\n const nodeLODs = this._getLODs(extensionContext, node, this._loader.gltf.nodes, extension.ids);\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\r\n const nodeLOD = nodeLODs[indexLOD];\r\n\r\n if (indexLOD !== 0) {\r\n this._nodeIndexLOD = indexLOD;\r\n this._nodeSignalLODs[indexLOD] = this._nodeSignalLODs[indexLOD] || new Deferred();\r\n }\r\n\r\n const assignWrap = (babylonTransformNode: TransformNode) => {\r\n assign(babylonTransformNode);\r\n babylonTransformNode.setEnabled(false);\r\n };\r\n\r\n const promise = this._loader.loadNodeAsync(`/nodes/${nodeLOD.index}`, nodeLOD, assignWrap).then((babylonMesh) => {\r\n if (indexLOD !== 0) {\r\n // TODO: should not rely on _babylonTransformNode\r\n const previousNodeLOD = nodeLODs[indexLOD - 1];\r\n if (previousNodeLOD._babylonTransformNode) {\r\n this._disposeTransformNode(previousNodeLOD._babylonTransformNode);\r\n delete previousNodeLOD._babylonTransformNode;\r\n }\r\n }\r\n\r\n babylonMesh.setEnabled(true);\r\n return babylonMesh;\r\n });\r\n\r\n this._nodePromiseLODs[indexLOD] = this._nodePromiseLODs[indexLOD] || [];\r\n\r\n if (indexLOD === 0) {\r\n firstPromise = promise;\r\n } else {\r\n this._nodeIndexLOD = null;\r\n this._nodePromiseLODs[indexLOD].push(promise);\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n return firstPromise!;\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadMaterialAsync(\r\n context: string,\r\n material: IMaterial,\r\n babylonMesh: Nullable<Mesh>,\r\n babylonDrawMode: number,\r\n assign: (babylonMaterial: Material) => void\r\n ): Nullable<Promise<Material>> {\r\n // Don't load material LODs if already loading a node LOD.\r\n if (this._nodeIndexLOD) {\r\n return null;\r\n }\r\n\r\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, Material>(context, material, this.name, (extensionContext, extension) => {\r\n let firstPromise: Promise<Material>;\r\n\r\n const materialLODs = this._getLODs(extensionContext, material, this._loader.gltf.materials, extension.ids);\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n for (let indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {\r\n const materialLOD = materialLODs[indexLOD];\r\n\r\n if (indexLOD !== 0) {\r\n this._materialIndexLOD = indexLOD;\r\n }\r\n\r\n const promise = this._loader\r\n ._loadMaterialAsync(`/materials/${materialLOD.index}`, materialLOD, babylonMesh, babylonDrawMode, (babylonMaterial) => {\r\n if (indexLOD === 0) {\r\n assign(babylonMaterial);\r\n }\r\n })\r\n .then((babylonMaterial) => {\r\n if (indexLOD !== 0) {\r\n assign(babylonMaterial);\r\n\r\n // TODO: should not rely on _data\r\n const previousDataLOD = materialLODs[indexLOD - 1]._data!;\r\n if (previousDataLOD[babylonDrawMode]) {\r\n this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);\r\n delete previousDataLOD[babylonDrawMode];\r\n }\r\n }\r\n\r\n return babylonMaterial;\r\n });\r\n\r\n this._materialPromiseLODs[indexLOD] = this._materialPromiseLODs[indexLOD] || [];\r\n\r\n if (indexLOD === 0) {\r\n firstPromise = promise;\r\n } else {\r\n this._materialIndexLOD = null;\r\n this._materialPromiseLODs[indexLOD].push(promise);\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n return firstPromise!;\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>> {\r\n // Defer the loading of uris if loading a node or material LOD.\r\n if (this._nodeIndexLOD !== null) {\r\n this._loader.log(`deferred`);\r\n const previousIndexLOD = this._nodeIndexLOD - 1;\r\n this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred<void>();\r\n return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(() => {\r\n return this._loader.loadUriAsync(context, property, uri);\r\n });\r\n } else if (this._materialIndexLOD !== null) {\r\n this._loader.log(`deferred`);\r\n const previousIndexLOD = this._materialIndexLOD - 1;\r\n this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred<void>();\r\n return this._materialSignalLODs[previousIndexLOD].promise.then(() => {\r\n return this._loader.loadUriAsync(context, property, uri);\r\n });\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>> {\r\n if (this._loader.parent.useRangeRequests && !buffer.uri) {\r\n if (!this._loader.bin) {\r\n throw new Error(`${context}: Uri is missing or the binary glTF is missing its binary chunk`);\r\n }\r\n\r\n const loadAsync = (bufferLODs: Array<IBufferInfo>, indexLOD: number) => {\r\n const start = byteOffset;\r\n const end = start + byteLength - 1;\r\n let bufferLOD = bufferLODs[indexLOD];\r\n if (bufferLOD) {\r\n bufferLOD.start = Math.min(bufferLOD.start, start);\r\n bufferLOD.end = Math.max(bufferLOD.end, end);\r\n } else {\r\n bufferLOD = { start: start, end: end, loaded: new Deferred() };\r\n bufferLODs[indexLOD] = bufferLOD;\r\n }\r\n\r\n return bufferLOD.loaded.promise.then((data) => {\r\n return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);\r\n });\r\n };\r\n\r\n this._loader.log(`deferred`);\r\n\r\n if (this._nodeIndexLOD !== null) {\r\n return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);\r\n } else if (this._materialIndexLOD !== null) {\r\n return loadAsync(this._materialBufferLODs, this._materialIndexLOD);\r\n } else {\r\n return loadAsync(this._bufferLODs, 0);\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private _loadBufferLOD(bufferLODs: Array<IBufferInfo>, indexLOD: number): void {\r\n const bufferLOD = bufferLODs[indexLOD];\r\n if (bufferLOD) {\r\n this._loader.log(`Loading buffer range [${bufferLOD.start}-${bufferLOD.end}]`);\r\n this._loader.bin!.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(\r\n (data) => {\r\n bufferLOD.loaded.resolve(data);\r\n },\r\n (error) => {\r\n bufferLOD.loaded.reject(error);\r\n }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * @returns an array of LOD properties from lowest to highest.\r\n * @param context\r\n * @param property\r\n * @param array\r\n * @param ids\r\n */\r\n private _getLODs<T>(context: string, property: T, array: ArrayLike<T> | undefined, ids: number[]): T[] {\r\n if (this.maxLODsToLoad <= 0) {\r\n throw new Error(\"maxLODsToLoad must be greater than zero\");\r\n }\r\n\r\n const properties: T[] = [];\r\n\r\n for (let i = ids.length - 1; i >= 0; i--) {\r\n properties.push(ArrayItem.Get(`${context}/ids/${ids[i]}`, array, ids[i]));\r\n if (properties.length === this.maxLODsToLoad) {\r\n return properties;\r\n }\r\n }\r\n\r\n properties.push(property);\r\n return properties;\r\n }\r\n\r\n private _disposeTransformNode(babylonTransformNode: TransformNode): void {\r\n const babylonMaterials: Material[] = [];\r\n const babylonMaterial = (babylonTransformNode as Mesh).material;\r\n if (babylonMaterial) {\r\n babylonMaterials.push(babylonMaterial);\r\n }\r\n for (const babylonMesh of babylonTransformNode.getChildMeshes()) {\r\n if (babylonMesh.material) {\r\n babylonMaterials.push(babylonMesh.material);\r\n }\r\n }\r\n\r\n babylonTransformNode.dispose();\r\n\r\n const babylonMaterialsToDispose = babylonMaterials.filter((babylonMaterial) => this._loader.babylonScene.meshes.every((mesh) => mesh.material != babylonMaterial));\r\n this._disposeMaterials(babylonMaterialsToDispose);\r\n }\r\n\r\n private _disposeMaterials(babylonMaterials: Material[]): void {\r\n const babylonTextures: { [uniqueId: number]: BaseTexture } = {};\r\n\r\n for (const babylonMaterial of babylonMaterials) {\r\n for (const babylonTexture of babylonMaterial.getActiveTextures()) {\r\n babylonTextures[babylonTexture.uniqueId] = babylonTexture;\r\n }\r\n\r\n babylonMaterial.dispose();\r\n }\r\n\r\n for (const uniqueId in babylonTextures) {\r\n for (const babylonMaterial of this._loader.babylonScene.materials) {\r\n if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {\r\n delete babylonTextures[uniqueId];\r\n }\r\n }\r\n }\r\n\r\n for (const uniqueId in babylonTextures) {\r\n babylonTextures[uniqueId].dispose();\r\n }\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new MSFT_lod(loader));\r\n"]}
@@ -1,5 +1,6 @@
1
1
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
3
4
  const NAME = "MSFT_minecraftMesh";
4
5
  /** @internal */
5
6
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -35,5 +36,6 @@ export class MSFT_minecraftMesh {
35
36
  });
36
37
  }
37
38
  }
38
- GLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_minecraftMesh(loader));
39
+ unregisterGLTFExtension(NAME);
40
+ registerGLTFExtension(NAME, true, (loader) => new MSFT_minecraftMesh(loader));
39
41
  //# sourceMappingURL=MSFT_minecraftMesh.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_minecraftMesh.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAI7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAalC,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAS3B,gBAAgB;IAChB,YAAY,MAAkB;QAT9B,gBAAgB;QACA,SAAI,GAAG,IAAI,CAAC;QASxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,cAAc,CAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YAC5F,IAAI,KAAK,EAAE;gBACP,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;oBAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,+BAA+B,CAAC,CAAC;iBACnE;gBAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAE7F,IAAI,eAAe,CAAC,iBAAiB,EAAE,EAAE;oBACrC,eAAe,CAAC,eAAe,GAAG,IAAI,CAAC;oBACvC,eAAe,CAAC,mBAAmB,GAAG,IAAI,CAAC;iBAC9C;gBAED,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;gBAClE,eAAe,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAExC,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\n\r\nconst NAME = \"MSFT_minecraftMesh\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_minecraftMesh extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_minecraftMesh\"]: {};\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_minecraftMesh implements IGLTFLoaderExtension {\r\n /** @internal */\r\n public readonly name = NAME;\r\n\r\n /** @internal */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @internal */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, (extraContext, extra) => {\r\n if (extra) {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${extraContext}: Material type not supported`);\r\n }\r\n\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n if (babylonMaterial.needAlphaBlending()) {\r\n babylonMaterial.forceDepthWrite = true;\r\n babylonMaterial.separateCullingPass = true;\r\n }\r\n\r\n babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;\r\n babylonMaterial.twoSidedLighting = true;\r\n\r\n return promise;\r\n }\r\n\r\n return null;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_minecraftMesh(loader));\r\n"]}
1
+ {"version":3,"file":"MSFT_minecraftMesh.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAI7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAalC,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAS3B,gBAAgB;IAChB,YAAY,MAAkB;QAT9B,gBAAgB;QACA,SAAI,GAAG,IAAI,CAAC;QASxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,cAAc,CAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YAC5F,IAAI,KAAK,EAAE;gBACP,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;oBAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,+BAA+B,CAAC,CAAC;iBACnE;gBAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAE7F,IAAI,eAAe,CAAC,iBAAiB,EAAE,EAAE;oBACrC,eAAe,CAAC,eAAe,GAAG,IAAI,CAAC;oBACvC,eAAe,CAAC,mBAAmB,GAAG,IAAI,CAAC;iBAC9C;gBAED,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;gBAClE,eAAe,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAExC,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"MSFT_minecraftMesh\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_minecraftMesh extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_minecraftMesh\"]: {};\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_minecraftMesh implements IGLTFLoaderExtension {\r\n /** @internal */\r\n public readonly name = NAME;\r\n\r\n /** @internal */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @internal */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, (extraContext, extra) => {\r\n if (extra) {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${extraContext}: Material type not supported`);\r\n }\r\n\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n if (babylonMaterial.needAlphaBlending()) {\r\n babylonMaterial.forceDepthWrite = true;\r\n babylonMaterial.separateCullingPass = true;\r\n }\r\n\r\n babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;\r\n babylonMaterial.twoSidedLighting = true;\r\n\r\n return promise;\r\n }\r\n\r\n return null;\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new MSFT_minecraftMesh(loader));\r\n"]}
@@ -1,5 +1,6 @@
1
1
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
3
4
  const NAME = "MSFT_sRGBFactors";
4
5
  /** @internal */
5
6
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -36,5 +37,6 @@ export class MSFT_sRGBFactors {
36
37
  });
37
38
  }
38
39
  }
39
- GLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_sRGBFactors(loader));
40
+ unregisterGLTFExtension(NAME);
41
+ registerGLTFExtension(NAME, true, (loader) => new MSFT_sRGBFactors(loader));
40
42
  //# sourceMappingURL=MSFT_sRGBFactors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_sRGBFactors.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAI7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAahC,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,OAAO,gBAAgB;IASzB,gBAAgB;IAChB,YAAY,MAAkB;QAT9B,gBAAgB;QACA,SAAI,GAAG,IAAI,CAAC;QASxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,cAAc,CAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YAC5F,IAAI,KAAK,EAAE;gBACP,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;oBAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,+BAA+B,CAAC,CAAC;iBACnE;gBAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAE7F,MAAM,uBAAuB,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC,uBAAuB,CAAC;gBAC/F,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE;oBAChC,eAAe,CAAC,WAAW,CAAC,kBAAkB,CAAC,eAAe,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;iBACxG;gBAED,IAAI,CAAC,eAAe,CAAC,mBAAmB,EAAE;oBACtC,eAAe,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;iBACpH;gBAED,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\n\r\nconst NAME = \"MSFT_sRGBFactors\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_sRGBFactors extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_sRGBFactors\"]: {};\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_sRGBFactors implements IGLTFLoaderExtension {\r\n /** @internal */\r\n public readonly name = NAME;\r\n\r\n /** @internal */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @internal */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, (extraContext, extra) => {\r\n if (extra) {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${extraContext}: Material type not supported`);\r\n }\r\n\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n const useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions;\r\n if (!babylonMaterial.albedoTexture) {\r\n babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions);\r\n }\r\n\r\n if (!babylonMaterial.reflectivityTexture) {\r\n babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions);\r\n }\r\n\r\n return promise;\r\n }\r\n\r\n return null;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_sRGBFactors(loader));\r\n"]}
1
+ {"version":3,"file":"MSFT_sRGBFactors.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAI7D,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AAe,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;iBACpH;gBAED,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"MSFT_sRGBFactors\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_sRGBFactors extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_sRGBFactors\"]: {};\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_sRGBFactors implements IGLTFLoaderExtension {\r\n /** @internal */\r\n public readonly name = NAME;\r\n\r\n /** @internal */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @internal */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, (extraContext, extra) => {\r\n if (extra) {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${extraContext}: Material type not supported`);\r\n }\r\n\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n const useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions;\r\n if (!babylonMaterial.albedoTexture) {\r\n babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions);\r\n }\r\n\r\n if (!babylonMaterial.reflectivityTexture) {\r\n babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions);\r\n }\r\n\r\n return promise;\r\n }\r\n\r\n return null;\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new MSFT_sRGBFactors(loader));\r\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Registers the built-in glTF 2.0 extension async factories, which dynamically imports and loads each glTF extension on demand (e.g. only when a glTF model uses the extension).
3
+ */
4
+ export declare function registerBuiltInGLTFExtensions(): void;