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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. package/package.json +20 -198
  2. package/OBJ/index.d.ts +0 -4
  3. package/OBJ/index.js +0 -5
  4. package/OBJ/index.js.map +0 -1
  5. package/OBJ/mtlFileLoader.d.ts +0 -40
  6. package/OBJ/mtlFileLoader.js +0 -222
  7. package/OBJ/mtlFileLoader.js.map +0 -1
  8. package/OBJ/objFileLoader.d.ts +0 -133
  9. package/OBJ/objFileLoader.js +0 -301
  10. package/OBJ/objFileLoader.js.map +0 -1
  11. package/OBJ/objLoadingOptions.d.ts +0 -43
  12. package/OBJ/objLoadingOptions.js +0 -2
  13. package/OBJ/objLoadingOptions.js.map +0 -1
  14. package/OBJ/solidParser.d.ts +0 -153
  15. package/OBJ/solidParser.js +0 -700
  16. package/OBJ/solidParser.js.map +0 -1
  17. package/STL/index.d.ts +0 -1
  18. package/STL/index.js +0 -2
  19. package/STL/index.js.map +0 -1
  20. package/STL/stlFileLoader.d.ts +0 -71
  21. package/STL/stlFileLoader.js +0 -240
  22. package/STL/stlFileLoader.js.map +0 -1
  23. package/glTF/1.0/glTFBinaryExtension.d.ts +0 -13
  24. package/glTF/1.0/glTFBinaryExtension.js +0 -62
  25. package/glTF/1.0/glTFBinaryExtension.js.map +0 -1
  26. package/glTF/1.0/glTFLoader.d.ts +0 -106
  27. package/glTF/1.0/glTFLoader.js +0 -1697
  28. package/glTF/1.0/glTFLoader.js.map +0 -1
  29. package/glTF/1.0/glTFLoaderInterfaces.d.ts +0 -412
  30. package/glTF/1.0/glTFLoaderInterfaces.js +0 -96
  31. package/glTF/1.0/glTFLoaderInterfaces.js.map +0 -1
  32. package/glTF/1.0/glTFLoaderUtils.d.ts +0 -62
  33. package/glTF/1.0/glTFLoaderUtils.js +0 -233
  34. package/glTF/1.0/glTFLoaderUtils.js.map +0 -1
  35. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +0 -10
  36. package/glTF/1.0/glTFMaterialsCommonExtension.js +0 -128
  37. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +0 -1
  38. package/glTF/1.0/index.d.ts +0 -5
  39. package/glTF/1.0/index.js +0 -6
  40. package/glTF/1.0/index.js.map +0 -1
  41. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +0 -36
  42. package/glTF/2.0/Extensions/EXT_lights_image_based.js +0 -111
  43. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +0 -1
  44. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +0 -27
  45. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +0 -80
  46. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +0 -1
  47. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +0 -27
  48. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +0 -43
  49. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +0 -1
  50. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +0 -21
  51. package/glTF/2.0/Extensions/EXT_texture_webp.js +0 -33
  52. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +0 -1
  53. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +0 -32
  54. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +0 -56
  55. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +0 -1
  56. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +0 -31
  57. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +0 -102
  58. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +0 -1
  59. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +0 -28
  60. package/glTF/2.0/Extensions/KHR_lights_punctual.js +0 -82
  61. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +0 -1
  62. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +0 -31
  63. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +0 -87
  64. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +0 -1
  65. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +0 -30
  66. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +0 -46
  67. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +0 -1
  68. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +0 -34
  69. package/glTF/2.0/Extensions/KHR_materials_ior.js +0 -55
  70. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +0 -1
  71. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +0 -30
  72. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +0 -73
  73. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +0 -1
  74. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -31
  75. package/glTF/2.0/Extensions/KHR_materials_sheen.js +0 -77
  76. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +0 -1
  77. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +0 -30
  78. package/glTF/2.0/Extensions/KHR_materials_specular.js +0 -67
  79. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +0 -1
  80. package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +0 -31
  81. package/glTF/2.0/Extensions/KHR_materials_translucency.js +0 -77
  82. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +0 -1
  83. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +0 -30
  84. package/glTF/2.0/Extensions/KHR_materials_transmission.js +0 -278
  85. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +0 -1
  86. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +0 -30
  87. package/glTF/2.0/Extensions/KHR_materials_unlit.js +0 -66
  88. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +0 -1
  89. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +0 -76
  90. package/glTF/2.0/Extensions/KHR_materials_variants.js +0 -244
  91. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +0 -1
  92. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +0 -31
  93. package/glTF/2.0/Extensions/KHR_materials_volume.js +0 -79
  94. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +0 -1
  95. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +0 -19
  96. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +0 -22
  97. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +0 -1
  98. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +0 -21
  99. package/glTF/2.0/Extensions/KHR_texture_basisu.js +0 -33
  100. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +0 -1
  101. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +0 -25
  102. package/glTF/2.0/Extensions/KHR_texture_transform.js +0 -54
  103. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +0 -1
  104. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +0 -29
  105. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +0 -47
  106. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +0 -1
  107. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +0 -38
  108. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +0 -217
  109. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +0 -1
  110. package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -75
  111. package/glTF/2.0/Extensions/MSFT_lod.js +0 -334
  112. package/glTF/2.0/Extensions/MSFT_lod.js.map +0 -1
  113. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +0 -14
  114. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +0 -37
  115. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +0 -1
  116. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +0 -14
  117. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +0 -37
  118. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +0 -1
  119. package/glTF/2.0/Extensions/index.d.ts +0 -26
  120. package/glTF/2.0/Extensions/index.js +0 -27
  121. package/glTF/2.0/Extensions/index.js.map +0 -1
  122. package/glTF/2.0/glTFLoader.d.ts +0 -357
  123. package/glTF/2.0/glTFLoader.js +0 -2249
  124. package/glTF/2.0/glTFLoader.js.map +0 -1
  125. package/glTF/2.0/glTFLoaderExtension.d.ts +0 -152
  126. package/glTF/2.0/glTFLoaderExtension.js +0 -2
  127. package/glTF/2.0/glTFLoaderExtension.js.map +0 -1
  128. package/glTF/2.0/glTFLoaderInterfaces.d.ts +0 -209
  129. package/glTF/2.0/glTFLoaderInterfaces.js +0 -2
  130. package/glTF/2.0/glTFLoaderInterfaces.js.map +0 -1
  131. package/glTF/2.0/index.d.ts +0 -4
  132. package/glTF/2.0/index.js +0 -5
  133. package/glTF/2.0/index.js.map +0 -1
  134. package/glTF/glTFFileLoader.d.ts +0 -368
  135. package/glTF/glTFFileLoader.js +0 -869
  136. package/glTF/glTFFileLoader.js.map +0 -1
  137. package/glTF/glTFValidation.d.ts +0 -29
  138. package/glTF/glTFValidation.js +0 -122
  139. package/glTF/glTFValidation.js.map +0 -1
  140. package/glTF/index.d.ts +0 -5
  141. package/glTF/index.js +0 -6
  142. package/glTF/index.js.map +0 -1
  143. package/index.d.ts +0 -3
  144. package/index.js.map +0 -1
  145. package/legacy/legacy-glTF.d.ts +0 -2
  146. package/legacy/legacy-glTF.js +0 -19
  147. package/legacy/legacy-glTF.js.map +0 -1
  148. package/legacy/legacy-glTF1.d.ts +0 -2
  149. package/legacy/legacy-glTF1.js +0 -15
  150. package/legacy/legacy-glTF1.js.map +0 -1
  151. package/legacy/legacy-glTF1FileLoader.d.ts +0 -2
  152. package/legacy/legacy-glTF1FileLoader.js +0 -3
  153. package/legacy/legacy-glTF1FileLoader.js.map +0 -1
  154. package/legacy/legacy-glTF2.d.ts +0 -2
  155. package/legacy/legacy-glTF2.js +0 -33
  156. package/legacy/legacy-glTF2.js.map +0 -1
  157. package/legacy/legacy-glTF2FileLoader.d.ts +0 -2
  158. package/legacy/legacy-glTF2FileLoader.js +0 -3
  159. package/legacy/legacy-glTF2FileLoader.js.map +0 -1
  160. package/legacy/legacy-glTFFileLoader.d.ts +0 -3
  161. package/legacy/legacy-glTFFileLoader.js +0 -4
  162. package/legacy/legacy-glTFFileLoader.js.map +0 -1
  163. package/legacy/legacy-objFileLoader.d.ts +0 -1
  164. package/legacy/legacy-objFileLoader.js +0 -13
  165. package/legacy/legacy-objFileLoader.js.map +0 -1
  166. package/legacy/legacy-stlFileLoader.d.ts +0 -1
  167. package/legacy/legacy-stlFileLoader.js +0 -13
  168. package/legacy/legacy-stlFileLoader.js.map +0 -1
  169. package/legacy/legacy.d.ts +0 -6
  170. package/legacy/legacy.js +0 -7
  171. package/legacy/legacy.js.map +0 -1
  172. package/readme.md +0 -24
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAY,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAgDnD;;GAEG;AACH;IAkCI;;;;OAIG;IACH,4BAAY,OAA4C,EAAE,KAAY;QAAtE,iBAeC;QA/BO,wBAAmB,GAAkC,IAAI,CAAC;QAC1D,uBAAkB,GAAmB,EAAE,CAAC;QACxC,4BAAuB,GAAmB,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,OAAoB;gBACvB,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBAC5D,WAAW,CAAC,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACvD,CAAC,CAAC,CAAC;SACV;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;IACL,iCAAC;AAAD,CAAC,AAnFD,IAmFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { IKHRMaterialsTransmission } from 'babylonjs-gltf2interface';\nimport { Scene } from \"@babylonjs/core/scene\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\nimport { RenderTargetTexture } from \"@babylonjs/core/Materials/Textures/renderTargetTexture\";\nimport { Observable, Observer } from \"@babylonjs/core/Misc/observable\";\nimport { Constants } from \"@babylonjs/core/Engines/constants\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { Color4 } from \"@babylonjs/core/Maths/math.color\";\n\ninterface ITransmissionHelperHolder {\n /**\n * @hidden\n */\n _transmissionHelper: TransmissionHelper | undefined;\n}\n\ninterface ITransmissionHelperOptions {\n /**\n * The size of the render buffers (default: 1024)\n */\n renderSize: number;\n\n /**\n * The number of samples to use when generating the render target texture for opaque meshes (default: 4)\n */\n samples: number;\n\n /**\n * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)\n */\n lodGenerationScale: number;\n\n /**\n * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)\n */\n lodGenerationOffset: number;\n\n /**\n * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)\n */\n renderTargetTextureType: number;\n\n /**\n * Defines if the mipmaps for the refraction render target texture must be generated (default: true)\n */\n generateMipmaps: boolean;\n\n /**\n * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).\n * If provided, should be in linear space\n */\n clearColor?: Color4;\n}\n\n/**\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\n */\nclass TransmissionHelper {\n\n /**\n * Creates the default options for the helper.\n */\n private static _getDefaultOptions(): ITransmissionHelperOptions {\n return {\n renderSize: 1024,\n samples: 4,\n lodGenerationScale: 1,\n lodGenerationOffset: -4,\n renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,\n generateMipmaps: true,\n };\n }\n\n /**\n * Stores the creation options.\n */\n private readonly _scene: Scene & ITransmissionHelperHolder;\n\n private _options: ITransmissionHelperOptions;\n\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\n private _opaqueMeshesCache: AbstractMesh[] = [];\n private _transparentMeshesCache: AbstractMesh[] = [];\n private _materialObservers: { [id: string]: Nullable<Observer<AbstractMesh>> } = {};\n\n /**\n * This observable will be notified with any error during the creation of the environment,\n * mainly texture creation errors.\n */\n public onErrorObservable: Observable<{ message?: string, exception?: any }>;\n\n /**\n * constructor\n * @param options Defines the options we want to customize the helper\n * @param scene The scene to add the material to\n */\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\n this._options = {\n ...TransmissionHelper._getDefaultOptions(),\n ...options\n };\n this._scene = scene as any;\n this._scene._transmissionHelper = this;\n\n this.onErrorObservable = new Observable();\n this._scene.onDisposeObservable.addOnce((scene) => {\n this.dispose();\n });\n\n this._parseScene();\n this._setupRenderTargets();\n }\n\n /**\n * Updates the background according to the new options\n * @param options\n */\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\n // First check if any options are actually being changed. If not, exit.\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\n if (!newValues.length) {\n return;\n }\n\n const newOptions = {\n ...this._options,\n ...options\n };\n\n const oldOptions = this._options;\n this._options = newOptions;\n\n // If size changes, recreate everything\n if (newOptions.renderSize !== oldOptions.renderSize || newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || newOptions.generateMipmaps !== oldOptions.generateMipmaps || !this._opaqueRenderTarget) {\n this._setupRenderTargets();\n } else {\n this._opaqueRenderTarget.samples = newOptions.samples;\n this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;\n this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;\n }\n }\n\n public getOpaqueTarget(): Nullable<Texture> {\n return this._opaqueRenderTarget;\n }\n\n private shouldRenderAsTransmission(material: Nullable<Material>): boolean {\n if (!material) {\n return false;\n }\n if (material instanceof PBRMaterial && (material.subSurface.isRefractionEnabled)) {\n return true;\n }\n return false;\n }\n\n private _addMesh(mesh: AbstractMesh): void {\n this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));\n\n // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some\n // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)\n Tools.SetImmediate(() => {\n if (this.shouldRenderAsTransmission(mesh.material)) {\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\n this._transparentMeshesCache.push(mesh);\n } else {\n this._opaqueMeshesCache.push(mesh);\n }\n });\n }\n\n private _removeMesh(mesh: AbstractMesh): void {\n mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);\n delete this._materialObservers[mesh.uniqueId];\n let idx = this._transparentMeshesCache.indexOf(mesh);\n if (idx !== -1) {\n this._transparentMeshesCache.splice(idx, 1);\n }\n idx = this._opaqueMeshesCache.indexOf(mesh);\n if (idx !== -1) {\n this._opaqueMeshesCache.splice(idx, 1);\n }\n }\n\n private _parseScene(): void {\n this._scene.meshes.forEach(this._addMesh.bind(this));\n // Listen for when a mesh is added to the scene and add it to our cache lists.\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\n }\n\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\n private _onMeshMaterialChanged(mesh: AbstractMesh) {\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\n\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\n const useTransmission = this.shouldRenderAsTransmission(mesh.material);\n if (useTransmission) {\n if (mesh.material instanceof PBRMaterial) {\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\n }\n if (opaqueIdx !== -1) {\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\n this._transparentMeshesCache.push(mesh);\n } else if (transparentIdx === -1) {\n this._transparentMeshesCache.push(mesh);\n }\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\n } else {\n if (transparentIdx !== -1) {\n this._transparentMeshesCache.splice(transparentIdx, 1);\n this._opaqueMeshesCache.push(mesh);\n } else if (opaqueIdx === -1) {\n this._opaqueMeshesCache.push(mesh);\n }\n }\n }\n\n /**\n * Setup the render targets according to the specified options.\n */\n private _setupRenderTargets(): void {\n if (this._opaqueRenderTarget) {\n this._opaqueRenderTarget.dispose();\n }\n this._opaqueRenderTarget = new RenderTargetTexture(\"opaqueSceneTexture\", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType);\n this._opaqueRenderTarget.ignoreCameraViewport = true;\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\n this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();\n this._opaqueRenderTarget.gammaSpace = false;\n this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;\n this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;\n this._opaqueRenderTarget.samples = this._options.samples;\n\n let sceneImageProcessingapplyByPostProcess: boolean;\n\n let saveSceneEnvIntensity: number;\n this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {\n saveSceneEnvIntensity = this._scene.environmentIntensity;\n this._scene.environmentIntensity = 1.0;\n sceneImageProcessingapplyByPostProcess = this._scene.imageProcessingConfiguration.applyByPostProcess;\n if (!this._options.clearColor) {\n this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor);\n } else {\n opaqueRenderTarget.clearColor.copyFrom(this._options.clearColor);\n }\n // we do not use the applyByPostProcess setter to avoid flagging all the materials as \"image processing dirty\"!\n this._scene.imageProcessingConfiguration._applyByPostProcess = true;\n });\n this._opaqueRenderTarget.onAfterUnbindObservable.add(() => {\n this._scene.environmentIntensity = saveSceneEnvIntensity;\n this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;\n });\n\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\n if (this.shouldRenderAsTransmission(mesh.material)) {\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\n }\n });\n }\n\n /**\n * Dispose all the elements created by the Helper.\n */\n public dispose(): void {\n this._scene._transmissionHelper = undefined;\n if (this._opaqueRenderTarget) {\n this._opaqueRenderTarget.dispose();\n this._opaqueRenderTarget = null;\n }\n this._transparentMeshesCache = [];\n this._opaqueMeshesCache = [];\n }\n}\n\nconst NAME = \"KHR_materials_transmission\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\n */\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 175;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n if (this.enabled) {\n loader.parent.transparencyAsCoverage = true;\n }\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\n return Promise.all(promises).then(() => { });\n });\n }\n\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n let pbrMaterial = babylonMaterial as PBRMaterial;\n\n // Enables \"refraction\" texture which represents transmitted light.\n pbrMaterial.subSurface.isRefractionEnabled = true;\n\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\n\n // Albedo colour will tint transmission.\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\n\n if (extension.transmissionFactor !== undefined) {\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\n new TransmissionHelper({}, pbrMaterial.getScene());\n }\n } else {\n pbrMaterial.subSurface.refractionIntensity = 0.0;\n pbrMaterial.subSurface.isRefractionEnabled = false;\n return Promise.resolve();\n }\n\n pbrMaterial.subSurface.minimumThickness = 0.0;\n pbrMaterial.subSurface.maximumThickness = 0.0;\n if (extension.transmissionTexture) {\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined)\n .then((texture: BaseTexture) => {\n pbrMaterial.subSurface.refractionIntensityTexture = texture;\n pbrMaterial.subSurface.useGltfStyleTextures = true;\n });\n } else {\n return Promise.resolve();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\n"]}
@@ -1,30 +0,0 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { Material } from "@babylonjs/core/Materials/material";
3
- import { IMaterial } from "../glTFLoaderInterfaces";
4
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
- import { GLTFLoader } from "../glTFLoader";
6
- /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
8
- */
9
- export declare class KHR_materials_unlit implements IGLTFLoaderExtension {
10
- /**
11
- * The name of this extension.
12
- */
13
- readonly name = "KHR_materials_unlit";
14
- /**
15
- * Defines whether this extension is enabled.
16
- */
17
- enabled: boolean;
18
- /**
19
- * Defines a number that determines the order the extensions are applied.
20
- */
21
- order: number;
22
- private _loader;
23
- /** @hidden */
24
- constructor(loader: GLTFLoader);
25
- /** @hidden */
26
- dispose(): void;
27
- /** @hidden */
28
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
29
- private _loadUnlitPropertiesAsync;
30
- }
@@ -1,66 +0,0 @@
1
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
2
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
3
- import { GLTFLoader } from "../glTFLoader.js";
4
- var NAME = "KHR_materials_unlit";
5
- /**
6
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
7
- */
8
- var KHR_materials_unlit = /** @class */ (function () {
9
- /** @hidden */
10
- function KHR_materials_unlit(loader) {
11
- /**
12
- * The name of this extension.
13
- */
14
- this.name = NAME;
15
- /**
16
- * Defines a number that determines the order the extensions are applied.
17
- */
18
- this.order = 210;
19
- this._loader = loader;
20
- this.enabled = this._loader.isExtensionUsed(NAME);
21
- }
22
- /** @hidden */
23
- KHR_materials_unlit.prototype.dispose = function () {
24
- this._loader = null;
25
- };
26
- /** @hidden */
27
- KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
28
- var _this = this;
29
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function () {
30
- return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial);
31
- });
32
- };
33
- KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) {
34
- if (!(babylonMaterial instanceof PBRMaterial)) {
35
- throw new Error("".concat(context, ": Material type not supported"));
36
- }
37
- var promises = new Array();
38
- babylonMaterial.unlit = true;
39
- var properties = material.pbrMetallicRoughness;
40
- if (properties) {
41
- if (properties.baseColorFactor) {
42
- babylonMaterial.albedoColor = Color3.FromArray(properties.baseColorFactor);
43
- babylonMaterial.alpha = properties.baseColorFactor[3];
44
- }
45
- else {
46
- babylonMaterial.albedoColor = Color3.White();
47
- }
48
- if (properties.baseColorTexture) {
49
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) {
50
- texture.name = "".concat(babylonMaterial.name, " (Base Color)");
51
- babylonMaterial.albedoTexture = texture;
52
- }));
53
- }
54
- }
55
- if (material.doubleSided) {
56
- babylonMaterial.backFaceCulling = false;
57
- babylonMaterial.twoSidedLighting = true;
58
- }
59
- this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
60
- return Promise.all(promises).then(function () { });
61
- };
62
- return KHR_materials_unlit;
63
- }());
64
- export { KHR_materials_unlit };
65
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); });
66
- //# sourceMappingURL=KHR_materials_unlit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_unlit.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH;IAkBI,cAAc;IACd,6BAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAMf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,qCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,cAAc;IACP,yDAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAIC;QAHG,OAAO,UAAU,CAAC,kBAAkB,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE;YAC/D,OAAO,KAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,uDAAyB,GAAjC,UAAkC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC7F,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,UAAG,OAAO,kCAA+B,CAA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,CAAC,MAAM,CAAC,EAA/B,CAA+B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Color3 } from \"@babylonjs/core/Maths/math.color\";\r\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\r\nimport { Material } from \"@babylonjs/core/Materials/material\";\r\n\r\nimport { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_materials_unlit\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)\r\n */\r\nexport class KHR_materials_unlit 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 = 210;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync(context, material, this.name, () => {\r\n return this._loadUnlitPropertiesAsync(context, material, babylonMaterial);\r\n });\r\n }\r\n\r\n private _loadUnlitPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n babylonMaterial.unlit = true;\r\n\r\n const properties = material.pbrMetallicRoughness;\r\n if (properties) {\r\n if (properties.baseColorFactor) {\r\n babylonMaterial.albedoColor = Color3.FromArray(properties.baseColorFactor);\r\n babylonMaterial.alpha = properties.baseColorFactor[3];\r\n }\r\n else {\r\n babylonMaterial.albedoColor = Color3.White();\r\n }\r\n\r\n if (properties.baseColorTexture) {\r\n promises.push(this._loader.loadTextureInfoAsync(`${context}/baseColorTexture`, properties.baseColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Base Color)`;\r\n babylonMaterial.albedoTexture = texture;\r\n }));\r\n }\r\n }\r\n\r\n if (material.doubleSided) {\r\n babylonMaterial.backFaceCulling = false;\r\n babylonMaterial.twoSidedLighting = true;\r\n }\r\n\r\n this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);\r\n\r\n return Promise.all(promises).then(() => { });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_unlit(loader));"]}
@@ -1,76 +0,0 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
3
- import { GLTFLoader } from "../glTFLoader";
4
- import { Mesh } from '@babylonjs/core/Meshes/mesh';
5
- import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
6
- import { INode, IMeshPrimitive, IMesh } from '../glTFLoaderInterfaces';
7
- /**
8
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
9
- */
10
- export declare class KHR_materials_variants implements IGLTFLoaderExtension {
11
- /**
12
- * The name of this extension.
13
- */
14
- readonly name = "KHR_materials_variants";
15
- /**
16
- * Defines whether this extension is enabled.
17
- */
18
- enabled: boolean;
19
- private _loader;
20
- private _variants?;
21
- /** @hidden */
22
- constructor(loader: GLTFLoader);
23
- /** @hidden */
24
- dispose(): void;
25
- /**
26
- * Gets the list of available variant names for this asset.
27
- * @param rootMesh The glTF root mesh
28
- * @returns the list of all the variant names for this model
29
- */
30
- static GetAvailableVariants(rootMesh: Mesh): string[];
31
- /**
32
- * Gets the list of available variant names for this asset.
33
- * @param rootMesh The glTF root mesh
34
- * @returns the list of all the variant names for this model
35
- */
36
- getAvailableVariants(rootMesh: Mesh): string[];
37
- /**
38
- * Select a variant given a variant name or a list of variant names.
39
- * @param rootMesh The glTF root mesh
40
- * @param variantName The variant name(s) to select.
41
- */
42
- static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
43
- /**
44
- * Select a variant given a variant name or a list of variant names.
45
- * @param rootMesh The glTF root mesh
46
- * @param variantName The variant name(s) to select.
47
- */
48
- selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
49
- /**
50
- * Reset back to the original before selecting a variant.
51
- * @param rootMesh The glTF root mesh
52
- */
53
- static Reset(rootMesh: Mesh): void;
54
- /**
55
- * Reset back to the original before selecting a variant.
56
- * @param rootMesh The glTF root mesh
57
- */
58
- reset(rootMesh: Mesh): void;
59
- /**
60
- * Gets the last selected variant name(s) or null if original.
61
- * @param rootMesh The glTF root mesh
62
- * @returns The selected variant name(s).
63
- */
64
- static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
65
- /**
66
- * Gets the last selected variant name(s) or null if original.
67
- * @param rootMesh The glTF root mesh
68
- * @returns The selected variant name(s).
69
- */
70
- getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
71
- private static _GetExtensionMetadata;
72
- /** @hidden */
73
- onLoading(): void;
74
- /** @hidden */
75
- _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
76
- }
@@ -1,244 +0,0 @@
1
- import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
2
- import { Mesh } from '@babylonjs/core/Meshes/mesh.js';
3
- var NAME = "KHR_materials_variants";
4
- /**
5
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
6
- */
7
- var KHR_materials_variants = /** @class */ (function () {
8
- /** @hidden */
9
- function KHR_materials_variants(loader) {
10
- /**
11
- * The name of this extension.
12
- */
13
- this.name = NAME;
14
- this._loader = loader;
15
- this.enabled = this._loader.isExtensionUsed(NAME);
16
- }
17
- /** @hidden */
18
- KHR_materials_variants.prototype.dispose = function () {
19
- this._loader = null;
20
- };
21
- /**
22
- * Gets the list of available variant names for this asset.
23
- * @param rootMesh The glTF root mesh
24
- * @returns the list of all the variant names for this model
25
- */
26
- KHR_materials_variants.GetAvailableVariants = function (rootMesh) {
27
- var extensionMetadata = this._GetExtensionMetadata(rootMesh);
28
- if (!extensionMetadata) {
29
- return [];
30
- }
31
- return Object.keys(extensionMetadata.variants);
32
- };
33
- /**
34
- * Gets the list of available variant names for this asset.
35
- * @param rootMesh The glTF root mesh
36
- * @returns the list of all the variant names for this model
37
- */
38
- KHR_materials_variants.prototype.getAvailableVariants = function (rootMesh) {
39
- return KHR_materials_variants.GetAvailableVariants(rootMesh);
40
- };
41
- /**
42
- * Select a variant given a variant name or a list of variant names.
43
- * @param rootMesh The glTF root mesh
44
- * @param variantName The variant name(s) to select.
45
- */
46
- KHR_materials_variants.SelectVariant = function (rootMesh, variantName) {
47
- var extensionMetadata = this._GetExtensionMetadata(rootMesh);
48
- if (!extensionMetadata) {
49
- throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(NAME, " extension"));
50
- }
51
- var select = function (variantName) {
52
- var entries = extensionMetadata.variants[variantName];
53
- if (entries) {
54
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
55
- var entry = entries_1[_i];
56
- entry.mesh.material = entry.material;
57
- }
58
- }
59
- };
60
- if (variantName instanceof Array) {
61
- for (var _i = 0, variantName_1 = variantName; _i < variantName_1.length; _i++) {
62
- var name_1 = variantName_1[_i];
63
- select(name_1);
64
- }
65
- }
66
- else {
67
- select(variantName);
68
- }
69
- extensionMetadata.lastSelected = variantName;
70
- };
71
- /**
72
- * Select a variant given a variant name or a list of variant names.
73
- * @param rootMesh The glTF root mesh
74
- * @param variantName The variant name(s) to select.
75
- */
76
- KHR_materials_variants.prototype.selectVariant = function (rootMesh, variantName) {
77
- return KHR_materials_variants.SelectVariant(rootMesh, variantName);
78
- };
79
- /**
80
- * Reset back to the original before selecting a variant.
81
- * @param rootMesh The glTF root mesh
82
- */
83
- KHR_materials_variants.Reset = function (rootMesh) {
84
- var extensionMetadata = this._GetExtensionMetadata(rootMesh);
85
- if (!extensionMetadata) {
86
- throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(NAME, " extension"));
87
- }
88
- for (var _i = 0, _a = extensionMetadata.original; _i < _a.length; _i++) {
89
- var entry = _a[_i];
90
- entry.mesh.material = entry.material;
91
- }
92
- extensionMetadata.lastSelected = null;
93
- };
94
- /**
95
- * Reset back to the original before selecting a variant.
96
- * @param rootMesh The glTF root mesh
97
- */
98
- KHR_materials_variants.prototype.reset = function (rootMesh) {
99
- return KHR_materials_variants.Reset(rootMesh);
100
- };
101
- /**
102
- * Gets the last selected variant name(s) or null if original.
103
- * @param rootMesh The glTF root mesh
104
- * @returns The selected variant name(s).
105
- */
106
- KHR_materials_variants.GetLastSelectedVariant = function (rootMesh) {
107
- var extensionMetadata = this._GetExtensionMetadata(rootMesh);
108
- if (!extensionMetadata) {
109
- throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(NAME, " extension"));
110
- }
111
- return extensionMetadata.lastSelected;
112
- };
113
- /**
114
- * Gets the last selected variant name(s) or null if original.
115
- * @param rootMesh The glTF root mesh
116
- * @returns The selected variant name(s).
117
- */
118
- KHR_materials_variants.prototype.getLastSelectedVariant = function (rootMesh) {
119
- return KHR_materials_variants.GetLastSelectedVariant(rootMesh);
120
- };
121
- KHR_materials_variants._GetExtensionMetadata = function (rootMesh) {
122
- var _a, _b;
123
- return ((_b = (_a = rootMesh === null || rootMesh === void 0 ? void 0 : rootMesh.metadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b[NAME]) || null;
124
- };
125
- /** @hidden */
126
- KHR_materials_variants.prototype.onLoading = function () {
127
- var extensions = this._loader.gltf.extensions;
128
- if (extensions && extensions[this.name]) {
129
- var extension = extensions[this.name];
130
- this._variants = extension.variants;
131
- }
132
- };
133
- /** @hidden */
134
- KHR_materials_variants.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) {
135
- var _this = this;
136
- return GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
137
- var promises = new Array();
138
- promises.push(_this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, function (babylonMesh) {
139
- assign(babylonMesh);
140
- if (babylonMesh instanceof Mesh) {
141
- var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);
142
- var root_1 = _this._loader.rootBabylonMesh;
143
- var metadata = (root_1 ? root_1.metadata = root_1.metadata || {} : {});
144
- var gltf = (metadata.gltf = metadata.gltf || {});
145
- var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });
146
- // Store the original material.
147
- extensionMetadata_1.original.push({ mesh: babylonMesh, material: babylonMesh.material });
148
- var _loop_1 = function (mappingIndex) {
149
- var mapping = extension.mappings[mappingIndex];
150
- var material = ArrayItem.Get("".concat(extensionContext, "/mappings/").concat(mappingIndex, "/material"), _this._loader.gltf.materials, mapping.material);
151
- promises.push(_this._loader._loadMaterialAsync("#/materials/".concat(mapping.material), material, babylonMesh, babylonDrawMode, function (babylonMaterial) {
152
- var _loop_2 = function (mappingVariantIndex) {
153
- var variantIndex = mapping.variants[mappingVariantIndex];
154
- var variant = ArrayItem.Get("/extensions/".concat(NAME, "/variants/").concat(variantIndex), _this._variants, variantIndex);
155
- extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || [];
156
- extensionMetadata_1.variants[variant.name].push({
157
- mesh: babylonMesh,
158
- material: babylonMaterial
159
- });
160
- // Replace the target when original mesh is cloned
161
- babylonMesh.onClonedObservable.add(function (newOne) {
162
- var newMesh = newOne;
163
- var metadata = null;
164
- var newRoot = newMesh;
165
- // Find root to get medata
166
- do {
167
- newRoot = newRoot.parent;
168
- if (!newRoot) {
169
- return;
170
- }
171
- metadata = KHR_materials_variants._GetExtensionMetadata(newRoot);
172
- } while (metadata === null);
173
- // Need to clone the metadata on the root (first time only)
174
- if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) {
175
- // Copy main metadata
176
- newRoot.metadata = {};
177
- for (var key in root_1.metadata) {
178
- newRoot.metadata[key] = root_1.metadata[key];
179
- }
180
- // Copy the gltf metadata
181
- newRoot.metadata.gltf = [];
182
- for (var key in root_1.metadata.gltf) {
183
- newRoot.metadata.gltf[key] = root_1.metadata.gltf[key];
184
- }
185
- // Duplicate the extension specific metadata
186
- newRoot.metadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };
187
- for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) {
188
- var original = _a[_i];
189
- newRoot.metadata.gltf[NAME].original.push({
190
- mesh: original.mesh,
191
- material: original.material
192
- });
193
- }
194
- for (var key in metadata.variants) {
195
- if (metadata.variants.hasOwnProperty(key)) {
196
- newRoot.metadata.gltf[NAME].variants[key] = [];
197
- for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) {
198
- var variantEntry = _c[_b];
199
- newRoot.metadata.gltf[NAME].variants[key].push({
200
- mesh: variantEntry.mesh,
201
- material: variantEntry.material
202
- });
203
- }
204
- }
205
- }
206
- metadata = newRoot.metadata.gltf[NAME];
207
- }
208
- // Relocate
209
- for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) {
210
- var target = _e[_d];
211
- if (target.mesh === babylonMesh) {
212
- target.mesh = newMesh;
213
- }
214
- }
215
- for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) {
216
- var target = _g[_f];
217
- if (target.mesh === babylonMesh) {
218
- target.mesh = newMesh;
219
- }
220
- }
221
- });
222
- };
223
- for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {
224
- _loop_2(mappingVariantIndex);
225
- }
226
- }));
227
- };
228
- // For each mapping, look at the variants and make a new entry for them.
229
- for (var mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {
230
- _loop_1(mappingIndex);
231
- }
232
- }
233
- }));
234
- return Promise.all(promises).then(function (_a) {
235
- var babylonMesh = _a[0];
236
- return babylonMesh;
237
- });
238
- });
239
- };
240
- return KHR_materials_variants;
241
- }());
242
- export { KHR_materials_variants };
243
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_variants(loader); });
244
- //# sourceMappingURL=KHR_materials_variants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_variants.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAMnD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AAYtC;;GAEG;AACH;IAeI,cAAc;IACd,gCAAY,MAAkB;QAf9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAaxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,wCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACW,2CAAoB,GAAlC,UAAmC,QAAc;QAC7C,IAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,iBAAiB,EAAE;YACpB,OAAO,EAAE,CAAC;SACb;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,C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gCACL,CAAC,CAAC,CAAC;;4BAzEP,KAAK,IAAI,mBAAmB,GAAG,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,mBAAmB;wCAA7F,mBAAmB;6BA0E3B;wBACL,CAAC,CAAC,CAAC,CAAC;;oBAhFR,wEAAwE;oBACxE,KAAK,IAAI,YAAY,GAAG,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,YAAY;gCAA1E,YAAY;qBAgFpB;iBACJ;YACL,CAAC,CAAC,CAAC,CAAC;YACJ,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAC,EAAa;oBAAZ,WAAW,QAAA;gBAC3C,OAAO,WAAW,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACL,6BAAC;AAAD,CAAC,AAjQD,IAiQC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\n\nimport { Material } from '@babylonjs/core/Materials/material';\nimport { Mesh } from '@babylonjs/core/Meshes/mesh';\nimport { Node } from '@babylonjs/core/node';\nimport { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';\nimport { INode, IMeshPrimitive, IMesh } from '../glTFLoaderInterfaces';\nimport { IKHRMaterialVariants_Mapping, IKHRMaterialVariants_Variant, IKHRMaterialVariants_Variants } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_variants\";\n\ninterface IVariantsMap {\n [key: string]: Array<{ mesh: AbstractMesh, material: Nullable<Material> }>;\n}\n\ninterface IExtensionMetadata {\n lastSelected: Nullable<string | Array<string>>;\n original: Array<{ mesh: AbstractMesh, material: Nullable<Material> }>;\n variants: IVariantsMap;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)\n */\nexport class KHR_materials_variants implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n private _variants?: Array<IKHRMaterialVariants_Variant>;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /**\n * Gets the list of available variant names for this asset.\n * @param rootMesh The glTF root mesh\n * @returns the list of all the variant names for this model\n */\n public static GetAvailableVariants(rootMesh: Mesh): string[] {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n return [];\n }\n\n return Object.keys(extensionMetadata.variants);\n }\n\n /**\n * Gets the list of available variant names for this asset.\n * @param rootMesh The glTF root mesh\n * @returns the list of all the variant names for this model\n */\n public getAvailableVariants(rootMesh: Mesh): string[] {\n return KHR_materials_variants.GetAvailableVariants(rootMesh);\n }\n\n /**\n * Select a variant given a variant name or a list of variant names.\n * @param rootMesh The glTF root mesh\n * @param variantName The variant name(s) to select.\n */\n public static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot select variant on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n const select = (variantName: string): void => {\n const entries = extensionMetadata.variants[variantName];\n if (entries) {\n for (const entry of entries) {\n entry.mesh.material = entry.material;\n }\n }\n };\n\n if (variantName instanceof Array) {\n for (const name of variantName) {\n select(name);\n }\n } else {\n select(variantName);\n }\n\n extensionMetadata.lastSelected = variantName;\n }\n\n /**\n * Select a variant given a variant name or a list of variant names.\n * @param rootMesh The glTF root mesh\n * @param variantName The variant name(s) to select.\n */\n public selectVariant(rootMesh: Mesh, variantName: string | string[]): void {\n return KHR_materials_variants.SelectVariant(rootMesh, variantName);\n }\n\n /**\n * Reset back to the original before selecting a variant.\n * @param rootMesh The glTF root mesh\n */\n public static Reset(rootMesh: Mesh): void {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot reset on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n for (const entry of extensionMetadata.original) {\n entry.mesh.material = entry.material;\n }\n\n extensionMetadata.lastSelected = null;\n }\n\n /**\n * Reset back to the original before selecting a variant.\n * @param rootMesh The glTF root mesh\n */\n public reset(rootMesh: Mesh): void {\n return KHR_materials_variants.Reset(rootMesh);\n }\n\n /**\n * Gets the last selected variant name(s) or null if original.\n * @param rootMesh The glTF root mesh\n * @returns The selected variant name(s).\n */\n public static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n return extensionMetadata.lastSelected;\n }\n\n /**\n * Gets the last selected variant name(s) or null if original.\n * @param rootMesh The glTF root mesh\n * @returns The selected variant name(s).\n */\n public getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\n return KHR_materials_variants.GetLastSelectedVariant(rootMesh);\n }\n\n private static _GetExtensionMetadata(rootMesh: Nullable<Mesh>): Nullable<IExtensionMetadata> {\n return rootMesh?.metadata?.gltf?.[NAME] || null;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IKHRMaterialVariants_Variants;\n this._variants = extension.variants;\n }\n }\n\n /** @hidden */\n public _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialVariants_Mapping, AbstractMesh>(context, primitive, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, (babylonMesh) => {\n assign(babylonMesh);\n\n if (babylonMesh instanceof Mesh) {\n const babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);\n\n const root = this._loader.rootBabylonMesh;\n const metadata = (root ? root.metadata = root.metadata || {} : {});\n const gltf = (metadata.gltf = metadata.gltf || {});\n const extensionMetadata: IExtensionMetadata = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });\n\n // Store the original material.\n extensionMetadata.original.push({ mesh: babylonMesh, material: babylonMesh.material });\n\n // For each mapping, look at the variants and make a new entry for them.\n for (let mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {\n const mapping = extension.mappings[mappingIndex];\n const material = ArrayItem.Get(`${extensionContext}/mappings/${mappingIndex}/material`, this._loader.gltf.materials, mapping.material);\n promises.push(this._loader._loadMaterialAsync(`#/materials/${mapping.material}`, material, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n for (let mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {\n const variantIndex = mapping.variants[mappingVariantIndex];\n const variant = ArrayItem.Get(`/extensions/${NAME}/variants/${variantIndex}`, this._variants, variantIndex);\n extensionMetadata.variants[variant.name] = extensionMetadata.variants[variant.name] || [];\n extensionMetadata.variants[variant.name].push({\n mesh: babylonMesh,\n material: babylonMaterial\n });\n\n // Replace the target when original mesh is cloned\n babylonMesh.onClonedObservable.add((newOne: Node) => {\n const newMesh = newOne as Mesh;\n let metadata: Nullable<IExtensionMetadata> = null;\n let newRoot: Nullable<Node> = newMesh;\n\n // Find root to get medata\n do {\n newRoot = newRoot!.parent;\n if (!newRoot) {\n return;\n }\n metadata = KHR_materials_variants._GetExtensionMetadata(newRoot as Mesh);\n }\n while (metadata === null);\n\n // Need to clone the metadata on the root (first time only)\n if (root && metadata === KHR_materials_variants._GetExtensionMetadata(root)) {\n // Copy main metadata\n newRoot.metadata = {};\n for (var key in root.metadata) {\n newRoot.metadata[key] = root.metadata[key];\n }\n\n // Copy the gltf metadata\n newRoot.metadata.gltf = [];\n for (var key in root.metadata.gltf) {\n newRoot.metadata.gltf[key] = root.metadata.gltf[key];\n }\n\n // Duplicate the extension specific metadata\n newRoot.metadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };\n for (var original of metadata.original) {\n newRoot.metadata.gltf[NAME].original.push({\n mesh: original.mesh,\n material: original.material\n });\n }\n for (var key in metadata.variants) {\n if (metadata.variants.hasOwnProperty(key)) {\n newRoot.metadata.gltf[NAME].variants[key] = [];\n for (var variantEntry of metadata.variants[key]) {\n newRoot.metadata.gltf[NAME].variants[key].push({\n mesh: variantEntry.mesh,\n material: variantEntry.material\n });\n }\n }\n }\n\n metadata = newRoot.metadata.gltf[NAME];\n }\n\n // Relocate\n for (var target of metadata!.original) {\n if (target.mesh === babylonMesh) {\n target.mesh = newMesh;\n }\n }\n for (var target of metadata!.variants[variant.name]) {\n if (target.mesh === babylonMesh) {\n target.mesh = newMesh;\n }\n }\n });\n }\n }));\n }\n }\n }));\n return Promise.all(promises).then(([babylonMesh]) => {\n return babylonMesh;\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_variants(loader));\n"]}
@@ -1,31 +0,0 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { Material } from "@babylonjs/core/Materials/material";
3
- import { IMaterial } from "../glTFLoaderInterfaces";
4
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
- import { GLTFLoader } from "../glTFLoader";
6
- /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume)
8
- * @since 5.0.0
9
- */
10
- export declare class KHR_materials_volume implements IGLTFLoaderExtension {
11
- /**
12
- * The name of this extension.
13
- */
14
- readonly name = "KHR_materials_volume";
15
- /**
16
- * Defines whether this extension is enabled.
17
- */
18
- enabled: boolean;
19
- /**
20
- * Defines a number that determines the order the extensions are applied.
21
- */
22
- order: number;
23
- private _loader;
24
- /** @hidden */
25
- constructor(loader: GLTFLoader);
26
- /** @hidden */
27
- dispose(): void;
28
- /** @hidden */
29
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
30
- private _loadVolumePropertiesAsync;
31
- }