@babylonjs/core 7.32.5 → 7.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/Cameras/arcRotateCamera.d.ts +14 -0
  2. package/Cameras/arcRotateCamera.js +39 -19
  3. package/Cameras/arcRotateCamera.js.map +1 -1
  4. package/Decorators/nodeDecorator.d.ts +2 -0
  5. package/Decorators/nodeDecorator.js +1 -0
  6. package/Decorators/nodeDecorator.js.map +1 -1
  7. package/Engines/abstractEngine.js +2 -2
  8. package/Engines/abstractEngine.js.map +1 -1
  9. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +63 -0
  10. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +150 -0
  11. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -0
  12. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +3 -47
  13. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +2 -129
  14. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
  15. package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.d.ts +40 -0
  16. package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +98 -0
  17. package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -0
  18. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
  19. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  20. package/FrameGraph/Node/Blocks/index.d.ts +3 -2
  21. package/FrameGraph/Node/Blocks/index.js +3 -2
  22. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  23. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  24. package/FrameGraph/Passes/renderPass.js +1 -1
  25. package/FrameGraph/Passes/renderPass.js.map +1 -1
  26. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +21 -0
  27. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +110 -0
  28. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -0
  29. package/FrameGraph/frameGraph.d.ts +6 -0
  30. package/FrameGraph/frameGraph.js +15 -1
  31. package/FrameGraph/frameGraph.js.map +1 -1
  32. package/FrameGraph/frameGraphRenderContext.d.ts +3 -2
  33. package/FrameGraph/frameGraphRenderContext.js +9 -4
  34. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  35. package/FrameGraph/frameGraphTask.js +5 -1
  36. package/FrameGraph/frameGraphTask.js.map +1 -1
  37. package/FrameGraph/frameGraphTextureManager.d.ts +8 -0
  38. package/FrameGraph/frameGraphTextureManager.js +51 -7
  39. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  40. package/FrameGraph/frameGraphTypes.d.ts +2 -0
  41. package/FrameGraph/frameGraphTypes.js.map +1 -1
  42. package/FrameGraph/index.d.ts +3 -2
  43. package/FrameGraph/index.js +3 -2
  44. package/FrameGraph/index.js.map +1 -1
  45. package/Layers/layer.d.ts +4 -0
  46. package/Layers/layer.js +13 -2
  47. package/Layers/layer.js.map +1 -1
  48. package/Loading/sceneLoader.d.ts +11 -8
  49. package/Loading/sceneLoader.js +64 -35
  50. package/Loading/sceneLoader.js.map +1 -1
  51. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +2 -0
  52. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +12 -0
  53. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  54. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +16 -0
  55. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +40 -7
  56. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  57. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js +6 -1
  58. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js.map +1 -1
  59. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +9 -2
  60. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
  61. package/Materials/Node/Blocks/GaussianSplatting/index.d.ts +2 -0
  62. package/Materials/Node/Blocks/GaussianSplatting/index.js +3 -0
  63. package/Materials/Node/Blocks/GaussianSplatting/index.js.map +1 -1
  64. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +10 -3
  65. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
  66. package/Materials/Node/nodeMaterial.d.ts +1 -1
  67. package/Materials/Node/nodeMaterial.js +1 -1
  68. package/Materials/Node/nodeMaterial.js.map +1 -1
  69. package/Materials/effectRenderer.d.ts +1 -1
  70. package/Materials/effectRenderer.js +2 -2
  71. package/Materials/effectRenderer.js.map +1 -1
  72. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +2 -0
  73. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +7 -2
  74. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  75. package/Meshes/Node/nodeGeometry.js.map +1 -1
  76. package/Meshes/abstractMesh.hotSpot.js +2 -0
  77. package/Meshes/abstractMesh.hotSpot.js.map +1 -1
  78. package/Meshes/csg2.js +0 -3
  79. package/Meshes/csg2.js.map +1 -1
  80. package/Misc/webRequest.fetch.d.ts +16 -0
  81. package/Misc/webRequest.fetch.js +33 -0
  82. package/Misc/webRequest.fetch.js.map +1 -0
  83. package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +2 -0
  84. package/PostProcesses/RenderPipeline/Pipelines/index.js +2 -0
  85. package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
  86. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.d.ts +6 -8
  87. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +32 -49
  88. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
  89. package/PostProcesses/thinTAAPostProcess.d.ts +72 -0
  90. package/PostProcesses/thinTAAPostProcess.js +149 -0
  91. package/PostProcesses/thinTAAPostProcess.js.map +1 -0
  92. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  93. package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +3 -3
  94. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +7 -7
  95. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
  96. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +81 -80
  97. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +102 -112
  98. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  99. package/Rendering/geometryBufferRenderer.js +8 -6
  100. package/Rendering/geometryBufferRenderer.js.map +1 -1
  101. package/Shaders/geometry.vertex.js +1 -1
  102. package/Shaders/geometry.vertex.js.map +1 -1
  103. package/Shaders/iblShadowAccumulation.fragment.js +2 -1
  104. package/Shaders/iblShadowAccumulation.fragment.js.map +1 -1
  105. package/Shaders/layer.fragment.js +3 -1
  106. package/Shaders/layer.fragment.js.map +1 -1
  107. package/Shaders/volumetricLightScattering.fragment.js +1 -1
  108. package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
  109. package/ShadersWGSL/ShadersInclude/gaussianSplatting.d.ts +5 -0
  110. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +47 -0
  111. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -0
  112. package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.d.ts +7 -0
  113. package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js +20 -0
  114. package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js.map +1 -0
  115. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.d.ts +7 -0
  116. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +13 -0
  117. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -0
  118. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.d.ts +5 -0
  119. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +10 -0
  120. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -0
  121. package/ShadersWGSL/gaussianSplatting.fragment.d.ts +10 -0
  122. package/ShadersWGSL/gaussianSplatting.fragment.js +23 -0
  123. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -0
  124. package/ShadersWGSL/gaussianSplatting.vertex.d.ts +14 -0
  125. package/ShadersWGSL/gaussianSplatting.vertex.js +31 -0
  126. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -0
  127. package/ShadersWGSL/geometry.vertex.js +1 -1
  128. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  129. package/ShadersWGSL/iblShadowAccumulation.fragment.js +2 -1
  130. package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -1
  131. package/ShadersWGSL/layer.fragment.js +4 -2
  132. package/ShadersWGSL/layer.fragment.js.map +1 -1
  133. package/ShadersWGSL/taa.fragment.d.ts +5 -0
  134. package/ShadersWGSL/taa.fragment.js +11 -0
  135. package/ShadersWGSL/taa.fragment.js.map +1 -0
  136. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraphTypes.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTypes.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA4B,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAA4B,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, TextureSize, FrameGraphContext, IMultiRenderTargetOptions } from \"core/index\";\r\n\r\n/**\r\n * Represents a texture handle in the frame graph.\r\n */\r\nexport type FrameGraphTextureHandle = number;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer color texture.\r\n */\r\nexport const backbufferColorTextureHandle: FrameGraphTextureHandle = 0;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer depth/stencil texture.\r\n */\r\nexport const backbufferDepthStencilTextureHandle: FrameGraphTextureHandle = 1;\r\n\r\n/**\r\n * Options used to create a texture in the frame graph.\r\n */\r\nexport type FrameGraphTextureCreationOptions = {\r\n /** Size of the texture. If sizeIsPercentage is true, these are percentages relative to the screen size */\r\n size: TextureSize;\r\n\r\n /** Options used to create the (multi) render target texture */\r\n options: IMultiRenderTargetOptions;\r\n\r\n /** If true, indicates that \"size\" is percentages relative to the screen size */\r\n sizeIsPercentage: boolean;\r\n};\r\n\r\n/**\r\n * Represents a texture description in the frame graph.\r\n * This is basically the same thing than FrameGraphTextureCreationOptions, but the size is never in percentage and always in pixels.\r\n */\r\nexport type FrameGraphTextureDescription = {\r\n /**\r\n * Size of the texture.\r\n */\r\n size: { width: number; height: number };\r\n\r\n /**\r\n * Options used when the (multi) render target texture had been created.\r\n */\r\n options: IMultiRenderTargetOptions;\r\n};\r\n\r\n/**\r\n * Defines a pass in the frame graph.\r\n */\r\nexport interface IFrameGraphPass {\r\n /**\r\n * The name of the pass.\r\n */\r\n name: string;\r\n\r\n /**\r\n * Sets the function to execute when the pass is executed\r\n * @param func The function to execute when the pass is executed\r\n */\r\n setExecuteFunc(func: (context: FrameGraphContext) => void): void;\r\n\r\n /** @internal */\r\n _execute(): void;\r\n\r\n /** @internal */\r\n _isValid(): Nullable<string>;\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraphTypes.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTypes.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA4B,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAA4B,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, TextureSize, FrameGraphContext, IMultiRenderTargetOptions } from \"core/index\";\r\n\r\n/**\r\n * Represents a texture handle in the frame graph.\r\n */\r\nexport type FrameGraphTextureHandle = number;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer color texture.\r\n */\r\nexport const backbufferColorTextureHandle: FrameGraphTextureHandle = 0;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer depth/stencil texture.\r\n */\r\nexport const backbufferDepthStencilTextureHandle: FrameGraphTextureHandle = 1;\r\n\r\n/**\r\n * Options used to create a texture in the frame graph.\r\n */\r\nexport type FrameGraphTextureCreationOptions = {\r\n /** Size of the texture. If sizeIsPercentage is true, these are percentages relative to the screen size */\r\n size: TextureSize;\r\n\r\n /** Options used to create the (multi) render target texture */\r\n options: IMultiRenderTargetOptions;\r\n\r\n /** If true, indicates that \"size\" is percentages relative to the screen size */\r\n sizeIsPercentage: boolean;\r\n\r\n /** Indicates that the texture is a history texture */\r\n isHistoryTexture?: boolean;\r\n};\r\n\r\n/**\r\n * Represents a texture description in the frame graph.\r\n * This is basically the same thing than FrameGraphTextureCreationOptions, but the size is never in percentage and always in pixels.\r\n */\r\nexport type FrameGraphTextureDescription = {\r\n /**\r\n * Size of the texture.\r\n */\r\n size: { width: number; height: number };\r\n\r\n /**\r\n * Options used when the (multi) render target texture had been created.\r\n */\r\n options: IMultiRenderTargetOptions;\r\n};\r\n\r\n/**\r\n * Defines a pass in the frame graph.\r\n */\r\nexport interface IFrameGraphPass {\r\n /**\r\n * The name of the pass.\r\n */\r\n name: string;\r\n\r\n /**\r\n * Sets the function to execute when the pass is executed\r\n * @param func The function to execute when the pass is executed\r\n */\r\n setExecuteFunc(func: (context: FrameGraphContext) => void): void;\r\n\r\n /** @internal */\r\n _execute(): void;\r\n\r\n /** @internal */\r\n _isValid(): Nullable<string>;\r\n}\r\n"]}
@@ -16,9 +16,10 @@ export * from "./Tasks/PostProcesses/postProcessTask";
16
16
  export * from "./Tasks/Texture/clearTextureTask";
17
17
  export * from "./Tasks/Texture/copyToBackbufferColorTask";
18
18
  export * from "./Tasks/Texture/copyToTextureTask";
19
- export * from "./Tasks/Rendering/objectRendererTask";
20
- export * from "./Tasks/Rendering/geometryRendererTask";
21
19
  export * from "./Tasks/Rendering/cullObjectsTask";
20
+ export * from "./Tasks/Rendering/geometryRendererTask";
21
+ export * from "./Tasks/Rendering/objectRendererTask";
22
+ export * from "./Tasks/Rendering/taaObjectRendererTask";
22
23
  export * from "./frameGraph";
23
24
  export * from "./frameGraphContext";
24
25
  export * from "./frameGraphObjectList";
@@ -17,9 +17,10 @@ export * from "./Tasks/PostProcesses/postProcessTask.js";
17
17
  export * from "./Tasks/Texture/clearTextureTask.js";
18
18
  export * from "./Tasks/Texture/copyToBackbufferColorTask.js";
19
19
  export * from "./Tasks/Texture/copyToTextureTask.js";
20
- export * from "./Tasks/Rendering/objectRendererTask.js";
21
- export * from "./Tasks/Rendering/geometryRendererTask.js";
22
20
  export * from "./Tasks/Rendering/cullObjectsTask.js";
21
+ export * from "./Tasks/Rendering/geometryRendererTask.js";
22
+ export * from "./Tasks/Rendering/objectRendererTask.js";
23
+ export * from "./Tasks/Rendering/taaObjectRendererTask.js";
23
24
  export * from "./frameGraph.js";
24
25
  export * from "./frameGraphContext.js";
25
26
  export * from "./frameGraphObjectList.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AAEpC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AAEtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mCAAmC,CAAC;AAElD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAElD,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./Node/nodeRenderGraph\";\r\nexport * from \"./Node/nodeRenderGraphBlock\";\r\nexport * from \"./Node/nodeRenderGraphBlockConnectionPoint\";\r\nexport * from \"./Node/nodeRenderGraphBuildState\";\r\nexport * from \"./Node/Types/nodeRenderGraphTypes\";\r\nexport * from \"./Node/Blocks/index\";\r\n\r\nexport * from \"./Passes/pass\";\r\nexport * from \"./Passes/renderPass\";\r\n\r\nexport * from \"./Tasks/PostProcesses/blackAndWhiteTask\";\r\nexport * from \"./Tasks/PostProcesses/bloomTask\";\r\nexport * from \"./Tasks/PostProcesses/blurTask\";\r\nexport * from \"./Tasks/PostProcesses/circleOfConfusionTask\";\r\nexport * from \"./Tasks/PostProcesses/depthOfFieldTask\";\r\nexport * from \"./Tasks/PostProcesses/extractHighlightsTask\";\r\nexport * from \"./Tasks/PostProcesses/postProcessTask\";\r\n\r\nexport * from \"./Tasks/Texture/clearTextureTask\";\r\nexport * from \"./Tasks/Texture/copyToBackbufferColorTask\";\r\nexport * from \"./Tasks/Texture/copyToTextureTask\";\r\n\r\nexport * from \"./Tasks/Rendering/objectRendererTask\";\r\nexport * from \"./Tasks/Rendering/geometryRendererTask\";\r\nexport * from \"./Tasks/Rendering/cullObjectsTask\";\r\n\r\nexport * from \"./frameGraph\";\r\nexport * from \"./frameGraphContext\";\r\nexport * from \"./frameGraphObjectList\";\r\nexport * from \"./frameGraphRenderContext\";\r\nexport * from \"./frameGraphTask\";\r\nexport * from \"./frameGraphTextureManager\";\r\nexport * from \"./frameGraphTypes\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AAEpC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AAEtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mCAAmC,CAAC;AAElD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AAExD,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./Node/nodeRenderGraph\";\r\nexport * from \"./Node/nodeRenderGraphBlock\";\r\nexport * from \"./Node/nodeRenderGraphBlockConnectionPoint\";\r\nexport * from \"./Node/nodeRenderGraphBuildState\";\r\nexport * from \"./Node/Types/nodeRenderGraphTypes\";\r\nexport * from \"./Node/Blocks/index\";\r\n\r\nexport * from \"./Passes/pass\";\r\nexport * from \"./Passes/renderPass\";\r\n\r\nexport * from \"./Tasks/PostProcesses/blackAndWhiteTask\";\r\nexport * from \"./Tasks/PostProcesses/bloomTask\";\r\nexport * from \"./Tasks/PostProcesses/blurTask\";\r\nexport * from \"./Tasks/PostProcesses/circleOfConfusionTask\";\r\nexport * from \"./Tasks/PostProcesses/depthOfFieldTask\";\r\nexport * from \"./Tasks/PostProcesses/extractHighlightsTask\";\r\nexport * from \"./Tasks/PostProcesses/postProcessTask\";\r\n\r\nexport * from \"./Tasks/Texture/clearTextureTask\";\r\nexport * from \"./Tasks/Texture/copyToBackbufferColorTask\";\r\nexport * from \"./Tasks/Texture/copyToTextureTask\";\r\n\r\nexport * from \"./Tasks/Rendering/cullObjectsTask\";\r\nexport * from \"./Tasks/Rendering/geometryRendererTask\";\r\nexport * from \"./Tasks/Rendering/objectRendererTask\";\r\nexport * from \"./Tasks/Rendering/taaObjectRendererTask\";\r\n\r\nexport * from \"./frameGraph\";\r\nexport * from \"./frameGraphContext\";\r\nexport * from \"./frameGraphObjectList\";\r\nexport * from \"./frameGraphRenderContext\";\r\nexport * from \"./frameGraphTask\";\r\nexport * from \"./frameGraphTextureManager\";\r\nexport * from \"./frameGraphTypes\";\r\n"]}
package/Layers/layer.d.ts CHANGED
@@ -71,6 +71,10 @@ export declare class Layer {
71
71
  * renders in the main frame buffer of the canvas.
72
72
  */
73
73
  renderOnlyInRenderTargetTextures: boolean;
74
+ /**
75
+ * Define if the colors of the layer should be generated in linear space (default: false)
76
+ */
77
+ convertToLinearSpace: boolean;
74
78
  /**
75
79
  * Define if the layer is enabled (ie. should be displayed). Default: true
76
80
  */
package/Layers/layer.js CHANGED
@@ -105,6 +105,10 @@ export class Layer {
105
105
  * renders in the main frame buffer of the canvas.
106
106
  */
107
107
  this.renderOnlyInRenderTargetTextures = false;
108
+ /**
109
+ * Define if the colors of the layer should be generated in linear space (default: false)
110
+ */
111
+ this.convertToLinearSpace = false;
108
112
  /**
109
113
  * Define if the layer is enabled (ie. should be displayed). Default: true
110
114
  */
@@ -180,8 +184,15 @@ export class Layer {
180
184
  if (this.alphaTest) {
181
185
  defines = "#define ALPHATEST";
182
186
  }
183
- if (this.texture && !this.texture.gammaSpace) {
184
- defines += "\n#define LINEAR";
187
+ if (this.texture) {
188
+ if (this.texture.gammaSpace) {
189
+ if (this.convertToLinearSpace) {
190
+ defines += "\n#define CONVERT_TO_LINEAR";
191
+ }
192
+ }
193
+ else if (!this.convertToLinearSpace) {
194
+ defines += "\n#define CONVERT_TO_GAMMA";
195
+ }
185
196
  }
186
197
  if (this._previousDefines !== defines) {
187
198
  this._previousDefines = defines;
@@ -1 +1 @@
1
- {"version":3,"file":"layer.js","sourceRoot":"","sources":["../../../../dev/core/src/Layers/layer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAiBd;;;OAGG;IACH,IAAW,gBAAgB,CAAC,KA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YACd,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;SACzD;QAED,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;QAED,iBAAiB;QACjB,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;QAE/B,oBAAoB;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEpC,WAAW;QACX,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IAC1C,CAAC;;AAtWD;;;GAGG;AACW,eAAS,GAAG,KAAK,AAAR,CAAS","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Vector2 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Material } from \"../Materials/material\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { LayerSceneComponent } from \"./layerSceneComponent\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * This represents a full screen 2d layer.\r\n * This can be useful to display a picture in the background of your scene for instance.\r\n * @see https://www.babylonjs-playground.com/#08A2BS#1\r\n */\r\nexport class Layer {\r\n /**\r\n * Force all the layers to compile to glsl even on WebGPU engines.\r\n * False by default. This is mostly meant for backward compatibility.\r\n */\r\n public static ForceGLSL = false;\r\n /**\r\n * Define the texture the layer should display.\r\n */\r\n public texture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Is the layer in background or foreground.\r\n */\r\n public isBackground: boolean;\r\n\r\n private _applyPostProcess: boolean = true;\r\n /**\r\n * Determines if the layer is drawn before (true) or after (false) post-processing.\r\n * If the layer is background, it is always before.\r\n */\r\n public set applyPostProcess(value: boolean) {\r\n this._applyPostProcess = value;\r\n }\r\n public get applyPostProcess(): boolean {\r\n return this.isBackground || this._applyPostProcess;\r\n }\r\n\r\n /**\r\n * Define the color of the layer (instead of texture).\r\n */\r\n public color: Color4;\r\n\r\n /**\r\n * Define the scale of the layer in order to zoom in out of the texture.\r\n */\r\n public scale = new Vector2(1, 1);\r\n\r\n /**\r\n * Define an offset for the layer in order to shift the texture.\r\n */\r\n public offset = new Vector2(0, 0);\r\n\r\n /**\r\n * Define the alpha blending mode used in the layer in case the texture or color has an alpha.\r\n */\r\n public alphaBlendingMode = Constants.ALPHA_COMBINE;\r\n\r\n /**\r\n * Define if the layer should alpha test or alpha blend with the rest of the scene.\r\n * Alpha test will not mix with the background color in case of transparency.\r\n * It will either use the texture color or the background depending on the alpha value of the current pixel.\r\n */\r\n public alphaTest: boolean;\r\n\r\n /**\r\n * Define a mask to restrict the layer to only some of the scene cameras.\r\n */\r\n public layerMask: number = 0x0fffffff;\r\n\r\n /**\r\n * Define the list of render target the layer is visible into.\r\n */\r\n public renderTargetTextures: RenderTargetTexture[] = [];\r\n\r\n /**\r\n * Define if the layer is only used in renderTarget or if it also\r\n * renders in the main frame buffer of the canvas.\r\n */\r\n public renderOnlyInRenderTargetTextures = false;\r\n\r\n /**\r\n * Define if the layer is enabled (ie. should be displayed). Default: true\r\n */\r\n public isEnabled = true;\r\n\r\n private _scene: Scene;\r\n private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n private _indexBuffer: Nullable<DataBuffer>;\r\n private _drawWrapper: DrawWrapper;\r\n private _previousDefines: string;\r\n\r\n /**\r\n * An event triggered when the layer is disposed.\r\n */\r\n public onDisposeObservable = new Observable<Layer>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<Layer>>;\r\n /**\r\n * Back compatibility with callback before the onDisposeObservable existed.\r\n * The set callback will be triggered when the layer has been disposed.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered before rendering the scene\r\n */\r\n public onBeforeRenderObservable = new Observable<Layer>();\r\n\r\n private _onBeforeRenderObserver: Nullable<Observer<Layer>>;\r\n /**\r\n * Back compatibility with callback before the onBeforeRenderObservable existed.\r\n * The set callback will be triggered just before rendering the layer.\r\n */\r\n public set onBeforeRender(callback: () => void) {\r\n if (this._onBeforeRenderObserver) {\r\n this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n }\r\n this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered after rendering the scene\r\n */\r\n public onAfterRenderObservable = new Observable<Layer>();\r\n\r\n private _onAfterRenderObserver: Nullable<Observer<Layer>>;\r\n /**\r\n * Back compatibility with callback before the onAfterRenderObservable existed.\r\n * The set callback will be triggered just after rendering the layer.\r\n */\r\n public set onAfterRender(callback: () => void) {\r\n if (this._onAfterRenderObserver) {\r\n this.onAfterRenderObservable.remove(this._onAfterRenderObserver);\r\n }\r\n this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);\r\n }\r\n\r\n /** Shader language used by the material */\r\n private _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language used in this material.\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Instantiates a new layer.\r\n * This represents a full screen 2d layer.\r\n * This can be useful to display a picture in the background of your scene for instance.\r\n * @see https://www.babylonjs-playground.com/#08A2BS#1\r\n * @param name Define the name of the layer in the scene\r\n * @param imgUrl Define the url of the texture to display in the layer\r\n * @param scene Define the scene the layer belongs to\r\n * @param isBackground Defines whether the layer is displayed in front or behind the scene\r\n * @param color Defines a color for the layer\r\n * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false\r\n */\r\n constructor(\r\n /**\r\n * Define the name of the layer.\r\n */\r\n public name: string,\r\n imgUrl: Nullable<string>,\r\n scene: Nullable<Scene>,\r\n isBackground?: boolean,\r\n color?: Color4,\r\n forceGLSL = false\r\n ) {\r\n this.texture = imgUrl ? new Texture(imgUrl, scene, true) : null;\r\n this.isBackground = isBackground === undefined ? true : isBackground;\r\n this.color = color === undefined ? new Color4(1, 1, 1, 1) : color;\r\n\r\n this._scene = <Scene>(scene || EngineStore.LastCreatedScene);\r\n const engine = this._scene.getEngine();\r\n if (engine.isWebGPU && !forceGLSL && !Layer.ForceGLSL) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n let layerComponent = this._scene._getComponent(SceneComponentConstants.NAME_LAYER) as LayerSceneComponent;\r\n if (!layerComponent) {\r\n layerComponent = new LayerSceneComponent(this._scene);\r\n this._scene._addComponent(layerComponent);\r\n }\r\n this._scene.layers.push(this);\r\n\r\n this._drawWrapper = new DrawWrapper(engine);\r\n\r\n // VBO\r\n const vertices = [];\r\n vertices.push(1, 1);\r\n vertices.push(-1, 1);\r\n vertices.push(-1, -1);\r\n vertices.push(1, -1);\r\n\r\n const vertexBuffer = new VertexBuffer(engine, vertices, VertexBuffer.PositionKind, false, false, 2);\r\n this._vertexBuffers[VertexBuffer.PositionKind] = vertexBuffer;\r\n\r\n this._createIndexBuffer();\r\n }\r\n\r\n private _shadersLoaded = false;\r\n\r\n private _createIndexBuffer(): void {\r\n const engine = this._scene.getEngine();\r\n\r\n // Indices\r\n const indices = [];\r\n indices.push(0);\r\n indices.push(1);\r\n indices.push(2);\r\n\r\n indices.push(0);\r\n indices.push(2);\r\n indices.push(3);\r\n\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const vb = this._vertexBuffers[VertexBuffer.PositionKind];\r\n\r\n if (vb) {\r\n vb._rebuild();\r\n }\r\n\r\n this._createIndexBuffer();\r\n }\r\n\r\n /**\r\n * Checks if the layer is ready to be rendered\r\n * @returns true if the layer is ready. False otherwise.\r\n */\r\n public isReady() {\r\n const engine = this._scene.getEngine();\r\n\r\n let defines = \"\";\r\n\r\n if (this.alphaTest) {\r\n defines = \"#define ALPHATEST\";\r\n }\r\n\r\n if (this.texture && !this.texture.gammaSpace) {\r\n defines += \"\\n#define LINEAR\";\r\n }\r\n\r\n if (this._previousDefines !== defines) {\r\n this._previousDefines = defines;\r\n this._drawWrapper.effect = engine.createEffect(\r\n \"layer\",\r\n [VertexBuffer.PositionKind],\r\n [\"textureMatrix\", \"color\", \"scale\", \"offset\"],\r\n [\"textureSampler\"],\r\n defines,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._shaderLanguage,\r\n this._shadersLoaded\r\n ? undefined\r\n : async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../ShadersWGSL/layer.vertex\"), import(\"../ShadersWGSL/layer.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/layer.vertex\"), import(\"../Shaders/layer.fragment\")]);\r\n }\r\n this._shadersLoaded = true;\r\n }\r\n );\r\n }\r\n\r\n const currentEffect = this._drawWrapper.effect;\r\n\r\n return !!currentEffect?.isReady() && (!this.texture || this.texture.isReady());\r\n }\r\n\r\n /**\r\n * Renders the layer in the scene.\r\n */\r\n public render(): void {\r\n if (!this.isEnabled) {\r\n return;\r\n }\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n // Check\r\n if (!this.isReady()) {\r\n return;\r\n }\r\n\r\n const currentEffect = this._drawWrapper.effect!;\r\n\r\n this.onBeforeRenderObservable.notifyObservers(this);\r\n\r\n // Render\r\n engine.enableEffect(this._drawWrapper);\r\n engine.setState(false);\r\n\r\n // Texture\r\n if (this.texture) {\r\n currentEffect.setTexture(\"textureSampler\", this.texture);\r\n currentEffect.setMatrix(\"textureMatrix\", this.texture.getTextureMatrix());\r\n }\r\n\r\n // Color\r\n currentEffect.setFloat4(\"color\", this.color.r, this.color.g, this.color.b, this.color.a);\r\n\r\n // Scale / offset\r\n currentEffect.setVector2(\"offset\", this.offset);\r\n currentEffect.setVector2(\"scale\", this.scale);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);\r\n\r\n // Draw order\r\n if (!this.alphaTest) {\r\n engine.setAlphaMode(this.alphaBlendingMode);\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n } else {\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n }\r\n\r\n this.onAfterRenderObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Disposes and releases the associated resources.\r\n */\r\n public dispose(): void {\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this._scene.getEngine()._releaseBuffer(this._indexBuffer);\r\n this._indexBuffer = null;\r\n }\r\n\r\n if (this.texture) {\r\n this.texture.dispose();\r\n this.texture = null;\r\n }\r\n\r\n // Clean RTT list\r\n this.renderTargetTextures = [];\r\n\r\n // Remove from scene\r\n const index = this._scene.layers.indexOf(this);\r\n this._scene.layers.splice(index, 1);\r\n\r\n // Callback\r\n this.onDisposeObservable.notifyObservers(this);\r\n\r\n this.onDisposeObservable.clear();\r\n this.onAfterRenderObservable.clear();\r\n this.onBeforeRenderObservable.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"layer.js","sourceRoot":"","sources":["../../../../dev/core/src/Layers/layer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAiBd;;;OAGG;IACH,IAAW,gBAAgB,CAAC,KAAc;Q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CAAC,uBAAuB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,YAAY,EAAE;YACd,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;SACzD;QAED,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;QAED,iBAAiB;QACjB,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;QAE/B,oBAAoB;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEpC,WAAW;QACX,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IAC1C,CAAC;;AAjXD;;;GAGG;AACW,eAAS,GAAG,KAAK,AAAR,CAAS","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Vector2 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Material } from \"../Materials/material\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { LayerSceneComponent } from \"./layerSceneComponent\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * This represents a full screen 2d layer.\r\n * This can be useful to display a picture in the background of your scene for instance.\r\n * @see https://www.babylonjs-playground.com/#08A2BS#1\r\n */\r\nexport class Layer {\r\n /**\r\n * Force all the layers to compile to glsl even on WebGPU engines.\r\n * False by default. This is mostly meant for backward compatibility.\r\n */\r\n public static ForceGLSL = false;\r\n /**\r\n * Define the texture the layer should display.\r\n */\r\n public texture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Is the layer in background or foreground.\r\n */\r\n public isBackground: boolean;\r\n\r\n private _applyPostProcess: boolean = true;\r\n /**\r\n * Determines if the layer is drawn before (true) or after (false) post-processing.\r\n * If the layer is background, it is always before.\r\n */\r\n public set applyPostProcess(value: boolean) {\r\n this._applyPostProcess = value;\r\n }\r\n public get applyPostProcess(): boolean {\r\n return this.isBackground || this._applyPostProcess;\r\n }\r\n\r\n /**\r\n * Define the color of the layer (instead of texture).\r\n */\r\n public color: Color4;\r\n\r\n /**\r\n * Define the scale of the layer in order to zoom in out of the texture.\r\n */\r\n public scale = new Vector2(1, 1);\r\n\r\n /**\r\n * Define an offset for the layer in order to shift the texture.\r\n */\r\n public offset = new Vector2(0, 0);\r\n\r\n /**\r\n * Define the alpha blending mode used in the layer in case the texture or color has an alpha.\r\n */\r\n public alphaBlendingMode = Constants.ALPHA_COMBINE;\r\n\r\n /**\r\n * Define if the layer should alpha test or alpha blend with the rest of the scene.\r\n * Alpha test will not mix with the background color in case of transparency.\r\n * It will either use the texture color or the background depending on the alpha value of the current pixel.\r\n */\r\n public alphaTest: boolean;\r\n\r\n /**\r\n * Define a mask to restrict the layer to only some of the scene cameras.\r\n */\r\n public layerMask: number = 0x0fffffff;\r\n\r\n /**\r\n * Define the list of render target the layer is visible into.\r\n */\r\n public renderTargetTextures: RenderTargetTexture[] = [];\r\n\r\n /**\r\n * Define if the layer is only used in renderTarget or if it also\r\n * renders in the main frame buffer of the canvas.\r\n */\r\n public renderOnlyInRenderTargetTextures = false;\r\n\r\n /**\r\n * Define if the colors of the layer should be generated in linear space (default: false)\r\n */\r\n public convertToLinearSpace = false;\r\n\r\n /**\r\n * Define if the layer is enabled (ie. should be displayed). Default: true\r\n */\r\n public isEnabled = true;\r\n\r\n private _scene: Scene;\r\n private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n private _indexBuffer: Nullable<DataBuffer>;\r\n private _drawWrapper: DrawWrapper;\r\n private _previousDefines: string;\r\n\r\n /**\r\n * An event triggered when the layer is disposed.\r\n */\r\n public onDisposeObservable = new Observable<Layer>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<Layer>>;\r\n /**\r\n * Back compatibility with callback before the onDisposeObservable existed.\r\n * The set callback will be triggered when the layer has been disposed.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered before rendering the scene\r\n */\r\n public onBeforeRenderObservable = new Observable<Layer>();\r\n\r\n private _onBeforeRenderObserver: Nullable<Observer<Layer>>;\r\n /**\r\n * Back compatibility with callback before the onBeforeRenderObservable existed.\r\n * The set callback will be triggered just before rendering the layer.\r\n */\r\n public set onBeforeRender(callback: () => void) {\r\n if (this._onBeforeRenderObserver) {\r\n this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n }\r\n this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered after rendering the scene\r\n */\r\n public onAfterRenderObservable = new Observable<Layer>();\r\n\r\n private _onAfterRenderObserver: Nullable<Observer<Layer>>;\r\n /**\r\n * Back compatibility with callback before the onAfterRenderObservable existed.\r\n * The set callback will be triggered just after rendering the layer.\r\n */\r\n public set onAfterRender(callback: () => void) {\r\n if (this._onAfterRenderObserver) {\r\n this.onAfterRenderObservable.remove(this._onAfterRenderObserver);\r\n }\r\n this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);\r\n }\r\n\r\n /** Shader language used by the material */\r\n private _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language used in this material.\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Instantiates a new layer.\r\n * This represents a full screen 2d layer.\r\n * This can be useful to display a picture in the background of your scene for instance.\r\n * @see https://www.babylonjs-playground.com/#08A2BS#1\r\n * @param name Define the name of the layer in the scene\r\n * @param imgUrl Define the url of the texture to display in the layer\r\n * @param scene Define the scene the layer belongs to\r\n * @param isBackground Defines whether the layer is displayed in front or behind the scene\r\n * @param color Defines a color for the layer\r\n * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false\r\n */\r\n constructor(\r\n /**\r\n * Define the name of the layer.\r\n */\r\n public name: string,\r\n imgUrl: Nullable<string>,\r\n scene: Nullable<Scene>,\r\n isBackground?: boolean,\r\n color?: Color4,\r\n forceGLSL = false\r\n ) {\r\n this.texture = imgUrl ? new Texture(imgUrl, scene, true) : null;\r\n this.isBackground = isBackground === undefined ? true : isBackground;\r\n this.color = color === undefined ? new Color4(1, 1, 1, 1) : color;\r\n\r\n this._scene = <Scene>(scene || EngineStore.LastCreatedScene);\r\n const engine = this._scene.getEngine();\r\n if (engine.isWebGPU && !forceGLSL && !Layer.ForceGLSL) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n let layerComponent = this._scene._getComponent(SceneComponentConstants.NAME_LAYER) as LayerSceneComponent;\r\n if (!layerComponent) {\r\n layerComponent = new LayerSceneComponent(this._scene);\r\n this._scene._addComponent(layerComponent);\r\n }\r\n this._scene.layers.push(this);\r\n\r\n this._drawWrapper = new DrawWrapper(engine);\r\n\r\n // VBO\r\n const vertices = [];\r\n vertices.push(1, 1);\r\n vertices.push(-1, 1);\r\n vertices.push(-1, -1);\r\n vertices.push(1, -1);\r\n\r\n const vertexBuffer = new VertexBuffer(engine, vertices, VertexBuffer.PositionKind, false, false, 2);\r\n this._vertexBuffers[VertexBuffer.PositionKind] = vertexBuffer;\r\n\r\n this._createIndexBuffer();\r\n }\r\n\r\n private _shadersLoaded = false;\r\n\r\n private _createIndexBuffer(): void {\r\n const engine = this._scene.getEngine();\r\n\r\n // Indices\r\n const indices = [];\r\n indices.push(0);\r\n indices.push(1);\r\n indices.push(2);\r\n\r\n indices.push(0);\r\n indices.push(2);\r\n indices.push(3);\r\n\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const vb = this._vertexBuffers[VertexBuffer.PositionKind];\r\n\r\n if (vb) {\r\n vb._rebuild();\r\n }\r\n\r\n this._createIndexBuffer();\r\n }\r\n\r\n /**\r\n * Checks if the layer is ready to be rendered\r\n * @returns true if the layer is ready. False otherwise.\r\n */\r\n public isReady() {\r\n const engine = this._scene.getEngine();\r\n\r\n let defines = \"\";\r\n\r\n if (this.alphaTest) {\r\n defines = \"#define ALPHATEST\";\r\n }\r\n\r\n if (this.texture) {\r\n if (this.texture.gammaSpace) {\r\n if (this.convertToLinearSpace) {\r\n defines += \"\\n#define CONVERT_TO_LINEAR\";\r\n }\r\n } else if (!this.convertToLinearSpace) {\r\n defines += \"\\n#define CONVERT_TO_GAMMA\";\r\n }\r\n }\r\n\r\n if (this._previousDefines !== defines) {\r\n this._previousDefines = defines;\r\n this._drawWrapper.effect = engine.createEffect(\r\n \"layer\",\r\n [VertexBuffer.PositionKind],\r\n [\"textureMatrix\", \"color\", \"scale\", \"offset\"],\r\n [\"textureSampler\"],\r\n defines,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._shaderLanguage,\r\n this._shadersLoaded\r\n ? undefined\r\n : async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../ShadersWGSL/layer.vertex\"), import(\"../ShadersWGSL/layer.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/layer.vertex\"), import(\"../Shaders/layer.fragment\")]);\r\n }\r\n this._shadersLoaded = true;\r\n }\r\n );\r\n }\r\n\r\n const currentEffect = this._drawWrapper.effect;\r\n\r\n return !!currentEffect?.isReady() && (!this.texture || this.texture.isReady());\r\n }\r\n\r\n /**\r\n * Renders the layer in the scene.\r\n */\r\n public render(): void {\r\n if (!this.isEnabled) {\r\n return;\r\n }\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n // Check\r\n if (!this.isReady()) {\r\n return;\r\n }\r\n\r\n const currentEffect = this._drawWrapper.effect!;\r\n\r\n this.onBeforeRenderObservable.notifyObservers(this);\r\n\r\n // Render\r\n engine.enableEffect(this._drawWrapper);\r\n engine.setState(false);\r\n\r\n // Texture\r\n if (this.texture) {\r\n currentEffect.setTexture(\"textureSampler\", this.texture);\r\n currentEffect.setMatrix(\"textureMatrix\", this.texture.getTextureMatrix());\r\n }\r\n\r\n // Color\r\n currentEffect.setFloat4(\"color\", this.color.r, this.color.g, this.color.b, this.color.a);\r\n\r\n // Scale / offset\r\n currentEffect.setVector2(\"offset\", this.offset);\r\n currentEffect.setVector2(\"scale\", this.scale);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);\r\n\r\n // Draw order\r\n if (!this.alphaTest) {\r\n engine.setAlphaMode(this.alphaBlendingMode);\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n } else {\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n }\r\n\r\n this.onAfterRenderObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Disposes and releases the associated resources.\r\n */\r\n public dispose(): void {\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this._scene.getEngine()._releaseBuffer(this._indexBuffer);\r\n this._indexBuffer = null;\r\n }\r\n\r\n if (this.texture) {\r\n this.texture.dispose();\r\n this.texture = null;\r\n }\r\n\r\n // Clean RTT list\r\n this.renderTargetTextures = [];\r\n\r\n // Remove from scene\r\n const index = this._scene.layers.indexOf(this);\r\n this._scene.layers.splice(index, 1);\r\n\r\n // Callback\r\n this.onDisposeObservable.notifyObservers(this);\r\n\r\n this.onDisposeObservable.clear();\r\n this.onAfterRenderObservable.clear();\r\n this.onBeforeRenderObservable.clear();\r\n }\r\n}\r\n"]}
@@ -81,6 +81,7 @@ export interface ISceneLoaderPluginExtensions {
81
81
  */
82
82
  readonly [extension: string]: {
83
83
  readonly isBinary: boolean;
84
+ readonly mimeType?: string;
84
85
  };
85
86
  }
86
87
  /**
@@ -259,6 +260,7 @@ interface IRegisteredPlugin {
259
260
  * Defines if the plugin supports binary data
260
261
  */
261
262
  isBinary: boolean;
263
+ mimeType?: string;
262
264
  }
263
265
  /**
264
266
  * Defines options for SceneLoader plugins. This interface is extended by specific plugins.
@@ -463,9 +465,9 @@ export declare class SceneLoader {
463
465
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
464
466
  * @param pluginExtension the extension used to determine the plugin
465
467
  * @param name defines the name of the file, if the data is binary
466
- * @returns The loaded plugin
468
+ * @deprecated Please use ImportMeshAsync instead
467
469
  */
468
- static ImportMesh(meshNames: string | readonly string[] | null | undefined, rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
470
+ static ImportMesh(meshNames: string | readonly string[] | null | undefined, rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): void;
469
471
  /**
470
472
  * Import meshes into a scene
471
473
  * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
@@ -488,9 +490,9 @@ export declare class SceneLoader {
488
490
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
489
491
  * @param pluginExtension the extension used to determine the plugin
490
492
  * @param name defines the filename, if the data is binary
491
- * @returns The loaded plugin
493
+ * @deprecated Please use LoadAsync instead
492
494
  */
493
- static Load(rootUrl: string, sceneFilename?: SceneSource, engine?: Nullable<AbstractEngine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
495
+ static Load(rootUrl: string, sceneFilename?: SceneSource, engine?: Nullable<AbstractEngine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): void;
494
496
  /**
495
497
  * Load a scene
496
498
  * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
@@ -512,9 +514,9 @@ export declare class SceneLoader {
512
514
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
513
515
  * @param pluginExtension the extension used to determine the plugin
514
516
  * @param name defines the name of the file, if the data is binary
515
- * @returns The loaded plugin
517
+ * @deprecated Please use AppendAsync instead
516
518
  */
517
- static Append(rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
519
+ static Append(rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): void;
518
520
  /**
519
521
  * Append a scene
520
522
  * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
@@ -536,9 +538,9 @@ export declare class SceneLoader {
536
538
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
537
539
  * @param pluginExtension the extension used to determine the plugin
538
540
  * @param name defines the filename, if the data is binary
539
- * @returns The loaded plugin
541
+ * @deprecated Please use LoadAssetContainerAsync instead
540
542
  */
541
- static LoadAssetContainer(rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
543
+ static LoadAssetContainer(rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): void;
542
544
  /**
543
545
  * Load a scene into an asset container
544
546
  * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
@@ -563,6 +565,7 @@ export declare class SceneLoader {
563
565
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
564
566
  * @param pluginExtension the extension used to determine the plugin
565
567
  * @param name defines the filename, if the data is binary
568
+ * @deprecated Please use ImportAnimationsAsync instead
566
569
  */
567
570
  static ImportAnimations(rootUrl: string, sceneFilename?: SceneSource, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>, name?: string): void;
568
571
  /**
@@ -9,6 +9,7 @@ import { IsBase64DataUrl } from "../Misc/fileTools.js";
9
9
  import { RuntimeError, ErrorCodes } from "../Misc/error.js";
10
10
  import { RandomGUID } from "../Misc/guid.js";
11
11
  import { AbstractEngine } from "../Engines/abstractEngine.js";
12
+ import { _FetchAsync } from "../Misc/webRequest.fetch.js";
12
13
  /**
13
14
  * Mode that determines how to handle old animation groups before loading new ones.
14
15
  */
@@ -43,7 +44,16 @@ let showingLoadingScreen = false;
43
44
  function getDefaultPlugin() {
44
45
  return registeredPlugins[".babylon"];
45
46
  }
46
- function getPluginForExtension(extension) {
47
+ function getPluginForMimeType(mimeType) {
48
+ for (const registeredPluginKey in registeredPlugins) {
49
+ const registeredPlugin = registeredPlugins[registeredPluginKey];
50
+ if (registeredPlugin.mimeType === mimeType) {
51
+ return registeredPlugin;
52
+ }
53
+ }
54
+ return undefined;
55
+ }
56
+ function getPluginForExtension(extension, returnDefault) {
47
57
  const registeredPlugin = registeredPlugins[extension];
48
58
  if (registeredPlugin) {
49
59
  return registeredPlugin;
@@ -51,7 +61,7 @@ function getPluginForExtension(extension) {
51
61
  Logger.Warn("Unable to find a plugin to load " +
52
62
  extension +
53
63
  " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes");
54
- return getDefaultPlugin();
64
+ return returnDefault ? getDefaultPlugin() : undefined;
55
65
  }
56
66
  function isPluginForExtensionAvailable(extension) {
57
67
  return !!registeredPlugins[extension];
@@ -65,14 +75,13 @@ function getPluginForDirectLoad(data) {
65
75
  }
66
76
  return getDefaultPlugin();
67
77
  }
68
- function getPluginForFilename(sceneFilename) {
78
+ function getFilenameExtension(sceneFilename) {
69
79
  const queryStringPosition = sceneFilename.indexOf("?");
70
80
  if (queryStringPosition !== -1) {
71
81
  sceneFilename = sceneFilename.substring(0, queryStringPosition);
72
82
  }
73
83
  const dotPosition = sceneFilename.lastIndexOf(".");
74
- const extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
75
- return getPluginForExtension(extension);
84
+ return sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
76
85
  }
77
86
  function getDirectLoad(sceneFilename) {
78
87
  if (sceneFilename.substring(0, 5) === "data:") {
@@ -91,13 +100,31 @@ function formatErrorMessage(fileInfo, message, exception) {
91
100
  }
92
101
  return errorMessage;
93
102
  }
94
- function loadData(fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension, name, pluginOptions) {
103
+ async function loadDataAsync(fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension, name, pluginOptions) {
95
104
  const directLoad = getDirectLoad(fileInfo.url);
96
105
  if (fileInfo.rawData && !pluginExtension) {
97
106
  // eslint-disable-next-line no-throw-literal
98
107
  throw "When using ArrayBufferView to load data the file extension must be provided.";
99
108
  }
100
- const registeredPlugin = pluginExtension ? getPluginForExtension(pluginExtension) : directLoad ? getPluginForDirectLoad(fileInfo.url) : getPluginForFilename(fileInfo.url);
109
+ const fileExtension = !directLoad && !pluginExtension ? getFilenameExtension(fileInfo.url) : "";
110
+ let registeredPlugin = pluginExtension
111
+ ? getPluginForExtension(pluginExtension, true)
112
+ : directLoad
113
+ ? getPluginForDirectLoad(fileInfo.url)
114
+ : getPluginForExtension(fileExtension, false);
115
+ if (!registeredPlugin && fileExtension) {
116
+ if (fileInfo.url && !fileInfo.url.startsWith("blob:")) {
117
+ // Fetching head content to get the mime type
118
+ const response = await _FetchAsync(fileInfo.url, { method: "HEAD", responseHeaders: ["Content-Type"] });
119
+ const mimeType = response.headerValues ? response.headerValues["Content-Type"] : "";
120
+ if (mimeType) {
121
+ registeredPlugin = getPluginForMimeType(mimeType);
122
+ }
123
+ }
124
+ if (!registeredPlugin) {
125
+ registeredPlugin = getDefaultPlugin();
126
+ }
127
+ }
101
128
  if (!registeredPlugin) {
102
129
  throw new Error(`No plugin or fallback for ${pluginExtension ?? fileInfo.url}`);
103
130
  }
@@ -217,7 +244,7 @@ function loadData(fileInfo, scene, onSuccess, onProgress, onError, onDispose, pl
217
244
  }
218
245
  });
219
246
  }
220
- function getFileInfo(rootUrl, sceneSource) {
247
+ function _getFileInfo(rootUrl, sceneSource) {
221
248
  let url;
222
249
  let name;
223
250
  let file = null;
@@ -281,16 +308,17 @@ export function registerSceneLoaderPlugin(plugin) {
281
308
  registeredPlugins[extension.toLowerCase()] = {
282
309
  plugin: plugin,
283
310
  isBinary: extensions[extension].isBinary,
311
+ mimeType: extensions[extension].mimeType,
284
312
  };
285
313
  });
286
314
  }
287
315
  }
288
- function importMesh(meshNames, rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScene, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
316
+ async function importMeshAsync(meshNames, rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScene, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
289
317
  if (!scene) {
290
318
  Logger.Error("No scene available to import mesh to");
291
319
  return null;
292
320
  }
293
- const fileInfo = getFileInfo(rootUrl, sceneFilename);
321
+ const fileInfo = _getFileInfo(rootUrl, sceneFilename);
294
322
  if (!fileInfo) {
295
323
  return null;
296
324
  }
@@ -332,7 +360,7 @@ function importMesh(meshNames, rootUrl, sceneFilename = "", scene = EngineStore.
332
360
  }
333
361
  scene.removePendingData(loadingToken);
334
362
  };
335
- return loadData(fileInfo, scene, (plugin, data, responseURL) => {
363
+ return await loadDataAsync(fileInfo, scene, (plugin, data, responseURL) => {
336
364
  if (plugin.rewriteRootURL) {
337
365
  fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
338
366
  }
@@ -363,7 +391,7 @@ function importMesh(meshNames, rootUrl, sceneFilename = "", scene = EngineStore.
363
391
  }
364
392
  function importMeshAsyncCore(meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions) {
365
393
  return new Promise((resolve, reject) => {
366
- importMesh(meshNames, rootUrl, sceneFilename, scene, (meshes, particleSystems, skeletons, animationGroups, transformNodes, geometries, lights, spriteManagers) => {
394
+ importMeshAsync(meshNames, rootUrl, sceneFilename, scene, (meshes, particleSystems, skeletons, animationGroups, transformNodes, geometries, lights, spriteManagers) => {
367
395
  resolve({
368
396
  meshes: meshes,
369
397
  particleSystems: particleSystems,
@@ -382,9 +410,9 @@ function importMeshAsyncCore(meshNames, rootUrl, sceneFilename, scene, onProgres
382
410
  function loadScene(rootUrl, sceneFilename = "", engine = EngineStore.LastCreatedEngine, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
383
411
  if (!engine) {
384
412
  Tools.Error("No engine available");
385
- return null;
413
+ return;
386
414
  }
387
- return append(rootUrl, sceneFilename, new Scene(engine), onSuccess, onProgress, onError, pluginExtension, name, pluginOptions);
415
+ appendAsync(rootUrl, sceneFilename, new Scene(engine), onSuccess, onProgress, onError, pluginExtension, name, pluginOptions);
388
416
  }
389
417
  /**
390
418
  * Load a scene
@@ -407,12 +435,12 @@ function loadSceneAsyncCore(rootUrl, sceneFilename, engine, onProgress, pluginEx
407
435
  }, pluginExtension, name, pluginOptions);
408
436
  });
409
437
  }
410
- function append(rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScene, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
438
+ async function appendAsync(rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScene, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
411
439
  if (!scene) {
412
440
  Logger.Error("No scene available to append to");
413
441
  return null;
414
442
  }
415
- const fileInfo = getFileInfo(rootUrl, sceneFilename);
443
+ const fileInfo = _getFileInfo(rootUrl, sceneFilename);
416
444
  if (!fileInfo) {
417
445
  return null;
418
446
  }
@@ -461,7 +489,7 @@ function append(rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScen
461
489
  }
462
490
  scene.removePendingData(loadingToken);
463
491
  };
464
- return loadData(fileInfo, scene, (plugin, data) => {
492
+ return await loadDataAsync(fileInfo, scene, (plugin, data) => {
465
493
  if (plugin.load) {
466
494
  const syncedPlugin = plugin;
467
495
  if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
@@ -497,19 +525,19 @@ export async function appendSceneAsync(source, scene, options) {
497
525
  }
498
526
  function appendSceneAsyncCore(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions) {
499
527
  return new Promise((resolve, reject) => {
500
- append(rootUrl, sceneFilename, scene, (scene) => {
528
+ appendAsync(rootUrl, sceneFilename, scene, (scene) => {
501
529
  resolve(scene);
502
530
  }, onProgress, (scene, message, exception) => {
503
531
  reject(exception || new Error(message));
504
532
  }, pluginExtension, name, pluginOptions);
505
533
  });
506
534
  }
507
- function loadAssetContainer(rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScene, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
535
+ async function loadAssetContainerCoreAsync(rootUrl, sceneFilename = "", scene = EngineStore.LastCreatedScene, onSuccess = null, onProgress = null, onError = null, pluginExtension = null, name = "", pluginOptions = {}) {
508
536
  if (!scene) {
509
537
  Logger.Error("No scene available to load asset container to");
510
538
  return null;
511
539
  }
512
- const fileInfo = getFileInfo(rootUrl, sceneFilename);
540
+ const fileInfo = _getFileInfo(rootUrl, sceneFilename);
513
541
  if (!fileInfo) {
514
542
  return null;
515
543
  }
@@ -550,7 +578,7 @@ function loadAssetContainer(rootUrl, sceneFilename = "", scene = EngineStore.Las
550
578
  }
551
579
  scene.removePendingData(loadingToken);
552
580
  };
553
- return loadData(fileInfo, scene, (plugin, data) => {
581
+ return await loadDataAsync(fileInfo, scene, (plugin, data) => {
554
582
  if (plugin.loadAssetContainer) {
555
583
  const syncedPlugin = plugin;
556
584
  const assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
@@ -589,11 +617,11 @@ function loadAssetContainer(rootUrl, sceneFilename = "", scene = EngineStore.Las
589
617
  */
590
618
  export function loadAssetContainerAsync(source, scene, options) {
591
619
  const { rootUrl = "", onProgress, pluginExtension, name, pluginOptions } = options ?? {};
592
- return loadAssetContainerAsyncCore(rootUrl, source, scene, onProgress, pluginExtension, name, pluginOptions);
620
+ return internalLoadAssetContainerAsync(rootUrl, source, scene, onProgress, pluginExtension, name, pluginOptions);
593
621
  }
594
- function loadAssetContainerAsyncCore(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions) {
622
+ function internalLoadAssetContainerAsync(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions) {
595
623
  return new Promise((resolve, reject) => {
596
- loadAssetContainer(rootUrl, sceneFilename, scene, (assets) => {
624
+ loadAssetContainerCoreAsync(rootUrl, sceneFilename, scene, (assets) => {
597
625
  resolve(assets);
598
626
  }, onProgress, (scene, message, exception) => {
599
627
  reject(exception || new Error(message));
@@ -656,7 +684,7 @@ function importAnimations(rootUrl, sceneFilename = "", scene = EngineStore.LastC
656
684
  onSuccess(scene);
657
685
  }
658
686
  };
659
- loadAssetContainer(rootUrl, sceneFilename, scene, onAssetContainerLoaded, onProgress, onError, pluginExtension, name, pluginOptions);
687
+ loadAssetContainerCoreAsync(rootUrl, sceneFilename, scene, onAssetContainerLoaded, onProgress, onError, pluginExtension, name, pluginOptions);
660
688
  }
661
689
  /**
662
690
  * Import animations from a file into a scene
@@ -736,7 +764,7 @@ export class SceneLoader {
736
764
  * @returns a plugin or null if none works
737
765
  */
738
766
  static GetPluginForExtension(extension) {
739
- return getPluginForExtension(extension)?.plugin;
767
+ return getPluginForExtension(extension, true)?.plugin;
740
768
  }
741
769
  /**
742
770
  * Gets a boolean indicating that the given extension can be loaded
@@ -764,10 +792,10 @@ export class SceneLoader {
764
792
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
765
793
  * @param pluginExtension the extension used to determine the plugin
766
794
  * @param name defines the name of the file, if the data is binary
767
- * @returns The loaded plugin
795
+ * @deprecated Please use ImportMeshAsync instead
768
796
  */
769
797
  static ImportMesh(meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name) {
770
- return importMesh(meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name);
798
+ importMeshAsync(meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name);
771
799
  }
772
800
  /**
773
801
  * Import meshes into a scene
@@ -793,10 +821,10 @@ export class SceneLoader {
793
821
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
794
822
  * @param pluginExtension the extension used to determine the plugin
795
823
  * @param name defines the filename, if the data is binary
796
- * @returns The loaded plugin
824
+ * @deprecated Please use LoadAsync instead
797
825
  */
798
826
  static Load(rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension, name) {
799
- return loadScene(rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension, name);
827
+ loadScene(rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension, name);
800
828
  }
801
829
  /**
802
830
  * Load a scene
@@ -821,10 +849,10 @@ export class SceneLoader {
821
849
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
822
850
  * @param pluginExtension the extension used to determine the plugin
823
851
  * @param name defines the name of the file, if the data is binary
824
- * @returns The loaded plugin
852
+ * @deprecated Please use AppendAsync instead
825
853
  */
826
854
  static Append(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name) {
827
- return append(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name);
855
+ appendAsync(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name);
828
856
  }
829
857
  /**
830
858
  * Append a scene
@@ -849,10 +877,10 @@ export class SceneLoader {
849
877
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
850
878
  * @param pluginExtension the extension used to determine the plugin
851
879
  * @param name defines the filename, if the data is binary
852
- * @returns The loaded plugin
880
+ * @deprecated Please use LoadAssetContainerAsync instead
853
881
  */
854
882
  static LoadAssetContainer(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name) {
855
- return loadAssetContainer(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name);
883
+ loadAssetContainerCoreAsync(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, name);
856
884
  }
857
885
  /**
858
886
  * Load a scene into an asset container
@@ -865,7 +893,7 @@ export class SceneLoader {
865
893
  * @returns The loaded asset container
866
894
  */
867
895
  static LoadAssetContainerAsync(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name) {
868
- return loadAssetContainerAsyncCore(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name);
896
+ return internalLoadAssetContainerAsync(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name);
869
897
  }
870
898
  /**
871
899
  * Import animations from a file into a scene
@@ -880,6 +908,7 @@ export class SceneLoader {
880
908
  * @param onError a callback with the scene, a message, and possibly an exception when import fails
881
909
  * @param pluginExtension the extension used to determine the plugin
882
910
  * @param name defines the filename, if the data is binary
911
+ * @deprecated Please use ImportAnimationsAsync instead
883
912
  */
884
913
  static ImportAnimations(rootUrl, sceneFilename, scene, overwriteAnimations, animationGroupLoadingMode, targetConverter, onSuccess, onProgress, onError, pluginExtension, name) {
885
914
  importAnimations(rootUrl, sceneFilename, scene, overwriteAnimations, animationGroupLoadingMode, targetConverter, onSuccess, onProgress, onError, pluginExtension, name);