@babylonjs/core 6.33.2 → 6.34.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/Animations/animation.js +1 -1
  2. package/Animations/animation.js.map +1 -1
  3. package/Buffers/storageBuffer.d.ts +2 -1
  4. package/Buffers/storageBuffer.js +3 -2
  5. package/Buffers/storageBuffer.js.map +1 -1
  6. package/Cameras/Inputs/followCameraMouseWheelInput.js +12 -9
  7. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  8. package/Cameras/Inputs/followCameraPointersInput.js +28 -9
  9. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  10. package/Cameras/arcRotateCamera.js +1 -1
  11. package/Cameras/arcRotateCamera.js.map +1 -1
  12. package/Cameras/followCameraInputsManager.js +2 -1
  13. package/Cameras/followCameraInputsManager.js.map +1 -1
  14. package/Debug/skeletonViewer.js +2 -1
  15. package/Debug/skeletonViewer.js.map +1 -1
  16. package/Engines/Extensions/engine.alpha.js +8 -116
  17. package/Engines/Extensions/engine.alpha.js.map +1 -1
  18. package/Engines/Extensions/engine.cubeTexture.d.ts +1 -1
  19. package/Engines/Extensions/engine.cubeTexture.js +11 -213
  20. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  21. package/Engines/Extensions/engine.dynamicBuffer.js +5 -42
  22. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  23. package/Engines/Extensions/engine.dynamicTexture.d.ts +1 -1
  24. package/Engines/Extensions/engine.dynamicTexture.js +5 -47
  25. package/Engines/Extensions/engine.dynamicTexture.js.map +1 -1
  26. package/Engines/Extensions/engine.multiRender.js +11 -341
  27. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  28. package/Engines/Extensions/engine.multiview.js +6 -57
  29. package/Engines/Extensions/engine.multiview.js.map +1 -1
  30. package/Engines/Extensions/engine.query.d.ts +8 -2
  31. package/Engines/Extensions/engine.query.js +44 -152
  32. package/Engines/Extensions/engine.query.js.map +1 -1
  33. package/Engines/Extensions/engine.rawTexture.d.ts +1 -1
  34. package/Engines/Extensions/engine.rawTexture.js +20 -361
  35. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  36. package/Engines/Extensions/engine.readTexture.js +6 -112
  37. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  38. package/Engines/Extensions/engine.renderTarget.d.ts +1 -1
  39. package/Engines/Extensions/engine.renderTarget.js +8 -173
  40. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  41. package/Engines/Extensions/engine.renderTargetCube.js +4 -55
  42. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  43. package/Engines/Extensions/engine.storageBuffer.d.ts +2 -1
  44. package/Engines/Extensions/engine.storageBuffer.js.map +1 -1
  45. package/Engines/Extensions/engine.textureSelector.js +11 -52
  46. package/Engines/Extensions/engine.textureSelector.js.map +1 -1
  47. package/Engines/Extensions/engine.transformFeedback.js +10 -11
  48. package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
  49. package/Engines/Extensions/engine.uniformBuffer.js +9 -59
  50. package/Engines/Extensions/engine.uniformBuffer.js.map +1 -1
  51. package/Engines/Extensions/engine.videoTexture.js +4 -54
  52. package/Engines/Extensions/engine.videoTexture.js.map +1 -1
  53. package/Engines/Extensions/engine.views.d.ts +2 -24
  54. package/Engines/Extensions/engine.views.js +17 -136
  55. package/Engines/Extensions/engine.views.js.map +1 -1
  56. package/Engines/Processors/shaderCodeInliner.js +15 -14
  57. package/Engines/Processors/shaderCodeInliner.js.map +1 -1
  58. package/Engines/WebGPU/Extensions/engine.computeShader.js +3 -2
  59. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  60. package/Engines/WebGPU/Extensions/engine.storageBuffer.js +14 -5
  61. package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
  62. package/Engines/WebGPU/webgpuShaderProcessor.js +2 -1
  63. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  64. package/Engines/WebGPU/webgpuTintWASM.js +3 -2
  65. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  66. package/Engines/engine.d.ts +15 -64
  67. package/Engines/engine.js +322 -773
  68. package/Engines/engine.js.map +1 -1
  69. package/Engines/nativeEngine.d.ts +1 -1
  70. package/Engines/nativeEngine.js.map +1 -1
  71. package/Engines/nullEngine.d.ts +1 -1
  72. package/Engines/nullEngine.js.map +1 -1
  73. package/Engines/thinEngine.d.ts +160 -151
  74. package/Engines/thinEngine.js +712 -3281
  75. package/Engines/thinEngine.js.map +1 -1
  76. package/Engines/webgpuEngine.d.ts +5 -8
  77. package/Engines/webgpuEngine.js +143 -112
  78. package/Engines/webgpuEngine.js.map +1 -1
  79. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +2 -1
  80. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
  81. package/FlowGraph/flowGraphBlock.js +1 -21
  82. package/FlowGraph/flowGraphBlock.js.map +1 -1
  83. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -0
  84. package/FlowGraph/flowGraphExecutionBlock.js +20 -0
  85. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  86. package/Gizmos/axisScaleGizmo.d.ts +1 -0
  87. package/Gizmos/axisScaleGizmo.js +12 -0
  88. package/Gizmos/axisScaleGizmo.js.map +1 -1
  89. package/Gizmos/lightGizmo.js +2 -1
  90. package/Gizmos/lightGizmo.js.map +1 -1
  91. package/Gizmos/rotationGizmo.js +1 -1
  92. package/Gizmos/rotationGizmo.js.map +1 -1
  93. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  94. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  95. package/Materials/Node/Blocks/Dual/lightBlock.js +2 -1
  96. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  97. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +3 -2
  98. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
  99. package/Materials/Node/Blocks/Fragment/fragDepthBlock.js +2 -1
  100. package/Materials/Node/Blocks/Fragment/fragDepthBlock.js.map +1 -1
  101. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +2 -1
  102. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
  103. package/Materials/Node/Blocks/PBR/anisotropyBlock.js +2 -1
  104. package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
  105. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +3 -2
  106. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  107. package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -1
  108. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  109. package/Materials/Node/nodeMaterial.js +9 -8
  110. package/Materials/Node/nodeMaterial.js.map +1 -1
  111. package/Materials/Node/nodeMaterialBlock.js +2 -1
  112. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  113. package/Materials/drawWrapper.js +3 -2
  114. package/Materials/drawWrapper.js.map +1 -1
  115. package/Materials/effect.js +2 -1
  116. package/Materials/effect.js.map +1 -1
  117. package/Materials/material.js +2 -1
  118. package/Materials/material.js.map +1 -1
  119. package/Materials/uniformBuffer.d.ts +4 -1
  120. package/Materials/uniformBuffer.js +5 -2
  121. package/Materials/uniformBuffer.js.map +1 -1
  122. package/Meshes/Node/nodeGeometryBlock.js +2 -1
  123. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  124. package/Meshes/abstractMesh.js +3 -1
  125. package/Meshes/abstractMesh.js.map +1 -1
  126. package/Misc/assetsManager.js +2 -2
  127. package/Misc/assetsManager.js.map +1 -1
  128. package/Misc/dds.d.ts +2 -0
  129. package/Misc/dds.js +27 -23
  130. package/Misc/dds.js.map +1 -1
  131. package/Misc/logger.d.ts +3 -3
  132. package/Misc/logger.js +8 -4
  133. package/Misc/logger.js.map +1 -1
  134. package/Misc/sceneSerializer.js +2 -1
  135. package/Misc/sceneSerializer.js.map +1 -1
  136. package/Navigation/Plugins/recastJSPlugin.js +2 -2
  137. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  138. package/Physics/v2/Plugins/havokPlugin.js +1 -1
  139. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  140. package/Physics/v2/index.d.ts +1 -0
  141. package/Physics/v2/index.js +1 -0
  142. package/Physics/v2/index.js.map +1 -1
  143. package/Physics/v2/ragdoll.d.ts +107 -0
  144. package/Physics/v2/ragdoll.js +228 -0
  145. package/Physics/v2/ragdoll.js.map +1 -0
  146. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -2
  147. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  148. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +3 -2
  149. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  150. package/PostProcesses/index.d.ts +1 -1
  151. package/PostProcesses/index.js +1 -1
  152. package/PostProcesses/index.js.map +1 -1
  153. package/PostProcesses/passPostProcess.d.ts +1 -0
  154. package/PostProcesses/passPostProcess.js +6 -2
  155. package/PostProcesses/passPostProcess.js.map +1 -1
  156. package/PostProcesses/screenSpaceCurvaturePostProcess.js +1 -1
  157. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  158. package/PostProcesses/screenSpaceReflectionPostProcess.js +3 -2
  159. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  160. package/Rendering/depthPeelingRenderer.js +2 -1
  161. package/Rendering/depthPeelingRenderer.js.map +1 -1
  162. package/Shaders/ShadersInclude/pbrBlockSubSurface.js +3 -2
  163. package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  164. package/XR/features/WebXRControllerPhysics.js +2 -2
  165. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  166. package/XR/features/WebXRMeshDetector.js +2 -1
  167. package/XR/features/WebXRMeshDetector.js.map +1 -1
  168. package/XR/features/WebXRWalkingLocomotion.js +1 -1
  169. package/XR/features/WebXRWalkingLocomotion.js.map +1 -1
  170. package/XR/webXRExperienceHelper.js +2 -2
  171. package/XR/webXRExperienceHelper.js.map +1 -1
  172. package/assetContainer.js +2 -2
  173. package/assetContainer.js.map +1 -1
  174. package/esm/Engines/Extensions/alpha/alpha.base.d.ts +34 -0
  175. package/esm/Engines/Extensions/alpha/alpha.base.js +2 -0
  176. package/esm/Engines/Extensions/alpha/alpha.base.js.map +1 -0
  177. package/esm/Engines/Extensions/computeShaders/computeShaders.base.d.ts +87 -0
  178. package/esm/Engines/Extensions/computeShaders/computeShaders.base.js +12 -0
  179. package/esm/Engines/Extensions/computeShaders/computeShaders.base.js.map +1 -0
  180. package/esm/Engines/Extensions/cubeTexture/cubeTexture.base.d.ts +79 -0
  181. package/esm/Engines/Extensions/cubeTexture/cubeTexture.base.js +2 -0
  182. package/esm/Engines/Extensions/cubeTexture/cubeTexture.base.js.map +1 -0
  183. package/esm/Engines/Extensions/debugging/debugging.base.d.ts +11 -0
  184. package/esm/Engines/Extensions/debugging/debugging.base.js +2 -0
  185. package/esm/Engines/Extensions/debugging/debugging.base.js.map +1 -0
  186. package/esm/Engines/Extensions/dynamicBuffer/dynamicBuffer.base.d.ts +20 -0
  187. package/esm/Engines/Extensions/dynamicBuffer/dynamicBuffer.base.js +2 -0
  188. package/esm/Engines/Extensions/dynamicBuffer/dynamicBuffer.base.js.map +1 -0
  189. package/esm/Engines/Extensions/dynamicTexture/dynamicTexture.base.d.ts +26 -0
  190. package/esm/Engines/Extensions/dynamicTexture/dynamicTexture.base.js +2 -0
  191. package/esm/Engines/Extensions/dynamicTexture/dynamicTexture.base.js.map +1 -0
  192. package/esm/Engines/Extensions/engine.extensions.d.ts +67 -0
  193. package/esm/Engines/Extensions/engine.extensions.js +49 -0
  194. package/esm/Engines/Extensions/engine.extensions.js.map +1 -0
  195. package/esm/Engines/Extensions/externalTexture/externalTexture.base.d.ts +16 -0
  196. package/esm/Engines/Extensions/externalTexture/externalTexture.base.js +2 -0
  197. package/esm/Engines/Extensions/externalTexture/externalTexture.base.js.map +1 -0
  198. package/esm/Engines/Extensions/multiRender/multiRender.base.d.ts +54 -0
  199. package/esm/Engines/Extensions/multiRender/multiRender.base.js +2 -0
  200. package/esm/Engines/Extensions/multiRender/multiRender.base.js.map +1 -0
  201. package/esm/Engines/Extensions/multiview/multiview.base.d.ts +67 -0
  202. package/esm/Engines/Extensions/multiview/multiview.base.js +79 -0
  203. package/esm/Engines/Extensions/multiview/multiview.base.js.map +1 -0
  204. package/esm/Engines/Extensions/query/query.base.d.ts +164 -0
  205. package/esm/Engines/Extensions/query/query.base.js +168 -0
  206. package/esm/Engines/Extensions/query/query.base.js.map +1 -0
  207. package/esm/Engines/Extensions/rawTexture/engine.rawTexture.base.d.ts +187 -0
  208. package/esm/Engines/Extensions/rawTexture/engine.rawTexture.base.js +2 -0
  209. package/esm/Engines/Extensions/rawTexture/engine.rawTexture.base.js.map +1 -0
  210. package/esm/Engines/Extensions/readTexture/readTexture.base.d.ts +9 -0
  211. package/esm/Engines/Extensions/readTexture/readTexture.base.js +2 -0
  212. package/esm/Engines/Extensions/readTexture/readTexture.base.js.map +1 -0
  213. package/esm/Engines/Extensions/renderTarget/renderTarget.base.d.ts +35 -0
  214. package/esm/Engines/Extensions/renderTarget/renderTarget.base.js +2 -0
  215. package/esm/Engines/Extensions/renderTarget/renderTarget.base.js.map +1 -0
  216. package/esm/Engines/Extensions/renderTargetCube/renderTargetCube.base.d.ts +12 -0
  217. package/esm/Engines/Extensions/renderTargetCube/renderTargetCube.base.js +2 -0
  218. package/esm/Engines/Extensions/renderTargetCube/renderTargetCube.base.js.map +1 -0
  219. package/esm/Engines/Extensions/storageBuffer/storageBuffer.base.d.ts +36 -0
  220. package/esm/Engines/Extensions/storageBuffer/storageBuffer.base.js +2 -0
  221. package/esm/Engines/Extensions/storageBuffer/storageBuffer.base.js.map +1 -0
  222. package/esm/Engines/Extensions/textureSampler/textureSampler.base.d.ts +11 -0
  223. package/esm/Engines/Extensions/textureSampler/textureSampler.base.js +2 -0
  224. package/esm/Engines/Extensions/textureSampler/textureSampler.base.js.map +1 -0
  225. package/esm/Engines/Extensions/textureSelector/textureSelector.base.d.ts +50 -0
  226. package/esm/Engines/Extensions/textureSelector/textureSelector.base.js +53 -0
  227. package/esm/Engines/Extensions/textureSelector/textureSelector.base.js.map +1 -0
  228. package/esm/Engines/Extensions/transformFeedback/engine.transformFeedback.base.d.ts +42 -0
  229. package/esm/Engines/Extensions/transformFeedback/engine.transformFeedback.base.js +2 -0
  230. package/esm/Engines/Extensions/transformFeedback/engine.transformFeedback.base.js.map +1 -0
  231. package/esm/Engines/Extensions/uniformBuffer/uniformBuffer.base.d.ts +48 -0
  232. package/esm/Engines/Extensions/uniformBuffer/uniformBuffer.base.js +2 -0
  233. package/esm/Engines/Extensions/uniformBuffer/uniformBuffer.base.js.map +1 -0
  234. package/esm/Engines/Extensions/videoTexture/videoTexture.base.d.ts +13 -0
  235. package/esm/Engines/Extensions/videoTexture/videoTexture.base.js +2 -0
  236. package/esm/Engines/Extensions/videoTexture/videoTexture.base.js.map +1 -0
  237. package/esm/Engines/Extensions/views/views.base.d.ts +85 -0
  238. package/esm/Engines/Extensions/views/views.base.js +33 -0
  239. package/esm/Engines/Extensions/views/views.base.js.map +1 -0
  240. package/esm/Engines/WebGL/Extensions/alpha/alpha.webgl.d.ts +8 -0
  241. package/esm/Engines/WebGL/Extensions/alpha/alpha.webgl.js +137 -0
  242. package/esm/Engines/WebGL/Extensions/alpha/alpha.webgl.js.map +1 -0
  243. package/esm/Engines/WebGL/Extensions/cubeTexture/cubeTexture.webgl.d.ts +11 -0
  244. package/esm/Engines/WebGL/Extensions/cubeTexture/cubeTexture.webgl.js +251 -0
  245. package/esm/Engines/WebGL/Extensions/cubeTexture/cubeTexture.webgl.js.map +1 -0
  246. package/esm/Engines/WebGL/Extensions/dynamicBuffer/dynamicBuffer.webgl.d.ts +5 -0
  247. package/esm/Engines/WebGL/Extensions/dynamicBuffer/dynamicBuffer.webgl.js +55 -0
  248. package/esm/Engines/WebGL/Extensions/dynamicBuffer/dynamicBuffer.webgl.js.map +1 -0
  249. package/esm/Engines/WebGL/Extensions/dynamicTexture/dynamicTexture.webgl.d.ts +5 -0
  250. package/esm/Engines/WebGL/Extensions/dynamicTexture/dynamicTexture.webgl.js +65 -0
  251. package/esm/Engines/WebGL/Extensions/dynamicTexture/dynamicTexture.webgl.js.map +1 -0
  252. package/esm/Engines/WebGL/Extensions/multiRender/multiRender.webgl.d.ts +10 -0
  253. package/esm/Engines/WebGL/Extensions/multiRender/multiRender.webgl.js +375 -0
  254. package/esm/Engines/WebGL/Extensions/multiRender/multiRender.webgl.js.map +1 -0
  255. package/esm/Engines/WebGL/Extensions/multiview/multiview.webgl.d.ts +6 -0
  256. package/esm/Engines/WebGL/Extensions/multiview/multiview.webgl.js +77 -0
  257. package/esm/Engines/WebGL/Extensions/multiview/multiview.webgl.js.map +1 -0
  258. package/esm/Engines/WebGL/Extensions/query/query.webgl.d.ts +21 -0
  259. package/esm/Engines/WebGL/Extensions/query/query.webgl.js +220 -0
  260. package/esm/Engines/WebGL/Extensions/query/query.webgl.js.map +1 -0
  261. package/esm/Engines/WebGL/Extensions/rawTexture/engine.rawTexture.webgl.d.ts +15 -0
  262. package/esm/Engines/WebGL/Extensions/rawTexture/engine.rawTexture.webgl.js +392 -0
  263. package/esm/Engines/WebGL/Extensions/rawTexture/engine.rawTexture.webgl.js.map +1 -0
  264. package/esm/Engines/WebGL/Extensions/readTexture/readTexture.webgl.d.ts +17 -0
  265. package/esm/Engines/WebGL/Extensions/readTexture/readTexture.webgl.js +133 -0
  266. package/esm/Engines/WebGL/Extensions/readTexture/readTexture.webgl.js.map +1 -0
  267. package/esm/Engines/WebGL/Extensions/renderTarget/renderTarget.webgl.d.ts +8 -0
  268. package/esm/Engines/WebGL/Extensions/renderTarget/renderTarget.webgl.js +199 -0
  269. package/esm/Engines/WebGL/Extensions/renderTarget/renderTarget.webgl.js.map +1 -0
  270. package/esm/Engines/WebGL/Extensions/renderTargetCube/renderTargetCube.webgl.d.ts +2 -0
  271. package/esm/Engines/WebGL/Extensions/renderTargetCube/renderTargetCube.webgl.js +62 -0
  272. package/esm/Engines/WebGL/Extensions/renderTargetCube/renderTargetCube.webgl.js.map +1 -0
  273. package/esm/Engines/WebGL/Extensions/textureSelector/textureSelector.webgl.d.ts +5 -0
  274. package/esm/Engines/WebGL/Extensions/textureSelector/textureSelector.webgl.js +28 -0
  275. package/esm/Engines/WebGL/Extensions/textureSelector/textureSelector.webgl.js.map +1 -0
  276. package/esm/Engines/WebGL/Extensions/transformFeedback/engine.transformFeedback.webgl.d.ts +11 -0
  277. package/esm/Engines/WebGL/Extensions/transformFeedback/engine.transformFeedback.webgl.js +45 -0
  278. package/esm/Engines/WebGL/Extensions/transformFeedback/engine.transformFeedback.webgl.js.map +1 -0
  279. package/esm/Engines/WebGL/Extensions/uniformBuffer/uniformBuffer.webgl.d.ts +9 -0
  280. package/esm/Engines/WebGL/Extensions/uniformBuffer/uniformBuffer.webgl.js +78 -0
  281. package/esm/Engines/WebGL/Extensions/uniformBuffer/uniformBuffer.webgl.js.map +1 -0
  282. package/esm/Engines/WebGL/Extensions/videoTexture/videoTexture.webgl.d.ts +4 -0
  283. package/esm/Engines/WebGL/Extensions/videoTexture/videoTexture.webgl.js +67 -0
  284. package/esm/Engines/WebGL/Extensions/videoTexture/videoTexture.webgl.js.map +1 -0
  285. package/esm/Engines/WebGL/Extensions/views/views.webgl.d.ts +18 -0
  286. package/esm/Engines/WebGL/Extensions/views/views.webgl.js +152 -0
  287. package/esm/Engines/WebGL/Extensions/views/views.webgl.js.map +1 -0
  288. package/esm/Engines/WebGL/engine.adapterHelpers.d.ts +43 -0
  289. package/esm/Engines/WebGL/engine.adapterHelpers.js +107 -0
  290. package/esm/Engines/WebGL/engine.adapterHelpers.js.map +1 -0
  291. package/esm/Engines/WebGL/engine.webgl.d.ts +1030 -0
  292. package/esm/Engines/WebGL/engine.webgl.js +4083 -0
  293. package/esm/Engines/WebGL/engine.webgl.js.map +1 -0
  294. package/esm/Engines/WebGPU/engine.adapterHelpers.d.ts +7 -0
  295. package/esm/Engines/WebGPU/engine.adapterHelpers.js +20 -0
  296. package/esm/Engines/WebGPU/engine.adapterHelpers.js.map +1 -0
  297. package/esm/Engines/WebGPU/engine.webgpu.constants.d.ts +391 -0
  298. package/esm/Engines/WebGPU/engine.webgpu.constants.js +2 -0
  299. package/esm/Engines/WebGPU/engine.webgpu.constants.js.map +1 -0
  300. package/esm/Engines/WebGPU/engine.webgpu.d.ts +277 -0
  301. package/esm/Engines/WebGPU/engine.webgpu.js +1281 -0
  302. package/esm/Engines/WebGPU/engine.webgpu.js.map +1 -0
  303. package/esm/Engines/engine.adapters.d.ts +32 -0
  304. package/esm/Engines/engine.adapters.js +27 -0
  305. package/esm/Engines/engine.adapters.js.map +1 -0
  306. package/esm/Engines/engine.base.d.ts +807 -0
  307. package/esm/Engines/engine.base.js +1235 -0
  308. package/esm/Engines/engine.base.js.map +1 -0
  309. package/esm/Engines/engine.constants.d.ts +735 -0
  310. package/esm/Engines/engine.constants.js +3 -0
  311. package/esm/Engines/engine.constants.js.map +1 -0
  312. package/esm/Engines/engine.extendable.d.ts +180 -0
  313. package/esm/Engines/engine.extendable.js +477 -0
  314. package/esm/Engines/engine.extendable.js.map +1 -0
  315. package/esm/Engines/engine.interfaces.d.ts +16 -0
  316. package/esm/Engines/engine.interfaces.js +9 -0
  317. package/esm/Engines/engine.interfaces.js.map +1 -0
  318. package/esm/Engines/engine.static.d.ts +215 -0
  319. package/esm/Engines/engine.static.js +345 -0
  320. package/esm/Engines/engine.static.js.map +1 -0
  321. package/esm/Engines/engine.tools.d.ts +20 -0
  322. package/esm/Engines/engine.tools.js +33 -0
  323. package/esm/Engines/engine.tools.js.map +1 -0
  324. package/esm/Engines/public.d.ts +1 -0
  325. package/esm/Engines/public.js +2 -0
  326. package/esm/Engines/public.js.map +1 -0
  327. package/esm/Engines/runtimeEnvironment.d.ts +37 -0
  328. package/esm/Engines/runtimeEnvironment.js +56 -0
  329. package/esm/Engines/runtimeEnvironment.js.map +1 -0
  330. package/package.json +2 -1
  331. package/scene.js +1 -1
  332. package/scene.js.map +1 -1
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Static engine functionality. Static functions don't require the engine state to run.
3
+ */
4
+ import type { IInternalTextureLoader } from "../../Materials/Textures/internalTextureLoader.js";
5
+ import { Constants } from "./engine.constants";
6
+ import type { Nullable } from "../../types.js";
7
+ import type { IBaseEnginePublic } from "./engine.base";
8
+ import type { Scene } from "../../scene.js";
9
+ import { Observable } from "../../Misc/observable.js";
10
+ import type { ICanvas } from "../../Engines/ICanvas.js";
11
+ import type { Material } from "../../Materials/material.js";
12
+ import type { IOfflineProvider } from "../../Offline/IOfflineProvider.js";
13
+ import type { IAudioEngine } from "../../Audio/Interfaces/IAudioEngine.js";
14
+ import type { ILoadingScreen } from "../../Loading/loadingScreen.js";
15
+ import type { PostProcess } from "../../PostProcesses/postProcess.js";
16
+ import type { Engine } from "../../Engines/engine.js";
17
+ export interface IEngineStore<T extends IBaseEnginePublic = IBaseEnginePublic> {
18
+ /** Gets the list of created engines */
19
+ Instances: Array<IBaseEnginePublic>;
20
+ /**
21
+ * Notifies when an engine was disposed.
22
+ * Mainly used for static/cache cleanup
23
+ */
24
+ OnEnginesDisposedObservable: Observable<T>;
25
+ /**
26
+ * Gets the latest created engine
27
+ */
28
+ readonly LastCreatedEngine: Nullable<Engine>;
29
+ /**
30
+ * Gets the latest created scene
31
+ */
32
+ LastCreatedScene: Nullable<Scene>;
33
+ /**
34
+ * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
35
+ */
36
+ UseFallbackTexture: boolean;
37
+ /**
38
+ * Texture content used if a texture cannot loaded
39
+ */
40
+ FallbackTexture: string;
41
+ /**
42
+ * Gets the audio engine
43
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic
44
+ * @ignorenaming
45
+ */
46
+ audioEngine: Nullable<IAudioEngine>;
47
+ /**
48
+ * Default AudioEngine factory responsible of creating the Audio Engine.
49
+ * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
50
+ */
51
+ AudioEngineFactory?: (hostElement: Nullable<HTMLElement>, audioContext: Nullable<AudioContext>, audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>) => IAudioEngine;
52
+ /**
53
+ * Default offline support factory responsible of creating a tool used to store data locally.
54
+ * By default, this will create a Database object if the workload has been embedded.
55
+ */
56
+ OfflineProviderFactory?: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
57
+ /**
58
+ * Method called to create the default loading screen.
59
+ * This can be overridden in your own app.
60
+ * @param canvas The rendering canvas element
61
+ * @returns The loading screen
62
+ */
63
+ DefaultLoadingScreenFactory?: (canvas: HTMLCanvasElement) => ILoadingScreen;
64
+ /**
65
+ * Method called to create the default rescale post process on each engine.
66
+ */
67
+ _RescalePostProcessFactory: Nullable<(engine: T) => PostProcess>;
68
+ _engineMappings: WeakMap<T, Engine>;
69
+ }
70
+ export declare const EngineStore: IEngineStore;
71
+ export declare const ExceptionList: {
72
+ webgl: ({
73
+ key: string;
74
+ capture: string;
75
+ captureConstraint: number;
76
+ targets: string[];
77
+ } | {
78
+ key: string;
79
+ capture: null;
80
+ captureConstraint: null;
81
+ targets: string[];
82
+ })[];
83
+ };
84
+ export declare const _TextureLoaders: IInternalTextureLoader[];
85
+ export declare const NpmPackage = "@babylonjs/esm@6.33.1";
86
+ export declare const Version = "6.33.1";
87
+ export declare const CollisionEpsilon = 0.001;
88
+ export declare let ShadersRepository: string;
89
+ /**
90
+ * Sets the shader repository path to use
91
+ * @param path the path to load shaders from
92
+ */
93
+ export declare function SetShadersRepository(path: string): void;
94
+ /**
95
+ * Queue a new function into the requested animation frame pool (ie. this function will be executed by the browser (or the javascript engine) for the next frame)
96
+ * @param func - the function to be called
97
+ * @param requester - the object that will request the next frame. Falls back to window.
98
+ * @returns frame number
99
+ */
100
+ export declare function QueueNewFrame(func: FrameRequestCallback, requester?: any): number;
101
+ export declare function IsWebGPUSupported(): Promise<boolean>;
102
+ /**
103
+ * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
104
+ * @returns true if the engine can be created
105
+ */
106
+ export declare function IsWebGLSupported(): boolean;
107
+ /**
108
+ * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
109
+ */
110
+ export declare function HasMajorPerformanceCaveat(): boolean;
111
+ /**
112
+ * Find the next highest power of two.
113
+ * @param x Number to start search from.
114
+ * @returns Next highest power of two.
115
+ */
116
+ export declare function CeilingPOT(x: number): number;
117
+ /**
118
+ * Find the next lowest power of two.
119
+ * @param x Number to start search from.
120
+ * @returns Next lowest power of two.
121
+ */
122
+ export declare function FloorPOT(x: number): number;
123
+ /**
124
+ * Find the nearest power of two.
125
+ * @param x Number to start search from.
126
+ * @returns Next nearest power of two.
127
+ */
128
+ export declare function NearestPOT(x: number): number;
129
+ /**
130
+ * Get the closest exponent of two
131
+ * @param value defines the value to approximate
132
+ * @param max defines the maximum value to return
133
+ * @param mode defines how to define the closest value
134
+ * @returns closest exponent of two of the given value
135
+ */
136
+ export declare function GetExponentOfTwo(value: number, max: number, mode?: Constants): number;
137
+ export declare function _CreateCanvas(width: number, height: number): ICanvas;
138
+ /**
139
+ * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
140
+ * @param flag defines which part of the materials must be marked as dirty
141
+ * @param predicate defines a predicate used to filter which materials should be affected
142
+ */
143
+ export declare function MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
144
+ /**
145
+ * Ask the browser to promote the current element to pointerlock mode
146
+ * @param element defines the DOM element to promote
147
+ */
148
+ export declare function _RequestPointerlock(element: HTMLElement): void;
149
+ /** Pointerlock and fullscreen */
150
+ /**
151
+ * Asks the browser to exit pointerlock mode
152
+ */
153
+ export declare function _ExitPointerlock(): void;
154
+ /**
155
+ * Ask the browser to promote the current element to fullscreen rendering mode
156
+ * @param element defines the DOM element to promote
157
+ */
158
+ export declare function _RequestFullscreen(element: HTMLElement): void;
159
+ /**
160
+ * Asks the browser to exit fullscreen mode
161
+ */
162
+ export declare function _ExitFullscreen(): void;
163
+ /**
164
+ * Get Font size information
165
+ * @param font font name
166
+ * @returns an object containing ascent, height and descent
167
+ */
168
+ export declare function getFontOffset(font: string): {
169
+ ascent: number;
170
+ height: number;
171
+ descent: number;
172
+ };
173
+ /**
174
+ * Engine abstraction for loading and creating an image bitmap from a given source string.
175
+ * @internal
176
+ * @param imageSource source to load the image from.
177
+ * @param options An object that sets options for the image's extraction.
178
+ * @returns ImageBitmap.
179
+ */
180
+ export declare function _createImageBitmapFromSource({ createImageBitmap, }: {
181
+ createImageBitmap: (image: ImageBitmapSource, options?: ImageBitmapOptions) => Promise<ImageBitmap>;
182
+ }, imageSource: string, options?: ImageBitmapOptions): Promise<ImageBitmap>;
183
+ /**
184
+ * Resize an image and returns the image data as an uint8array
185
+ * @param image image to resize
186
+ * @param bufferWidth destination buffer width
187
+ * @param bufferHeight destination buffer height
188
+ * @returns an uint8array containing RGBA values of bufferWidth * bufferHeight size
189
+ */
190
+ export declare function resizeImageBitmap({ createCanvas, }: {
191
+ createCanvas?: (width: number, height: number) => ICanvas;
192
+ }, image: HTMLImageElement | ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;
193
+ export declare function _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
194
+ declare const _default: {
195
+ NpmPackage: string;
196
+ Version: string;
197
+ CollisionEpsilon: number;
198
+ ShadersRepository: string;
199
+ _TextureLoaders: IInternalTextureLoader[];
200
+ SetShadersRepository: typeof SetShadersRepository;
201
+ ExceptionList: {
202
+ webgl: ({
203
+ key: string;
204
+ capture: string;
205
+ captureConstraint: number;
206
+ targets: string[];
207
+ } | {
208
+ key: string;
209
+ capture: null;
210
+ captureConstraint: null;
211
+ targets: string[];
212
+ })[];
213
+ };
214
+ };
215
+ export default _default;
@@ -0,0 +1,345 @@
1
+ /**
2
+ * Static engine functionality. Static functions don't require the engine state to run.
3
+ */
4
+ /* eslint-disable @typescript-eslint/naming-convention */
5
+ import { Effect } from "../../Materials/effect.js";
6
+ import { IsWindowObjectExist } from "./runtimeEnvironment.js";
7
+ import { Observable } from "../../Misc/observable.js";
8
+ export const EngineStore = {
9
+ Instances: [],
10
+ get LastCreatedEngine() {
11
+ if (this.Instances.length === 0) {
12
+ return null;
13
+ }
14
+ return EngineStore._engineMappings.get(EngineStore.Instances[EngineStore.Instances.length - 1]);
15
+ },
16
+ LastCreatedScene: null,
17
+ UseFallbackTexture: true,
18
+ FallbackTexture: "",
19
+ OnEnginesDisposedObservable: new Observable(),
20
+ audioEngine: null,
21
+ _RescalePostProcessFactory: null,
22
+ _engineMappings: new WeakMap(),
23
+ };
24
+ // used to be WebGL only, a single array
25
+ export const ExceptionList = {
26
+ webgl: [
27
+ { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
28
+ { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
29
+ { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
30
+ { key: "Chrome/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
31
+ { key: "Chrome/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
32
+ { key: "Chrome/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
33
+ { key: "Mac OS.+Chrome/71", capture: null, captureConstraint: null, targets: ["vao"] },
34
+ { key: "Mac OS.+Chrome/72", capture: null, captureConstraint: null, targets: ["vao"] },
35
+ { key: "Mac OS.+Chrome", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
36
+ { key: "Chrome/12\\d\\..+?Mobile", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
37
+ // desktop osx safari 15.4
38
+ { key: ".*AppleWebKit.*(15.4).*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] },
39
+ // mobile browsers using safari 15.4 on ios
40
+ { key: ".*(15.4).*AppleWebKit.*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] },
41
+ ],
42
+ };
43
+ // elements added to this array will persist between imports
44
+ export const _TextureLoaders = [];
45
+ export const NpmPackage = "@babylonjs/esm@6.33.1";
46
+ export const Version = "6.33.1";
47
+ export const CollisionEpsilon = 0.001;
48
+ // A string cannot be modified when imported from an es6 module. It needs a mutating function
49
+ export let ShadersRepository = Effect.ShadersRepository;
50
+ /**
51
+ * Sets the shader repository path to use
52
+ * @param path the path to load shaders from
53
+ */
54
+ export function SetShadersRepository(path) {
55
+ Effect.ShadersRepository = path;
56
+ ShadersRepository = Effect.ShadersRepository;
57
+ }
58
+ /**
59
+ * Queue a new function into the requested animation frame pool (ie. this function will be executed by the browser (or the javascript engine) for the next frame)
60
+ * @param func - the function to be called
61
+ * @param requester - the object that will request the next frame. Falls back to window.
62
+ * @returns frame number
63
+ */
64
+ export function QueueNewFrame(func, requester) {
65
+ // Note that there is kind of a typing issue here, as `setTimeout` might return something else than a number (NodeJs returns a NodeJS.Timeout object).
66
+ // Also if the global `requestAnimationFrame`'s returnType is number, `requester.requestPostAnimationFrame` and `requester.requestAnimationFrame` types
67
+ // are `any`.
68
+ if (!IsWindowObjectExist()) {
69
+ if (typeof requestAnimationFrame === "function") {
70
+ return requestAnimationFrame(func);
71
+ }
72
+ }
73
+ else {
74
+ const { requestAnimationFrame } = requester || window;
75
+ if (typeof requestAnimationFrame === "function") {
76
+ return requestAnimationFrame(func);
77
+ }
78
+ }
79
+ // fallback to the global `setTimeout`.
80
+ // In most cases (aka in the browser), `window` is the global object, so instead of calling `window.setTimeout` we could call the global `setTimeout`.
81
+ return setTimeout(func, 16);
82
+ }
83
+ let _IsWebGLSupported = null;
84
+ export function IsWebGPUSupported() {
85
+ return !navigator.gpu
86
+ ? Promise.resolve(false)
87
+ : navigator.gpu
88
+ .requestAdapter()
89
+ .then((adapter) => !!adapter, () => false)
90
+ .catch(() => false);
91
+ }
92
+ /**
93
+ * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
94
+ * @returns true if the engine can be created
95
+ */
96
+ export function IsWebGLSupported() {
97
+ if (_HasMajorPerformanceCaveat !== null) {
98
+ return !_HasMajorPerformanceCaveat; // We know it is performant so WebGL is supported
99
+ }
100
+ if (_IsWebGLSupported === null) {
101
+ try {
102
+ const tempcanvas = _CreateCanvas(1, 1);
103
+ const gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
104
+ _IsWebGLSupported = gl != null && !!window.WebGLRenderingContext;
105
+ }
106
+ catch (e) {
107
+ _IsWebGLSupported = false;
108
+ }
109
+ }
110
+ return _IsWebGLSupported;
111
+ }
112
+ let _HasMajorPerformanceCaveat = null;
113
+ /**
114
+ * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
115
+ */
116
+ export function HasMajorPerformanceCaveat() {
117
+ if (_HasMajorPerformanceCaveat === null) {
118
+ try {
119
+ const tempcanvas = _CreateCanvas(1, 1);
120
+ const gl = tempcanvas.getContext("webgl", { failIfMajorPerformanceCaveat: true }) ||
121
+ tempcanvas.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: true });
122
+ _HasMajorPerformanceCaveat = !gl;
123
+ }
124
+ catch (e) {
125
+ _HasMajorPerformanceCaveat = false;
126
+ }
127
+ }
128
+ return _HasMajorPerformanceCaveat;
129
+ }
130
+ /**
131
+ * Find the next highest power of two.
132
+ * @param x Number to start search from.
133
+ * @returns Next highest power of two.
134
+ */
135
+ export function CeilingPOT(x) {
136
+ x--;
137
+ x |= x >> 1;
138
+ x |= x >> 2;
139
+ x |= x >> 4;
140
+ x |= x >> 8;
141
+ x |= x >> 16;
142
+ x++;
143
+ return x;
144
+ }
145
+ /**
146
+ * Find the next lowest power of two.
147
+ * @param x Number to start search from.
148
+ * @returns Next lowest power of two.
149
+ */
150
+ export function FloorPOT(x) {
151
+ x = x | (x >> 1);
152
+ x = x | (x >> 2);
153
+ x = x | (x >> 4);
154
+ x = x | (x >> 8);
155
+ x = x | (x >> 16);
156
+ return x - (x >> 1);
157
+ }
158
+ /**
159
+ * Find the nearest power of two.
160
+ * @param x Number to start search from.
161
+ * @returns Next nearest power of two.
162
+ */
163
+ export function NearestPOT(x) {
164
+ const c = CeilingPOT(x);
165
+ const f = FloorPOT(x);
166
+ return c - x > x - f ? f : c;
167
+ }
168
+ /**
169
+ * Get the closest exponent of two
170
+ * @param value defines the value to approximate
171
+ * @param max defines the maximum value to return
172
+ * @param mode defines how to define the closest value
173
+ * @returns closest exponent of two of the given value
174
+ */
175
+ export function GetExponentOfTwo(value, max, mode = 2 /* 2 */) {
176
+ let pot;
177
+ switch (mode) {
178
+ case 1 /* 1 */:
179
+ pot = FloorPOT(value);
180
+ break;
181
+ case 2 /* 2 */:
182
+ pot = NearestPOT(value);
183
+ break;
184
+ case 3 /* 3 */:
185
+ default:
186
+ pot = CeilingPOT(value);
187
+ break;
188
+ }
189
+ return Math.min(pot, max);
190
+ }
191
+ export function _CreateCanvas(width, height) {
192
+ if (typeof document === "undefined") {
193
+ return new OffscreenCanvas(width, height);
194
+ }
195
+ const canvas = document.createElement("canvas");
196
+ canvas.width = width;
197
+ canvas.height = height;
198
+ return canvas;
199
+ }
200
+ // From Engine
201
+ /**
202
+ * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
203
+ * @param flag defines which part of the materials must be marked as dirty
204
+ * @param predicate defines a predicate used to filter which materials should be affected
205
+ */
206
+ export function MarkAllMaterialsAsDirty(flag, predicate) {
207
+ for (let engineIndex = 0; engineIndex < EngineStore.Instances.length; engineIndex++) {
208
+ const engine = EngineStore.Instances[engineIndex];
209
+ for (let sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
210
+ engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
211
+ }
212
+ }
213
+ }
214
+ /**
215
+ * Ask the browser to promote the current element to pointerlock mode
216
+ * @param element defines the DOM element to promote
217
+ */
218
+ export function _RequestPointerlock(element) {
219
+ if (element.requestPointerLock) {
220
+ // In some browsers, requestPointerLock returns a promise.
221
+ // Handle possible rejections to avoid an unhandled top-level exception.
222
+ const promise = element.requestPointerLock();
223
+ if (promise instanceof Promise)
224
+ promise
225
+ .then(() => {
226
+ element.focus();
227
+ })
228
+ .catch(() => { });
229
+ else
230
+ element.focus();
231
+ }
232
+ }
233
+ /** Pointerlock and fullscreen */
234
+ /**
235
+ * Asks the browser to exit pointerlock mode
236
+ */
237
+ export function _ExitPointerlock() {
238
+ if (document.exitPointerLock) {
239
+ document.exitPointerLock();
240
+ }
241
+ }
242
+ /**
243
+ * Ask the browser to promote the current element to fullscreen rendering mode
244
+ * @param element defines the DOM element to promote
245
+ */
246
+ export function _RequestFullscreen(element) {
247
+ const requestFunction = element.requestFullscreen || element.webkitRequestFullscreen;
248
+ if (!requestFunction) {
249
+ return;
250
+ }
251
+ requestFunction.call(element);
252
+ }
253
+ /**
254
+ * Asks the browser to exit fullscreen mode
255
+ */
256
+ export function _ExitFullscreen() {
257
+ const anyDoc = document;
258
+ if (document.exitFullscreen) {
259
+ document.exitFullscreen();
260
+ }
261
+ else if (anyDoc.webkitCancelFullScreen) {
262
+ anyDoc.webkitCancelFullScreen();
263
+ }
264
+ }
265
+ /**
266
+ * Get Font size information
267
+ * @param font font name
268
+ * @returns an object containing ascent, height and descent
269
+ */
270
+ export function getFontOffset(font) {
271
+ const text = document.createElement("span");
272
+ text.innerHTML = "Hg";
273
+ text.setAttribute("style", `font: ${font} !important`);
274
+ const block = document.createElement("div");
275
+ block.style.display = "inline-block";
276
+ block.style.width = "1px";
277
+ block.style.height = "0px";
278
+ block.style.verticalAlign = "bottom";
279
+ const div = document.createElement("div");
280
+ div.style.whiteSpace = "nowrap";
281
+ div.appendChild(text);
282
+ div.appendChild(block);
283
+ document.body.appendChild(div);
284
+ let fontAscent = 0;
285
+ let fontHeight = 0;
286
+ try {
287
+ fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
288
+ block.style.verticalAlign = "baseline";
289
+ fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
290
+ }
291
+ finally {
292
+ document.body.removeChild(div);
293
+ }
294
+ return { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
295
+ }
296
+ /**
297
+ * Engine abstraction for loading and creating an image bitmap from a given source string.
298
+ * @internal
299
+ * @param imageSource source to load the image from.
300
+ * @param options An object that sets options for the image's extraction.
301
+ * @returns ImageBitmap.
302
+ */
303
+ export async function _createImageBitmapFromSource({ createImageBitmap, }, imageSource, options) {
304
+ const promise = new Promise((resolve, reject) => {
305
+ const image = new Image();
306
+ image.onload = () => {
307
+ image.decode().then(() => {
308
+ createImageBitmap(image, options).then((imageBitmap) => {
309
+ resolve(imageBitmap);
310
+ });
311
+ });
312
+ };
313
+ image.onerror = () => {
314
+ reject(`Error loading image ${image.src}`);
315
+ };
316
+ image.src = imageSource;
317
+ });
318
+ return promise;
319
+ }
320
+ /**
321
+ * Resize an image and returns the image data as an uint8array
322
+ * @param image image to resize
323
+ * @param bufferWidth destination buffer width
324
+ * @param bufferHeight destination buffer height
325
+ * @returns an uint8array containing RGBA values of bufferWidth * bufferHeight size
326
+ */
327
+ export function resizeImageBitmap({ createCanvas, }, image, bufferWidth, bufferHeight) {
328
+ const canvas = (createCanvas !== null && createCanvas !== void 0 ? createCanvas : _CreateCanvas)(bufferWidth, bufferHeight);
329
+ const context = canvas.getContext("2d");
330
+ if (!context) {
331
+ throw new Error("Unable to get 2d context for resizeImageBitmap");
332
+ }
333
+ context.drawImage(image, 0, 0);
334
+ // Create VertexData from map data
335
+ // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
336
+ const buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
337
+ return buffer;
338
+ }
339
+ // eslint-disable-next-line @typescript-eslint/naming-convention
340
+ export function _ConcatenateShader(source, defines, shaderVersion = "") {
341
+ return shaderVersion + (defines ? defines + "\n" : "") + source;
342
+ }
343
+ // TODO is this needed? this will allow `import Statics from "package/Engines"`.
344
+ export default { NpmPackage, Version, CollisionEpsilon, ShadersRepository, _TextureLoaders, SetShadersRepository, ExceptionList };
345
+ //# sourceMappingURL=engine.static.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.static.js","sourceRoot":"","sources":["../../../../../dev/core/src/esm/Engines/engine.static.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,yDAAyD;AACzD,OAAO,EAAE,MAAM,EAAE,kCAA8B;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAK3D,OAAO,EAAE,UAAU,EAAE,iCAA6B;AA2ElD,MAAM,CAAC,MAAM,WAAW,GAAiB;IACrC,SAAS,EAAE,EAAE;IACb,IAAI,iBAAiB;QACjB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC;SACf;QAED,OAAO,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAE,CAAC;IACrG,CAAC;IACD,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,eAAe,EAAE,EAAE;IACnB,2BAA2B,EAAE,IAAI,UAAU,EAAE;IAC7C,WAAW,EAAE,IAAI;IACjB,0BAA0B,EAAE,IAAI;IAChC,eAAe,EAAE,IAAI,OAAO,EAAE;CACjC,CAAC;AAEF,wCAAwC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,KAAK,EAAE;QACH,EAAE,GAAG,EA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IAED,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/B,kCAAkC;IAClC,+GAA+G;IAC/G,MAAM,MAAM,GAAqB,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,IAAK,CAAC;IAC7F,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAAyB,EAAE,gBAAwB,EAAE;IACpG,OAAO,aAAa,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;AACpE,CAAC;AAED,gFAAgF;AAChF,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,CAAC","sourcesContent":["/**\r\n * Static engine functionality. Static functions don't require the engine state to run.\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Effect } from \"core/Materials/effect\";\r\nimport type { IInternalTextureLoader } from \"core/Materials/Textures/internalTextureLoader\";\r\nimport { IsWindowObjectExist } from \"./runtimeEnvironment\";\r\nimport { Constants } from \"./engine.constants\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { IBaseEnginePublic } from \"./engine.base\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport type { ICanvas } from \"core/Engines/ICanvas\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { IOfflineProvider } from \"core/Offline/IOfflineProvider\";\r\nimport type { IAudioEngine } from \"core/Audio/Interfaces/IAudioEngine\";\r\nimport type { ILoadingScreen } from \"core/Loading/loadingScreen\";\r\nimport type { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\nexport interface IEngineStore<T extends IBaseEnginePublic = IBaseEnginePublic> {\r\n /** Gets the list of created engines */\r\n Instances: Array<IBaseEnginePublic>;\r\n /**\r\n * Notifies when an engine was disposed.\r\n * Mainly used for static/cache cleanup\r\n */\r\n OnEnginesDisposedObservable: Observable<T>;\r\n /**\r\n * Gets the latest created engine\r\n */\r\n readonly LastCreatedEngine: Nullable<Engine>;\r\n /**\r\n * Gets the latest created scene\r\n */\r\n LastCreatedScene: Nullable<Scene>;\r\n /**\r\n * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded\r\n */\r\n UseFallbackTexture: boolean;\r\n /**\r\n * Texture content used if a texture cannot loaded\r\n */\r\n FallbackTexture: string;\r\n\r\n /**\r\n * Gets the audio engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n audioEngine: Nullable<IAudioEngine>;\r\n\r\n /**\r\n * Default AudioEngine factory responsible of creating the Audio Engine.\r\n * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.\r\n */\r\n AudioEngineFactory?: (\r\n hostElement: Nullable<HTMLElement>,\r\n audioContext: Nullable<AudioContext>,\r\n audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>\r\n ) => IAudioEngine;\r\n\r\n /**\r\n * Default offline support factory responsible of creating a tool used to store data locally.\r\n * By default, this will create a Database object if the workload has been embedded.\r\n */\r\n OfflineProviderFactory?: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;\r\n\r\n /**\r\n * Method called to create the default loading screen.\r\n * This can be overridden in your own app.\r\n * @param canvas The rendering canvas element\r\n * @returns The loading screen\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n DefaultLoadingScreenFactory?: (canvas: HTMLCanvasElement) => ILoadingScreen;\r\n\r\n /**\r\n * Method called to create the default rescale post process on each engine.\r\n */\r\n _RescalePostProcessFactory: Nullable<(engine: T) => PostProcess>;\r\n\r\n _engineMappings: WeakMap<T, Engine>;\r\n}\r\n\r\nexport const EngineStore: IEngineStore = {\r\n Instances: [],\r\n get LastCreatedEngine() {\r\n if (this.Instances.length === 0) {\r\n return null;\r\n }\r\n\r\n return EngineStore._engineMappings.get(EngineStore.Instances[EngineStore.Instances.length - 1])!;\r\n },\r\n LastCreatedScene: null,\r\n UseFallbackTexture: true,\r\n FallbackTexture: \"\",\r\n OnEnginesDisposedObservable: new Observable(),\r\n audioEngine: null,\r\n _RescalePostProcessFactory: null,\r\n _engineMappings: new WeakMap(),\r\n};\r\n\r\n// used to be WebGL only, a single array\r\nexport const ExceptionList = {\r\n webgl: [\r\n { key: \"Chrome/63.0\", capture: \"63\\\\.0\\\\.3239\\\\.(\\\\d+)\", captureConstraint: 108, targets: [\"uniformBuffer\"] },\r\n { key: \"Firefox/58\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\r\n { key: \"Firefox/59\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\r\n { key: \"Chrome/72.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Chrome/73.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Chrome/74.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Mac OS.+Chrome/71\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Mac OS.+Chrome/72\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Mac OS.+Chrome\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\r\n { key: \"Chrome/12\\\\d\\\\..+?Mobile\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\r\n // desktop osx safari 15.4\r\n { key: \".*AppleWebKit.*(15.4).*Safari\", capture: null, captureConstraint: null, targets: [\"antialias\", \"maxMSAASamples\"] },\r\n // mobile browsers using safari 15.4 on ios\r\n { key: \".*(15.4).*AppleWebKit.*Safari\", capture: null, captureConstraint: null, targets: [\"antialias\", \"maxMSAASamples\"] },\r\n ],\r\n};\r\n\r\n// elements added to this array will persist between imports\r\nexport const _TextureLoaders: IInternalTextureLoader[] = [];\r\n\r\nexport const NpmPackage = \"@babylonjs/esm@6.33.1\";\r\nexport const Version = \"6.33.1\";\r\n\r\nexport const CollisionEpsilon = 0.001;\r\n\r\n// A string cannot be modified when imported from an es6 module. It needs a mutating function\r\nexport let ShadersRepository = Effect.ShadersRepository;\r\n\r\n/**\r\n * Sets the shader repository path to use\r\n * @param path the path to load shaders from\r\n */\r\nexport function SetShadersRepository(path: string): void {\r\n Effect.ShadersRepository = path;\r\n ShadersRepository = Effect.ShadersRepository;\r\n}\r\n\r\n/**\r\n * Queue a new function into the requested animation frame pool (ie. this function will be executed by the browser (or the javascript engine) for the next frame)\r\n * @param func - the function to be called\r\n * @param requester - the object that will request the next frame. Falls back to window.\r\n * @returns frame number\r\n */\r\nexport function QueueNewFrame(func: FrameRequestCallback, requester?: any): number {\r\n // Note that there is kind of a typing issue here, as `setTimeout` might return something else than a number (NodeJs returns a NodeJS.Timeout object).\r\n // Also if the global `requestAnimationFrame`'s returnType is number, `requester.requestPostAnimationFrame` and `requester.requestAnimationFrame` types\r\n // are `any`.\r\n\r\n if (!IsWindowObjectExist()) {\r\n if (typeof requestAnimationFrame === \"function\") {\r\n return requestAnimationFrame(func);\r\n }\r\n } else {\r\n const { requestAnimationFrame } = requester || window;\r\n if (typeof requestAnimationFrame === \"function\") {\r\n return requestAnimationFrame(func);\r\n }\r\n }\r\n\r\n // fallback to the global `setTimeout`.\r\n // In most cases (aka in the browser), `window` is the global object, so instead of calling `window.setTimeout` we could call the global `setTimeout`.\r\n return setTimeout(func, 16) as unknown as number;\r\n}\r\n\r\nlet _IsWebGLSupported: Nullable<boolean> = null;\r\n\r\nexport function IsWebGPUSupported(): Promise<boolean> {\r\n return !navigator.gpu\r\n ? Promise.resolve(false)\r\n : navigator.gpu\r\n .requestAdapter()\r\n .then(\r\n (adapter: GPUAdapter | undefined) => !!adapter,\r\n () => false\r\n )\r\n .catch(() => false);\r\n}\r\n\r\n/**\r\n * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)\r\n * @returns true if the engine can be created\r\n */\r\nexport function IsWebGLSupported(): boolean {\r\n if (_HasMajorPerformanceCaveat !== null) {\r\n return !_HasMajorPerformanceCaveat; // We know it is performant so WebGL is supported\r\n }\r\n\r\n if (_IsWebGLSupported === null) {\r\n try {\r\n const tempcanvas = _CreateCanvas(1, 1);\r\n const gl = tempcanvas.getContext(\"webgl\") || (tempcanvas as any).getContext(\"experimental-webgl\");\r\n\r\n _IsWebGLSupported = gl != null && !!window.WebGLRenderingContext;\r\n } catch (e) {\r\n _IsWebGLSupported = false;\r\n }\r\n }\r\n\r\n return _IsWebGLSupported;\r\n}\r\n\r\nlet _HasMajorPerformanceCaveat: Nullable<boolean> = null;\r\n\r\n/**\r\n * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)\r\n */\r\nexport function HasMajorPerformanceCaveat(): boolean {\r\n if (_HasMajorPerformanceCaveat === null) {\r\n try {\r\n const tempcanvas = _CreateCanvas(1, 1);\r\n const gl =\r\n tempcanvas.getContext(\"webgl\", { failIfMajorPerformanceCaveat: true }) ||\r\n (tempcanvas as any).getContext(\"experimental-webgl\", { failIfMajorPerformanceCaveat: true });\r\n\r\n _HasMajorPerformanceCaveat = !gl;\r\n } catch (e) {\r\n _HasMajorPerformanceCaveat = false;\r\n }\r\n }\r\n\r\n return _HasMajorPerformanceCaveat;\r\n}\r\n\r\n/**\r\n * Find the next highest power of two.\r\n * @param x Number to start search from.\r\n * @returns Next highest power of two.\r\n */\r\nexport function CeilingPOT(x: number): number {\r\n x--;\r\n x |= x >> 1;\r\n x |= x >> 2;\r\n x |= x >> 4;\r\n x |= x >> 8;\r\n x |= x >> 16;\r\n x++;\r\n return x;\r\n}\r\n\r\n/**\r\n * Find the next lowest power of two.\r\n * @param x Number to start search from.\r\n * @returns Next lowest power of two.\r\n */\r\nexport function FloorPOT(x: number): number {\r\n x = x | (x >> 1);\r\n x = x | (x >> 2);\r\n x = x | (x >> 4);\r\n x = x | (x >> 8);\r\n x = x | (x >> 16);\r\n return x - (x >> 1);\r\n}\r\n\r\n/**\r\n * Find the nearest power of two.\r\n * @param x Number to start search from.\r\n * @returns Next nearest power of two.\r\n */\r\nexport function NearestPOT(x: number): number {\r\n const c = CeilingPOT(x);\r\n const f = FloorPOT(x);\r\n return c - x > x - f ? f : c;\r\n}\r\n\r\n/**\r\n * Get the closest exponent of two\r\n * @param value defines the value to approximate\r\n * @param max defines the maximum value to return\r\n * @param mode defines how to define the closest value\r\n * @returns closest exponent of two of the given value\r\n */\r\nexport function GetExponentOfTwo(value: number, max: number, mode = Constants.SCALEMODE_NEAREST): number {\r\n let pot;\r\n\r\n switch (mode) {\r\n case Constants.SCALEMODE_FLOOR:\r\n pot = FloorPOT(value);\r\n break;\r\n case Constants.SCALEMODE_NEAREST:\r\n pot = NearestPOT(value);\r\n break;\r\n case Constants.SCALEMODE_CEILING:\r\n default:\r\n pot = CeilingPOT(value);\r\n break;\r\n }\r\n\r\n return Math.min(pot, max);\r\n}\r\n\r\nexport function _CreateCanvas(width: number, height: number): ICanvas {\r\n if (typeof document === \"undefined\") {\r\n return <ICanvas>(<any>new OffscreenCanvas(width, height));\r\n }\r\n const canvas = <ICanvas>(<any>document.createElement(\"canvas\"));\r\n canvas.width = width;\r\n canvas.height = height;\r\n return canvas;\r\n}\r\n\r\n// From Engine\r\n\r\n/**\r\n * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation\r\n * @param flag defines which part of the materials must be marked as dirty\r\n * @param predicate defines a predicate used to filter which materials should be affected\r\n */\r\nexport function MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void {\r\n for (let engineIndex = 0; engineIndex < EngineStore.Instances.length; engineIndex++) {\r\n const engine = EngineStore.Instances[engineIndex];\r\n\r\n for (let sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {\r\n engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Ask the browser to promote the current element to pointerlock mode\r\n * @param element defines the DOM element to promote\r\n */\r\nexport function _RequestPointerlock(element: HTMLElement): void {\r\n if (element.requestPointerLock) {\r\n // In some browsers, requestPointerLock returns a promise.\r\n // Handle possible rejections to avoid an unhandled top-level exception.\r\n const promise: unknown = element.requestPointerLock();\r\n if (promise instanceof Promise)\r\n promise\r\n .then(() => {\r\n element.focus();\r\n })\r\n .catch(() => {});\r\n else element.focus();\r\n }\r\n}\r\n\r\n/** Pointerlock and fullscreen */\r\n\r\n/**\r\n * Asks the browser to exit pointerlock mode\r\n */\r\nexport function _ExitPointerlock(): void {\r\n if (document.exitPointerLock) {\r\n document.exitPointerLock();\r\n }\r\n}\r\n\r\n/**\r\n * Ask the browser to promote the current element to fullscreen rendering mode\r\n * @param element defines the DOM element to promote\r\n */\r\nexport function _RequestFullscreen(element: HTMLElement): void {\r\n const requestFunction = element.requestFullscreen || (<any>element).webkitRequestFullscreen;\r\n if (!requestFunction) {\r\n return;\r\n }\r\n requestFunction.call(element);\r\n}\r\n\r\n/**\r\n * Asks the browser to exit fullscreen mode\r\n */\r\nexport function _ExitFullscreen(): void {\r\n const anyDoc = document as any;\r\n\r\n if (document.exitFullscreen) {\r\n document.exitFullscreen();\r\n } else if (anyDoc.webkitCancelFullScreen) {\r\n anyDoc.webkitCancelFullScreen();\r\n }\r\n}\r\n\r\n/**\r\n * Get Font size information\r\n * @param font font name\r\n * @returns an object containing ascent, height and descent\r\n */\r\nexport function getFontOffset(font: string): { ascent: number; height: number; descent: number } {\r\n const text = document.createElement(\"span\");\r\n text.innerHTML = \"Hg\";\r\n text.setAttribute(\"style\", `font: ${font} !important`);\r\n\r\n const block = document.createElement(\"div\");\r\n block.style.display = \"inline-block\";\r\n block.style.width = \"1px\";\r\n block.style.height = \"0px\";\r\n block.style.verticalAlign = \"bottom\";\r\n\r\n const div = document.createElement(\"div\");\r\n div.style.whiteSpace = \"nowrap\";\r\n div.appendChild(text);\r\n div.appendChild(block);\r\n\r\n document.body.appendChild(div);\r\n\r\n let fontAscent = 0;\r\n let fontHeight = 0;\r\n try {\r\n fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;\r\n block.style.verticalAlign = \"baseline\";\r\n fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;\r\n } finally {\r\n document.body.removeChild(div);\r\n }\r\n return { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };\r\n}\r\n\r\n/**\r\n * Engine abstraction for loading and creating an image bitmap from a given source string.\r\n * @internal\r\n * @param imageSource source to load the image from.\r\n * @param options An object that sets options for the image's extraction.\r\n * @returns ImageBitmap.\r\n */\r\nexport async function _createImageBitmapFromSource(\r\n {\r\n createImageBitmap,\r\n }: {\r\n createImageBitmap: (image: ImageBitmapSource, options?: ImageBitmapOptions) => Promise<ImageBitmap>;\r\n },\r\n imageSource: string,\r\n options?: ImageBitmapOptions\r\n): Promise<ImageBitmap> {\r\n const promise = new Promise<ImageBitmap>((resolve, reject) => {\r\n const image = new Image();\r\n image.onload = () => {\r\n image.decode().then(() => {\r\n createImageBitmap(image, options).then((imageBitmap) => {\r\n resolve(imageBitmap);\r\n });\r\n });\r\n };\r\n image.onerror = () => {\r\n reject(`Error loading image ${image.src}`);\r\n };\r\n\r\n image.src = imageSource;\r\n });\r\n\r\n return promise;\r\n}\r\n\r\n/**\r\n * Resize an image and returns the image data as an uint8array\r\n * @param image image to resize\r\n * @param bufferWidth destination buffer width\r\n * @param bufferHeight destination buffer height\r\n * @returns an uint8array containing RGBA values of bufferWidth * bufferHeight size\r\n */\r\nexport function resizeImageBitmap(\r\n {\r\n createCanvas,\r\n }: {\r\n createCanvas?: (width: number, height: number) => ICanvas;\r\n },\r\n image: HTMLImageElement | ImageBitmap,\r\n bufferWidth: number,\r\n bufferHeight: number\r\n): Uint8Array {\r\n const canvas = (createCanvas ?? _CreateCanvas)(bufferWidth, bufferHeight);\r\n const context = canvas.getContext(\"2d\");\r\n\r\n if (!context) {\r\n throw new Error(\"Unable to get 2d context for resizeImageBitmap\");\r\n }\r\n\r\n context.drawImage(image, 0, 0);\r\n\r\n // Create VertexData from map data\r\n // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949\r\n const buffer = <Uint8Array>(<any>context.getImageData(0, 0, bufferWidth, bufferHeight).data);\r\n return buffer;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion: string = \"\"): string {\r\n return shaderVersion + (defines ? defines + \"\\n\" : \"\") + source;\r\n}\r\n\r\n// TODO is this needed? this will allow `import Statics from \"package/Engines\"`.\r\nexport default { NpmPackage, Version, CollisionEpsilon, ShadersRepository, _TextureLoaders, SetShadersRepository, ExceptionList };\r\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This file will include general engine tools, like reporters and loadFile
3
+ */
4
+ import type { IBaseEnginePublic } from "./engine.base";
5
+ import type { IOfflineProvider } from "../../Offline/IOfflineProvider.js";
6
+ import type { IWebRequest } from "../../Misc/interfaces/iWebRequest.js";
7
+ import type { IFileRequest } from "../../Misc/fileRequest.js";
8
+ /**
9
+ * @internal
10
+ */
11
+ export declare function _reportDrawCall(engineState: IBaseEnginePublic, numDrawCalls?: number): void;
12
+ /**
13
+ * initialize the draw calls perf counter
14
+ * @param engineState the engine state object
15
+ */
16
+ export declare function initDrawCallsPerfCounter(engineState: IBaseEnginePublic): void;
17
+ /**
18
+ * @internal
19
+ */
20
+ export declare function _loadFile(engineState: IBaseEnginePublic, url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;