@babylonjs/core 8.8.0 → 8.8.2

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 (409) hide show
  1. package/Actions/actionManager.js +2 -0
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Animations/animatable.core.js +1 -1
  4. package/Animations/animatable.core.js.map +1 -1
  5. package/Animations/animation.js +4 -2
  6. package/Animations/animation.js.map +1 -1
  7. package/Audio/audioEngine.d.ts +1 -1
  8. package/Audio/audioEngine.js +20 -10
  9. package/Audio/audioEngine.js.map +1 -1
  10. package/Audio/audioSceneComponent.js +2 -0
  11. package/Audio/audioSceneComponent.js.map +1 -1
  12. package/Audio/sound.js +2 -0
  13. package/Audio/sound.js.map +1 -1
  14. package/AudioV2/abstractAudio/audioEngineV2.js +8 -1
  15. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  16. package/AudioV2/abstractAudio/streamingSound.js +3 -1
  17. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  18. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +6 -2
  19. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
  20. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +3 -0
  21. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -1
  22. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +1 -0
  23. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  24. package/AudioV2/webAudio/webAudioEngine.js +5 -1
  25. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  26. package/AudioV2/webAudio/webAudioStaticSound.js +2 -0
  27. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  28. package/AudioV2/webAudio/webAudioStreamingSound.js +3 -0
  29. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  30. package/AudioV2/webAudio/webAudioUnmuteUI.js +1 -0
  31. package/AudioV2/webAudio/webAudioUnmuteUI.js.map +1 -1
  32. package/BakedVertexAnimation/vertexAnimationBaker.d.ts +1 -0
  33. package/BakedVertexAnimation/vertexAnimationBaker.js +3 -1
  34. package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
  35. package/Buffers/buffer.nonFloatVertexBuffers.js +1 -0
  36. package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -1
  37. package/Buffers/storageBuffer.js +1 -1
  38. package/Buffers/storageBuffer.js.map +1 -1
  39. package/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.js +2 -0
  40. package/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.js.map +1 -1
  41. package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +6 -1
  42. package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
  43. package/Cameras/VR/vrExperienceHelper.js +2 -0
  44. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  45. package/Collisions/gpuPicker.js +9 -6
  46. package/Collisions/gpuPicker.js.map +1 -1
  47. package/Compute/computeShader.js +1 -1
  48. package/Compute/computeShader.js.map +1 -1
  49. package/Culling/Helper/boundingInfoHelper.js +3 -3
  50. package/Culling/Helper/boundingInfoHelper.js.map +1 -1
  51. package/Culling/Helper/computeShaderBoundingHelper.js +3 -1
  52. package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
  53. package/Culling/Helper/transformFeedbackBoundingHelper.js +3 -0
  54. package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
  55. package/Debug/debugLayer.js +1 -1
  56. package/Debug/debugLayer.js.map +1 -1
  57. package/Engines/AbstractEngine/abstractEngine.cubeTexture.js +1 -0
  58. package/Engines/AbstractEngine/abstractEngine.cubeTexture.js.map +1 -1
  59. package/Engines/Extensions/engine.prefilteredCubeTexture.js +1 -0
  60. package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
  61. package/Engines/Extensions/engine.readTexture.js +1 -0
  62. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  63. package/Engines/WebGPU/Extensions/engine.computeShader.js +1 -0
  64. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  65. package/Engines/WebGPU/Extensions/engine.readTexture.js +1 -0
  66. package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
  67. package/Engines/WebGPU/Extensions/engine.videoTexture.js +2 -0
  68. package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
  69. package/Engines/WebGPU/webgpuBufferManager.js +3 -1
  70. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  71. package/Engines/WebGPU/webgpuOcclusionQuery.js +1 -0
  72. package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
  73. package/Engines/WebGPU/webgpuQuerySet.js +15 -9
  74. package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
  75. package/Engines/WebGPU/webgpuTextureManager.js +1 -0
  76. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  77. package/Engines/WebGPU/webgpuTimestampQuery.js +4 -2
  78. package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
  79. package/Engines/WebGPU/webgpuTintWASM.js +1 -0
  80. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  81. package/Engines/abstractEngine.js +5 -2
  82. package/Engines/abstractEngine.js.map +1 -1
  83. package/Engines/constants.d.ts +23 -0
  84. package/Engines/constants.js +23 -0
  85. package/Engines/constants.js.map +1 -1
  86. package/Engines/engine.common.js +7 -1
  87. package/Engines/engine.common.js.map +1 -1
  88. package/Engines/engine.js +5 -3
  89. package/Engines/engine.js.map +1 -1
  90. package/Engines/engineFactory.js +1 -1
  91. package/Engines/engineFactory.js.map +1 -1
  92. package/Engines/nativeEngine.js +19 -11
  93. package/Engines/nativeEngine.js.map +1 -1
  94. package/Engines/thinEngine.d.ts +1 -0
  95. package/Engines/thinEngine.js +22 -18
  96. package/Engines/thinEngine.js.map +1 -1
  97. package/Engines/webgpuEngine.js +30 -11
  98. package/Engines/webgpuEngine.js.map +1 -1
  99. package/FlowGraph/flowGraphParser.js +2 -2
  100. package/FlowGraph/flowGraphParser.js.map +1 -1
  101. package/FrameGraph/Node/nodeRenderGraph.js +5 -1
  102. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  103. package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -1
  104. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  105. package/FrameGraph/frameGraph.js +1 -1
  106. package/FrameGraph/frameGraph.js.map +1 -1
  107. package/Helpers/sceneHelpers.js +1 -3
  108. package/Helpers/sceneHelpers.js.map +1 -1
  109. package/Helpers/videoDome.js +1 -0
  110. package/Helpers/videoDome.js.map +1 -1
  111. package/Layers/thinEffectLayer.js +1 -0
  112. package/Layers/thinEffectLayer.js.map +1 -1
  113. package/LensFlares/lensFlareSystem.js +1 -0
  114. package/LensFlares/lensFlareSystem.js.map +1 -1
  115. package/Lights/Shadows/shadowGenerator.js +3 -2
  116. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  117. package/Lights/areaLight.js +2 -0
  118. package/Lights/areaLight.js.map +1 -1
  119. package/Loading/sceneLoader.js +56 -22
  120. package/Loading/sceneLoader.js.map +1 -1
  121. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +15 -1
  122. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +34 -7
  123. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  124. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +1 -0
  125. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
  126. package/Materials/Node/Blocks/Dual/fogBlock.js +1 -0
  127. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  128. package/Materials/Node/Blocks/Dual/lightBlock.js +1 -0
  129. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  130. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -0
  131. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  132. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +1 -0
  133. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  134. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +1 -0
  135. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  136. package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +1 -0
  137. package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
  138. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +9 -11
  139. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  140. package/Materials/Node/Blocks/PBR/sheenBlock.js +1 -1
  141. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  142. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +6 -2
  143. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  144. package/Materials/Node/Blocks/Vertex/bonesBlock.js +1 -0
  145. package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
  146. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +1 -0
  147. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  148. package/Materials/Node/nodeMaterial.js +11 -3
  149. package/Materials/Node/nodeMaterial.js.map +1 -1
  150. package/Materials/Node/nodeMaterialBuildState.js +1 -0
  151. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  152. package/Materials/PBR/pbrBRDFConfiguration.d.ts +11 -0
  153. package/Materials/PBR/pbrBRDFConfiguration.js +16 -0
  154. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  155. package/Materials/PBR/pbrBaseMaterial.d.ts +4 -0
  156. package/Materials/PBR/pbrBaseMaterial.js +12 -8
  157. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  158. package/Materials/PBR/pbrMaterial.d.ts +8 -0
  159. package/Materials/PBR/pbrMaterial.js +16 -0
  160. package/Materials/PBR/pbrMaterial.js.map +1 -1
  161. package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +1 -0
  162. package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
  163. package/Materials/Textures/Loaders/basisTextureLoader.js +4 -0
  164. package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
  165. package/Materials/Textures/Loaders/envTextureLoader.js +1 -0
  166. package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
  167. package/Materials/Textures/Loaders/exrTextureLoader.js +2 -0
  168. package/Materials/Textures/Loaders/exrTextureLoader.js.map +1 -1
  169. package/Materials/Textures/Loaders/ktxTextureLoader.js +1 -0
  170. package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
  171. package/Materials/Textures/Loaders/textureLoaderManager.js +9 -9
  172. package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
  173. package/Materials/Textures/Packer/packer.js +3 -1
  174. package/Materials/Textures/Packer/packer.js.map +1 -1
  175. package/Materials/Textures/Procedurals/proceduralTexture.js +1 -0
  176. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  177. package/Materials/Textures/baseTexture.polynomial.js +1 -0
  178. package/Materials/Textures/baseTexture.polynomial.js.map +1 -1
  179. package/Materials/Textures/hdrCubeTexture.js +1 -0
  180. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  181. package/Materials/Textures/internalTexture.js +1 -0
  182. package/Materials/Textures/internalTexture.js.map +1 -1
  183. package/Materials/Textures/rawCubeTexture.js +3 -0
  184. package/Materials/Textures/rawCubeTexture.js.map +1 -1
  185. package/Materials/Textures/renderTargetTexture.js +2 -0
  186. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  187. package/Materials/Textures/videoTexture.js +6 -0
  188. package/Materials/Textures/videoTexture.js.map +1 -1
  189. package/Materials/effect.js +2 -1
  190. package/Materials/effect.js.map +1 -1
  191. package/Materials/effect.webgl.functions.js +3 -1
  192. package/Materials/effect.webgl.functions.js.map +1 -1
  193. package/Materials/effectRenderer.js +1 -0
  194. package/Materials/effectRenderer.js.map +1 -1
  195. package/Materials/material.js +2 -1
  196. package/Materials/material.js.map +1 -1
  197. package/Materials/shaderMaterial.js +4 -2
  198. package/Materials/shaderMaterial.js.map +1 -1
  199. package/Meshes/Compression/dracoCodec.js +5 -1
  200. package/Meshes/Compression/dracoCodec.js.map +1 -1
  201. package/Meshes/Compression/dracoCompression.js +4 -3
  202. package/Meshes/Compression/dracoCompression.js.map +1 -1
  203. package/Meshes/Compression/dracoCompressionWorker.js +5 -2
  204. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  205. package/Meshes/Compression/dracoDecoder.js +5 -1
  206. package/Meshes/Compression/dracoDecoder.js.map +1 -1
  207. package/Meshes/Compression/dracoEncoder.js +3 -2
  208. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  209. package/Meshes/Compression/meshoptCompression.js +18 -18
  210. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  211. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +14 -15
  212. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  213. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +20 -10
  214. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  215. package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -0
  216. package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
  217. package/Meshes/Node/nodeGeometry.js +5 -1
  218. package/Meshes/Node/nodeGeometry.js.map +1 -1
  219. package/Meshes/mesh.js +2 -2
  220. package/Meshes/mesh.js.map +1 -1
  221. package/Meshes/meshUVSpaceRenderer.js +1 -0
  222. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  223. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -0
  224. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  225. package/Misc/assetsManager.js +2 -1
  226. package/Misc/assetsManager.js.map +1 -1
  227. package/Misc/asyncLock.js +5 -2
  228. package/Misc/asyncLock.js.map +1 -1
  229. package/Misc/basis.js +9 -2
  230. package/Misc/basis.js.map +1 -1
  231. package/Misc/basisWorker.js +3 -1
  232. package/Misc/basisWorker.js.map +1 -1
  233. package/Misc/copyTextureToTexture.js +1 -0
  234. package/Misc/copyTextureToTexture.js.map +1 -1
  235. package/Misc/coroutine.js +2 -1
  236. package/Misc/coroutine.js.map +1 -1
  237. package/Misc/dataReader.js +3 -4
  238. package/Misc/dataReader.js.map +1 -1
  239. package/Misc/dumpTools.js +7 -1
  240. package/Misc/dumpTools.js.map +1 -1
  241. package/Misc/environmentTextureTools.d.ts +0 -2
  242. package/Misc/environmentTextureTools.js +20 -7
  243. package/Misc/environmentTextureTools.js.map +1 -1
  244. package/Misc/equirectangularCapture.js +2 -1
  245. package/Misc/equirectangularCapture.js.map +1 -1
  246. package/Misc/fileTools.js +2 -0
  247. package/Misc/fileTools.js.map +1 -1
  248. package/Misc/filesInput.js +5 -1
  249. package/Misc/filesInput.js.map +1 -1
  250. package/Misc/khronosTextureContainer2.js +10 -3
  251. package/Misc/khronosTextureContainer2.js.map +1 -1
  252. package/Misc/khronosTextureContainer2Worker.js +4 -1
  253. package/Misc/khronosTextureContainer2Worker.js.map +1 -1
  254. package/Misc/minMaxReducer.js +1 -0
  255. package/Misc/minMaxReducer.js.map +1 -1
  256. package/Misc/observable.extensions.js +3 -1
  257. package/Misc/observable.extensions.js.map +1 -1
  258. package/Misc/observable.js +2 -0
  259. package/Misc/observable.js.map +1 -1
  260. package/Misc/observableCoroutine.js +1 -0
  261. package/Misc/observableCoroutine.js.map +1 -1
  262. package/Misc/reflector.js +1 -0
  263. package/Misc/reflector.js.map +1 -1
  264. package/Misc/rgbdTextureTools.js +2 -1
  265. package/Misc/rgbdTextureTools.js.map +1 -1
  266. package/Misc/sceneSerializer.js +2 -2
  267. package/Misc/sceneSerializer.js.map +1 -1
  268. package/Misc/screenshotTools.js +9 -4
  269. package/Misc/screenshotTools.js.map +1 -1
  270. package/Misc/textureTools.js +2 -0
  271. package/Misc/textureTools.js.map +1 -1
  272. package/Misc/tools.internals.js +2 -1
  273. package/Misc/tools.internals.js.map +1 -1
  274. package/Misc/tools.js +9 -3
  275. package/Misc/tools.js.map +1 -1
  276. package/Misc/videoRecorder.js +1 -0
  277. package/Misc/videoRecorder.js.map +1 -1
  278. package/Misc/webRequest.fetch.js +2 -1
  279. package/Misc/webRequest.fetch.js.map +1 -1
  280. package/Misc/workerPool.js +3 -0
  281. package/Misc/workerPool.js.map +1 -1
  282. package/Particles/flowMap.js +1 -1
  283. package/Particles/flowMap.js.map +1 -1
  284. package/Particles/particleHelper.js +7 -0
  285. package/Particles/particleHelper.js.map +1 -1
  286. package/Particles/pointsCloudSystem.js +7 -7
  287. package/Particles/pointsCloudSystem.js.map +1 -1
  288. package/Particles/thinParticleSystem.js +2 -0
  289. package/Particles/thinParticleSystem.js.map +1 -1
  290. package/Physics/physicsHelper.js +2 -2
  291. package/Physics/physicsHelper.js.map +1 -1
  292. package/Physics/v1/Plugins/oimoJSPlugin.js +1 -1
  293. package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
  294. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +1 -0
  295. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  296. package/Rendering/GlobalIllumination/giRSMManager.js +1 -0
  297. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  298. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +1 -0
  299. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  300. package/Rendering/depthRenderer.js +1 -0
  301. package/Rendering/depthRenderer.js.map +1 -1
  302. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +3 -1
  303. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
  304. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  305. package/Rendering/geometryBufferRenderer.js +1 -0
  306. package/Rendering/geometryBufferRenderer.js.map +1 -1
  307. package/Rendering/iblCdfGenerator.js +4 -1
  308. package/Rendering/iblCdfGenerator.js.map +1 -1
  309. package/Shaders/ShadersInclude/lightFragment.js +5 -1
  310. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  311. package/Shaders/ShadersInclude/pbrBRDFFunctions.js +12 -5
  312. package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  313. package/Shaders/ShadersInclude/pbrBlockDirectLighting.js +3 -0
  314. package/Shaders/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
  315. package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +21 -8
  316. package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
  317. package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js +3 -0
  318. package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  319. package/Shaders/ShadersInclude/pbrBlockReflectance.js +6 -6
  320. package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
  321. package/Shaders/ShadersInclude/pbrBlockReflectance0.js +2 -7
  322. package/Shaders/ShadersInclude/pbrBlockReflectance0.js.map +1 -1
  323. package/Shaders/ShadersInclude/pbrBlockReflectivity.js +20 -16
  324. package/Shaders/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
  325. package/Shaders/ShadersInclude/pbrBlockSubSurface.js +6 -8
  326. package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  327. package/Shaders/ShadersInclude/pbrDebug.js +2 -2
  328. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  329. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +1 -5
  330. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  331. package/Shaders/pbr.fragment.js +7 -3
  332. package/Shaders/pbr.fragment.js.map +1 -1
  333. package/ShadersWGSL/ShadersInclude/lightFragment.js +5 -1
  334. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  335. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +5 -5
  336. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  337. package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js +3 -0
  338. package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
  339. package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +21 -8
  340. package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
  341. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +3 -0
  342. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  343. package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +6 -6
  344. package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
  345. package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.js +2 -7
  346. package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.js.map +1 -1
  347. package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js +22 -15
  348. package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
  349. package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +6 -8
  350. package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  351. package/ShadersWGSL/ShadersInclude/pbrDebug.js +2 -2
  352. package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
  353. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -7
  354. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  355. package/ShadersWGSL/pbr.fragment.js +7 -3
  356. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  357. package/Sprites/spriteManager.js +5 -1
  358. package/Sprites/spriteManager.js.map +1 -1
  359. package/Sprites/spriteRenderer.js +1 -0
  360. package/Sprites/spriteRenderer.js.map +1 -1
  361. package/XR/features/WebXRAnchorSystem.js +4 -3
  362. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  363. package/XR/features/WebXRDepthSensing.js +1 -1
  364. package/XR/features/WebXRDepthSensing.js.map +1 -1
  365. package/XR/features/WebXRHandTracking.js +4 -1
  366. package/XR/features/WebXRHandTracking.js.map +1 -1
  367. package/XR/features/WebXRHitTest.js +4 -1
  368. package/XR/features/WebXRHitTest.js.map +1 -1
  369. package/XR/features/WebXRHitTestLegacy.js +6 -5
  370. package/XR/features/WebXRHitTestLegacy.js.map +1 -1
  371. package/XR/features/WebXRImageTracking.js +2 -1
  372. package/XR/features/WebXRImageTracking.js.map +1 -1
  373. package/XR/features/WebXRLightEstimation.js +3 -0
  374. package/XR/features/WebXRLightEstimation.js.map +1 -1
  375. package/XR/features/WebXRNearInteraction.js +2 -0
  376. package/XR/features/WebXRNearInteraction.js.map +1 -1
  377. package/XR/features/WebXRPlaneDetector.js +2 -2
  378. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  379. package/XR/motionController/webXRAbstractMotionController.js +3 -2
  380. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  381. package/XR/motionController/webXRMicrosoftMixedRealityController.js +6 -6
  382. package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
  383. package/XR/motionController/webXRMotionControllerManager.js +15 -9
  384. package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
  385. package/XR/motionController/webXRProfiledMotionController.js +1 -1
  386. package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
  387. package/XR/native/nativeXRFrame.js +1 -0
  388. package/XR/native/nativeXRFrame.js.map +1 -1
  389. package/XR/webXRDefaultExperience.js +10 -12
  390. package/XR/webXRDefaultExperience.js.map +1 -1
  391. package/XR/webXREnterExitUI.js +2 -1
  392. package/XR/webXREnterExitUI.js.map +1 -1
  393. package/XR/webXRExperienceHelper.js +5 -2
  394. package/XR/webXRExperienceHelper.js.map +1 -1
  395. package/XR/webXRFeaturesManager.js +1 -0
  396. package/XR/webXRFeaturesManager.js.map +1 -1
  397. package/XR/webXRInput.js +1 -0
  398. package/XR/webXRInput.js.map +1 -1
  399. package/XR/webXRInputSource.js +2 -0
  400. package/XR/webXRInputSource.js.map +1 -1
  401. package/XR/webXRManagedOutputCanvas.js +5 -1
  402. package/XR/webXRManagedOutputCanvas.js.map +1 -1
  403. package/XR/webXRSessionManager.js +56 -60
  404. package/XR/webXRSessionManager.js.map +1 -1
  405. package/assetContainer.js +28 -28
  406. package/assetContainer.js.map +1 -1
  407. package/package.json +1 -1
  408. package/scene.js +5 -4
  409. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB,EAChB,OAAO,GAAG,KAAK;IAEf,MAA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C,MAAM,eAAe,GAAG;IAC3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB;IAEhB;;;;;;;;;;;;;;;;OAgBG;IACH,qBAAqB;IAErB;;;;;;;;;;;;;OAaG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { _RetryWithInterval } from \"./timingTools\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number,\r\n useFill = false\r\n): void {\r\n const { height, width } = GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n return;\r\n }\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (!renderContext || !renderingCanvas) {\r\n Logger.Error(\"Failed to create screenshot. Rendering context or rendering canvas is not available.\");\r\n return;\r\n }\r\n\r\n const srcWidth = renderingCanvas.width;\r\n const srcHeight = renderingCanvas.height;\r\n const destWidth = screenshotCanvas.width;\r\n const destHeight = screenshotCanvas.height;\r\n\r\n // Calculate scale factors for width and height.\r\n const scaleX = destWidth / srcWidth;\r\n const scaleY = destHeight / srcHeight;\r\n // Use the larger of the two scales to fill the screenshot dimensions, else use the smaller to fit.\r\n const scale = useFill ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);\r\n const newWidth = srcWidth * scale;\r\n const newHeight = srcHeight * scale;\r\n\r\n // Center the image in the screenshot canvas\r\n const offsetX = (destWidth - newWidth) / 2;\r\n const offsetY = (destHeight - newHeight) / 2;\r\n\r\n renderContext.drawImage(renderingCanvas, 0, 0, srcWidth, srcHeight, offsetX, offsetY, newWidth, newHeight);\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport async function CreateScreenshotWithResizeAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n width: number,\r\n height: number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n // Prevent engine to render on screen while we do the screenshot\r\n engine.skipFrameRender = true;\r\n\r\n const originalGetRenderWidth = engine.getRenderWidth;\r\n const originalGetRenderHeight = engine.getRenderHeight;\r\n\r\n // Override getRenderWidth and getRenderHeight to return the desired size of the render\r\n // A few internal methods are relying on the canvas size to compute the render size\r\n // so we need to override these methods to ensure the correct size is used during the preparation of the render\r\n // as well as the screenshot\r\n engine.getRenderWidth = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.width;\r\n }\r\n\r\n return width;\r\n };\r\n engine.getRenderHeight = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.height;\r\n }\r\n\r\n return height;\r\n };\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const dumpDataFunc = customDumpData || DumpData;\r\n\r\n const renderWhenReady = () => {\r\n _RetryWithInterval(\r\n () => texture.isReadyForRendering() && camera.isReady(true),\r\n () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n dumpDataFunc(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n importPromise.then(async () =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n dumpDataFunc(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n // Record the original scene setup\r\n const originalCamera = scene.activeCamera;\r\n const originalCameras = scene.activeCameras;\r\n const originalOutputRenderTarget = camera.outputRenderTarget;\r\n const originalSpritesEnabled = scene.spritesEnabled;\r\n\r\n // Swap with the requested one\r\n scene.activeCamera = camera;\r\n scene.activeCameras = null;\r\n camera.outputRenderTarget = texture;\r\n scene.spritesEnabled = renderSprites;\r\n\r\n const currentMeshList = scene.meshes;\r\n scene.meshes = texture.renderList || scene.meshes;\r\n\r\n // render the scene on the RTT\r\n try {\r\n scene.render();\r\n } finally {\r\n // Restore the original scene camera setup\r\n scene.activeCamera = originalCamera;\r\n scene.activeCameras = originalCameras;\r\n camera.outputRenderTarget = originalOutputRenderTarget;\r\n scene.spritesEnabled = originalSpritesEnabled;\r\n scene.meshes = currentMeshList;\r\n\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n\r\n engine.skipFrameRender = false;\r\n }\r\n },\r\n () => {\r\n // Restore engine frame rendering on error\r\n engine.skipFrameRender = false;\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n }\r\n );\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Ensures the correct background color is used\r\n fxaaPostProcess.autoClear = true;\r\n\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture,\r\n customDumpData\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This size of the screenshot. can be a number or an object implementing IScreenshotSize\r\n * @returns height and width for screenshot size\r\n */\r\nfunction GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
1
+ {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB,EAChB,OAAO,GAAG,KAAK;IAEf,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAElE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,YAAY,KAAK,MAAM,EAAE,CAAC;QAChC,iCAAiC,CAC7B,MAAM,EACN,MAAM,EACN,IAA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,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { _RetryWithInterval } from \"./timingTools\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number,\r\n useFill = false\r\n): void {\r\n const { height, width } = GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n return;\r\n }\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (!renderContext || !renderingCanvas) {\r\n Logger.Error(\"Failed to create screenshot. Rendering context or rendering canvas is not available.\");\r\n return;\r\n }\r\n\r\n const srcWidth = renderingCanvas.width;\r\n const srcHeight = renderingCanvas.height;\r\n const destWidth = screenshotCanvas.width;\r\n const destHeight = screenshotCanvas.height;\r\n\r\n // Calculate scale factors for width and height.\r\n const scaleX = destWidth / srcWidth;\r\n const scaleY = destHeight / srcHeight;\r\n // Use the larger of the two scales to fill the screenshot dimensions, else use the smaller to fit.\r\n const scale = useFill ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);\r\n const newWidth = srcWidth * scale;\r\n const newHeight = srcHeight * scale;\r\n\r\n // Center the image in the screenshot canvas\r\n const offsetX = (destWidth - newWidth) / 2;\r\n const offsetY = (destHeight - newHeight) / 2;\r\n\r\n renderContext.drawImage(renderingCanvas, 0, 0, srcWidth, srcHeight, offsetX, offsetY, newWidth, newHeight);\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<string> {\r\n return await new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport async function CreateScreenshotWithResizeAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n width: number,\r\n height: number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<void> {\r\n return await new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n // Prevent engine to render on screen while we do the screenshot\r\n engine.skipFrameRender = true;\r\n\r\n const originalGetRenderWidth = engine.getRenderWidth;\r\n const originalGetRenderHeight = engine.getRenderHeight;\r\n\r\n // Override getRenderWidth and getRenderHeight to return the desired size of the render\r\n // A few internal methods are relying on the canvas size to compute the render size\r\n // so we need to override these methods to ensure the correct size is used during the preparation of the render\r\n // as well as the screenshot\r\n engine.getRenderWidth = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.width;\r\n }\r\n\r\n return width;\r\n };\r\n engine.getRenderHeight = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.height;\r\n }\r\n\r\n return height;\r\n };\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const dumpDataFunc = customDumpData || DumpData;\r\n\r\n const renderWhenReady = () => {\r\n _RetryWithInterval(\r\n () => texture.isReadyForRendering() && camera.isReady(true),\r\n () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n dumpDataFunc(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n importPromise.then(\r\n async () =>\r\n // eslint-disable-next-line github/no-then\r\n await ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n dumpDataFunc(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n // Record the original scene setup\r\n const originalCamera = scene.activeCamera;\r\n const originalCameras = scene.activeCameras;\r\n const originalOutputRenderTarget = camera.outputRenderTarget;\r\n const originalSpritesEnabled = scene.spritesEnabled;\r\n\r\n // Swap with the requested one\r\n scene.activeCamera = camera;\r\n scene.activeCameras = null;\r\n camera.outputRenderTarget = texture;\r\n scene.spritesEnabled = renderSprites;\r\n\r\n const currentMeshList = scene.meshes;\r\n scene.meshes = texture.renderList || scene.meshes;\r\n\r\n // render the scene on the RTT\r\n try {\r\n scene.render();\r\n } finally {\r\n // Restore the original scene camera setup\r\n scene.activeCamera = originalCamera;\r\n scene.activeCameras = originalCameras;\r\n camera.outputRenderTarget = originalOutputRenderTarget;\r\n scene.spritesEnabled = originalSpritesEnabled;\r\n scene.meshes = currentMeshList;\r\n\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n\r\n engine.skipFrameRender = false;\r\n }\r\n },\r\n () => {\r\n // Restore engine frame rendering on error\r\n engine.skipFrameRender = false;\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n }\r\n );\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Ensures the correct background color is used\r\n fxaaPostProcess.autoClear = true;\r\n\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): Promise<string> {\r\n return await new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture,\r\n customDumpData\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This size of the screenshot. can be a number or an object implementing IScreenshotSize\r\n * @returns height and width for screenshot size\r\n */\r\nfunction GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
@@ -61,6 +61,7 @@ export function CreateResizedCopy(texture, width, height, useBilinearMode = true
61
61
  * @param height height of the output texture. If not provided, use the one from internalTexture
62
62
  * @returns a promise with the internalTexture having its texture replaced by the result of the processing
63
63
  */
64
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
64
65
  export function ApplyPostProcess(postProcessName, internalTexture, scene, type, samplingMode, format, width, height) {
65
66
  // Gets everything ready.
66
67
  const engine = internalTexture.getEngine();
@@ -264,6 +265,7 @@ export async function GetTextureDataAsync(texture, width, height, face = 0, lod
264
265
  if (!texture.isReady() && texture._texture) {
265
266
  await new Promise((resolve, reject) => {
266
267
  if (texture._texture === null) {
268
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
267
269
  reject(0);
268
270
  return;
269
271
  }
@@ -1 +1 @@
1
- {"version":3,"file":"textureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/textureTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,KAAa,EAAE,MAAc,EAAE,kBAA2B,IAAI;IAC9G,MAAM,KAAK,GAAU,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAEjC,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAC/B,SAAS,GAAG,OAAO,CAAC,IAAI,EACxB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAChC,KAAK,EACL,CAAC,OAAO,CAAC,QAAQ,EACjB,IAAI,EACc,OAAO,CAAC,QAAS,CAAC,IAAI,EACxC,KAAK,EACL,OAAO,CAAC,YAAY,E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C;IAC5H,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClC,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC5B,MAAM,CAAC,CAAC,CAAC,CAAC;gBACV,OAAO;YACX,CAAC;YACD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC7C,OAAO,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,MAAM,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB;;;;;;;OAOG;IACH,iBAAiB;IAEjB;;;;;;;;;OASG;IACH,gBAAgB;IAChB;;;;OAIG;IACH,WAAW;IAEX;;;;OAIG;IACH,aAAa;IAEb;;;;;;;;;;OAUG;IACH,mBAAmB;CACtB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { PassPostProcess } from \"../PostProcesses/passPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Scene } from \"../scene\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport { ShaderLanguage } from \"core/Materials\";\r\n\r\n/**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\nexport function CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode: boolean = true): Texture {\r\n const scene = <Scene>texture.getScene();\r\n const engine = scene.getEngine();\r\n\r\n const rtt = new RenderTargetTexture(\r\n \"resized\" + texture.name,\r\n { width: width, height: height },\r\n scene,\r\n !texture.noMipmap,\r\n true,\r\n (<InternalTexture>texture._texture).type,\r\n false,\r\n texture.samplingMode,\r\n false\r\n );\r\n\r\n rtt.wrapU = texture.wrapU;\r\n rtt.wrapV = texture.wrapV;\r\n rtt.uOffset = texture.uOffset;\r\n rtt.vOffset = texture.vOffset;\r\n rtt.uScale = texture.uScale;\r\n rtt.vScale = texture.vScale;\r\n rtt.uAng = texture.uAng;\r\n rtt.vAng = texture.vAng;\r\n rtt.wAng = texture.wAng;\r\n rtt.coordinatesIndex = texture.coordinatesIndex;\r\n rtt.level = texture.level;\r\n rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;\r\n (<InternalTexture>rtt._texture).isReady = false;\r\n\r\n texture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n texture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n const passPostProcess = new PassPostProcess(\r\n \"pass\",\r\n 1,\r\n null,\r\n useBilinearMode ? Texture.BILINEAR_SAMPLINGMODE : Texture.NEAREST_SAMPLINGMODE,\r\n engine,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n passPostProcess.externalTextureSamplerBinding = true;\r\n passPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n e.executeWhenCompiled(() => {\r\n passPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n };\r\n\r\n const internalTexture = rtt.renderTarget;\r\n\r\n if (internalTexture) {\r\n scene.postProcessManager.directRender([passPostProcess], internalTexture);\r\n\r\n engine.unBindFramebuffer(internalTexture);\r\n rtt.disposeFramebufferObjects();\r\n passPostProcess.dispose();\r\n\r\n rtt.getInternalTexture()!.isReady = true;\r\n }\r\n });\r\n });\r\n\r\n return rtt;\r\n}\r\n\r\n/**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @param width width of the output texture. If not provided, use the one from internalTexture\r\n * @param height height of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\nexport function ApplyPostProcess(\r\n postProcessName: string,\r\n internalTexture: InternalTexture,\r\n scene: Scene,\r\n type?: number,\r\n samplingMode?: number,\r\n format?: number,\r\n width?: number,\r\n height?: number\r\n): Promise<InternalTexture> {\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine();\r\n\r\n internalTexture.isReady = false;\r\n\r\n samplingMode = samplingMode ?? internalTexture.samplingMode;\r\n type = type ?? internalTexture.type;\r\n format = format ?? internalTexture.format;\r\n width = width ?? internalTexture.width;\r\n height = height ?? internalTexture.height;\r\n\r\n if (type === -1) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n // Create the post process\r\n const postProcess = new PostProcess(\"postprocess\", postProcessName, null, null, 1, null, samplingMode, engine, false, undefined, type, undefined, null, false, format);\r\n postProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const encodedTexture = engine.createRenderTargetTexture(\r\n { width: width, height: height },\r\n {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode,\r\n type,\r\n format,\r\n }\r\n );\r\n\r\n postProcess.onEffectCreatedObservable.addOnce((e) => {\r\n e.executeWhenCompiled(() => {\r\n // PP Render Pass\r\n postProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n scene.postProcessManager.directRender([postProcess], encodedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (postProcess) {\r\n postProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n encodedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.type = type!;\r\n internalTexture.format = Constants.TEXTUREFORMAT_RGBA;\r\n internalTexture.isReady = true;\r\n\r\n resolve(internalTexture);\r\n });\r\n });\r\n });\r\n}\r\n\r\n// ref: http://stackoverflow.com/questions/32633585/how-do-you-convert-to-half-floats-in-javascript\r\nlet floatView: Float32Array;\r\nlet int32View: Int32Array;\r\n/**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\nexport function ToHalfFloat(value: number): number {\r\n if (!floatView) {\r\n floatView = new Float32Array(1);\r\n int32View = new Int32Array(floatView.buffer);\r\n }\r\n\r\n floatView[0] = value;\r\n const x = int32View[0];\r\n\r\n let bits = (x >> 16) & 0x8000; /* Get the sign */\r\n let m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */\r\n const e = (x >> 23) & 0xff; /* Using int is faster here */\r\n\r\n /* If zero, or denormal, or exponent underflows too much for a denormal\r\n * half, return signed zero. */\r\n if (e < 103) {\r\n return bits;\r\n }\r\n\r\n /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */\r\n if (e > 142) {\r\n bits |= 0x7c00;\r\n /* If exponent was 0xff and one mantissa bit was set, it means NaN,\r\n * not Inf, so make sure we set one mantissa bit too. */\r\n bits |= (e == 255 ? 0 : 1) && x & 0x007fffff;\r\n return bits;\r\n }\r\n\r\n /* If exponent underflows but not too much, return a denormal */\r\n if (e < 113) {\r\n m |= 0x0800;\r\n /* Extra rounding may overflow and set mantissa to 0 and exponent\r\n * to 1, which is OK. */\r\n bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);\r\n return bits;\r\n }\r\n\r\n bits |= ((e - 112) << 10) | (m >> 1);\r\n bits += m & 1;\r\n return bits;\r\n}\r\n\r\n/**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\nexport function FromHalfFloat(value: number): number {\r\n const s = (value & 0x8000) >> 15;\r\n const e = (value & 0x7c00) >> 10;\r\n const f = value & 0x03ff;\r\n\r\n if (e === 0) {\r\n return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));\r\n } else if (e == 0x1f) {\r\n return f ? NaN : (s ? -1 : 1) * Infinity;\r\n }\r\n\r\n return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + f / Math.pow(2, 10));\r\n}\r\n\r\nconst ProcessAsync = async (texture: BaseTexture, width: number, height: number, face: number, lod: number): Promise<Uint8Array> => {\r\n const scene = texture.getScene()!;\r\n const engine = scene.getEngine();\r\n\r\n if (!engine.isWebGPU) {\r\n if (texture.isCube) {\r\n await import(\"../Shaders/lodCube.fragment\");\r\n } else {\r\n await import(\"../Shaders/lod.fragment\");\r\n }\r\n } else {\r\n if (texture.isCube) {\r\n await import(\"../ShadersWGSL/lodCube.fragment\");\r\n } else {\r\n await import(\"../ShadersWGSL/lod.fragment\");\r\n }\r\n }\r\n\r\n let lodPostProcess: PostProcess;\r\n\r\n if (!texture.isCube) {\r\n lodPostProcess = new PostProcess(\"lod\", \"lod\", {\r\n uniforms: [\"lod\", \"gamma\"],\r\n samplingMode: Texture.NEAREST_NEAREST_MIPNEAREST,\r\n engine,\r\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n });\r\n } else {\r\n const faceDefines = [\"#define POSITIVEX\", \"#define NEGATIVEX\", \"#define POSITIVEY\", \"#define NEGATIVEY\", \"#define POSITIVEZ\", \"#define NEGATIVEZ\"];\r\n lodPostProcess = new PostProcess(\"lodCube\", \"lodCube\", {\r\n uniforms: [\"lod\", \"gamma\"],\r\n samplingMode: Texture.NEAREST_NEAREST_MIPNEAREST,\r\n engine,\r\n defines: faceDefines[face],\r\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n });\r\n }\r\n\r\n await new Promise((resolve) => {\r\n lodPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n e.executeWhenCompiled(() => {\r\n resolve(0);\r\n });\r\n });\r\n });\r\n\r\n const rtt = new RenderTargetTexture(\"temp\", { width: width, height: height }, scene, false);\r\n\r\n lodPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n effect.setFloat(\"lod\", lod);\r\n effect.setInt(\"gamma\", texture.gammaSpace ? 1 : 0);\r\n };\r\n\r\n const internalTexture = texture.getInternalTexture();\r\n\r\n try {\r\n if (rtt.renderTarget && internalTexture) {\r\n const samplingMode = internalTexture.samplingMode;\r\n if (lod !== 0) {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST_MIPNEAREST);\r\n } else {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST);\r\n }\r\n\r\n scene.postProcessManager.directRender([lodPostProcess], rtt.renderTarget, true);\r\n texture.updateSamplingMode(samplingMode);\r\n\r\n //Reading datas from WebGL\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n const data = new Uint8Array(bufferView.buffer, 0, bufferView.byteLength);\r\n\r\n // Unbind\r\n engine.unBindFramebuffer(rtt.renderTarget);\r\n\r\n return data;\r\n } else {\r\n throw Error(\"Render to texture failed.\");\r\n }\r\n } finally {\r\n rtt.dispose();\r\n lodPostProcess.dispose();\r\n }\r\n};\r\n\r\n/**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\nexport async function GetTextureDataAsync(texture: BaseTexture, width: number, height: number, face: number = 0, lod: number = 0): Promise<Uint8Array> {\r\n if (!texture.isReady() && texture._texture) {\r\n await new Promise((resolve, reject) => {\r\n if (texture._texture === null) {\r\n reject(0);\r\n return;\r\n }\r\n texture._texture.onLoadedObservable.addOnce(() => {\r\n resolve(0);\r\n });\r\n });\r\n }\r\n return await ProcessAsync(texture, width, height, face, lod);\r\n}\r\n\r\n/**\r\n * Class used to host texture specific utilities\r\n */\r\nexport const TextureTools = {\r\n /**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\n CreateResizedCopy,\r\n\r\n /**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n ApplyPostProcess,\r\n /**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\n ToHalfFloat,\r\n\r\n /**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\n FromHalfFloat,\r\n\r\n /**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param channels a filter for which of the RGBA channels to return in the result\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\n GetTextureDataAsync,\r\n};\r\n"]}
1
+ {"version":3,"file":"textureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/textureTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,KAAa,EAAE,MAAc,EAAE,kBAA2B,IAAI;IAC9G,MAAM,KAAK,GAAU,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAEjC,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAC/B,SAAS,GAAG,OAAO,CAAC,IAAI,EACxB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAChC,KAAK,EACL,CAAC,OAAO,CAAC,QAAQ,EACjB,IAAI,EACc,OAAO,CAAC,QAAS,CAAC,IAAI,EACxC,KAAK,EACL,OAAO,CAAC,YAAY,EACpB,KAAK,CACR,CAAC;IAEF,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAC9B,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAC9B,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC5B,GAAG,CAAC,MAAM,GAAG,OAAO,CA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AAC,OAAO,CAAC,GAAG,EAAE;gBAC7C,OAAO,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,MAAM,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB;;;;;;;OAOG;IACH,iBAAiB;IAEjB;;;;;;;;;OASG;IACH,gBAAgB;IAChB;;;;OAIG;IACH,WAAW;IAEX;;;;OAIG;IACH,aAAa;IAEb;;;;;;;;;;OAUG;IACH,mBAAmB;CACtB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { PassPostProcess } from \"../PostProcesses/passPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Scene } from \"../scene\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport { ShaderLanguage } from \"core/Materials\";\r\n\r\n/**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\nexport function CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode: boolean = true): Texture {\r\n const scene = <Scene>texture.getScene();\r\n const engine = scene.getEngine();\r\n\r\n const rtt = new RenderTargetTexture(\r\n \"resized\" + texture.name,\r\n { width: width, height: height },\r\n scene,\r\n !texture.noMipmap,\r\n true,\r\n (<InternalTexture>texture._texture).type,\r\n false,\r\n texture.samplingMode,\r\n false\r\n );\r\n\r\n rtt.wrapU = texture.wrapU;\r\n rtt.wrapV = texture.wrapV;\r\n rtt.uOffset = texture.uOffset;\r\n rtt.vOffset = texture.vOffset;\r\n rtt.uScale = texture.uScale;\r\n rtt.vScale = texture.vScale;\r\n rtt.uAng = texture.uAng;\r\n rtt.vAng = texture.vAng;\r\n rtt.wAng = texture.wAng;\r\n rtt.coordinatesIndex = texture.coordinatesIndex;\r\n rtt.level = texture.level;\r\n rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;\r\n (<InternalTexture>rtt._texture).isReady = false;\r\n\r\n texture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n texture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n const passPostProcess = new PassPostProcess(\r\n \"pass\",\r\n 1,\r\n null,\r\n useBilinearMode ? Texture.BILINEAR_SAMPLINGMODE : Texture.NEAREST_SAMPLINGMODE,\r\n engine,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n passPostProcess.externalTextureSamplerBinding = true;\r\n passPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n e.executeWhenCompiled(() => {\r\n passPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n };\r\n\r\n const internalTexture = rtt.renderTarget;\r\n\r\n if (internalTexture) {\r\n scene.postProcessManager.directRender([passPostProcess], internalTexture);\r\n\r\n engine.unBindFramebuffer(internalTexture);\r\n rtt.disposeFramebufferObjects();\r\n passPostProcess.dispose();\r\n\r\n rtt.getInternalTexture()!.isReady = true;\r\n }\r\n });\r\n });\r\n\r\n return rtt;\r\n}\r\n\r\n/**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @param width width of the output texture. If not provided, use the one from internalTexture\r\n * @param height height of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async\r\nexport function ApplyPostProcess(\r\n postProcessName: string,\r\n internalTexture: InternalTexture,\r\n scene: Scene,\r\n type?: number,\r\n samplingMode?: number,\r\n format?: number,\r\n width?: number,\r\n height?: number\r\n): Promise<InternalTexture> {\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine();\r\n\r\n internalTexture.isReady = false;\r\n\r\n samplingMode = samplingMode ?? internalTexture.samplingMode;\r\n type = type ?? internalTexture.type;\r\n format = format ?? internalTexture.format;\r\n width = width ?? internalTexture.width;\r\n height = height ?? internalTexture.height;\r\n\r\n if (type === -1) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n // Create the post process\r\n const postProcess = new PostProcess(\"postprocess\", postProcessName, null, null, 1, null, samplingMode, engine, false, undefined, type, undefined, null, false, format);\r\n postProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const encodedTexture = engine.createRenderTargetTexture(\r\n { width: width, height: height },\r\n {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode,\r\n type,\r\n format,\r\n }\r\n );\r\n\r\n postProcess.onEffectCreatedObservable.addOnce((e) => {\r\n e.executeWhenCompiled(() => {\r\n // PP Render Pass\r\n postProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n scene.postProcessManager.directRender([postProcess], encodedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (postProcess) {\r\n postProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n encodedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.type = type!;\r\n internalTexture.format = Constants.TEXTUREFORMAT_RGBA;\r\n internalTexture.isReady = true;\r\n\r\n resolve(internalTexture);\r\n });\r\n });\r\n });\r\n}\r\n\r\n// ref: http://stackoverflow.com/questions/32633585/how-do-you-convert-to-half-floats-in-javascript\r\nlet floatView: Float32Array;\r\nlet int32View: Int32Array;\r\n/**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\nexport function ToHalfFloat(value: number): number {\r\n if (!floatView) {\r\n floatView = new Float32Array(1);\r\n int32View = new Int32Array(floatView.buffer);\r\n }\r\n\r\n floatView[0] = value;\r\n const x = int32View[0];\r\n\r\n let bits = (x >> 16) & 0x8000; /* Get the sign */\r\n let m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */\r\n const e = (x >> 23) & 0xff; /* Using int is faster here */\r\n\r\n /* If zero, or denormal, or exponent underflows too much for a denormal\r\n * half, return signed zero. */\r\n if (e < 103) {\r\n return bits;\r\n }\r\n\r\n /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */\r\n if (e > 142) {\r\n bits |= 0x7c00;\r\n /* If exponent was 0xff and one mantissa bit was set, it means NaN,\r\n * not Inf, so make sure we set one mantissa bit too. */\r\n bits |= (e == 255 ? 0 : 1) && x & 0x007fffff;\r\n return bits;\r\n }\r\n\r\n /* If exponent underflows but not too much, return a denormal */\r\n if (e < 113) {\r\n m |= 0x0800;\r\n /* Extra rounding may overflow and set mantissa to 0 and exponent\r\n * to 1, which is OK. */\r\n bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);\r\n return bits;\r\n }\r\n\r\n bits |= ((e - 112) << 10) | (m >> 1);\r\n bits += m & 1;\r\n return bits;\r\n}\r\n\r\n/**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\nexport function FromHalfFloat(value: number): number {\r\n const s = (value & 0x8000) >> 15;\r\n const e = (value & 0x7c00) >> 10;\r\n const f = value & 0x03ff;\r\n\r\n if (e === 0) {\r\n return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));\r\n } else if (e == 0x1f) {\r\n return f ? NaN : (s ? -1 : 1) * Infinity;\r\n }\r\n\r\n return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + f / Math.pow(2, 10));\r\n}\r\n\r\nconst ProcessAsync = async (texture: BaseTexture, width: number, height: number, face: number, lod: number): Promise<Uint8Array> => {\r\n const scene = texture.getScene()!;\r\n const engine = scene.getEngine();\r\n\r\n if (!engine.isWebGPU) {\r\n if (texture.isCube) {\r\n await import(\"../Shaders/lodCube.fragment\");\r\n } else {\r\n await import(\"../Shaders/lod.fragment\");\r\n }\r\n } else {\r\n if (texture.isCube) {\r\n await import(\"../ShadersWGSL/lodCube.fragment\");\r\n } else {\r\n await import(\"../ShadersWGSL/lod.fragment\");\r\n }\r\n }\r\n\r\n let lodPostProcess: PostProcess;\r\n\r\n if (!texture.isCube) {\r\n lodPostProcess = new PostProcess(\"lod\", \"lod\", {\r\n uniforms: [\"lod\", \"gamma\"],\r\n samplingMode: Texture.NEAREST_NEAREST_MIPNEAREST,\r\n engine,\r\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n });\r\n } else {\r\n const faceDefines = [\"#define POSITIVEX\", \"#define NEGATIVEX\", \"#define POSITIVEY\", \"#define NEGATIVEY\", \"#define POSITIVEZ\", \"#define NEGATIVEZ\"];\r\n lodPostProcess = new PostProcess(\"lodCube\", \"lodCube\", {\r\n uniforms: [\"lod\", \"gamma\"],\r\n samplingMode: Texture.NEAREST_NEAREST_MIPNEAREST,\r\n engine,\r\n defines: faceDefines[face],\r\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n });\r\n }\r\n\r\n await new Promise((resolve) => {\r\n lodPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n e.executeWhenCompiled(() => {\r\n resolve(0);\r\n });\r\n });\r\n });\r\n\r\n const rtt = new RenderTargetTexture(\"temp\", { width: width, height: height }, scene, false);\r\n\r\n lodPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n effect.setFloat(\"lod\", lod);\r\n effect.setInt(\"gamma\", texture.gammaSpace ? 1 : 0);\r\n };\r\n\r\n const internalTexture = texture.getInternalTexture();\r\n\r\n try {\r\n if (rtt.renderTarget && internalTexture) {\r\n const samplingMode = internalTexture.samplingMode;\r\n if (lod !== 0) {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST_MIPNEAREST);\r\n } else {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST);\r\n }\r\n\r\n scene.postProcessManager.directRender([lodPostProcess], rtt.renderTarget, true);\r\n texture.updateSamplingMode(samplingMode);\r\n\r\n //Reading datas from WebGL\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n const data = new Uint8Array(bufferView.buffer, 0, bufferView.byteLength);\r\n\r\n // Unbind\r\n engine.unBindFramebuffer(rtt.renderTarget);\r\n\r\n return data;\r\n } else {\r\n throw Error(\"Render to texture failed.\");\r\n }\r\n } finally {\r\n rtt.dispose();\r\n lodPostProcess.dispose();\r\n }\r\n};\r\n\r\n/**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\nexport async function GetTextureDataAsync(texture: BaseTexture, width: number, height: number, face: number = 0, lod: number = 0): Promise<Uint8Array> {\r\n if (!texture.isReady() && texture._texture) {\r\n await new Promise((resolve, reject) => {\r\n if (texture._texture === null) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(0);\r\n return;\r\n }\r\n texture._texture.onLoadedObservable.addOnce(() => {\r\n resolve(0);\r\n });\r\n });\r\n }\r\n return await ProcessAsync(texture, width, height, face, lod);\r\n}\r\n\r\n/**\r\n * Class used to host texture specific utilities\r\n */\r\nexport const TextureTools = {\r\n /**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\n CreateResizedCopy,\r\n\r\n /**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n ApplyPostProcess,\r\n /**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\n ToHalfFloat,\r\n\r\n /**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\n FromHalfFloat,\r\n\r\n /**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param channels a filter for which of the RGBA channels to return in the result\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\n GetTextureDataAsync,\r\n};\r\n"]}
@@ -15,7 +15,7 @@ let UniqueResolveID = 0;
15
15
  * @internal DO NOT USE outside of Babylon.js core
16
16
  */
17
17
  export async function _LoadScriptModuleAsync(scriptUrl, scriptId) {
18
- return new Promise((resolve, reject) => {
18
+ return await new Promise((resolve, reject) => {
19
19
  // Need a relay
20
20
  let windowAsAny;
21
21
  let windowString;
@@ -41,6 +41,7 @@ export async function _LoadScriptModuleAsync(scriptUrl, scriptId) {
41
41
  `;
42
42
  UniqueResolveID++;
43
43
  Tools.LoadScript(scriptUrl, undefined, (message, exception) => {
44
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
44
45
  reject(exception || new Error(message));
45
46
  }, scriptId, true);
46
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"tools.internals.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/tools.internals.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,SAAiB,EAAE,QAAiB;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,eAAe;QACf,IAAI,WAAgB,CAAC;QACrB,IAAI,YAAoB,CAAC;QAEzB,IAAI,mBAAmB,EAAE,EAAE,CAAC;YACxB,WAAW,GAAG,MAAM,CAAC;YACrB,YAAY,GAAG,QAAQ,CAAC;QAC5B,CAAC;aAAM,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;YACrC,WAAW,GAAG,IAAI,CAAC;YACnB,YAAY,GAAG,MAAM,CAAC;QAC1B,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC,CAAC;YAC/E,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,wBAAwB,EAAE,CAAC;YACxC,WAAW,CAAC,wBAAwB,GAAG,EAAE,CAAC;QAC9C,CAAC;QACD,WAAW,CAAC,wBAAwB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC;QAEhE,SAAS,IAAI;cACP,YAAY,6BAA6B,eAAe;cACxD,YAAY,6BAA6B,eAAe;SAC7D,CAAC;QACF,eAAe,EAAE,CAAC;QAElB,KAAK,CAAC,UAAU,CACZ,SAAS,EACT,SAAS,EACT,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;YACnB,MAAM,CAAC,SAAS,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,CAAC,EACD,QAAQ,EACR,IAAI,CACP,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * This file is only for internal use only and should not be used in your code\r\n */\r\n\r\nimport { IsWindowObjectExist } from \"./domManagement\";\r\nimport { Tools } from \"./tools\";\r\n\r\nlet UniqueResolveID = 0;\r\n\r\n/**\r\n * Load an asynchronous script (identified by an url) in a module way. When the url returns, the\r\n * content of this file is added into a new script element, attached to the DOM (body element)\r\n * @param scriptUrl defines the url of the script to load\r\n * @param scriptId defines the id of the script element\r\n * @returns a promise request object\r\n * It is up to the caller to provide a script that will do the import and prepare a \"returnedValue\" variable\r\n * @internal DO NOT USE outside of Babylon.js core\r\n */\r\nexport async function _LoadScriptModuleAsync(scriptUrl: string, scriptId?: string): Promise<any> {\r\n return new Promise((resolve, reject) => {\r\n // Need a relay\r\n let windowAsAny: any;\r\n let windowString: string;\r\n\r\n if (IsWindowObjectExist()) {\r\n windowAsAny = window;\r\n windowString = \"window\";\r\n } else if (typeof self !== \"undefined\") {\r\n windowAsAny = self;\r\n windowString = \"self\";\r\n } else {\r\n reject(new Error(\"Cannot load script module outside of a window or a worker\"));\r\n return;\r\n }\r\n\r\n if (!windowAsAny._LoadScriptModuleResolve) {\r\n windowAsAny._LoadScriptModuleResolve = {};\r\n }\r\n windowAsAny._LoadScriptModuleResolve[UniqueResolveID] = resolve;\r\n\r\n scriptUrl += `\r\n ${windowString}._LoadScriptModuleResolve[${UniqueResolveID}](returnedValue);\r\n ${windowString}._LoadScriptModuleResolve[${UniqueResolveID}] = undefined;\r\n `;\r\n UniqueResolveID++;\r\n\r\n Tools.LoadScript(\r\n scriptUrl,\r\n undefined,\r\n (message, exception) => {\r\n reject(exception || new Error(message));\r\n },\r\n scriptId,\r\n true\r\n );\r\n });\r\n}\r\n"]}
1
+ {"version":3,"file":"tools.internals.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/tools.internals.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,SAAiB,EAAE,QAAiB;IAC7E,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACzC,eAAe;QACf,IAAI,WAAgB,CAAC;QACrB,IAAI,YAAoB,CAAC;QAEzB,IAAI,mBAAmB,EAAE,EAAE,CAAC;YACxB,WAAW,GAAG,MAAM,CAAC;YACrB,YAAY,GAAG,QAAQ,CAAC;QAC5B,CAAC;aAAM,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;YACrC,WAAW,GAAG,IAAI,CAAC;YACnB,YAAY,GAAG,MAAM,CAAC;QAC1B,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC,CAAC;YAC/E,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,wBAAwB,EAAE,CAAC;YACxC,WAAW,CAAC,wBAAwB,GAAG,EAAE,CAAC;QAC9C,CAAC;QACD,WAAW,CAAC,wBAAwB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC;QAEhE,SAAS,IAAI;cACP,YAAY,6BAA6B,eAAe;cACxD,YAAY,6BAA6B,eAAe;SAC7D,CAAC;QACF,eAAe,EAAE,CAAC;QAElB,KAAK,CAAC,UAAU,CACZ,SAAS,EACT,SAAS,EACT,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;YACnB,2EAA2E;YAC3E,MAAM,CAAC,SAAS,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,CAAC,EACD,QAAQ,EACR,IAAI,CACP,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * This file is only for internal use only and should not be used in your code\r\n */\r\n\r\nimport { IsWindowObjectExist } from \"./domManagement\";\r\nimport { Tools } from \"./tools\";\r\n\r\nlet UniqueResolveID = 0;\r\n\r\n/**\r\n * Load an asynchronous script (identified by an url) in a module way. When the url returns, the\r\n * content of this file is added into a new script element, attached to the DOM (body element)\r\n * @param scriptUrl defines the url of the script to load\r\n * @param scriptId defines the id of the script element\r\n * @returns a promise request object\r\n * It is up to the caller to provide a script that will do the import and prepare a \"returnedValue\" variable\r\n * @internal DO NOT USE outside of Babylon.js core\r\n */\r\nexport async function _LoadScriptModuleAsync(scriptUrl: string, scriptId?: string): Promise<any> {\r\n return await new Promise((resolve, reject) => {\r\n // Need a relay\r\n let windowAsAny: any;\r\n let windowString: string;\r\n\r\n if (IsWindowObjectExist()) {\r\n windowAsAny = window;\r\n windowString = \"window\";\r\n } else if (typeof self !== \"undefined\") {\r\n windowAsAny = self;\r\n windowString = \"self\";\r\n } else {\r\n reject(new Error(\"Cannot load script module outside of a window or a worker\"));\r\n return;\r\n }\r\n\r\n if (!windowAsAny._LoadScriptModuleResolve) {\r\n windowAsAny._LoadScriptModuleResolve = {};\r\n }\r\n windowAsAny._LoadScriptModuleResolve[UniqueResolveID] = resolve;\r\n\r\n scriptUrl += `\r\n ${windowString}._LoadScriptModuleResolve[${UniqueResolveID}](returnedValue);\r\n ${windowString}._LoadScriptModuleResolve[${UniqueResolveID}] = undefined;\r\n `;\r\n UniqueResolveID++;\r\n\r\n Tools.LoadScript(\r\n scriptUrl,\r\n undefined,\r\n (message, exception) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(exception || new Error(message));\r\n },\r\n scriptId,\r\n true\r\n );\r\n });\r\n}\r\n"]}
package/Misc/tools.js CHANGED
@@ -350,10 +350,11 @@ export class Tools {
350
350
  * @returns a promise containing an ArrayBuffer corresponding to the loaded file
351
351
  */
352
352
  static async LoadFileAsync(url, useArrayBuffer = true) {
353
- return new Promise((resolve, reject) => {
353
+ return await new Promise((resolve, reject) => {
354
354
  FileToolsLoadFile(url, (data) => {
355
355
  resolve(data);
356
356
  }, undefined, undefined, useArrayBuffer, (request, exception) => {
357
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
357
358
  reject(exception);
358
359
  });
359
360
  });
@@ -419,7 +420,7 @@ export class Tools {
419
420
  */
420
421
  static async LoadBabylonScriptAsync(scriptUrl) {
421
422
  scriptUrl = Tools.GetBabylonScriptURL(scriptUrl);
422
- return Tools.LoadScriptAsync(scriptUrl);
423
+ return await Tools.LoadScriptAsync(scriptUrl);
423
424
  }
424
425
  /**
425
426
  * This function is used internally by babylon components to load a script (identified by an url). When the url returns, the
@@ -480,10 +481,11 @@ export class Tools {
480
481
  * @returns a promise request object
481
482
  */
482
483
  static async LoadScriptAsync(scriptUrl, scriptId) {
483
- return new Promise((resolve, reject) => {
484
+ return await new Promise((resolve, reject) => {
484
485
  this.LoadScript(scriptUrl, () => {
485
486
  resolve();
486
487
  }, (message, exception) => {
488
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
487
489
  reject(exception || new Error(message));
488
490
  }, scriptId);
489
491
  });
@@ -679,11 +681,13 @@ export class Tools {
679
681
  };
680
682
  }
681
683
  if (Tools._IsOffScreenCanvas(canvas)) {
684
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
682
685
  canvas
683
686
  .convertToBlob({
684
687
  type: mimeType,
685
688
  quality,
686
689
  })
690
+ // eslint-disable-next-line github/no-then
687
691
  .then((blob) => successCallback(blob));
688
692
  }
689
693
  else {
@@ -745,11 +749,13 @@ export class Tools {
745
749
  }
746
750
  else if (successCallback) {
747
751
  if (Tools._IsOffScreenCanvas(canvas)) {
752
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
748
753
  canvas
749
754
  .convertToBlob({
750
755
  type: mimeType,
751
756
  quality,
752
757
  })
758
+ // eslint-disable-next-line github/no-then
753
759
  .then((blob) => {
754
760
  const reader = new FileReader();
755
761
  reader.readAsDataURL(blob);